gpt4 book ai didi

java - license-maven-plugin:update-file-header 如何排除项目名称?

转载 作者:行者123 更新时间:2023-12-01 20:08:49 27 4
gpt4 key购买 nike

我正在使用 license-maven-plugin 成功地将许可证 header 插入源树中的每个文件中。它生成以下内容:

/*-
* #%L
* my-unqualified-package-name
* %%
* Copyright (C) 2009 - 2017 My Company. <info@mycompany.com>
* %%
* This software is the property of My Company. Etc. Etc.
*
* #L%
*/

我的pom,

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<inceptionYear>2009</inceptionYear>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
<organizationName>My Company. &lt;info@mycompany.com&gt;</organizationName>
<licenseName>my_license</licenseName>
<licenseResolver>${project.baseUri}/src/license</licenseResolver>
<roots>
<!-- <root>src/main/java</root> -->
<root>src/test</root>
</roots>
</configuration>
<executions>
<execution>
<id>first</id>
<goals>
<goal>update-file-header</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

但我想要以下格式,

/**
* Copyright (C) 2009 - 2018 My Company. <info@mycompany.com>
*
* ====================================================================
* This software is the property of My Company. Etc. Etc.
* ====================================================================
*/

最佳答案

尝试切换到 com.mycila:license-maven-plugin 。他们的文档非常容易理解。

在文件中创建模板

例如,输入license-header.txt:

Copyright (C) ${license.years} ${license.owner} <${license.email}>

====================================================================
This software is the property of ${license.owner}. Etc. Etc.
====================================================================

配置插件

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<header>license-header.txt</header>
<properties>
<license.owner>My Company</license.owner>
<license.years>2009 - 2018</license.years>
<license.email>info@mycompany.com</license.email>
</properties>
<includes>
<include>src/*/java/**/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>first</id>
<goals>
<goal>check</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>

您可以使用 mvn license:format 进行格式化,或者只需将配置中的目标更改为 format 以便在每次运行时执行此操作。

关于java - license-maven-plugin:update-file-header 如何排除项目名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47030364/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com