我想使用license-maven-plugin以便能够为我的项目生成许可证头。
因此,我有以下pom.xml:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>bar-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Bar: Parent</name>
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<organization>
<name>My Corp.</name>
<url>http://www.mycorp.org/</url>
</organization>
<inceptionYear>2014</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.licenseName>apache_v2</license.licenseName>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<verbose>false</verbose>
<includes>
<includes>**/*.java</includes>
</includes>
</configuration>
<executions>
<execution>
<id>generate-license-headers</id>
<goals>
<goal>update-file-header</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<licenseName>Apache 2.0</licenseName>
<roots>
<root>src/main/java</root>
<root>src/test/java</root>
</roots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>我从命令行调用以下代码:
mvn license:update-file-header这一切都通过了,但是我的license头看起来像这样:
/*
* #%L
* Bar: Foo
* %%
* Copyright (C) 2014 My Corp.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/显然,我不想在我的license头中使用#%L、%%和#L%。我需要设置什么才能去掉它们?
发布于 2016-09-09 16:48:26
如另一个答案所示,这些标记是查找和更新许可证信息所必需的。你可以做的一件事就是让它们不那么烦人。
在我的项目中,我已经将它们更改为更漂亮的东西:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.9</version>
<configuration>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
<processStartTag>========================LICENSE_START=================================</processStartTag>
<processEndTag>=========================LICENSE_END==================================</processEndTag>
</configuration>
...
</plugin>在我看来,使用===的代码行比默认的#%L代码行更好,后者看起来像是意外留下了垃圾:-)
对这些标记的唯一要求是唯一的,因此是_START和_END部分。我还发现标签中的任何空格字符在插入到文件中之前都会被删除。
发布于 2014-06-21 01:58:23
The documentation for version 1.9 (latest at time of writing)表示,这些分隔符是用于查找报头的强制分隔符。
(1) #%L (2)项目说明(3) %% (4)版权所有(C) 2010贵组织(5) %% (6)许可证内容(7) #L%
对于用于检测标头开始的开始进程标记(从不抑制)。对于文件的delimiter
<
发布于 2020-08-19 20:35:16
取而代之的是使用Mycila license plugin,它是will do what you want (没有段标记),在某些方面更简单,并且在much more active development下。我也一直在使用这个插件,直到我遇到了this comment
https://stackoverflow.com/questions/22549517
复制相似问题