License Maven Plugin Configuration

Custom Headers to use the License Maven Plugin with IntelliJ Idea

License

License

Categories

Categories

Maven Build Tools config Application Layer Libs Configuration
GroupId

GroupId

com.tmtron
ArtifactId

ArtifactId

license-maven-plugin-config
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

License Maven Plugin Configuration
Custom Headers to use the License Maven Plugin with IntelliJ Idea
Project URL

Project URL

https://github.com/tmtron/license-config
Source Code Management

Source Code Management

https://github.com/tmtron/license-config

Download license-maven-plugin-config

How to add to project

<!-- https://jarcasting.com/artifacts/com.tmtron/license-maven-plugin-config/ -->
<dependency>
    <groupId>com.tmtron</groupId>
    <artifactId>license-maven-plugin-config</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.tmtron/license-maven-plugin-config/
implementation 'com.tmtron:license-maven-plugin-config:1.0.1'
// https://jarcasting.com/artifacts/com.tmtron/license-maven-plugin-config/
implementation ("com.tmtron:license-maven-plugin-config:1.0.1")
'com.tmtron:license-maven-plugin-config:jar:1.0.1'
<dependency org="com.tmtron" name="license-maven-plugin-config" rev="1.0.1">
  <artifact name="license-maven-plugin-config" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.tmtron', module='license-maven-plugin-config', version='1.0.1')
)
libraryDependencies += "com.tmtron" % "license-maven-plugin-config" % "1.0.1"
[com.tmtron/license-maven-plugin-config "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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 to license-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 the idea-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

  1. 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
  2. File - Settings - Copyright
    Default project copyright: select Apache2

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.

Versions

Version
1.0.1
1.0.0