jeff porter
jeff porter

Reputation: 6620

How to add License.txt to Maven project

I'm trying to add a LICENSE.txt to my maven project via a plugin.

I've tried using org.codehaus.mojo license-maven-plugin 1.14, with the following pom entries...

 <organizationName>My Organization</organizationName>
 <inceptionYear>2018</inceptionYear>

<licenses>
  <license>
    <name>GNU-JEFF General Public License (GPL)</name>
    <url>http://www.gnu.org/licenses/gpl.txt</url>
  </license>
</licenses> 
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <version>1.14</version>
            <configuration>
                <verbose>false</verbose>
                <addSvnKeyWords>true</addSvnKeyWords>
            </configuration>
            <executions>
                <execution>
                    <id>first</id>
                    <goals>
                        <goal>update-file-header</goal>
                    </goals>
                    <phase>process-sources</phase>
                    <configuration>
                        <licenseName>gpl_v3</licenseName>
                        <organizationName>My Organization</organizationName>
                        <inceptionYear>2017</inceptionYear>
                        <roots>
                            <root>src/main/java</root>
                            <root>src/test</root>
                        </roots>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

But with the following command...

mvn license:update-project-license

I get this error...

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.pcmsgroup.v21.pos.tools:confluence-updater:2.0.1-SNAPSHOT (C:\x\pom.xml) has 1 error
[ERROR]     Malformed POM C:\x\pom.xml: Unrecognised tag: 'organizationName' (position: START_TAG seen ...</packaging>\r\n\t\r\n<organizationName>... @9:19)  @ C:\tools\workspace\POS-ConfluenceUpdater\pom.xml, line 9, column 19 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Upvotes: 0

Views: 1997

Answers (1)

kaqqao
kaqqao

Reputation: 15439

The error has nothing to do with the plugin. As far as I can tell from the Maven XSD, your organizationName tag is indeed invalid, as the error says. Try replacing it with organization. That one does exist.

<organization>
    <name>My Organization</name>
    <url>http://example.com</url>
</organization>

Upvotes: 1

Related Questions