Search code examples
javamavenlicensing

wrong license displayed in maven site


  • Include details about your goal

I have a custom license in my project. When generating the project website using mvn site, I hope to see the correct license displayed under target/site/licenses.html

  • Describe expected results

After the run of mvn site, I wish to see my custom license under target/site/licenses.html

  • Describe actual results

After the run of mvn site, I see this license, instead of my custom license:

Project Licenses
Apache License, Version 2.0
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

enter image description here

  • Describe what I tried:

In the root folder of my project, I have this custom license:

Custom License

Copyright (c) 2024, John Smith

Some custom clauses:
[truncated]

Please note, it is definitely not a Apache license

Therefore, while doing mvn site, at the license generation page, I am hoping to see the correct license for my project (not the licenses of the projects I depend on, but my own project).

Please see the "Typically the licenses listed for the project are that of the project itself, and not of dependencies."

However, it seems 1) maven is not able to pick this custom license and display it on site webpage, 2) is displaying a default apache license, which is not the license of my project.

  • Show some code:

Here is the content of the pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>licenseone</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>licenseone</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>21</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

  • Question:

How do I display a custom license in the site generated by maven?

(please note, this is not a question about software licensing, but a technical maven question on how to display license properly)


Solution

  • pom.xml

    ... 
       <version>0.0.1-SNAPSHOT</version>
        <name>licenseone</name>
        <description>Demo project for Spring Boot</description>
        <properties>
            <java.version>21</java.version>
        </properties>
        <!-- Add this -->
        <licenses>
              <license>
                 <name>My License</name>
                 <url>MY-LICENSE-2.0.txt</url>
                 <distribution>manual</distribution>
                 <comments>My A business-friendly OSS license</comments>
              </license>
        </licenses> 
        
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
    ...
    
    
    

    put MY-LICENSE-2.0.txt in your project root directory (same directory as pom.xml)