I would like to use the license-maven-plugin
in order to be able to generate license headers for my project.
So I have the following 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>
I'm invoking the following from the command-line:
mvn license:update-file-header
This all passes, but my license header ends up looking like this:
/*
* #%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%
*/
Obviously, I don't want to the #%L
, %%
and #L%
in my license header. What do I need to set in order to get rid of those?
Use the Mycila license plugin instead, it will do what you want (no segment markers), is simpler in someways and is under much more active development. I was banging my head with this plugin as well, until I came across this comment
As shown in the other answer, these tags are required for finding and updating the license information. One thing you can do is make them less annoying...
In my project, I have changed them to something a bit more pretty:
<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>
The lines with ===
look better to me than the default #%L
lines, which look like accidentally left garbage to me :-)
The only requirement for these tags is to be unique, hence the _START
and _END
part. I've also found that any space characters in the tags are deleted before inserting into the file.
The documentation for version 1.9 (latest at time of writing) says these are mandatory delimiters for it to find the header.
(1) # % L (2) Project description (3) %% (4) Copyright (C) 2010 your organization (5) %% (6) License content (7) # L %
- The start process tag used to detect begin of header (NEVER suppress it).
- Project description section
- Header section delimiter
- Copyright section of the file (see next section for detail)
- Header section delimiter
- License section
- The end process tag used to detect end of header (NEVER suppress it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With