如何将License.txt添加到Maven项目

时间:2018-02-16 09:56:34

标签: java maven

我试图通过插件向我的maven项目添加LICENSE.txt。

我尝试过使用org.codehaus.mojo license-maven-plugin 1.14,并使用以下pom条目...

 <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>

但是使用以下命令......

mvn license:update-project-license

我收到此错误...

[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

1 个答案:

答案 0 :(得分:1)

该错误与插件无关。据我所知the Maven XSD,您的organizationName标记确实无效,正如错误所述。尝试将其替换为organization。那个确实存在。

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