License Configuration
This project contains some configuration to make the License Maven Plugin compatible to the IntelliJ Idea IDE.
It contains a custom Header style definition which matches the format of the Idea XML headers.
Usage
You want to make sure that the Idea configuration exactly matches the License Maven Plugin configuration.
Maven
Maven Configuration
Example configuration for the License Maven Plugin in the (parent) pom of the project:
<project>
<properties>
<owner.name>Martin Trummer</owner.name>
<owner.email>[email protected]</owner.email>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.tmtron</groupId>
<artifactId>license-maven-plugin-config</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<configuration>
<header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
<properties>
<owner>${owner.name}</owner>
<email>${owner.email}</email>
</properties>
<excludes>
<exclude>**/README</exclude>
<exclude>**/LICENSE</exclude>
<exclude>**/NOTICE</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
</excludes>
<mapping>
<java>SLASHSTAR_STYLE</java>
<xml>idea_xml_style</xml>
</mapping>
<headerDefinitions>
<headerDefinition>idea-xml-header.xml</headerDefinition>
</headerDefinitions>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Notes:
- the
license-maven-plugin
must define a dependency tolicense-maven-plugin-config
, so that the idea-xml-header.xml file can be found from the classpath. - we must add a
headerDefinition
item, to read theidea-xml-header.xml
file - finally we can use the
idea_xml_style
for the xml-mapping. - we also add an execution section, so that the license-check will be done during the maven verify build phase
Maven Execution
When you want to add missing file-headers to your project files, just run:
mvn license:format
Idea configuration
- File - Settings - Copyright- Copyright profiles
- Click the + button and add a new profile called
Apache2
- Add the copyright text - see section Idea Copyright Text below
- Click the + button and add a new profile called
- File - Settings - Copyright
Default project copyright: selectApache2
Idea Copyright Text
Notes:
- we use the copyright symbol, because the License Maven Plugin also replaces (C) with the symbol automatically.
- we use the
$today.year
variable in this template - this text must exactly match whath the License Maven Plugin expects.
Copyright © $today.year Martin Trummer ([email protected])
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.
Details
The configuration is required because the License Maven Plugin and Idea use different formats for the copyright in XML headers.
- Idea uses
~
at the beginning of each line - License Maven Plugin uses blanks only
License
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.