Maven-license-plugin-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 268 discussions
r1641 - in trunk: . src/test/java/org/nuiton/license/header/plugin src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 23:29:19 +0200 (Sat, 29 Aug 2009)
New Revision: 1641
Modified:
trunk/changelog.txt
trunk/pom.xml
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css
Log:
bump versions + reformat
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-08-29 16:56:52 UTC (rev 1640)
+++ trunk/changelog.txt 2009-08-29 21:29:19 UTC (rev 1641)
@@ -1,11 +1,11 @@
-maven-license-plugin (1.0.1) stable; urgency=high
+maven-license-plugin (2.0.0) stable; urgency=high
* [FIX] #28 (some java files content was lost if tags not well-formed)
* [FEATURE] add some documentation on site
* [FEATURE] rethink the plugin, now only one goal (update-header) for all processing
* [FEATURE] can customize the header to inject (velocity template)
- -- chemit --
+ -- chemit -- Sat, 29 Aug 2009 19:45:05 +0200
maven-license-plugin (1.0.0) stable; urgency=high
* add java-update-header and jaxx-update-header goals instead of switch goal
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-29 16:56:52 UTC (rev 1640)
+++ trunk/pom.xml 2009-08-29 21:29:19 UTC (rev 1641)
@@ -9,11 +9,11 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2-SNAPSHOT</version>
</parent>
<artifactId>maven-license-plugin</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<dependencies>
@@ -101,7 +101,7 @@
<helper.version>1.0.2-SNAPSHOT</helper.version>
<processor.version>1.0.1-SNAPSHOT</processor.version>
-
+
</properties>
<build>
@@ -131,7 +131,7 @@
<dependency>
<groupId>org.nuiton.jrst</groupId>
<artifactId>doxia-module-jrst</artifactId>
- <version>1.0.0</version>
+ <version>${jrst.version}</version>
</dependency>
</dependencies>
</plugin>
Modified: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:56:52 UTC (rev 1640)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 21:29:19 UTC (rev 1641)
@@ -39,7 +39,6 @@
public static final String _LICENSE_TO_CHANGE_ = LicenseFilter.HEADER + " license to change " + LicenseFilter.FOOTER;
public static final String _MUST_BE_THERE = "// MUST BE THERE!";
-
UpdateHeaderPlugin plugin;
@BeforeClass
Modified: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css 2009-08-29 16:56:52 UTC (rev 1640)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css 2009-08-29 21:29:19 UTC (rev 1641)
@@ -1,6 +1,6 @@
/*
* *##% license to change ##%*
- */
+*/
.yo {
content:"// MUST BE THERE!";
Modified: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css 2009-08-29 16:56:52 UTC (rev 1640)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css 2009-08-29 21:29:19 UTC (rev 1641)
@@ -1,3 +1,3 @@
- .yo {
- content:"// MUST BE THERE!";
- }
+.yo {
+ content:"// MUST BE THERE!";
+}
1
0
r1640 - in trunk: . src/main/java/org/nuiton/license/header/generator src/main/java/org/nuiton/license/header/generator/impl src/main/java/org/nuiton/license/header/plugin src/test/java/org/nuiton/license/header src/test/java/org/nuiton/license/header/plugin
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:56:52 +0200 (Sat, 29 Aug 2009)
New Revision: 1640
Modified:
trunk/pom.xml
trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
Log:
update license header
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/pom.xml 2009-08-29 16:56:52 UTC (rev 1640)
@@ -82,7 +82,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Plugin maven de changement de license</name>
+ <name>Maven License Plugin</name>
<description>
Plugin pour mettre à jour l'en-tête des fichiers (avec la license choisie)
Modified: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:55:01 UTC (rev 1639)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:56:52 UTC (rev 1640)
@@ -1,6 +1,6 @@
/*
* *##%
- * Plugin maven de changement de license
+ * Maven License Plugin
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
1
0
r1639 - in trunk/src: main/java/org/nuiton/license/header/generator main/java/org/nuiton/license/header/generator/impl main/java/org/nuiton/license/header/plugin test/java/org/nuiton/license/header test/java/org/nuiton/license/header/plugin
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:55:01 +0200 (Sat, 29 Aug 2009)
New Revision: 1639
Modified:
trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
Log:
java header is not a javadoc comment
Modified: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
Modified: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:48:11 UTC (rev 1638)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:55:01 UTC (rev 1639)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
1
0
r1638 - in trunk/src: main/java/org/nuiton/license/header/generator/impl site/rst
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:48:11 +0200 (Sat, 29 Aug 2009)
New Revision: 1638
Modified:
trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
trunk/src/site/rst/index.rst
Log:
java header is not a javadoc comment
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:41:14 UTC (rev 1637)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:48:11 UTC (rev 1638)
@@ -35,7 +35,7 @@
public static final String GENERATOR_DESCRIPTION = "generator with java comment style";
public JavaHeaderGenerator() {
- super(" *", "/**", " */", LicenseFilter.HEADER, LicenseFilter.FOOTER);
+ super(" *", "/*", " */", LicenseFilter.HEADER, LicenseFilter.FOOTER);
}
@Override
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2009-08-29 16:41:14 UTC (rev 1637)
+++ trunk/src/site/rst/index.rst 2009-08-29 16:48:11 UTC (rev 1638)
@@ -28,7 +28,7 @@
::
- /**
+ /*
* *##%
* Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
1
0
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:41:14 +0200 (Sat, 29 Aug 2009)
New Revision: 1637
Modified:
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
Log:
improve log
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:24:39 UTC (rev 1636)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:41:14 UTC (rev 1637)
@@ -279,6 +279,7 @@
// build the comment boxed header content
boxedLicenseHeaderContent = generator.getHeader(licenseHeaderContent);
+ getLog().info("config - header to use\n" + boxedLicenseHeaderContent);
} else {
getLog().info("no file to treate.");
1
0
r1636 - in trunk/src: main/java/org/nuiton/license/header/generator main/java/org/nuiton/license/header/generator/impl main/java/org/nuiton/license/header/plugin test/java/org/nuiton/license/header test/java/org/nuiton/license/header/plugin
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:24:39 +0200 (Sat, 29 Aug 2009)
New Revision: 1636
Modified:
trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
Log:
update license header
Modified: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header.generator;
import java.io.IOException;
@@ -27,7 +47,7 @@
@Override
public String getHeader(String licenseHeaderContent) {
- return openTag + "\n" + linePrefix + " " + openProcessTag + " " + licenseHeaderContent + " " + closeProcessTag + "\n " + closeTag + "\n";
+ return openTag + "\n" + linePrefix + " " + openProcessTag + " " + licenseHeaderContent + " " + closeProcessTag + "\n" + closeTag + "\n";
}
@Override
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,5 +1,6 @@
/**
- * *##% Plugin maven de changement de license
+ * *##%
+ * Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.license.header.generator;
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header.generator;
import java.util.Map;
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,5 +1,6 @@
/**
- * *##% Plugin maven de changement de license
+ * *##%
+ * Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.license.header.generator.impl;
@@ -33,7 +35,7 @@
public static final String GENERATOR_DESCRIPTION = "generator with java comment style";
public JavaHeaderGenerator() {
- super(" *", "/**", "*/", LicenseFilter.HEADER, LicenseFilter.FOOTER);
+ super(" *", "/**", " */", LicenseFilter.HEADER, LicenseFilter.FOOTER);
}
@Override
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header.generator.impl;
import org.nuiton.license.header.generator.*;
Modified: trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,5 +1,6 @@
/**
- * *##% Plugin maven de changement de license
+ * *##%
+ * Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.license.header.generator.impl;
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header.plugin;
import java.util.Map;
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,6 +1,7 @@
/**
- * *##% Maven helper plugin
- * Copyright (C) 2009 CodeLutin
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.license.header.plugin;
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,5 +1,6 @@
/*
- * *##% Plugin maven de changement de license
+ * *##%
+ * Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/test/java/org/nuiton/license/header/LicenseProcessorTest.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header;
import org.nuiton.processor.LicenseProcessor;
Modified: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:07:56 UTC (rev 1635)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 16:24:39 UTC (rev 1636)
@@ -1,3 +1,23 @@
+/**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.license.header.plugin;
import java.io.File;
1
0
29 Aug '09
Author: tchemit
Date: 2009-08-29 18:07:56 +0200 (Sat, 29 Aug 2009)
New Revision: 1635
Modified:
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
Log:
improve log
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 15:56:30 UTC (rev 1634)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 16:07:56 UTC (rev 1635)
@@ -268,18 +268,17 @@
LicenseFactory factory = LicenseFactory.newInstance(licenseResolver);
License license = factory.revolv(licenseName);
+ if (verbose) {
+ getLog().info("config - use license " + license.getName());
+ getLog().info("config - use generator " + generator.getName());
+ getLog().info("config - use template " + templateURL);
+ }
// obtain content of license header
licenseHeaderContent = computeHeader(license, templateURL, generator);
// build the comment boxed header content
boxedLicenseHeaderContent = generator.getHeader(licenseHeaderContent);
- if (verbose) {
- getLog().info("config - use license " + license.getName());
- getLog().info("config - use generator " + generator.getName());
- getLog().info("config - use template " + templateURL);
- getLog().info("config - header to use \n" + licenseHeaderContent);
- }
} else {
getLog().info("no file to treate.");
}
@@ -378,10 +377,13 @@
}
}
if (verbose) {
- getLog().info("will use parameters in template : ");
+ StringBuilder buffer = new StringBuilder();
+
+ buffer.append("config - parameters for template : ");
for (Entry<Object, Object> e : env.entrySet()) {
- getLog().info("<" + e.getKey() + " : " + e.getValue() + ">");
+ buffer.append("\n * " + e.getKey() + " : " + e.getValue());
}
+ getLog().info(buffer.toString());
}
// generation du contenu via velocity
1
0
r1634 - in trunk/src: main/java/org/nuiton/license/header/generator main/java/org/nuiton/license/header/plugin test/java/org/nuiton/license/header/plugin
by tchemit@users.nuiton.org 29 Aug '09
by tchemit@users.nuiton.org 29 Aug '09
29 Aug '09
Author: tchemit
Date: 2009-08-29 17:56:30 +0200 (Sat, 29 Aug 2009)
New Revision: 1634
Modified:
trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
Log:
improve format
Modified: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
+++ trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 15:56:30 UTC (rev 1634)
@@ -27,7 +27,7 @@
@Override
public String getHeader(String licenseHeaderContent) {
- return openTag + "\n" + linePrefix + " " + openProcessTag + " " + licenseHeaderContent + " " + closeProcessTag + "\n" + linePrefix + " " + closeTag + "\n";
+ return openTag + "\n" + linePrefix + " " + openProcessTag + " " + licenseHeaderContent + " " + closeProcessTag + "\n " + closeTag + "\n";
}
@Override
Modified: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 15:29:58 UTC (rev 1633)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 15:56:30 UTC (rev 1634)
@@ -330,9 +330,8 @@
processFile.renameTo(file);
} catch (Exception e) {
- getLog().error("could not process file " + file + " for reason " + e.getMessage(), e);
+ getLog().warn("skip file " + file + " (could not process for reason : " + e.getMessage() + ")");
processFile.delete();
- throw new MojoExecutionException("could not treate source file " + file + " for reason : " + e.getMessage(), e);
} finally {
// toujours cleaner les états du filtre du processeur
p.getLicenceFilter().reset();
Modified: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 15:29:58 UTC (rev 1633)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 15:56:30 UTC (rev 1634)
@@ -1,26 +1,5 @@
package org.nuiton.license.header.plugin;
-/**
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-
-import org.nuiton.license.header.plugin.UpdateHeaderPlugin;
import java.io.File;
import java.io.IOException;
import java.util.Map.Entry;
@@ -31,12 +10,16 @@
import org.junit.Test;
import org.junit.AfterClass;
+import org.nuiton.processor.filters.LicenseFilter;
import org.nuiton.util.BasePluginTestCase;
import org.nuiton.util.PluginHelper;
/** @author chemit */
public class UpdateHeaderPluginTest extends BasePluginTestCase {
+ public static final String _LICENSE_TO_CHANGE_ = LicenseFilter.HEADER + " license to change " + LicenseFilter.FOOTER;
+ public static final String _MUST_BE_THERE = "// MUST BE THERE!";
+
UpdateHeaderPlugin plugin;
@BeforeClass
@@ -63,7 +46,7 @@
@PluginConfig(pomName = "bug_28.xml", goalName = "update-header")
public void testBug_28() throws Exception {
- testPom(new String[]{"// MUST BE THERE!"}, new String[]{});
+ testPom(new String[]{_MUST_BE_THERE}, new String[]{});
}
@@ -71,7 +54,7 @@
@PluginConfig(pomName = "java.xml", goalName = "update-header")
public void testJava() throws Exception {
- testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+ testPom(new String[]{_MUST_BE_THERE}, new String[]{_LICENSE_TO_CHANGE_});
}
@@ -79,7 +62,7 @@
@PluginConfig(pomName = "xml.xml", goalName = "update-header")
public void testXml() throws Exception {
- testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+ testPom(new String[]{_MUST_BE_THERE}, new String[]{_LICENSE_TO_CHANGE_});
}
@@ -87,7 +70,7 @@
@PluginConfig(pomName = "properties.xml", goalName = "update-header")
public void testProperties() throws Exception {
- testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+ testPom(new String[]{_MUST_BE_THERE}, new String[]{_LICENSE_TO_CHANGE_});
}
1
0
Author: tchemit
Date: 2009-08-29 17:29:58 +0200 (Sat, 29 Aug 2009)
New Revision: 1633
Added:
trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/
trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/plugin/
trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
trunk/src/main/resources/license/
trunk/src/main/resources/license/defaultHeader.vm
trunk/src/test/java/org/nuiton/license/header/plugin/
trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
trunk/src/test/resources/org/nuiton/license/header/plugin/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28.xml
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_done.java2
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_skip.java2
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java.xml
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy.java2
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy_none.java2
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties.xml
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.properties
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.sh
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.properties
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.sh
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml.xml
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.html
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.xml
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.html
trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.xml
Removed:
trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java
trunk/src/main/java/org/nuiton/license/header/generator/JavaHeaderGenerator.java
trunk/src/main/java/org/nuiton/license/header/generator/XmlHeaderGenerator.java
trunk/src/main/resources/defaultHeader.vm
trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java
trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml
trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyKO.java2
trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyOK.java2
Modified:
trunk/changelog.txt
trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
trunk/src/main/resources/META-INF/services/org.nuiton.license.header.generator.HeaderGenerator
trunk/src/site/rst/index.rst
trunk/src/site/rst/usage.rst
trunk/src/site/site.xml
Log:
- doc is done
- plugin is (re)done
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/changelog.txt 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,25 +1,48 @@
-1.0.0
+maven-license-plugin (1.0.1) stable; urgency=high
+
+ * [FIX] #28 (some java files content was lost if tags not well-formed)
+ * [FEATURE] add some documentation on site
+ * [FEATURE] rethink the plugin, now only one goal (update-header) for all processing
+ * [FEATURE] can customize the header to inject (velocity template)
+
+ -- chemit --
+
+maven-license-plugin (1.0.0) stable; urgency=high
* add java-update-header and jaxx-update-header goals instead of switch goal
-0.9
+ -- chemit -- ???
+
+maven-license-plugin (0.9) stable; urgency=high
* migrate groupId to org.nuiton
-0.8 chemit 20090509
+ -- chemit -- ???
+
+maven-license-plugin (0.8) stable; urgency=high
* release avant passage en groupId nuiton
-0.6 chemit 20090218
+ -- chemit -- 20090509
+
+maven-license-plugin (0.6) stable; urgency=low
* 20090420 [chemit] clean code, use latest versions, use doxia-module-jrst instead of maven-jrst-plugin
* 20090217 [chemit] use project.build.sourceEncoding instead of maven.compile.encoding as default encoding
* 20081210 [chemit] use lutinproject 3.4
-ver-0-5 chemit 20081108
+ -- chemit -- 20090218
+
+maven-license-plugin (0.5) stable; urgency=low
* 20081121 [chemit] fix bug when no name is defined in license
* 20081118 [chemit] use lutinpluginproject 3.1
-ver-0-4 chemit 20081013
+ -- chemit -- 20081108
+
+maven-license-plugin (0.4) stable; urgency=high
* 20081013 [chemit] Improve third-party goal : onyl keep included dependencies
-ver-0-3 chemit 20081013
+ -- chemit -- 20081013
+
+maven-license-plugin (0.4) stable; urgency=low
* 20081013 [chemit] Improve licence resolving
* 20080922 [thimel] Modified version of jrst and plugin's groupId
* 20080922 [chemit] Using lutinpluginproject 3.0
+
+ -- chemit -- 20081013
\ No newline at end of file
Deleted: trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,465 +0,0 @@
-/**
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.license.header;
-
-import org.nuiton.processor.LicenseProcessor;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.ServiceLoader;
-import java.util.TreeMap;
-import org.apache.maven.project.MavenProject;
-import org.nuiton.AbstractPlugin;
-import org.nuiton.license.License;
-import org.nuiton.license.LicenseFactory;
-import org.nuiton.license.header.generator.HeaderGenerator;
-import org.nuiton.util.PluginHelper;
-import org.nuiton.util.VelocityTemplateGenerator;
-
-/**
- * The goal to update (or add) the licence header on some files.
- *
- * @author chemit
- * @requiresProject true
- * @goal update-header
- *
- * @since 1.0.1
- */
-public class UpdateHeaderPlugin extends AbstractPlugin {
-
- /**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @required
- * @since 1.0.0
- */
- protected MavenProject project;
- /**
- * Encoding a utiliser pour lire et ecrire les fichiers.
- *
- * @parameter expression="${license.encoding}" default-value="${project.build.sourceEncoding}"
- * @required
- * @since 1.0.0
- */
- protected String encoding;
- /**
- * Un flag pour forcer la generation.
- *
- * @parameter expression="${license.force}" default-value="false"
- * @since 1.0.0
- */
- protected boolean force;
- /**
- * l'annee de creation du module (sera place dans le header)
- *
- * @parameter expression="${license.inceptionYear}" default-value="${project.inceptionYear}"
- * @required
- * @since 1.0.0
- */
- protected String inceptionYear;
- /**
- * le nom de l'organisation (sera place dans le header)
- *
- * @parameter expression="${license.organizationName}" default-value="${project.organization.name}"
- * @required
- * @since 1.0.0
- */
- protected String organizationName;
- /**
- * le nom du projet (sera place dans le header)
- *
- * @parameter expression="${license.projectName}" default-value="${project.name}"
- * @required
- * @since 1.0.0
- */
- protected String projectName;
- /**
- * Le type de license a appliquer.
- *
- * @parameter expression="${license.licenseName}"
- * @required
- * @since 1.0.0
- */
- protected String licenseName;
- /**
- * Le type de générateur a utiliser pour encapsuler le header.
- *
- * Par défaut, on veut utiliser le plugin sur des fichiers sources java.
- *
- * @parameter expression="${license.generatorName}" default-value="java"
- * @required
- * @since 1.0.1
- */
- protected String generatorName;
- /**
- * La liste des patterns de fichiers à inclure (séparés par des virgules).
- *
- * Exemple : <code>**\/*.java,**\/*.properties</code>
- *
- * On recherchera alors les fichiers respectant l'un des patterns dans
- * tous les répertoires de sources et de tests.
- *
- * Par défaut, on veut utiliser le plugin sur des fichiers sources java.
- *
- * @parameter expression="${license.includes}" default-value="**\/*.java"
- * @required
- * @since 1.0.1
- */
- protected String includes = "**/*.java";
- /**
- * La liste des patterns de fichiers à exclure (séparés par des virgules).
- *
- * Exemple : <code>**\/*.java,**\/*.properties</code>
- *
- * On recherchera alors les fichiers respectant l'un des patterns dans
- * tous les répertoires de sources et de tests.
- *
- * Par défaut, on n'exclue rien.
- *
- * @parameter expression="${license.excludes}"
- * @since 1.0.1
- */
- protected String excludes;
- /**
- * Repertoires des fichiers sources a traiter.
- *
- * @parameter expression="${license.compileSourceRoots}" default-value="${project.compileSourceRoots}"
- * @required
- * @since 1.0.0
- */
- protected List<String> compileSourceRoots;
- /**
- * Repertoires des fichiers sources de test a traiter.
- *
- * @parameter expression="${license.testCompileSourceRoots}" default-value="${project.testCompileSourceRoots}"
- * @required
- * @since 1.0.0
- */
- protected List<String> testCompileSourceRoots;
- /**
- * Un resolver externe
- *
- * @parameter expression="${license.licenseResolver}"
- * @since 1.0.0
- */
- protected String licenseResolver;
- /**
- * La template (velocity) a utiliser pour construire le header.
- *
- * Cette template doit être dans le class-path ou être un fichier existant
- *
- * @parameter expression="${license.template}" default-value="/defaultHeader.vm"
- * @since 1.0.1
- */
- protected String template;
- /**
- * Des paramètres supplémentaires à utiliser dans la template du header.
- *
- * @parameter
- * @since 1.0.1
- */
- protected Map<String, String> templateParameters;
- /**
- * Un flag pour conserver un backup des fichiers modifies.
- *
- * @parameter expression="${license.keepBackup}" default-value="false"
- * @since 1.0.0
- */
- protected boolean keepBackup;
- /**
- * Un flag pour activer le mode verbeux.
- *
- * @parameter expression="${license.verbose}" default-value="${maven.verbose}"
- * @since 1.0.0
- */
- protected boolean verbose;
- /** le header a ajouter dans chaque fichier source java */
- protected String licenseHeaderContent;
- /** la liste des chemin relatifs des sources java a traiter pour chaque repertoire contenant des sources */
- protected Map<File, String[]> filesToTreate;
- /** le generateur d'en-tete a utiliser */
- protected HeaderGenerator generator;
- protected long timestamp;
- protected Map<String, HeaderGenerator> availableGenerators;
-
- public UpdateHeaderPlugin() {
- super("all files are up-to-date.");
- }
-
- @Override
- public boolean isVerbose() {
- return verbose;
- }
-
- @Override
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- @Override
- public MavenProject getProject() {
- return project;
- }
-
- @Override
- public void setProject(MavenProject project) {
- this.project = project;
- }
-
- @Override
- public boolean ensurePackaging() {
- return false;
-// return "pom".equals(project.getPackaging()) || "site".equals(project.getPackaging());
- }
-
- @Override
- public boolean init() throws Exception {
-
- timestamp = System.nanoTime();
-
- // obtain all generators available
- availableGenerators = getGenerators();
-
- if (verbose) {
- getLog().info("available generators : " + availableGenerators);
- }
-
- // check if given generator exists
- if (!availableGenerators.containsKey(generatorName)) {
- // the generator is unknown
- throw new MojoExecutionException("the generator named '" + generatorName + "' is unknown (use list-generators goal to see all of them)");
- }
-
- // obtain all java source files to be treated
- filesToTreate = getFilesToTreate();
-
- boolean doGenerate = !filesToTreate.isEmpty();
-
- if (doGenerate) {
-
- File templateFile = new File(template);
-
- // verifie que la template existe (dans le class-path ou en tant que fichier)
- checkResource(templateFile);
-
- URL templateURL = getTemplate(templateFile);
-
- // recuperation de la license a utiliser
- LicenseFactory factory = LicenseFactory.newInstance(licenseResolver);
- License license = factory.revolv(licenseName);
-
- // obtain content of license header
- licenseHeaderContent = computeHeader(license, templateURL);
-
- // recuperation du generateur de header a utiliser
- generator = availableGenerators.get(generatorName);
-
- if (verbose) {
- getLog().info("config - use the generator " + generator);
- getLog().info("config - use template " + templateURL);
- getLog().info("config - header to use \n" + licenseHeaderContent);
- }
- } else {
- getLog().info("no file to treate.");
- }
-
- return doGenerate;
- }
-
- @Override
- protected void doAction() throws Exception {
- // create a licence processor with given header
- LicenseProcessor p = new LicenseProcessor(licenseHeaderContent);
-
- for (Entry<File, String[]> entry : filesToTreate.entrySet()) {
- File src = entry.getKey();
- for (String javaRelativePath : entry.getValue()) {
- File sourceFile = new File(src, javaRelativePath);
- try {
- processFile(p, sourceFile);
- } catch (Exception e) {
- throw new MojoExecutionException("could not treate source file " + sourceFile + " for reason : " + e.getMessage(), e);
- }
- }
- }
- }
-
- /**
- * @param p license processor
- * @param file the file to process
- * @throws Exception if IO pb
- */
- protected void processFile(LicenseProcessor p, File file) throws Exception {
-
- if (verbose) {
- getLog().info("process file " + file);
- }
-
- // file where to writeFile result
- File processFile = new File(file.getAbsolutePath() + "_" + timestamp);
-
- try {
- p.process(file, processFile);
- boolean foundLicenseHeader = p.getLicenceFilter().wasTouched();
-
- if (!foundLicenseHeader) {
- if (p.getLicenceFilter().isDetectHeader()) {
- getLog().warn("skip file " + file + " (no license footer tag found : '##%*' !)");
- } else {
- // no license header found in file, add it
- getLog().info("adding license header on file " + file);
- String content = PluginHelper.readAsString(file, encoding);
- content = generator.getHeader(licenseHeaderContent) + content;
- writeFile(processFile, content, encoding);
- }
- }
-
- if (keepBackup) {
- File backupFile = new File(file.getAbsolutePath() + "~");
- if (verbose) {
- getLog().debug("backup original file " + file);
- }
- file.renameTo(backupFile);
- }
- processFile.renameTo(file);
-
- } catch (Exception e) {
- getLog().error("could not process file " + file + " for reason " + e.getMessage(), e);
- processFile.delete();
- throw e;
- } finally {
- p.getLicenceFilter().reset();
- }
- }
-
- protected Map<String, HeaderGenerator> getGenerators() {
- Map<String, HeaderGenerator> generators = new TreeMap<String, HeaderGenerator>();
- ServiceLoader<HeaderGenerator> loader = ServiceLoader.load(HeaderGenerator.class, getClass().getClassLoader());
- for (HeaderGenerator h : loader) {
- generators.put(h.getName(), h);
- }
- return generators;
- }
-
- protected Map<File, String[]> getFilesToTreate() {
-
- Map<File, String[]> files = new java.util.HashMap<File, String[]>();
-
- String[] in = includes.split(",");
- String[] ex = excludes == null ? null : excludes.split(",");
- getFilesToTreateForRoots(in, ex, compileSourceRoots, files, null);
- getFilesToTreateForRoots(in, ex, testCompileSourceRoots, files, null);
-
- return files;
- }
-
- protected String computeHeader(License license, URL templateURL) throws Exception {
-
- String licenseContent = license.getHeaderContent(encoding);
-
- // defined inceptionYear (if year is older than now suffix with a - thisYear)
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
- String thisYear = cal.get(Calendar.YEAR) + "";
- if (!thisYear.equals(inceptionYear)) {
- inceptionYear = inceptionYear + " - " + thisYear;
- }
-
- Properties env = new Properties();
- env.put("inceptionYear", inceptionYear);
- env.put("projectName", projectName);
- env.put("organizationName", organizationName);
- env.put("licenseContent", licenseContent);
-
- if (templateParameters != null) {
- for (Entry<String, String> e : templateParameters.entrySet()) {
- env.put(e.getKey(), e.getValue());
- }
- }
- if (verbose) {
- getLog().info("will use parameters in template : ");
- for (Entry<Object, Object> e : env.entrySet()) {
- getLog().info("<" + e.getKey() + " : " + e.getValue() + ">");
- }
- }
- StringWriter f = new StringWriter();
- VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
- gen.generate(env, f);
-
- String r = f.getBuffer().toString();
-
- // add " * " before each line
- BufferedReader reader = new BufferedReader(new java.io.StringReader(r));
- StringBuilder sb = new StringBuilder();
-
- String line = reader.readLine();
- sb.append(line).append('\n');
- while ((line = reader.readLine()) != null) {
- line = line.trim();
- if (line.isEmpty()) {
- sb.append(" *\n");
- } else {
- sb.append(" * ").append(line).append("\n");
- }
- }
-
- String result = sb.toString();
-
- return result.substring(0, result.length() - 1);
- }
-
- protected URL getTemplate(File f) throws IOException {
- URL r = null;
- if (f.exists()) {
- r = f.toURI().toURL();
- } else {
- r = getClass().getResource(f.toString());
- }
- return r;
- }
-
- protected void checkResource(File f) throws IOException {
- if (!f.exists()) {
- // test in classPath
- InputStream r = null;
- try {
- r = getClass().getResourceAsStream(f.toString());
- if (r == null) {
- throw new IOException("could not find ressource " + f);
- }
- } finally {
- if (r != null) {
- r.close();
- }
- }
- }
- }
-}
Added: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,88 @@
+package org.nuiton.license.header.generator;
+
+import java.io.IOException;
+import org.nuiton.util.PluginHelper;
+
+/**
+ * Une implentation de base pour les generateur d'en-tete de license.
+ *
+ * @author chemit
+ * @since 1.0.1
+ */
+public abstract class AbstractLicenseHeaderGenerator implements HeaderGenerator {
+
+ protected String linePrefix;
+ protected String openTag;
+ protected String closeTag;
+ protected String openProcessTag;
+ protected String closeProcessTag;
+
+ public AbstractLicenseHeaderGenerator(String linePrefix, String openTag, String closeTag, String openProcessTag, String closeProcessTag) {
+ this.linePrefix = linePrefix;
+ this.openTag = openTag;
+ this.closeTag = closeTag;
+ this.openProcessTag = openProcessTag;
+ this.closeProcessTag = closeProcessTag;
+ }
+
+ @Override
+ public String getHeader(String licenseHeaderContent) {
+ return openTag + "\n" + linePrefix + " " + openProcessTag + " " + licenseHeaderContent + " " + closeProcessTag + "\n" + linePrefix + " " + closeTag + "\n";
+ }
+
+ @Override
+ public String prefixContent(String content) throws IOException {
+ String result = PluginHelper.prefixLines(linePrefix + " ", linePrefix, content);
+ return result;
+ }
+
+ @Override
+ public String getLinePrefix() {
+ return linePrefix;
+ }
+
+ @Override
+ public String getCloseProcessTag() {
+ return closeProcessTag;
+ }
+
+ @Override
+ public String getCloseTag() {
+ return closeTag;
+ }
+
+ @Override
+ public String getOpenProcessTag() {
+ return openProcessTag;
+ }
+
+ @Override
+ public String getOpenTag() {
+ return openTag;
+ }
+
+ @Override
+ public void setCloseProcessTag(String closeProcessTag) {
+ this.closeProcessTag = closeProcessTag;
+ }
+
+ @Override
+ public void setCloseTag(String closeTag) {
+ this.closeTag = closeTag;
+ }
+
+ @Override
+ public void setLinePrefix(String linePrefix) {
+ this.linePrefix = linePrefix;
+ }
+
+ @Override
+ public void setOpenProcessTag(String openProcessTag) {
+ this.openProcessTag = openProcessTag;
+ }
+
+ @Override
+ public void setOpenTag(String openTag) {
+ this.openTag = openTag;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/generator/AbstractLicenseHeaderGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -18,6 +18,8 @@
*/
package org.nuiton.license.header.generator;
+import java.io.IOException;
+
/**
* A simple Contract to generate a new header for a given type of file.
*
@@ -33,8 +35,46 @@
String getName();
/**
- * @param licenseHeaderContent the content of the license header
+ *
+ * @return the description of the generator
+ */
+ String getDescription();
+
+ /**
+ * @param content the content to box.
* @return the full header to add on the first line of file.
*/
- String getHeader(String licenseHeaderContent);
+ String getHeader(String content);
+
+ /**
+ *
+ * @return the prefix to add on each lines of the header
+ */
+ String getLinePrefix();
+
+ /**
+ *
+ * @param content
+ * @return
+ * @throws IOException
+ */
+ String prefixContent(String content) throws IOException;
+
+ String getOpenTag();
+
+ String getCloseTag();
+
+ String getOpenProcessTag();
+
+ String getCloseProcessTag();
+
+ void setLinePrefix(String linePrefix);
+
+ void setOpenTag(String openTag);
+
+ void setCloseTag(String closeTag);
+
+ void setOpenProcessTag(String openProcessTag);
+
+ void setCloseProcessTag(String closeProcessTag);
}
Added: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,38 @@
+package org.nuiton.license.header.generator;
+
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.TreeMap;
+
+/**
+ * The class offers some usefull methods on {@link HeaderGenerator}.
+ *
+ * @author chemit
+ * @since 1.0.1
+ */
+public class HeaderGeneratorUtil {
+
+ /**
+ *
+ * @param classLoader the classLoader where to discover {@link HeaderGenerator}.
+ *
+ * @return the dictionnary of generators discovered associated to thier name.
+ */
+ public static Map<String, HeaderGenerator> getGenerators(ClassLoader classLoader) {
+ Map<String, HeaderGenerator> generators = new TreeMap<String, HeaderGenerator>();
+ ServiceLoader<HeaderGenerator> loader = ServiceLoader.load(HeaderGenerator.class, classLoader);
+ for (HeaderGenerator h : loader) {
+ generators.put(h.getName(), h);
+ }
+ return generators;
+ }
+
+ public static HeaderGenerator getGenerator(ClassLoader classLoader, String generatorName, boolean check) {
+ Map<String, HeaderGenerator> generators = getGenerators(classLoader);
+ HeaderGenerator get = generators.get(generatorName);
+ if (check && get == null) {
+ throw new IllegalArgumentException("could not find a generator named '" + generatorName + "'");
+ }
+ return get;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/generator/HeaderGeneratorUtil.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Deleted: trunk/src/main/java/org/nuiton/license/header/generator/JavaHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/JavaHeaderGenerator.java 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/java/org/nuiton/license/header/generator/JavaHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,44 +0,0 @@
-/**
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.license.header.generator;
-
-import org.nuiton.processor.filters.LicenseFilter;
-
-/**
- * Le générateur de header pour les fichiers java
- * maven.
- *
- * @author chemit
- *
- * @since 1.0.1
- */
-public class JavaHeaderGenerator implements HeaderGenerator {
-
- public static final String GENERATOR_NAME = "java";
-
- @Override
- public String getHeader(String licenseHeaderContent) {
- return "/**\n * " + LicenseFilter.HEADER + " " + licenseHeaderContent + " " + LicenseFilter.FOOTER + "\n */\n";
- }
-
- @Override
- public String getName() {
- return GENERATOR_NAME;
- }
-}
Deleted: trunk/src/main/java/org/nuiton/license/header/generator/XmlHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/XmlHeaderGenerator.java 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/java/org/nuiton/license/header/generator/XmlHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,43 +0,0 @@
-/**
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.license.header.generator;
-
-import org.nuiton.processor.filters.LicenseFilter;
-
-/**
- * Le header pour les fichiers xml.
- *
- * @author chemit
- *
- * @since 1.0.1
- */
-public class XmlHeaderGenerator implements HeaderGenerator {
-
- public static final String GENERATOR_NAME = "xml";
-
- @Override
- public String getHeader(String licenseHeaderContent) {
- return "<!--\n\n/**\n * " + LicenseFilter.HEADER + " " + licenseHeaderContent + " " + LicenseFilter.FOOTER + "\n */\n\n-->\n";
- }
-
- @Override
- public String getName() {
- return GENERATOR_NAME;
- }
-}
Copied: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java (from rev 1631, trunk/src/main/java/org/nuiton/license/header/generator/JavaHeaderGenerator.java)
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,48 @@
+/**
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.license.header.generator.impl;
+
+import org.nuiton.license.header.generator.*;
+import org.nuiton.processor.filters.LicenseFilter;
+
+/**
+ * Le geénérateur de header pour les fichiers sources java.
+ *
+ * @author chemit
+ * @since 1.0.1
+ */
+public class JavaHeaderGenerator extends AbstractLicenseHeaderGenerator {
+
+ public static final String GENERATOR_NAME = "license-java";
+ public static final String GENERATOR_DESCRIPTION = "generator with java comment style";
+
+ public JavaHeaderGenerator() {
+ super(" *", "/**", "*/", LicenseFilter.HEADER, LicenseFilter.FOOTER);
+ }
+
+ @Override
+ public String getName() {
+ return GENERATOR_NAME;
+ }
+
+ @Override
+ public String getDescription() {
+ return GENERATOR_DESCRIPTION;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/generator/impl/JavaHeaderGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Added: trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,32 @@
+package org.nuiton.license.header.generator.impl;
+
+import org.nuiton.license.header.generator.*;
+import org.nuiton.processor.filters.LicenseFilter;
+
+/**
+ * Le generateur de header pour des fichiers de proprietes.
+ *
+ * @author chemit
+ * @since 1.0.1
+ */
+public class PropertiesHeaderGenerator extends AbstractLicenseHeaderGenerator {
+
+ public static final String GENERATOR_NAME = "license-properties";
+ public static final String GENERATOR_DESCRIPTION = "generator with properties file comment style";
+ public static final String LINE = "###############################################################################";
+ public static final String PREFIX = "#";
+
+ public PropertiesHeaderGenerator() {
+ super("#", LINE, LINE, LicenseFilter.HEADER, LicenseFilter.FOOTER);
+ }
+
+ @Override
+ public String getName() {
+ return GENERATOR_NAME;
+ }
+
+ @Override
+ public String getDescription() {
+ return GENERATOR_DESCRIPTION;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/generator/impl/PropertiesHeaderGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java (from rev 1631, trunk/src/main/java/org/nuiton/license/header/generator/XmlHeaderGenerator.java)
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,48 @@
+/**
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.license.header.generator.impl;
+
+import org.nuiton.license.header.generator.*;
+import org.nuiton.processor.filters.LicenseFilter;
+
+/**
+ * Le header pour les fichiers xml.
+ *
+ * @author chemit
+ * @since 1.0.1
+ */
+public class XmlHeaderGenerator extends AbstractLicenseHeaderGenerator {
+
+ public static final String GENERATOR_NAME = "license-xml";
+ public static final String GENERATOR_DESCRIPTION = "generator with xml comment style";
+
+ public XmlHeaderGenerator() {
+ super(" ", "<!--", "-->", LicenseFilter.HEADER, LicenseFilter.FOOTER);
+ }
+
+ @Override
+ public String getName() {
+ return GENERATOR_NAME;
+ }
+
+ @Override
+ public String getDescription() {
+ return GENERATOR_DESCRIPTION;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/generator/impl/XmlHeaderGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Added: trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,51 @@
+package org.nuiton.license.header.plugin;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.license.header.generator.HeaderGenerator;
+import org.nuiton.license.header.generator.HeaderGeneratorUtil;
+
+/**
+ * The goal display all the knwon generators.
+ *
+ * @author chemit
+ *
+ * @requiresProject true
+ * @requiresDirectInvocation
+ * @goal generator-list
+ *
+ * @since 1.0.1
+ *
+ */
+public class GeneratorListPlugin extends AbstractMojo {
+
+ /**
+ * Un drapeau pour afficher aussi le contenu des license.
+ *
+ * @parameter expression="${detail}"
+ * @since 1.0.1
+ */
+ protected boolean detail;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ // obtain all available generators
+ Map<String, HeaderGenerator> generators = HeaderGeneratorUtil.getGenerators(getClass().getClassLoader());
+
+ // display it
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("list of available generators :\n");
+ for (Entry<String, HeaderGenerator> e : generators.entrySet()) {
+ buffer.append(" - ").append(e.getKey()).append(" : ").append(e.getValue().getDescription());
+ buffer.append("\n");
+ if (detail) {
+ buffer.append("example : \n").append(e.getValue().getHeader("content ")).append('\n');
+ }
+ }
+ getLog().info(buffer.toString());
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/plugin/GeneratorListPlugin.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,86 @@
+/**
+ * *##% Maven helper plugin
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.license.header.plugin;
+
+import java.io.IOException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.license.LicenseFactory;
+
+import java.util.Map.Entry;
+import org.nuiton.license.License;
+
+/**
+ * Le goal pour afficher dans la console les differentes licenses connues.
+ *
+ * @author chemit
+ * @goal license-list
+ * @requiresProject false
+ * @requiresDirectInvocation
+ *
+ * @since 1.0.1
+ */
+public class LicenseListPlugin extends AbstractMojo {
+
+ /**
+ * La baseURL d'un resolver de license supplementaire
+ *
+ * @parameter expression="${extraResolver}"
+ * @since 1.0.1
+ */
+ protected String extraResolver;
+ /**
+ * Encoding a utiliser pour lire et ecrire les fichiers.
+ *
+ * @parameter expression="${encoding}" default-value="UTF-8"
+ * @required
+ * @since 1.0.0
+ */
+ protected String encoding;
+ /**
+ * Un drapeau pour afficher aussi le contenu des license.
+ *
+ * @parameter expression="${detail}"
+ * @since 1.0.1
+ */
+ protected boolean detail;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Available licenses :\n");
+
+ LicenseFactory factory = LicenseFactory.newInstance(extraResolver);
+
+ for (Entry<String, String> entry : factory.getLicenseNames().entrySet()) {
+ String licenseName = entry.getKey();
+ sb.append(" * ").append(licenseName).append(" : ").append(entry.getValue()).append('\n');
+ if (detail) {
+ License license = factory.revolv(licenseName);
+ try {
+ sb.append(license.getHeaderContent(encoding)).append('\n');
+ } catch (IOException ex) {
+ throw new MojoExecutionException("could not instanciate license with name " + licenseName + " for reason " + ex.getMessage(), ex);
+ }
+ }
+ }
+ getLog().info(sb.toString());
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/plugin/LicenseListPlugin.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java (from rev 1632, trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java)
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,401 @@
+/*
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.license.header.plugin;
+
+import org.nuiton.processor.LicenseProcessor;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import org.apache.maven.project.MavenProject;
+import org.nuiton.AbstractPlugin;
+import org.nuiton.license.License;
+import org.nuiton.license.LicenseFactory;
+import org.nuiton.license.header.generator.HeaderGenerator;
+import org.nuiton.license.header.generator.HeaderGeneratorUtil;
+import org.nuiton.util.PluginHelper;
+import org.nuiton.util.VelocityTemplateGenerator;
+
+/**
+ * The goal to update (or add) the licence header on some files.
+ *
+ * @author chemit
+ * @requiresProject true
+ * @goal update-header
+ *
+ * @since 1.0.1
+ */
+public class UpdateHeaderPlugin extends AbstractPlugin {
+
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @since 1.0.0
+ */
+ protected MavenProject project;
+ /**
+ * Encoding a utiliser pour lire et ecrire les fichiers.
+ *
+ * @parameter expression="${license.encoding}" default-value="${project.build.sourceEncoding}"
+ * @required
+ * @since 1.0.0
+ */
+ protected String encoding;
+ /**
+ * l'annee de creation du module (sera place dans le header)
+ *
+ * @parameter expression="${license.inceptionYear}" default-value="${project.inceptionYear}"
+ * @required
+ * @since 1.0.0
+ */
+ protected String inceptionYear;
+ /**
+ * le nom de l'organisation (sera place dans le header)
+ *
+ * @parameter expression="${license.organizationName}" default-value="${project.organization.name}"
+ * @required
+ * @since 1.0.0
+ */
+ protected String organizationName;
+ /**
+ * le nom du projet (sera place dans le header)
+ *
+ * @parameter expression="${license.projectName}" default-value="${project.name}"
+ * @required
+ * @since 1.0.0
+ */
+ protected String projectName;
+ /**
+ * Le type de license a appliquer.
+ *
+ * @parameter expression="${license.licenseName}"
+ * @required
+ * @since 1.0.0
+ */
+ protected String licenseName;
+ /**
+ * Le type de générateur a utiliser pour encapsuler le header.
+ *
+ * Par défaut, on veut utiliser le plugin sur des fichiers sources java.
+ *
+ * @parameter expression="${license.generatorName}" default-value="license-java"
+ * @required
+ * @since 1.0.1
+ */
+ protected String generatorName;
+ /**
+ * La liste des patterns de fichiers à inclure (séparés par des virgules).
+ *
+ * Exemple : <code>**\/*.java,**\/*.properties</code>
+ *
+ * On recherchera alors les fichiers respectant l'un des patterns dans
+ * tous les répertoires de sources et de tests.
+ *
+ * Par défaut, on veut utiliser le plugin sur des fichiers sources java.
+ *
+ * @parameter expression="${license.includes}" default-value="**\/*.java"
+ * @required
+ * @since 1.0.1
+ */
+ protected String includes = "**/*.java";
+ /**
+ * La liste des patterns de fichiers à exclure (séparés par des virgules).
+ *
+ * Exemple : <code>**\/*.java,**\/*.properties</code>
+ *
+ * On recherchera alors les fichiers respectant l'un des patterns dans
+ * tous les répertoires de sources et de tests.
+ *
+ * Par défaut, on n'exclue rien.
+ *
+ * @parameter expression="${license.excludes}"
+ * @since 1.0.1
+ */
+ protected String excludes;
+ /**
+ * Repertoires des fichiers sources a traiter.
+ *
+ * @parameter expression="${license.compileSourceRoots}" default-value="${project.compileSourceRoots}"
+ * @required
+ * @since 1.0.0
+ */
+ protected List<String> compileSourceRoots;
+ /**
+ * Repertoires des fichiers sources de test a traiter.
+ *
+ * @parameter expression="${license.testCompileSourceRoots}" default-value="${project.testCompileSourceRoots}"
+ * @required
+ * @since 1.0.0
+ */
+ protected List<String> testCompileSourceRoots;
+ /**
+ * Un resolver externe
+ *
+ * @parameter expression="${license.licenseResolver}"
+ * @since 1.0.0
+ */
+ protected String licenseResolver;
+ /**
+ * La template (velocity) a utiliser pour construire le header.
+ *
+ * Cette template doit être dans le class-path ou être un fichier existant
+ *
+ * @parameter expression="${license.template}" default-value="/license/defaultHeader.vm"
+ * @since 1.0.1
+ */
+ protected String template;
+ /**
+ * Des paramètres supplémentaires à utiliser dans la template du header.
+ *
+ * @parameter
+ * @since 1.0.1
+ */
+ protected Map<String, String> templateParameters;
+ /**
+ * Un flag pour conserver un backup des fichiers modifies.
+ *
+ * @parameter expression="${license.keepBackup}" default-value="false"
+ * @since 1.0.0
+ */
+ protected boolean keepBackup;
+ /**
+ * Un flag pour activer le mode verbeux.
+ *
+ * @parameter expression="${license.verbose}" default-value="${maven.verbose}"
+ * @since 1.0.0
+ */
+ protected boolean verbose;
+ /** le header a ajouter dans chaque fichier source java */
+ protected String licenseHeaderContent;
+ /** le header complet (avec les balises de commentaires) */
+ protected String boxedLicenseHeaderContent;
+ /** la liste des chemin relatifs des sources java a traiter pour chaque repertoire contenant des sources */
+ protected Map<File, String[]> filesToTreate;
+ /** le timestamp utilise pour la generation*/
+ protected long timestamp;
+
+ public UpdateHeaderPlugin() {
+ super("all files are up-to-date.");
+ }
+
+ @Override
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ @Override
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ @Override
+ public MavenProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(MavenProject project) {
+ this.project = project;
+ }
+
+ @Override
+ public boolean ensurePackaging() {
+ return false;
+ }
+
+ @Override
+ public boolean init() throws Exception {
+
+ timestamp = System.nanoTime();
+
+ HeaderGenerator generator;
+
+ // obtain the header generator
+ try {
+ generator = HeaderGeneratorUtil.getGenerator(getClass().getClassLoader(), generatorName, true);
+ } catch (IllegalArgumentException e) {
+ // generator non trouve
+ throw new MojoExecutionException("the generator named '" + generatorName + "' is unknown (use generator-list goal to see all of them)");
+ }
+
+ // obtain all files to be treated
+
+ filesToTreate = new HashMap<File, String[]>();
+ String[] in = includes.split(",");
+ String[] ex = excludes == null ? null : excludes.split(",");
+ getFilesToTreateForRoots(in, ex, compileSourceRoots, filesToTreate, null);
+ getFilesToTreateForRoots(in, ex, testCompileSourceRoots, filesToTreate, null);
+
+ boolean doGenerate = !filesToTreate.isEmpty();
+
+ if (doGenerate) {
+
+ File templateFile = new File(template);
+
+ // verifie que la template existe (dans le class-path ou en tant que fichier)
+ checkResource(templateFile);
+
+ URL templateURL = getTemplate(templateFile);
+
+ // recuperation de la license a utiliser
+ LicenseFactory factory = LicenseFactory.newInstance(licenseResolver);
+ License license = factory.revolv(licenseName);
+
+ // obtain content of license header
+ licenseHeaderContent = computeHeader(license, templateURL, generator);
+
+ // build the comment boxed header content
+ boxedLicenseHeaderContent = generator.getHeader(licenseHeaderContent);
+
+ if (verbose) {
+ getLog().info("config - use license " + license.getName());
+ getLog().info("config - use generator " + generator.getName());
+ getLog().info("config - use template " + templateURL);
+ getLog().info("config - header to use \n" + licenseHeaderContent);
+ }
+ } else {
+ getLog().info("no file to treate.");
+ }
+
+ return doGenerate;
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ // create a licence processor with given header
+ LicenseProcessor p = new LicenseProcessor(licenseHeaderContent);
+
+ for (Entry<File, String[]> entry : filesToTreate.entrySet()) {
+ File src = entry.getKey();
+ for (String javaRelativePath : entry.getValue()) {
+ File file = new File(src, javaRelativePath);
+
+ if (verbose) {
+ getLog().info("process file " + file);
+ }
+
+ // file where to writeFile result
+ File processFile = new File(file.getAbsolutePath() + "_" + timestamp);
+
+ try {
+ p.process(file, processFile);
+ boolean foundLicenseHeader = p.getLicenceFilter().wasTouched();
+
+ if (!foundLicenseHeader) {
+ if (p.getLicenceFilter().isDetectHeader()) {
+ getLog().warn("skip file " + file + " (no license footer tag found : '##%*' !)");
+ } else {
+ // no license header found in file, add it
+ getLog().info("adding license header on file " + file);
+ String content = PluginHelper.readAsString(file, encoding);
+ content = boxedLicenseHeaderContent + content;
+ writeFile(processFile, content, encoding);
+ }
+ }
+
+ if (keepBackup) {
+ File backupFile = new File(file.getAbsolutePath() + "~");
+ if (verbose) {
+ getLog().debug("backup original file " + file);
+ }
+ file.renameTo(backupFile);
+ }
+ processFile.renameTo(file);
+
+ } catch (Exception e) {
+ getLog().error("could not process file " + file + " for reason " + e.getMessage(), e);
+ processFile.delete();
+ throw new MojoExecutionException("could not treate source file " + file + " for reason : " + e.getMessage(), e);
+ } finally {
+ // toujours cleaner les états du filtre du processeur
+ p.getLicenceFilter().reset();
+ }
+ }
+ }
+ }
+
+ /**
+ * Construction du header a utiliser.
+ *
+ * Le header est généré à partir de la template velocity donnée et de la
+ * license donnée.
+ *
+ * @param license
+ * @param templateURL
+ * @param generator
+ * @return le header construit
+ * @throws Exception pour toute erreur pendant la construction du header
+ */
+ protected String computeHeader(License license, URL templateURL, HeaderGenerator generator) throws Exception {
+
+ // recuperation de la license a mettre dans le header
+ String licenseContent = license.getHeaderContent(encoding);
+
+ // defined inceptionYear (if year is older than now suffix with a - thisYear)
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ String thisYear = cal.get(Calendar.YEAR) + "";
+ if (!thisYear.equals(inceptionYear)) {
+ inceptionYear = inceptionYear + " - " + thisYear;
+ }
+
+ // preparation de l'environnement velocity
+ Properties env = new Properties();
+ env.put("inceptionYear", inceptionYear);
+ env.put("projectName", projectName);
+ env.put("organizationName", organizationName);
+ env.put("licenseContent", licenseContent);
+
+ if (templateParameters != null) {
+ for (Entry<String, String> e : templateParameters.entrySet()) {
+ env.put(e.getKey(), e.getValue());
+ }
+ }
+ if (verbose) {
+ getLog().info("will use parameters in template : ");
+ for (Entry<Object, Object> e : env.entrySet()) {
+ getLog().info("<" + e.getKey() + " : " + e.getValue() + ">");
+ }
+ }
+
+ // generation du contenu via velocity
+ StringWriter writer = new StringWriter();
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
+ gen.generate(env, writer);
+
+ // recuperation du contenu du texte genere
+ String r = writer.getBuffer().toString();
+
+ // prefixage de toutes les lignes par un " * "
+ String result = generator.prefixContent(r.trim() + "\n\n");
+
+ return '\n' + result;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/license/header/plugin/UpdateHeaderPlugin.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/src/main/resources/META-INF/services/org.nuiton.license.header.generator.HeaderGenerator
===================================================================
--- trunk/src/main/resources/META-INF/services/org.nuiton.license.header.generator.HeaderGenerator 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/resources/META-INF/services/org.nuiton.license.header.generator.HeaderGenerator 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,2 +1,3 @@
-org.nuiton.license.header.generator.JavaHeaderGenerator
-org.nuiton.license.header.generator.XmlHeaderGenerator
+org.nuiton.license.header.generator.impl.JavaHeaderGenerator
+org.nuiton.license.header.generator.impl.XmlHeaderGenerator
+org.nuiton.license.header.generator.impl.PropertiesHeaderGenerator
Deleted: trunk/src/main/resources/defaultHeader.vm
===================================================================
--- trunk/src/main/resources/defaultHeader.vm 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/main/resources/defaultHeader.vm 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,4 +0,0 @@
-$projectName
-Copyright (C) $inceptionYear $organizationName
-
-$licenseContent
Copied: trunk/src/main/resources/license/defaultHeader.vm (from rev 1632, trunk/src/main/resources/defaultHeader.vm)
===================================================================
--- trunk/src/main/resources/license/defaultHeader.vm (rev 0)
+++ trunk/src/main/resources/license/defaultHeader.vm 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,4 @@
+$projectName
+Copyright (C) $inceptionYear $organizationName
+
+$licenseContent
Property changes on: trunk/src/main/resources/license/defaultHeader.vm
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/site/rst/index.rst 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,11 +1,54 @@
Introduction
------------
-Maven license-switcher Plugin
-=============================
+Maven license Plugin
+====================
-The Maven License Switcher Plugin is used to switch the license on java sources of a maven module.
+The Maven License Plugin is used to add or update the header (with license) on
+files.
+License header
+~~~~~~~~~~~~~~
+
+The license header is a comment added on the top of sources files.
+
+To detect the header on files we use processor technology, with tags
+
+::
+
+ *##% Content ##%*
+
+The header is composed of two parts :
+
+ * the first part gives some common informations for all files of a maven
+ module (such as project name, organisation, ...).
+ * the second part resumes the license used.
+
+Here a example :
+
+::
+
+ /**
+ * *##%
+ * Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
Goals Overview
~~~~~~~~~~~~~~
@@ -13,21 +56,29 @@
* `license update-header`_ add or update license header on some files.
+ * `license generator-list`_ display list of available generators.
+
+ * `license license-list`_ display list of available license.
+
* `license help`_ display help about the plugin (goals, usage).
Usage
~~~~~
- Instructions on how to use the Plugin can be found on `usage page`_
+ Instructions on how to use the Plugin can be found on `usage`_ page
Examples
~~~~~~~~
to be done.
-.. _license update-header: license-mojo.html
+.. _license update-header: update-header-mojo.html
+.. _license generator-list: generator-list-mojo.html
+
+.. _license license-list: license-list-mojo.html
+
.. _license help: help-mojo.html
-.. _usage page: usage.html
+.. _usage: usage.html
\ No newline at end of file
Modified: trunk/src/site/rst/usage.rst
===================================================================
--- trunk/src/site/rst/usage.rst 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/site/rst/usage.rst 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,11 +1,51 @@
Usage
-----
-Update-header goal
+generator-list goal
+===================
+
+This goal display of available generators.
+
+Use it directly (and only) from commandline :
+
+::
+
+ mvn license:generator-list
+
+To display an example of each generator, use the *detail* parameter :
+
+::
+
+ mvn license:generator-list -Ddetail
+
+for full detail see `generator-list`_ detail page.
+
+license-list goal
+=================
+
+This goal display of available licenses.
+
+Use it directly (and only) from commandline :
+
+::
+
+ mvn license:license-list
+
+To display the license header, use the *detail* parameter :
+
+::
+
+ mvn license:license-list -Ddetail
+
+for full detail see `license-list`_ detail page.
+
+update-header goal
==================
This goal adds or updates the license header on some files.
+for full detail see `update-header`_ detail page.
+
How does it work ?
~~~~~~~~~~~~~~~~~~
@@ -13,11 +53,13 @@
::
- *##% My LICENSE ##%*
+ *##% My Header ##%*
If the pattern is not found, it will add a license header, otherwise it will
-update the content of the text between tags (here *MY LICENSE*).
+update the content of the text between tags (here *My MyHeader*).
+The plugin will seek in all projets sources roots (and test sources roots).
+
Note : to detect the license header we use the nuiton-processor library.
Update java files
@@ -45,23 +87,39 @@
mvn license:update-header -Dlicense.licenseName=lgpl_v3
-It is possible to use it with other files (see next section)
+It is possible to use it with other files... (see next)
+Construct the license header
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We explain here how to build your own license header.
+
+The licenseName property
+************************
+
+The *licenseName* property indicates which license header to use in the
+file header.
+
+The license discovering is a mecanism from *maven-helper-plugin*, see this
+project to have more detail about it.
+
The generatorName property
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+**************************
-The *generatorName** property allows you to change the type of header to add or
-update. At the moment there is two king of generator :
+The *generatorName* property allows you to change the type of header to add or
+update. At the moment there is two kinds of generator :
- * *java* generator, which box the license header in a java comment style
- * *xml* generator, which box the license header in a xml comment style
+ * *license-java* generator, which box the license header in a java comment style
+ * *license-xml* generator, which box the license header in a xml comment style
+ * *license-properties* generator, which box the license header in a properties comment style (dashed)
Example of java license header :
::
- /**
- * *##% Plugin maven de changement de license
+ /*
+ * *##%
+ * Plugin maven de changement de license
* Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -76,7 +134,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
Example of xml license header :
@@ -84,21 +143,141 @@
::
<!--
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ *##%
+ Plugin maven de changement de license
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
-->
+Example of properties license header :
+
+::
+
+ ###############################################################################
+ # *##%
+ # Plugin maven de changement de license
+ # Copyright (C) 2008 - 2009 CodeLutin
+ #
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as
+ # published by the Free Software Foundation, either version 3 of the
+ # License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Lesser Public License for more details.
+ #
+ # You should have received a copy of the GNU General Lesser Public
+ # License along with this program. If not, see
+ # <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ # ##%*
+ ###############################################################################
+
+The template property
+*********************
+
+The velocity template to use to generate the full license header text.
+
+The template can be a class-path resource, or a file.
+
+By default, the is a template offers by the plugin */license/default.vm*
+
+::
+
+ $projectName
+ Copyright (C) $inceptionYear $organizationName
+
+ $licenseContent
+
+If you want to write your own template, here is the list of available properties
+in the velocity template :
+
+ * *projectName*
+ * *inceptionYear*
+ * *organizationName*
+ * *licenseContent*
+
+And also, all entries of property *templateParameters*.
+
+After been generated, all lines of the content is prefix with generator linePrefix.
+
+Other properties
+****************
+
+There is some other properties used to build the header :
+
+ * *projectName*
+ * *inceptionYear*
+ * *organizationName*
+ * *templateParameters*
+
+See the goal `detail`_ page to have them all.
+
+
+.. _detail: update-header-mojo.html
+
+
+Files to treate
+~~~~~~~~~~~~~~~
+
+To change the set of files to treate, use the *includes* and *excludes*
+properties.
+
+By default, the mojo will scan in all source roots and test source roots
+
+::
+
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <version>XXX</version>
+ <configuration>
+ <includes>**/*.xml,**/*.html</includes>
+ <excludes>**/site.xml</excludes>
+ </configuration>
+ </plugin>
+
+
+help goal
+=========
+
+
+This goal display the help of the plugin (available goals).
+
+Use it directly (and only) from commandline :
+
+::
+
+ mvn license:help
+
+To display verbose help :
+
+::
+
+ mvn license:help -Ddetail
+
+for full detail see `help`_ detail page.
+
+
+.. _update-header: update-header-mojo.html
+
+.. _generator-list: generator-list-mojo.html
+
+.. _license-list: license-list-mojo.html
+
+.. _help: help-mojo.html
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/site/site.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -21,8 +21,11 @@
<menu name="Utilisateur">
<item name="Introduction" href="index.html"/>
+ <item name="Usage" href="usage.html"/>
<item name="Goals" href="plugin-info.html">
<item name="update-header" href="update-header-mojo.html"/>
+ <item name="generator-list" href="generator-list-mojo.html"/>
+ <item name="license-list" href="license-list-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
</menu>
Deleted: trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,86 +0,0 @@
-/**
- * *##% Plugin maven de changement de license
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.license.header;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map.Entry;
-import org.nuiton.util.PluginConfig;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.junit.AfterClass;
-import org.nuiton.util.BasePluginTestCase;
-import org.nuiton.util.PluginHelper;
-
-/** @author chemit */
-public class UpdateHeaderPluginTest extends BasePluginTestCase {
-
- @BeforeClass
- public static void initClass() throws Exception {
- initConfigs(UpdateHeaderPluginTest.class, "testBug_28");
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- configItr = null;
- testDir = null;
- }
-
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @Test
- @PluginConfig(pomName = "bug_28.xml", goalName = "update-header")
- public void testBug_28() throws MojoExecutionException, MojoFailureException, IOException {
- assertNotNull(mojo);
-
- UpdateHeaderPlugin p = (UpdateHeaderPlugin) mojo;
- p.projectName = "projectName";
- p.organizationName = "organizationName";
- p.execute();
-
- for (Entry<File, String[]> entry : p.filesToTreate.entrySet()) {
- File src = entry.getKey();
- for (String javaRelativePath : entry.getValue()) {
- File f = new File(src, javaRelativePath);
- checkPattern("// MUST BE THERE!", true, f);
- }
- }
- }
-
- protected void checkPattern(String pattern, boolean required, File f) throws IOException {
- if (mojo.isVerbose()) {
- mojo.getLog().info("check generated file " + f);
- }
-
- assertTrue("generated file " + f + " was not found...", f.exists());
- String content = PluginHelper.readAsString(f, "utf-8");
-
- String errorMessage = required ? "could not find the pattern : " : "should not have found pattern :";
- assertEquals(errorMessage + pattern + " in file " + f, required, content.contains(pattern));
- }
-}
Copied: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java (from rev 1632, trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java)
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java (rev 0)
+++ trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,125 @@
+package org.nuiton.license.header.plugin;
+
+/**
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+
+import org.nuiton.license.header.plugin.UpdateHeaderPlugin;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map.Entry;
+import org.nuiton.util.PluginConfig;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.junit.AfterClass;
+import org.nuiton.util.BasePluginTestCase;
+import org.nuiton.util.PluginHelper;
+
+/** @author chemit */
+public class UpdateHeaderPluginTest extends BasePluginTestCase {
+
+ UpdateHeaderPlugin plugin;
+
+ @BeforeClass
+ public static void initClass() throws Exception {
+ initConfigs(UpdateHeaderPluginTest.class, "testBug_28", "testJava", "testXml", "testProperties");
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ configItr = null;
+ testDir = null;
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ assertNotNull(mojo);
+ plugin = (UpdateHeaderPlugin) mojo;
+ plugin.setVerbose(true);
+ }
+
+ @Test
+ @PluginConfig(pomName = "bug_28.xml", goalName = "update-header")
+ public void testBug_28() throws Exception {
+
+ testPom(new String[]{"// MUST BE THERE!"}, new String[]{});
+
+ }
+
+ @Test
+ @PluginConfig(pomName = "java.xml", goalName = "update-header")
+ public void testJava() throws Exception {
+
+ testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+
+ }
+
+ @Test
+ @PluginConfig(pomName = "xml.xml", goalName = "update-header")
+ public void testXml() throws Exception {
+
+ testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+
+ }
+
+ @Test
+ @PluginConfig(pomName = "properties.xml", goalName = "update-header")
+ public void testProperties() throws Exception {
+
+ testPom(new String[]{"// MUST BE THERE!"}, new String[]{"*##% license to change ##%*"});
+
+ }
+
+ public void testPom(String[] mandatoryPatterns, String[] excludePatterns) throws Exception {
+
+ plugin.execute();
+
+ for (Entry<File, String[]> entry : plugin.filesToTreate.entrySet()) {
+ File src = entry.getKey();
+ for (String javaRelativePath : entry.getValue()) {
+ File f = new File(src, javaRelativePath);
+
+ assertTrue("generated file " + f + " was not found...", f.exists());
+
+ String content = PluginHelper.readAsString(f, "utf-8");
+
+ if (mojo.isVerbose()) {
+ mojo.getLog().info("check generated file " + f);
+ }
+ for (String p : mandatoryPatterns) {
+ checkPattern(content, p, true, f);
+ }
+ for (String p : excludePatterns) {
+ checkPattern(content, p, false, f);
+ }
+ }
+ }
+ }
+
+ protected void checkPattern(String content, String pattern, boolean required, File f) throws IOException {
+
+ String errorMessage = required ? "could not find the pattern : " : "should not have found pattern :";
+ assertEquals(errorMessage + pattern + " in file " + f, required, content.contains(pattern));
+ }
+}
Property changes on: trunk/src/test/java/org/nuiton/license/header/plugin/UpdateHeaderPluginTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyKO.java2
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyKO.java2 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyKO.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,25 +0,0 @@
-/*
- * *##% Maven helper plugin
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.license.header.UpdateHeaderPluginTest.bug_28;
-
-/** @author chemit */
-public class JavaDummy {
-
-// MUST BE THERE!
-}
Deleted: trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyOK.java2
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyOK.java2 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyOK.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,25 +0,0 @@
-/*
- * *##% Maven helper plugin
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%
- */
-package org.nuiton.license.header.UpdateHeaderPluginTest.bug_28;
-
-/** @author chemit */
-public class JavaDummy {
-
-// MUST BE THERE!
-}
Deleted: trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml 2009-08-28 10:14:10 UTC (rev 1632)
+++ trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -1,41 +0,0 @@
-<?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/maven-v4_0_0.xsd">
-
- <groupId>org.nuiton</groupId>
- <artifactId>maven-license-plugin-bug_28</artifactId>
- <version>0</version>
-
- <name>TestOne</name>
-
- <build>
-
- <plugins>
- <plugin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-license-plugin</artifactId>
- <configuration>
- <encoding>UTF-8</encoding>
- <licenseName>lgpl_v3</licenseName>
- <generatorName>java</generatorName>
- <includes>**/*.java2</includes>
- <template>/defaultHeader.vm</template>
- <compileSourceRoots>
- <dir>target/test-classes/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28</dir>
- </compileSourceRoots>
- <testCompileSourceRoots>
- </testCompileSourceRoots>
- <!--<verbose>true</verbose>-->
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>update-header</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
Copied: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_done.java2 (from rev 1630, trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyKO.java2)
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_done.java2 (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_done.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,25 @@
+/*
+ * *##% Maven helper plugin
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+package org.nuiton.license.header.UpdateHeaderPluginTest.bug_28;
+
+/** @author chemit */
+public class JavaDummy {
+
+// MUST BE THERE!
+}
Property changes on: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_done.java2
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_skip.java2 (from rev 1630, trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28/JavaDummyOK.java2)
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_skip.java2 (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_skip.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,25 @@
+/*
+ * *##% Maven helper plugin
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%
+ */
+package org.nuiton.license.header.UpdateHeaderPluginTest.bug_28;
+
+/** @author chemit */
+public class JavaDummy {
+
+// MUST BE THERE!
+}
Property changes on: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28/JavaDummy_skip.java2
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28.xml (from rev 1632, trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml)
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,43 @@
+<?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/maven-v4_0_0.xsd">
+
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin-bug_28</artifactId>
+ <version>0</version>
+
+ <name>TestOne</name>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <projectName>maven-license-plugin-bug_28</projectName>
+ <organizationName>CodeLutin</organizationName>
+ <inceptionYear>2009</inceptionYear>
+ <encoding>UTF-8</encoding>
+ <licenseName>lgpl_v3</licenseName>
+ <generatorName>license-java</generatorName>
+ <template>/license/defaultHeader.vm</template>
+ <compileSourceRoots>
+ <dir>target/test-classes/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28</dir>
+ </compileSourceRoots>
+ <testCompileSourceRoots/>
+ <includes>**/*.java2</includes>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>update-header</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Property changes on: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/bug_28.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy.java2
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy.java2 (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,10 @@
+/*
+ * *##% license to change ##%*
+ */
+package org.nuiton.license.header.UpdateHeaderPluginTest.java;
+
+/** @author chemit */
+public class JavaDummy {
+
+// MUST BE THERE!
+}
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy_none.java2
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy_none.java2 (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/JavaDummy_none.java2 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,7 @@
+package org.nuiton.license.header.UpdateHeaderPluginTest.java;
+
+/** @author chemit */
+public class JavaDummy {
+
+// MUST BE THERE!
+}
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy.css 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,7 @@
+/*
+ * *##% license to change ##%*
+ */
+
+.yo {
+ content:"// MUST BE THERE!";
+}
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java/javaDummy_none.css 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,3 @@
+ .yo {
+ content:"// MUST BE THERE!";
+ }
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,43 @@
+<?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/maven-v4_0_0.xsd">
+
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin-java</artifactId>
+ <version>0</version>
+
+ <name>TestOne</name>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <projectName>maven-license-plugin-java</projectName>
+ <organizationName>CodeLutin</organizationName>
+ <inceptionYear>2009</inceptionYear>
+ <encoding>UTF-8</encoding>
+ <licenseName>lgpl_v3</licenseName>
+ <generatorName>license-java</generatorName>
+ <template>/license/defaultHeader.vm</template>
+ <compileSourceRoots>
+ <dir>target/test-classes/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/java</dir>
+ </compileSourceRoots>
+ <testCompileSourceRoots/>
+ <includes>**/*.java2,**/*.css</includes>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>update-header</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.properties
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.properties (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.properties 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,6 @@
+####
+# *##% license to change ##%*
+####
+
+property.one=one
+# // MUST BE THERE!
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.sh
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.sh (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy.sh 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+####
+# *##% license to change ##%*
+####
+
+echo " // MUST BE THERE!"
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.properties
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.properties (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.properties 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,2 @@
+property.one=one
+# // MUST BE THERE!
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.sh
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.sh (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties/javaDummy_none.sh 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo " // MUST BE THERE!"
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,43 @@
+<?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/maven-v4_0_0.xsd">
+
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin-properties</artifactId>
+ <version>0</version>
+
+ <name>TestOne</name>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <projectName>maven-license-plugin-properties</projectName>
+ <organizationName>CodeLutin</organizationName>
+ <inceptionYear>2009</inceptionYear>
+ <encoding>UTF-8</encoding>
+ <licenseName>lgpl_v3</licenseName>
+ <generatorName>license-properties</generatorName>
+ <template>/license/defaultHeader.vm</template>
+ <compileSourceRoots>
+ <dir>target/test-classes/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/properties</dir>
+ </compileSourceRoots>
+ <testCompileSourceRoots/>
+ <includes>**/*.properties,**/*.sh</includes>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>update-header</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.html
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.html (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.html 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,9 @@
+<!--
+ * *##% license to change ##%*
+-->
+<html>
+ <head/>
+ <body>
+ // MUST BE THERE!
+ </body>
+</html>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,6 @@
+<!--
+ * *##% license to change ##%*
+ -->
+<xml>
+ // MUST BE THERE!
+</xml>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.html
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.html (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.html 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,6 @@
+<html>
+ <head/>
+ <body>
+ // MUST BE THERE!
+ </body>
+</html>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml/javaDummy_none.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,4 @@
+
+<xml>
+ // MUST BE THERE!
+</xml>
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml.xml 2009-08-29 15:29:58 UTC (rev 1633)
@@ -0,0 +1,43 @@
+<?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/maven-v4_0_0.xsd">
+
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin-xml</artifactId>
+ <version>0</version>
+
+ <name>TestOne</name>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <projectName>maven-license-plugin-xml</projectName>
+ <organizationName>CodeLutin</organizationName>
+ <inceptionYear>2009</inceptionYear>
+ <encoding>UTF-8</encoding>
+ <licenseName>lgpl_v3</licenseName>
+ <generatorName>license-xml</generatorName>
+ <template>/license/defaultHeader.vm</template>
+ <compileSourceRoots>
+ <dir>target/test-classes/org/nuiton/license/header/plugin/UpdateHeaderPluginTest/xml</dir>
+ </compileSourceRoots>
+ <testCompileSourceRoots/>
+ <includes>**/*.xml,**/*.html</includes>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>update-header</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
1
0
r1632 - in trunk/src: main/java/org/nuiton/license/header main/resources site site/rst test/java/org/nuiton/license/header test/resources/org/nuiton/license/header/UpdateHeaderPluginTest
by tchemit@users.nuiton.org 28 Aug '09
by tchemit@users.nuiton.org 28 Aug '09
28 Aug '09
Author: tchemit
Date: 2009-08-28 12:14:10 +0200 (Fri, 28 Aug 2009)
New Revision: 1632
Added:
trunk/src/main/resources/defaultHeader.vm
Modified:
trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java
trunk/src/site/rst/usage.rst
trunk/src/site/site.xml
trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java
trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml
Log:
- can customize header template (with velocity)
- begin of usage docs
Modified: trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java 2009-08-26 20:26:44 UTC (rev 1631)
+++ trunk/src/main/java/org/nuiton/license/header/UpdateHeaderPlugin.java 2009-08-28 10:14:10 UTC (rev 1632)
@@ -24,11 +24,15 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.ServiceLoader;
import java.util.TreeMap;
import org.apache.maven.project.MavenProject;
@@ -37,6 +41,7 @@
import org.nuiton.license.LicenseFactory;
import org.nuiton.license.header.generator.HeaderGenerator;
import org.nuiton.util.PluginHelper;
+import org.nuiton.util.VelocityTemplateGenerator;
/**
* The goal to update (or add) the licence header on some files.
@@ -167,6 +172,22 @@
*/
protected String licenseResolver;
/**
+ * La template (velocity) a utiliser pour construire le header.
+ *
+ * Cette template doit être dans le class-path ou être un fichier existant
+ *
+ * @parameter expression="${license.template}" default-value="/defaultHeader.vm"
+ * @since 1.0.1
+ */
+ protected String template;
+ /**
+ * Des paramètres supplémentaires à utiliser dans la template du header.
+ *
+ * @parameter
+ * @since 1.0.1
+ */
+ protected Map<String, String> templateParameters;
+ /**
* Un flag pour conserver un backup des fichiers modifies.
*
* @parameter expression="${license.keepBackup}" default-value="false"
@@ -220,7 +241,7 @@
}
@Override
- public boolean init() throws IOException, MojoExecutionException {
+ public boolean init() throws Exception {
timestamp = System.nanoTime();
@@ -244,16 +265,26 @@
if (doGenerate) {
+ File templateFile = new File(template);
+
+ // verifie que la template existe (dans le class-path ou en tant que fichier)
+ checkResource(templateFile);
+
+ URL templateURL = getTemplate(templateFile);
+
+ // recuperation de la license a utiliser
LicenseFactory factory = LicenseFactory.newInstance(licenseResolver);
License license = factory.revolv(licenseName);
// obtain content of license header
- licenseHeaderContent = computeHeader(license);
+ licenseHeaderContent = computeHeader(license, templateURL);
+ // recuperation du generateur de header a utiliser
generator = availableGenerators.get(generatorName);
if (verbose) {
- getLog().info("config - will use the generator " + generator);
+ getLog().info("config - use the generator " + generator);
+ getLog().info("config - use template " + templateURL);
getLog().info("config - header to use \n" + licenseHeaderContent);
}
} else {
@@ -301,7 +332,7 @@
if (!foundLicenseHeader) {
if (p.getLicenceFilter().isDetectHeader()) {
- getLog().warn("license footer tag was not find on file " + file);
+ getLog().warn("skip file " + file + " (no license footer tag found : '##%*' !)");
} else {
// no license header found in file, add it
getLog().info("adding license header on file " + file);
@@ -350,9 +381,9 @@
return files;
}
- protected String computeHeader(License license) throws IOException {
+ protected String computeHeader(License license, URL templateURL) throws Exception {
- String tmpHeader = license.getHeaderContent(encoding);
+ String licenseContent = license.getHeaderContent(encoding);
// defined inceptionYear (if year is older than now suffix with a - thisYear)
Calendar cal = Calendar.getInstance();
@@ -362,11 +393,31 @@
inceptionYear = inceptionYear + " - " + thisYear;
}
- // format header with projet informations
- tmpHeader = String.format(tmpHeader, projectName, inceptionYear, organizationName);
+ Properties env = new Properties();
+ env.put("inceptionYear", inceptionYear);
+ env.put("projectName", projectName);
+ env.put("organizationName", organizationName);
+ env.put("licenseContent", licenseContent);
+ if (templateParameters != null) {
+ for (Entry<String, String> e : templateParameters.entrySet()) {
+ env.put(e.getKey(), e.getValue());
+ }
+ }
+ if (verbose) {
+ getLog().info("will use parameters in template : ");
+ for (Entry<Object, Object> e : env.entrySet()) {
+ getLog().info("<" + e.getKey() + " : " + e.getValue() + ">");
+ }
+ }
+ StringWriter f = new StringWriter();
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
+ gen.generate(env, f);
+
+ String r = f.getBuffer().toString();
+
// add " * " before each line
- BufferedReader reader = new BufferedReader(new java.io.StringReader(tmpHeader));
+ BufferedReader reader = new BufferedReader(new java.io.StringReader(r));
StringBuilder sb = new StringBuilder();
String line = reader.readLine();
@@ -379,7 +430,36 @@
sb.append(" * ").append(line).append("\n");
}
}
- tmpHeader = sb.toString();
- return tmpHeader.substring(0, tmpHeader.length() - 1);
+
+ String result = sb.toString();
+
+ return result.substring(0, result.length() - 1);
}
+
+ protected URL getTemplate(File f) throws IOException {
+ URL r = null;
+ if (f.exists()) {
+ r = f.toURI().toURL();
+ } else {
+ r = getClass().getResource(f.toString());
+ }
+ return r;
+ }
+
+ protected void checkResource(File f) throws IOException {
+ if (!f.exists()) {
+ // test in classPath
+ InputStream r = null;
+ try {
+ r = getClass().getResourceAsStream(f.toString());
+ if (r == null) {
+ throw new IOException("could not find ressource " + f);
+ }
+ } finally {
+ if (r != null) {
+ r.close();
+ }
+ }
+ }
+ }
}
Added: trunk/src/main/resources/defaultHeader.vm
===================================================================
--- trunk/src/main/resources/defaultHeader.vm (rev 0)
+++ trunk/src/main/resources/defaultHeader.vm 2009-08-28 10:14:10 UTC (rev 1632)
@@ -0,0 +1,4 @@
+$projectName
+Copyright (C) $inceptionYear $organizationName
+
+$licenseContent
Modified: trunk/src/site/rst/usage.rst
===================================================================
--- trunk/src/site/rst/usage.rst 2009-08-26 20:26:44 UTC (rev 1631)
+++ trunk/src/site/rst/usage.rst 2009-08-28 10:14:10 UTC (rev 1632)
@@ -1,4 +1,104 @@
Usage
-----
-To be done soon...
\ No newline at end of file
+Update-header goal
+==================
+
+This goal adds or updates the license header on some files.
+
+How does it work ?
+~~~~~~~~~~~~~~~~~~
+
+The plugin is looking in the included files for the text between the tags :
+
+::
+
+ *##% My LICENSE ##%*
+
+If the pattern is not found, it will add a license header, otherwise it will
+update the content of the text between tags (here *MY LICENSE*).
+
+Note : to detect the license header we use the nuiton-processor library.
+
+Update java files
+~~~~~~~~~~~~~~~~~
+
+The usual files to use such license header are java sources, that's why it is
+configure to do this task and should ask you the minimum config
+
+::
+
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <version>XXX</version>
+ <configuration>
+ <licenseName>lgpl_v3</licenseName>
+ </configuration>
+ </plugin>
+
+will add or update for all java source files of the module (and java test files).
+
+The command can be launch on the commandline :
+
+::
+
+ mvn license:update-header -Dlicense.licenseName=lgpl_v3
+
+It is possible to use it with other files (see next section)
+
+The generatorName property
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The *generatorName** property allows you to change the type of header to add or
+update. At the moment there is two king of generator :
+
+ * *java* generator, which box the license header in a java comment style
+ * *xml* generator, which box the license header in a xml comment style
+
+Example of java license header :
+
+::
+
+ /**
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+Example of xml license header :
+
+::
+
+ <!--
+ * *##% Plugin maven de changement de license
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ -->
+
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-08-26 20:26:44 UTC (rev 1631)
+++ trunk/src/site/site.xml 2009-08-28 10:14:10 UTC (rev 1632)
@@ -22,9 +22,7 @@
<menu name="Utilisateur">
<item name="Introduction" href="index.html"/>
<item name="Goals" href="plugin-info.html">
- <item name="java-update-header" href="java-update-header-mojo.html"/>
- <item name="jaxx-update-header" href="jaxx-update-header-mojo.html"/>
- <item name="switch" href="switch-mojo.html"/>
+ <item name="update-header" href="update-header-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
</menu>
Modified: trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java 2009-08-26 20:26:44 UTC (rev 1631)
+++ trunk/src/test/java/org/nuiton/license/header/UpdateHeaderPluginTest.java 2009-08-28 10:14:10 UTC (rev 1632)
@@ -59,6 +59,8 @@
assertNotNull(mojo);
UpdateHeaderPlugin p = (UpdateHeaderPlugin) mojo;
+ p.projectName = "projectName";
+ p.organizationName = "organizationName";
p.execute();
for (Entry<File, String[]> entry : p.filesToTreate.entrySet()) {
Modified: trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml 2009-08-26 20:26:44 UTC (rev 1631)
+++ trunk/src/test/resources/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28.xml 2009-08-28 10:14:10 UTC (rev 1632)
@@ -20,6 +20,7 @@
<licenseName>lgpl_v3</licenseName>
<generatorName>java</generatorName>
<includes>**/*.java2</includes>
+ <template>/defaultHeader.vm</template>
<compileSourceRoots>
<dir>target/test-classes/org/nuiton/license/header/UpdateHeaderPluginTest/bug_28</dir>
</compileSourceRoots>
1
0