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

标签 java maven

我正在尝试通过插件将 LICENSE.txt 添加到我的 Maven 项目中。

我尝试使用 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

最佳答案

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

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

关于java - 如何将License.txt添加到Maven项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48824142/

相关文章:

java - 如何使用 httpclient 登录网站?

java - EqualsBuilder 与自己的 equals 方法

maven - Maven、Artifactory 和 Jenkins 环境中各种 Maven 配置文件(jboss、tomcat、glassfish)的不同数据库库名称( Artifact )

java - 如何从 Maven 构建 jar 中排除一组包?

java - Spring 中的 Maven 配置文件和应用程序 yml 文件

java - 无法在java中读取公钥进行验证

JavaCPP - 如何实际生成 C++ JNI 包装器?

java - 异步任务,关闭alertdialog后进度对话框不会消失

java - 从 Java 代码中的 Import 语句查找 Maven 依赖项或 Repo

java - META-INF 中的 Maven pom.xml 与 Maven 存储库中的 pom.xml