/** * Copyright (C) 2010-2012 MyCompany - All rights reserved. */
Copyright (C) ${h_inceptionYear}-${h_currentYear} ${h_copyrightOwner} - All rights reserved.
<properties> ... <inceptionYear>2010</inceptionYear> <copyrightOwner>MyCompany</copyrightOwner> </properties>
<!-- Creating current year element -->
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
import java.util.Date
import java.text.MessageFormat
def vartimestamp = MessageFormat.format("{0,date,yyyy}", new Date())
project.properties['currentYear'] = vartimestamp
</source>
</configuration>
</execution>
</executions>
</plugin>
<!-- Adding header to file -->
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.8.0</version>
<configuration>
<!-- Template location -->
<header>src/main/resources/fileHeader.txt</header>
<properties>
<!-- Values to be substituted in template -->
<h_inceptionYear>${inceptionYear}</h_inceptionYear>
<h_currentYear>${currentYear}</h_currentYear>
<h_copyrightOwner>${copyrightOwner}</h_copyrightOwner>
</properties>
<strictCheck>true</strictCheck>
<excludes>
<exclude>**/*.html</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.txt</exclude>
<exclude>**/*.ec</exclude>
<exclude>**/*.log</exclude>
<exclude>**/*.css</exclude>
<exclude>**/*.js</exclude>
<exclude>**/*.jsp</exclude>
<exclude>**/*.md</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
During the build process, proper headers are added (or updated) in code files:
/**
* Copyright (C) 2010-2012 MyCompany - All rights reserved.
*/
package com.mypackage;
public class MyClass {
// ...
}
And if I need to put this comment after the fist line!?
ReplyDeleteI am not sure it is possible with this pluggin...
Delete