Nuiton-utils-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
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
August 2008
- 2 participants
- 110 discussions
[Lutinutil-commits] r1056 - in trunk/lutinutil/src/main/java/org/codelutin: log util
by bpoussin@users.labs.libre-entreprise.org 21 Aug '08
by bpoussin@users.labs.libre-entreprise.org 21 Aug '08
21 Aug '08
Author: bpoussin
Date: 2008-08-21 16:25:08 +0000 (Thu, 21 Aug 2008)
New Revision: 1056
Added:
trunk/lutinutil/src/main/java/org/codelutin/log/UserLog.java
Modified:
trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java
trunk/lutinutil/src/main/java/org/codelutin/util/ListenerSet.java
Log:
- Ajout d'un nouvelle classe de log UserLog (tout debut) pour permettre des logs graphiques ou non pour l'utilisateur
- correction de bug dans ApplicationConfig (si donnee en cache, on retournait null a la la place de la valeur)
Added: trunk/lutinutil/src/main/java/org/codelutin/log/UserLog.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/log/UserLog.java (rev 0)
+++ trunk/lutinutil/src/main/java/org/codelutin/log/UserLog.java 2008-08-21 16:25:08 UTC (rev 1056)
@@ -0,0 +1,153 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package org.codelutin.log;
+
+
+import java.awt.GraphicsEnvironment;
+import javax.swing.JOptionPane;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ListenerSet;
+
+/**
+ * Classe permettant d'afficher facillement des messages a l'utilisateur.
+ * Si une interface graphique est disponible alors des boites de dialogue
+ * sont affichees. Il est aussi possible d'indique des composants a utiliser
+ * pour afficher les messages. N'importe quel composant ayant une methode
+ * setText convient
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class UserLog {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(UserLog.class);
+
+ static public enum Level {
+ DEBUG, INFO, WARN, ERROR, FATAL
+ }
+
+ protected static ListenerSet<Object> listeners = new ListenerSet<Object>();
+ protected static boolean graphicUI = true;
+
+ public static void addListeners(ListenerSet<Object> l) {
+ listeners.add(l);
+ }
+ public static void removeListeners(ListenerSet<Object> l) {
+ listeners.remove(l);
+ }
+
+
+ public static void setGraphicUI(boolean graphicUI) {
+ UserLog.graphicUI = graphicUI;
+ }
+
+ public static boolean isGraphicUI() {
+ return graphicUI && !GraphicsEnvironment.isHeadless();
+ }
+
+ /**
+ * Appel la methode setText de tous les listeners avec le message en
+ * parametre et si {@link #isGraphicUI} retourne vrai affiche une boite
+ * de dialogue avec le message
+ *
+ * @param level le niveau du message
+ * @param msg le message
+ * @param eee l'exception s'il y en a une
+ */
+ protected static void show(Level level, String msg, Throwable eee) {
+ try {
+ listeners.fire("setText", msg);
+ } catch (Exception zzz) {
+ log.warn("Can't call setText on listener", zzz);
+ }
+
+ if (isGraphicUI()) {
+ String title = level.name();
+ int type = JOptionPane.PLAIN_MESSAGE;
+ switch (level) {
+ case DEBUG:
+ type = JOptionPane.PLAIN_MESSAGE;
+ break;
+ case INFO:
+ type = JOptionPane.INFORMATION_MESSAGE;
+ break;
+ case WARN:
+ type = JOptionPane.WARNING_MESSAGE;
+ break;
+ case ERROR:
+ case FATAL:
+ type = JOptionPane.ERROR_MESSAGE;
+ break;
+ }
+ JOptionPane.showMessageDialog(null, msg, title, type);
+ }
+ }
+
+ public static void debug(String msg) {
+ log.debug(msg);
+ show(Level.DEBUG, msg, null);
+ }
+ public static void debug(String msg, Throwable eee) {
+ log.debug(msg, eee);
+ show(Level.DEBUG, msg, eee);
+ }
+
+ public static void info(String msg) {
+ log.info(msg);
+ show(Level.INFO, msg, null);
+ }
+ public static void info(String msg, Throwable eee) {
+ log.info(msg, eee);
+ show(Level.INFO, msg, eee);
+ }
+
+ public static void warn(String msg) {
+ log.warn(msg);
+ show(Level.WARN, msg, null);
+ }
+ public static void warn(String msg, Throwable eee) {
+ log.warn(msg, eee);
+ show(Level.WARN, msg, eee);
+ }
+
+ public static void error(String msg) {
+ log.error(msg);
+ show(Level.ERROR, msg, null);
+ }
+ public static void error(String msg, Throwable eee) {
+ log.error(msg, eee);
+ show(Level.ERROR, msg, eee);
+ }
+
+ public static void fatal(String msg) {
+ log.fatal(msg);
+ show(Level.FATAL, msg, null);
+ }
+ public static void fatal(String msg, Throwable eee) {
+ log.fatal(msg, eee);
+ show(Level.FATAL, msg, eee);
+ }
+
+}
Modified: trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-08-20 13:20:48 UTC (rev 1055)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-08-21 16:25:08 UTC (rev 1056)
@@ -272,7 +272,7 @@
*/
static final private String CLASS_METHOD_SEPARATOR = "#";
- static final public String CONFIG_FILE_NAME = "configFileName";
+ static final public String CONFIG_FILE_NAME = "config.file";
protected boolean useOnlyAliases = false;
protected Map<String, List<String>> aliases = new HashMap<String, List<String>>();
@@ -547,6 +547,8 @@
result = (T) ConvertUtils.convert(value, clazz);
cacheItem = new CacheItem<T>(result, hash);
cacheOption.put(cacheKey, cacheItem);
+ } else {
+ result = cacheItem.item;
}
return result;
@@ -884,4 +886,21 @@
throw new ArgumentsParserException("Can't parse argument", eee);
}
}
+
+ /**
+ * For debugging
+ */
+ public void printConfig() {
+ System.out.println("-------------------Value-------------------------");
+ System.out.println("defaults " + defaults);
+ System.out.println("classpath " + classpath);
+ System.out.println("etcfile " + etcfile);
+ System.out.println("homefile " + homefile);
+ System.out.println("curfile " + curfile);
+ System.out.println("env " + env);
+ System.out.println("jvm " + jvm);
+ System.out.println("line " + line);
+ System.out.println("options " + options);
+ System.out.println("-------------------------------------------------");
+ }
}
Modified: trunk/lutinutil/src/main/java/org/codelutin/util/ListenerSet.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/ListenerSet.java 2008-08-20 13:20:48 UTC (rev 1055)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/ListenerSet.java 2008-08-21 16:25:08 UTC (rev 1056)
@@ -119,7 +119,7 @@
*/
public void addAll(ListenerSet<Listerner> ls) {
// if (listenerClass == null || (ls.listenerClass != null &&
-// listenerClass.isAssignableFrom(ls.listenerClass))) {
+// listenerClass.isAssignableFrom(ls.listenDOCUMENTME Description of the ExceptionerClass))) {
listeners.addAll(ls.listeners);
// } else {
// throw new IllegalArgumentException("Listener object ("
@@ -133,9 +133,9 @@
* Cette méthode echoue si la methode ou l'objet contenant la methode a
* appeler n'est pas public
*
+ * @param methodName le nom de la methode a appeler
* @param event l'event a passer en parametre de la methode a appeler
- * @param methodName DOCUMENTME Description of the Parameter
- * @throws Exception DOCUMENTME Description of the Exception
+ * @throws Exception si un des listeners leve une exception lors de l'appel
*/
public void fire(String methodName, Object event) throws Exception {
for (Iterator i = iterator(); i.hasNext();) {
@@ -150,8 +150,8 @@
* Cette méthode echoue si la methode ou l'objet contenant la methode a
* appeler n'est pas public
*
- * @param methodName DOCUMENTME Description of the Parameter
- * @throws Exception DOCUMENTME Description of the Exception
+ * @param methodName le nom de la methode a appeler
+ * @throws Exception si un des listeners leve une exception lors de l'appel
*/
public void fire(String methodName) throws Exception {
for (Iterator i = iterator(); i.hasNext();) {
1
0
20 Aug '08
Author: bpoussin
Date: 2008-08-20 13:20:48 +0000 (Wed, 20 Aug 2008)
New Revision: 1055
Modified:
trunk/lutinutil/changelog
Log:
ajout de deprecated de ArgumentParser
Modified: trunk/lutinutil/changelog
===================================================================
--- trunk/lutinutil/changelog 2008-08-19 18:41:23 UTC (rev 1054)
+++ trunk/lutinutil/changelog 2008-08-20 13:20:48 UTC (rev 1055)
@@ -1,11 +1,15 @@
ver-0-31 chemit 2008????
* utilisation de lutinproject 2.4 et nettoyage du pom
* reorganisation du site
+ * <poussin> ArgumentsParser.java marked deprecated
ver-0-30 chemit 20080710
- * passage en maven 2 layout directory
- * utilisation de lutinproject 2.3
- * suppression du code vcs du projet
+ * <chemit> passage en maven 2 layout directory
+ * <chemit> utilisation de lutinproject 2.3
+ * <chemit> suppression du code vcs du projet
+ * <poussin> add ApplicationConfig class
+ * <poussin> enhance ObjectUtil
+ * <poussin> HashMapMultiKey marked deprecated
ver-0-26 poussin 2007????
* bug in concat(Object [] ...), better array type now work
1
0
[Lutinutil-commits] r1054 - trunk/lutinutil/src/main/java/org/codelutin/util
by bpoussin@users.labs.libre-entreprise.org 19 Aug '08
by bpoussin@users.labs.libre-entreprise.org 19 Aug '08
19 Aug '08
Author: bpoussin
Date: 2008-08-19 18:41:23 +0000 (Tue, 19 Aug 2008)
New Revision: 1054
Modified:
trunk/lutinutil/src/main/java/org/codelutin/util/ArgumentsParser.java
Log:
annonce que cette lib est depreciee
Modified: trunk/lutinutil/src/main/java/org/codelutin/util/ArgumentsParser.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/ArgumentsParser.java 2008-08-19 18:40:42 UTC (rev 1053)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/ArgumentsParser.java 2008-08-19 18:41:23 UTC (rev 1054)
@@ -40,7 +40,11 @@
* Parser d'option de la ligne de commande.
* IDEA: ajouter le type de l'argument a parser (int, double, String, boolean, Class, File, ...)
* et mettre des methodes pour récupérer directement ce type.
+ *
+ * @author poussin
+ * @deprecated utiliser maintenant {@link ApplicationConfig}
*/
+@Deprecated
public class ArgumentsParser {
/** La liste des arguments qui ne sont pas des options */
1
0
[Lutinutil-commits] r1053 - trunk/lutinutil/src/main/java/org/codelutin/util
by bpoussin@users.labs.libre-entreprise.org 19 Aug '08
by bpoussin@users.labs.libre-entreprise.org 19 Aug '08
19 Aug '08
Author: bpoussin
Date: 2008-08-19 18:40:42 +0000 (Tue, 19 Aug 2008)
New Revision: 1053
Modified:
trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java
Log:
ajout commentaire et uncheck
Modified: trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java
===================================================================
--- trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-08-18 22:21:09 UTC (rev 1052)
+++ trunk/lutinutil/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-08-19 18:40:42 UTC (rev 1053)
@@ -530,6 +530,7 @@
* @param key the option's key
* @return typed value
*/
+ @SuppressWarnings("unchecked")
public <T> T getOption(Class<T> clazz, String key) {
T result = null;
String cacheKey = key + "-" + clazz.getName();
1
0
[Lutinutil-commits] r1052 - trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 22:21:09 +0000 (Mon, 18 Aug 2008)
New Revision: 1052
Modified:
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
Log:
version finale du plugin license-switcher (certainsrepertoires peuvent ne pas exister)
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 22:19:20 UTC (rev 1051)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 22:21:09 UTC (rev 1052)
@@ -181,7 +181,7 @@
for (String src : roots) {
File f = new File(src);
- if (f.exists()) {
+ if (!f.exists()) {
// do nothing
continue;
}
1
0
[Lutinutil-commits] r1051 - trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 22:19:20 +0000 (Mon, 18 Aug 2008)
New Revision: 1051
Modified:
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
Log:
version finale du plugin license-switcher (certainsrepertoires peuvent ne pas exister)
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 22:19:20 UTC (rev 1051)
@@ -180,10 +180,14 @@
roots.addAll(testCompileSourceRoots);
for (String src : roots) {
+ File f = new File(src);
+ if (f.exists()) {
+ // do nothing
+ continue;
+ }
if (verbose) {
getLog().info("discovering java source files in root " + src);
}
- File f = new File(src);
ds.setBasedir(f);
// scan
ds.scan();
1
0
[Lutinutil-commits] r1050 - in trunk/maven-license-switcher-plugin/src: main/java/org/codelutin/license site/apt test/java/org/codelutin/license
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 22:16:08 +0000 (Mon, 18 Aug 2008)
New Revision: 1050
Added:
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AbstractLicenceMojo.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseMojo.java
Modified:
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java
trunk/maven-license-switcher-plugin/src/site/apt/index.apt
trunk/maven-license-switcher-plugin/src/site/apt/usage.apt
trunk/maven-license-switcher-plugin/src/test/java/org/codelutin/license/LicenseTypeTest.java
Log:
version finale du plugin license-switcher
Added: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AbstractLicenceMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AbstractLicenceMojo.java (rev 0)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AbstractLicenceMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -0,0 +1,107 @@
+/**
+ * *##% Plugin maven pour switcher les licenses
+ * Copyright (C) 2008 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.codelutin.license;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codelutin.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Un MOJO de base pour les autres MOJO concrets avec les options communes.
+ *
+ * @author chemit
+ */
+public abstract class AbstractLicenceMojo extends AbstractMojo {
+
+ /**
+ * la methode qui est lancee au debut de la methode {@link #execute()} pour preparer l'init du goal.
+ *
+ * @throws Exception if any
+ */
+ protected abstract void init() throws Exception;
+
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Repertoire de sortie des classes (classpath).
+ *
+ * @parameter expression="${licence-switcher.outputDirectory}" default-value="${project.build.outputDirectory}"
+ * @required
+ */
+ protected File projectOutputDirectory;
+
+ /**
+ * Encoding a utiliser pour lire et ecrire les fichiers.
+ *
+ * @parameter expression="${licence-switcher.encoding}" default-value="${maven.compile.encoding}"
+ * @required
+ */
+ protected String encoding;
+
+ /**
+ * Un flag pour conserver un backup des fichiers modifies.
+ *
+ * @parameter expression="${license-switcher.keepBackup}" default-value="false"
+ */
+ protected boolean keepBackup;
+ /**
+ * Un flag pour activer le mode verbeux.
+ *
+ * @parameter expression="${license-switcher.verbose}" default-value="false"
+ */
+ protected boolean verbose;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e);
+ }
+ }
+
+ protected void copyFileToOutputDirectory(File file) throws MojoExecutionException {
+
+ final String type = project.getArtifact().getType();
+ if ("pom".equals(type) || "site".equals(type)) {
+ // project is not classpath cabable
+ return;
+ }
+ File target = new File(projectOutputDirectory, file.getName());
+
+ try {
+
+ FileUtil.copy(file, target);
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("could not write file " + target + " for reason : " + e.getMessage(), e);
+ }
+ }
+}
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -3,8 +3,8 @@
* Copyright (C) 2008 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
+ * 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,
@@ -12,7 +12,7 @@
* 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
+ * 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>. ##%*
*/
Added: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseMojo.java (rev 0)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -0,0 +1,108 @@
+/**
+ * *##% Plugin maven pour switcher les licenses
+ * Copyright (C) 2008 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.codelutin.license;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codelutin.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Le goal pour ajouter le fichier LICENSE.txt dans le classpath (et le generer s'il n'existe pas).
+ *
+ * @author chemit
+ * @goal license
+ * @phase process-classes
+ * @requiresProject true
+ */
+public class LicenseMojo extends AbstractLicenceMojo {
+ /**
+ * Un flag pour indiquer la regeneration des fichiers.
+ *
+ * @parameter expression="${license-switcher.doGenerate}" default-value="false"
+ */
+ protected boolean doGenerate;
+ /**
+ * Fichier de la licence du module.
+ *
+ * @parameter expression="${license-switcher.licenceFile}" default-value="${basedir}/LICENSE.txt"
+ * @required
+ * @readonly
+ */
+ protected File licenseFile;
+
+ /**
+ * Le type de license a appliquer.
+ *
+ * @parameter expression="${license-switcher.licenseType}" default-value="LGPL_V3"
+ * @required
+ */
+ protected String licenseType;
+
+ /** le header a ajouter dans chaque fichier java */
+ protected String licenseHeaderContent;
+
+ /** le texte de la licence a placer dans le fichier ${basedir}/LICENSE.txt */
+ protected String licenseFileContent;
+
+ protected void init() throws Exception {
+
+ // must generate if file does not exist
+ doGenerate = doGenerate || !licenseFile.exists();
+
+ if (doGenerate) {
+
+ // prepare licenseFileContent
+
+ LicenseType type = LicenseType.valueOf(licenseType);
+
+ licenseFileContent = FileUtil.readAsString(type.getLicenceFileReader(encoding));
+ }
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ super.execute();
+
+ if (doGenerate) {
+
+ if (licenseFile.exists() && keepBackup) {
+ if (verbose) {
+ getLog().info("backup " + licenseFile);
+ }
+ // copy it to backup file
+ File backup = new File(licenseFile.getAbsolutePath() + "~");
+ licenseFile.renameTo(backup);
+ }
+ try {
+ FileUtil.writeString(licenseFile, licenseFileContent, encoding);
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("could not write license file " + licenseFile + " for reason : " + e.getMessage(), e);
+ }
+ }
+
+ // copy LICENSE.txt to classpath
+ copyFileToOutputDirectory(licenseFile);
+ }
+
+}
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -3,8 +3,8 @@
* Copyright (C) 2008 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
+ * 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,
@@ -12,7 +12,7 @@
* 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
+ * 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/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -1,10 +1,9 @@
-/**
- * *##% Plugin maven pour switcher les licenses
+/*##% Plugin maven pour switcher les licenses
* Copyright (C) 2008 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
+ * 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,
@@ -12,16 +11,14 @@
* 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
+ * 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.codelutin.license;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codelutin.processor.LicenseProcessor;
import org.codelutin.processor.filters.LicenseFilter;
@@ -30,29 +27,25 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
/**
- * Le goal pour switcher les licenses de tous les sources java d'un module maven et de positionner le fichier LICENSE.txt
+ * Le goal pour switcher les licenses de tous les sources java d'un module
+ * maven.
*
* @author chemit
* @goal switch
- * @phase process-sources
- * @execute goal=third-party
+ * @phase process-resources
* @requiresProject true
*/
-public class SwitchLicenseMojo extends AbstractMojo {
+public class SwitchLicenseMojo extends AbstractLicenceMojo {
/**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
* l'annee de creation du module (sera place dans le header)
*
* @parameter default-value="${project.inceptionYear}"
@@ -61,7 +54,7 @@
protected String inceptionYear;
/**
- * le nom de l'organisation ( sera place dans le header)
+ * le nom de l'organisation (sera place dans le header)
*
* @parameter default-value="${project.organization.name}"
* @required
@@ -70,7 +63,7 @@
protected String organizationName;
/**
- * le nom du projet ( sera place dans le header)
+ * le nom du projet (sera place dans le header)
*
* @parameter default-value="${project.name}"
* @required
@@ -78,128 +71,163 @@
*/
protected String projectName;
-
/**
- * encoding a utiliser pour lire et ecrire les fichiers.
+ * Le type de license a appliquer.
*
- * @parameter expression="${licence-switcher.encoding}" default-value="${maven.compile.encoding}"
+ * @parameter expression="${license-switcher.licenseType}" default-value="LGPL_V3"
* @required
*/
- protected String encoding;
+ protected String licenseType;
/**
- * Repertoire des fichiers sources a traiter.
+ * Repertoires des fichiers sources a traiter.
*
- * @parameter expression="${license-switcher.src}" default-value="${basedir}/src/main/java"
+ * @parameter expression="${license-switcher.compileSourceRoots}" default-value="${project.compileSourceRoots}"
* @required
- * @readonly
*/
- protected File src;
+ protected List<String> compileSourceRoots;
/**
- * Fichier de la licence du module.
+ * Repertoires des fichiers sources de test a traiter.
*
- * @parameter expression="${license-switcher.licenceFile}" default-value="${basedir}/LICENSE.txt"
+ * @parameter expression="${license-switcher.testCompileSourceRoots}" default-value="${project.testCompileSourceRoots}"
* @required
- * @readonly
*/
- protected File licenseFile;
+ protected List<String> testCompileSourceRoots;
/**
- * Le type de license a appliquer.
+ * Un flag pour indiquer de lancer le goal.
*
- * @parameter expression="${license-switcher.licenseType}" default-value="LGPL_V3"
+ * @parameter expression="${license-switcher.doSwitch}" default-value="false"
* @required
*/
- protected String licenseType;
+ protected boolean doSwitch;
- /**
- * un flag pour conserver un backup des fichiers modifies
- *
- * @parameter expression="${license-switcher.keepBackup}" default-value="false"
- */
- protected boolean keepBackup;
+ /** le header a ajouter dans chaque fichier source java */
+ protected String licenseHeaderContent;
- /**
- * un flag pour indiquer la recopie vers le repertoire des resources.
- *
- * @parameter expression="${license-switcher.copyToResource}" default-value="true"
- */
- protected boolean copyToResource;
+ /** la liste des chemin relatifs des sources java a traiter pour chaque repertoire contenant des sources */
+ protected Map<File, String[]> javaFilesToTreate;
- /**
- * un flag pour avoir les traces
- *
- * @parameter expression="${license-switcher.verbose}" default-value="false"
- */
- protected boolean verbose;
+ protected long timestamp;
+ protected void init() throws IOException {
- /** le header a ajouter dans chaque fichier java */
- protected String licenseHeaderContent;
+ timestamp = System.nanoTime();
- /** le texte de la licence a placer dans le fichier ${basedir}/LICENSE.txt */
- protected String licenseFileContent;
+ LicenseType type = LicenseType.valueOf(licenseType);
- /** la liste des chemin relatifs des sources java a traiter a partir de {@link #src} */
- protected String[] javaFilesToTreate;
+ // obtain all java source files to be treated
+ javaFilesToTreate = getFilesToTreate();
- protected long timestamp;
+ if (javaFilesToTreate.isEmpty()) {
+ // nothing to do, since no file to treate was found
+ return;
+ }
+ // obtain content of license header
+ licenseHeaderContent = computeHeader(type);
+
+
+ if (verbose) {
+ getLog().info("header to write on java source files \n" + licenseHeaderContent);
+ }
+
+ }
+
+ @Override
public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- init();
- } catch (IOException e) {
- throw new MojoExecutionException("could not init goal for reason : " + e.getMessage(), e);
+
+ if (!doSwitch) {
+ getLog().info("goal was not executed, you must specify the license-switcher.doSwitch to launch the goal");
+ return;
}
- // write project license
- writeLicense();
+ super.execute();
- if (javaFilesToTreate.length == 0) {
- getLog().warn("no java source files to treate.");
+ if (javaFilesToTreate.isEmpty()) {
+ getLog().warn("no java source files found to be treated.");
return;
}
// create a licence processor with given header
LicenseProcessor p = new LicenseProcessor(licenseHeaderContent);
- for (String javaRelativePath : javaFilesToTreate) {
-
- File sourceFile = new File(src, javaRelativePath);
-
- try {
- processJavaSource(p, sourceFile);
- } catch (Exception e) {
- throw new MojoExecutionException("could not treate java source file " + sourceFile + " for reason : " + e.getMessage(), e);
+ for (Entry<File, String[]> entry : javaFilesToTreate.entrySet()) {
+ File src = entry.getKey();
+ for (String javaRelativePath : entry.getValue()) {
+ File sourceFile = new File(src, javaRelativePath);
+ try {
+ processJavaSource(p, sourceFile);
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not treate java source file " + sourceFile + " for reason : " + e.getMessage(), e);
+ }
}
}
}
- protected void writeLicense() throws MojoExecutionException {
- if (licenseFile.exists() && keepBackup) {
+ protected Map<File, String[]> getFilesToTreate() {
+
+ // init directory scanner
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(new String[]{"**\\/*.java"});
+
+ Map<File, String[]> files = new java.util.HashMap<File, String[]>();
+
+ List<String> roots = new ArrayList<String>();
+
+ roots.addAll(compileSourceRoots);
+ roots.addAll(testCompileSourceRoots);
+
+ for (String src : roots) {
if (verbose) {
- getLog().info("backup " + licenseFile);
+ getLog().info("discovering java source files in root " + src);
}
- // copy it to backup file
- File backup = new File(licenseFile.getAbsolutePath() + "~");
- licenseFile.renameTo(backup);
+ File f = new File(src);
+ ds.setBasedir(f);
+ // scan
+ ds.scan();
+
+ // get files
+ String[] tmp = ds.getIncludedFiles();
+ if (tmp.length > 0) {
+ files.put(f, tmp);
+ }
}
- try {
- FileUtil.writeString(licenseFile, licenseFileContent, encoding);
- if (copyToResource) {
- File target = new File(project.getBasedir(), "src" + File.separator + "main" + File.separator + "resources" + File.separator + licenseFile.getName());
- if (target.exists() && keepBackup) {
- if (verbose) {
- getLog().info("backup " + target);
- }
- target.renameTo(new File(target.getAbsolutePath() + '~'));
- }
- FileUtil.copy(licenseFile, target);
+
+ return files;
+ }
+
+ protected String computeHeader(LicenseType type) throws IOException {
+ String tmpHeader = FileUtil.readAsString(type.getLicenceHeaderReader(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;
+ }
+
+ // format header with projet informations
+ tmpHeader = String.format(tmpHeader, projectName, inceptionYear, organizationName);
+
+ // add " * " before each line
+ BufferedReader reader = new BufferedReader(new java.io.StringReader(tmpHeader));
+ 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");
}
- } catch (IOException e) {
- throw new MojoExecutionException("could not write license file " + licenseFile + " for reason : " + e.getMessage(), e);
}
+ tmpHeader = sb.toString();
+ return tmpHeader.substring(0, tmpHeader.length() - 1);
}
/**
@@ -208,16 +236,19 @@
* @throws java.io.IOException if IO pb
*/
protected void processJavaSource(LicenseProcessor p, File sourceFile) throws Exception {
+
if (verbose) {
- getLog().info("treate file " + sourceFile);
+ getLog().info("process file " + sourceFile);
}
+ // file where to write result
File processFile = new File(sourceFile.getAbsolutePath() + "_" + timestamp);
try {
p.process(sourceFile, processFile);
if (!p.getLicenceFilter().wasTouched()) {
+ // no license header found in file, add it
addLicenseToJavaSourceFile(sourceFile, processFile);
}
@@ -242,62 +273,8 @@
protected void addLicenseToJavaSourceFile(File sourceFile, File processFile) throws IOException {
getLog().warn("no license was found on file " + sourceFile + ", adding one");
String content = FileUtil.readAsString(sourceFile, encoding);
- content = "/**\n * " + LicenseFilter.HEADER + " " + licenseHeaderContent + " " + LicenseFilter.HEADER + "\n */\n" + content;
+ content = "/**\n * " + LicenseFilter.HEADER + " " + licenseHeaderContent + " " + LicenseFilter.FOOTER + "\n */\n" + content;
FileUtil.writeString(processFile, content, encoding);
}
- protected void init() throws IOException {
-
- timestamp = System.nanoTime();
-
- LicenseType type = LicenseType.valueOf(licenseType);
-
- // obtain content of license file
- licenseFileContent = FileUtil.readAsString(type.getLicenceFileReader(encoding));
-
- // obtain content of license header
- String tmpHeader = FileUtil.readAsString(type.getLicenceHeaderReader(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;
- }
-
- // format header with projet informations
- tmpHeader = String.format(tmpHeader, projectName, inceptionYear, organizationName);
-
- // add " * " before each line
- BufferedReader reader = new BufferedReader(new java.io.StringReader(tmpHeader));
- StringBuilder sb = new StringBuilder();
-
- String line = reader.readLine();
- sb.append(line).append('\n');
- while ((line = reader.readLine()) != null) {
- if (line.isEmpty()) {
- sb.append(" *\n");
- } else {
- sb.append(" * ").append(line).append("\n");
- }
- }
- tmpHeader = sb.toString();
- licenseHeaderContent = tmpHeader.substring(0, tmpHeader.length() - 1);
-
- if (verbose) {
- getLog().info("header to write on java source files \n" + licenseHeaderContent);
- }
-
- // init directory scanner
- DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir(src);
- ds.setIncludes(new String[]{"**\\/*.java"});
-
- // scan
- ds.scan();
-
- // get files
- javaFilesToTreate = ds.getIncludedFiles();
- }
}
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -3,8 +3,8 @@
* Copyright (C) 2008 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
+ * 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,
@@ -12,7 +12,7 @@
* 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
+ * 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>. ##%*
*/
@@ -26,7 +26,6 @@
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.model.License;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
@@ -44,54 +43,20 @@
import java.util.TreeSet;
/**
- * Le goal pour ecrire le fichier THIRD-PARTY.txt contenant les licenses de toutes les dependances du projet.
+ * Le goal pour copier le fichier THIRD-PARTY.txt (contenant les licenses de toutes les dependances du projet)
+ * dans le classpath (et le generer s'il n'existe pas).
*
* @author chemit
* @goal third-party
+ * @phase process-classes
* @requiresDependencyResolution test
+ * @requiresProject true
*/
-public class ThirdPartyMojo extends AbstractMojo {
+public class ThirdPartyMojo extends AbstractLicenceMojo {
private static final String unknownLicenseMessage = "Unknown license";
/**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * encoding a utiliser pour lire et ecrire les fichiers.
- *
- * @parameter expression="${licence-switcher.encoding}" default-value="${maven.compile.encoding}"
- * @required
- */
- protected String encoding;
-
- /**
- * un flag pour conserver un backup des fichiers modifies
- *
- * @parameter expression="${license-switcher.keepBackup}" default-value="false"
- */
- protected boolean keepBackup;
-
- /**
- * un flag pour indiquer la recopie vers le repertoire des resources.
- *
- * @parameter expression="${license-switcher.copyToResource}" default-value="true"
- */
- protected boolean copyToResource;
-
- /**
- * un flag pour avoir les traces
- *
- * @parameter expression="${license-switcher.verbose}" default-value="false"
- */
- protected boolean verbose;
-
- /**
* Local Repository.
*
* @parameter expression="${localRepository}"
@@ -107,7 +72,6 @@
* @parameter expression="${project.remoteArtifactRepositories}"
* @required
* @readonly
- * @since 2.1
*/
protected List remoteRepositories;
@@ -116,7 +80,6 @@
*
* @parameter expression="${license-switcher.thirdPartyFile}" default-value="${basedir}/THIRD-PARTY.txt"
* @required
- * @readonly
*/
protected File thirdPartyFile;
@@ -155,46 +118,67 @@
*/
protected MavenProjectBuilder mavenProjectBuilder;
- public void execute() throws MojoExecutionException, MojoFailureException {
+ /**
+ * Un flag pour indiquer la regeneration des fichiers.
+ *
+ * @parameter expression="${license-switcher.doGenerate}" default-value="false"
+ */
+ protected boolean doGenerate;
+ /**
+ * content of third party file (only computed if {@link #doGenerate} is active or the
+ * {@link #thirdPartyFile} does not exist.
+ */
+ protected String thirdPartyFileContent;
- DependencyNode dependencyTreeNode = resolveProject();
+ protected void init() throws Exception {
- LicenseMap licenseMap = new LicenseMap();
+ // must generate if file does not exist
+ doGenerate = doGenerate || !thirdPartyFile.exists();
- for (Object o : dependencyTreeNode.getChildren()) {
+ if (doGenerate) {
- buildLicenseMap((DependencyNode) o, licenseMap);
+ // prepare thirdPartyFileContent
+
+ DependencyNode dependencyTreeNode = resolveProject();
+
+ LicenseMap licenseMap = new LicenseMap();
+
+ for (Object o : dependencyTreeNode.getChildren()) {
+
+ buildLicenseMap((DependencyNode) o, licenseMap);
+ }
+
+ thirdPartyFileContent = buildGroupedLicenses(licenseMap);
}
+ }
- String content = buildGroupedLicenses(licenseMap);
- try {
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ super.execute();
+
+ if (doGenerate) {
if (verbose) {
getLog().info("writing third-party file : " + thirdPartyFile);
}
- if (thirdPartyFile.exists() && keepBackup) {
+ if (keepBackup && thirdPartyFile.exists()) {
if (verbose) {
getLog().info("backup " + thirdPartyFile);
}
thirdPartyFile.renameTo(new File(thirdPartyFile.getAbsolutePath() + '~'));
}
- FileUtil.writeString(thirdPartyFile, content, encoding);
- if (copyToResource) {
- File target = new File(project.getBasedir(), "src" + File.separator + "main" + File.separator + "resources" + File.separator + thirdPartyFile.getName());
- if (target.exists() && keepBackup) {
- if (verbose) {
- getLog().info("backup " + target);
- }
- target.renameTo(new File(target.getAbsolutePath() + '~'));
- }
- FileUtil.copy(thirdPartyFile, target);
+ try {
+ FileUtil.writeString(thirdPartyFile, thirdPartyFileContent, encoding);
+ } catch (IOException e) {
+ throw new MojoExecutionException("could not write file " + thirdPartyFile + " for reason : " + e.getMessage(), e);
}
- } catch (IOException e) {
- throw new MojoExecutionException("could not write file " + thirdPartyFile + " for reason : " + e.getMessage(), e);
-
}
+ // copy third party file to classpath
+ copyFileToOutputDirectory(thirdPartyFile);
}
+
/** @return resolve the dependency tree */
protected DependencyNode resolveProject() {
try {
@@ -220,15 +204,14 @@
List licenses = artifactProject.getLicenses();
if (licenses.isEmpty()) {
+ // no license found for the dependency
+ getLog().warn("no license found for dependency " + artifactName);
licenseMap.put(unknownLicenseMessage, artifactName);
} else {
for (Object license : licenses) {
- License element = (License) license;
- String licenseName = element.getName();
-
- licenseMap.put(licenseName, artifactName);
+ licenseMap.put(((License) license).getName(), artifactName);
}
}
}
@@ -285,17 +268,17 @@
*/
protected MavenProject getMavenProjectFromRepository(Artifact artifact)
throws ProjectBuildingException {
- Artifact projectArtifact = artifact;
boolean allowStubModel = false;
+
if (!"pom".equals(artifact.getType())) {
- projectArtifact = factory.createProjectArtifact(artifact.getGroupId(), artifact.getArtifactId(),
+ artifact = factory.createProjectArtifact(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope());
allowStubModel = true;
}
// TODO: we should use the MavenMetadataSource instead
- return mavenProjectBuilder.buildFromRepository(projectArtifact, remoteRepositories, localRepository,
+ return mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository,
allowStubModel);
}
@@ -309,9 +292,11 @@
if (valueList == null) {
valueList = new TreeSet<String>();
}
- getLog().debug("key:" + key + ",value: " + value);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("key:" + key + ",value: " + value);
+ }
valueList.add(value);
- return super.put(key, valueList);
+ return put(key, valueList);
}
}
}
Modified: trunk/maven-license-switcher-plugin/src/site/apt/index.apt
===================================================================
--- trunk/maven-license-switcher-plugin/src/site/apt/index.apt 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/site/apt/index.apt 2008-08-18 22:16:08 UTC (rev 1050)
@@ -14,13 +14,15 @@
The plugin has the following goals:
- * {{{switch-mojo.html}llicense-switcher:switch}} parse Java sources and switch license header.
+ * {{{license-mojo.html}license-switcher:license}} add license file and third-party files to classpath (generate them if necessary).
* {{{third-party-mojo.html}license-switcher:third-party}} write the licenses of all third-party libraries used in project.
+
+ * {{{switch-mojo.html}license-switcher:switch}} parse Java sources and switch license header.
* {{{help-mojo.html}license-switcher:help}} display help about the plugin (goals, usage).
- * {{{help-mojo.html}license-switcher:available-licenses}} display the known licenses of the plugin.
+ * {{{available-licenses-mojo.html}license-switcher:available-licenses}} display the known licenses of the plugin.
* Usage
Modified: trunk/maven-license-switcher-plugin/src/site/apt/usage.apt
===================================================================
--- trunk/maven-license-switcher-plugin/src/site/apt/usage.apt 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/site/apt/usage.apt 2008-08-18 22:16:08 UTC (rev 1050)
@@ -10,13 +10,34 @@
Below are the different goals and configurations of the plugin.
+* The <<<license>>> Mojo
+
+ The <<<license>>> mojo is used to copy LICENSE.txt file on classpath and generate it on the
+ basedir of the project if necessary.
+
+ By default, the license to apply is the lgpl v 3. To change it pass the maven parameter
+ <<<-Dlicense-switcher.licenseType=ANOTHER LICENCE TYPE>>>
+
++-----+
+mvn license-switcher:license
++-----+
+
+* The <<<third-party>>> Mojo
+
+ The <<<third-party>>> copy the <<<THIRD-PARTY.txt>>> file (the licenses of all third party librairies
+ used by the project) to the classpath and generate it on the basedir if necessary.
+
++-----+
+mvn license-switcher:third-party
++-----+
+
* The <<<switch>>> Mojo
- The <<<switch>>> mojo is used to switch licence header on each java source files and add a LICENSE.txt file on the
- basedir of the project.
+ The <<<switch>>> mojo is used to switch licence header on each java source files and add a <<<LICENSE.txt>>> file
+ on the basedir of the project.
- By default, the license to apply is the lgpl v 3. To change it pass the maven parameter <<<-Dlicense-switcher.licenseType=ANOTHER LICENCE TYPE>>>
-
+ By default, the license to apply is the lgpl v 3. To change it pass the maven parameter
+ <<<-Dlicense-switcher.licenseType=ANOTHER LICENCE TYPE>>>
+-----+
mvn license-switcher:switch
@@ -30,14 +51,6 @@
mvn license-switcher:available-licenses
+-----+
-* The <<<third-party>>> Mojo
-
- The <<<third-party>>> write in the <<<THIRD-PARTY.txt>>> the licenses of all third party librairies used by the project.
-
-+-----+
-mvn license-switcher:third-party
-+-----+
-
* The <<<help>>> Mojo
The <<<help>>> mojo display in the console the help for the plugin.
@@ -45,4 +58,3 @@
+-----+
mvn license-switcher:help
+-----+
-
Modified: trunk/maven-license-switcher-plugin/src/test/java/org/codelutin/license/LicenseTypeTest.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/test/java/org/codelutin/license/LicenseTypeTest.java 2008-08-18 19:14:39 UTC (rev 1049)
+++ trunk/maven-license-switcher-plugin/src/test/java/org/codelutin/license/LicenseTypeTest.java 2008-08-18 22:16:08 UTC (rev 1050)
@@ -1,20 +1,20 @@
/**
* *##% Plugin maven pour switcher les licenses
* Copyright (C) 2008 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
+ * 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
+ *
+ * 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.codelutin.license;
1
0
[Lutinutil-commits] r1049 - trunk/maven-license-switcher-plugin/src/main/resources
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 19:14:39 +0000 (Mon, 18 Aug 2008)
New Revision: 1049
Removed:
trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt
trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt
Log:
do not duplicate these files :)
Deleted: trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt 2008-08-18 15:22:41 UTC (rev 1048)
+++ trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt 2008-08-18 19:14:39 UTC (rev 1049)
@@ -1,166 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
-
Deleted: trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt 2008-08-18 15:22:41 UTC (rev 1048)
+++ trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt 2008-08-18 19:14:39 UTC (rev 1049)
@@ -1,29 +0,0 @@
-List of third-party dependencies grouped by their license type.
-
-Common Public License Version 1.0 :
- * JUnit (junit:junit:3.8.1 - http://junit.org)
-
-LGPL :
- * Lutin file processor (org.codelutin:lutinprocessor:0.14 - http://labs.libre-entreprise.org/projects/lutinbuilder)
- * Lutin plugin utilities library (org.codelutin:lutinpluginutil:0.1 - http://labs.libre-entreprise.org/projects/lutinutil)
-
-The Apache Software License, Version 2.0 :
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Maven Artifact (org.apache.maven:maven-artifact:2.0.4 - http://maven.apache.org/maven-artifact)
- * Maven Artifact Manager (org.apache.maven:maven-artifact-manager:2.0.4 - http://maven.apache.org/maven-artifact-manager)
- * Maven Dependency Tree (org.apache.maven.shared:maven-dependency-tree:1.1 - http://maven.apache.org/shared/maven-dependency-tree)
- * Maven Local Settings Model (org.apache.maven:maven-settings:2.0.4 - http://maven.apache.org/maven-settings)
- * Maven Model (org.apache.maven:maven-model:2.0.4 - http://maven.apache.org/maven-model)
- * Maven Plugin API (org.apache.maven:maven-plugin-api:2.0.4 - http://maven.apache.org/maven-plugin-api)
- * Maven Profile Model (org.apache.maven:maven-profile:2.0.4 - http://maven.apache.org/maven-profile)
- * Maven Project Builder (org.apache.maven:maven-project:2.0.4 - http://maven.apache.org/maven-project)
- * Maven Project Builder (org.apache.maven:maven-project:2.0.8 - http://maven.apache.org/maven-project)
- * Maven Repository Metadata Model (org.apache.maven:maven-repository-metadata:2.0.4 - http://maven.apache.org/maven-repository-metadata)
- * Maven Wagon API (org.apache.maven.wagon:wagon-provider-api:1.0-alpha-6 - no url defined)
- * Unnamed - ant:ant:jar:1.6.5 (ant:ant:1.6.5 - http://www.apache.org/ant)
-
-Unknown license :
- * Default Plexus Container (org.codehaus.plexus:plexus-container-default:1.0-alpha-9 - no url defined)
- * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.0.4 - no url defined)
- * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.1 - no url defined)
- * classworlds (classworlds:classworlds:1.1-alpha-2 - http://classworlds.codehaus.org/)
\ No newline at end of file
1
0
[Lutinutil-commits] r1048 - trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 15:22:41 +0000 (Mon, 18 Aug 2008)
New Revision: 1048
Modified:
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
Log:
ajout d'un goal pour construire le third-party file
recopie des fichiers vers src/main/resources
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java 2008-08-18 14:25:26 UTC (rev 1047)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/AvailableLicensesMojo.java 2008-08-18 15:22:41 UTC (rev 1048)
@@ -1,17 +1,17 @@
/**
* *##% Plugin maven pour switcher les licenses
* Copyright (C) 2008 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/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java 2008-08-18 14:25:26 UTC (rev 1047)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseType.java 2008-08-18 15:22:41 UTC (rev 1048)
@@ -1,17 +1,17 @@
/**
* *##% Plugin maven pour switcher les licenses
* Copyright (C) 2008 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/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 14:25:26 UTC (rev 1047)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 15:22:41 UTC (rev 1048)
@@ -39,6 +39,7 @@
* @author chemit
* @goal switch
* @phase process-sources
+ * @execute goal=third-party
* @requiresProject true
*/
public class SwitchLicenseMojo extends AbstractMojo {
@@ -275,7 +276,11 @@
String line = reader.readLine();
sb.append(line).append('\n');
while ((line = reader.readLine()) != null) {
- sb.append(" * ").append(line).append("\n");
+ if (line.isEmpty()) {
+ sb.append(" *\n");
+ } else {
+ sb.append(" * ").append(line).append("\n");
+ }
}
tmpHeader = sb.toString();
licenseHeaderContent = tmpHeader.substring(0, tmpHeader.length() - 1);
1
0
[Lutinutil-commits] r1047 - in trunk/maven-license-switcher-plugin: . src/main/java/org/codelutin/license src/main/resources src/site/apt
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
by tchemit@users.labs.libre-entreprise.org 18 Aug '08
18 Aug '08
Author: tchemit
Date: 2008-08-18 14:25:26 +0000 (Mon, 18 Aug 2008)
New Revision: 1047
Added:
trunk/maven-license-switcher-plugin/THIRD-PARTY.txt
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java
trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt
trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt
Modified:
trunk/maven-license-switcher-plugin/pom.xml
trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
trunk/maven-license-switcher-plugin/src/site/apt/index.apt
trunk/maven-license-switcher-plugin/src/site/apt/usage.apt
Log:
ajout d'un goal pour construire le third-party file
recopie des fichiers vers src/main/resources
Added: trunk/maven-license-switcher-plugin/THIRD-PARTY.txt
===================================================================
--- trunk/maven-license-switcher-plugin/THIRD-PARTY.txt (rev 0)
+++ trunk/maven-license-switcher-plugin/THIRD-PARTY.txt 2008-08-18 14:25:26 UTC (rev 1047)
@@ -0,0 +1,29 @@
+List of third-party dependencies grouped by their license type.
+
+Common Public License Version 1.0 :
+ * JUnit (junit:junit:3.8.1 - http://junit.org)
+
+LGPL :
+ * Lutin file processor (org.codelutin:lutinprocessor:0.14 - http://labs.libre-entreprise.org/projects/lutinbuilder)
+ * Lutin plugin utilities library (org.codelutin:lutinpluginutil:0.1 - http://labs.libre-entreprise.org/projects/lutinutil)
+
+The Apache Software License, Version 2.0 :
+ * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
+ * Maven Artifact (org.apache.maven:maven-artifact:2.0.4 - http://maven.apache.org/maven-artifact)
+ * Maven Artifact Manager (org.apache.maven:maven-artifact-manager:2.0.4 - http://maven.apache.org/maven-artifact-manager)
+ * Maven Dependency Tree (org.apache.maven.shared:maven-dependency-tree:1.1 - http://maven.apache.org/shared/maven-dependency-tree)
+ * Maven Local Settings Model (org.apache.maven:maven-settings:2.0.4 - http://maven.apache.org/maven-settings)
+ * Maven Model (org.apache.maven:maven-model:2.0.4 - http://maven.apache.org/maven-model)
+ * Maven Plugin API (org.apache.maven:maven-plugin-api:2.0.4 - http://maven.apache.org/maven-plugin-api)
+ * Maven Profile Model (org.apache.maven:maven-profile:2.0.4 - http://maven.apache.org/maven-profile)
+ * Maven Project Builder (org.apache.maven:maven-project:2.0.4 - http://maven.apache.org/maven-project)
+ * Maven Project Builder (org.apache.maven:maven-project:2.0.8 - http://maven.apache.org/maven-project)
+ * Maven Repository Metadata Model (org.apache.maven:maven-repository-metadata:2.0.4 - http://maven.apache.org/maven-repository-metadata)
+ * Maven Wagon API (org.apache.maven.wagon:wagon-provider-api:1.0-alpha-6 - no url defined)
+ * Unnamed - ant:ant:jar:1.6.5 (ant:ant:1.6.5 - http://www.apache.org/ant)
+
+Unknown license :
+ * Default Plexus Container (org.codehaus.plexus:plexus-container-default:1.0-alpha-9 - no url defined)
+ * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.0.4 - no url defined)
+ * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.1 - no url defined)
+ * classworlds (classworlds:classworlds:1.1-alpha-2 - http://classworlds.codehaus.org/)
\ No newline at end of file
Modified: trunk/maven-license-switcher-plugin/pom.xml
===================================================================
--- trunk/maven-license-switcher-plugin/pom.xml 2008-08-18 09:47:49 UTC (rev 1046)
+++ trunk/maven-license-switcher-plugin/pom.xml 2008-08-18 14:25:26 UTC (rev 1047)
@@ -33,6 +33,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutinprocessor</artifactId>
<version>0.14</version>
Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 09:47:49 UTC (rev 1046)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-18 14:25:26 UTC (rev 1047)
@@ -1,17 +1,17 @@
/**
* *##% Plugin maven pour switcher les licenses
* Copyright (C) 2008 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>. ##%*
@@ -120,6 +120,13 @@
protected boolean keepBackup;
/**
+ * un flag pour indiquer la recopie vers le repertoire des resources.
+ *
+ * @parameter expression="${license-switcher.copyToResource}" default-value="true"
+ */
+ protected boolean copyToResource;
+
+ /**
* un flag pour avoir les traces
*
* @parameter expression="${license-switcher.verbose}" default-value="false"
@@ -179,6 +186,16 @@
}
try {
FileUtil.writeString(licenseFile, licenseFileContent, encoding);
+ if (copyToResource) {
+ File target = new File(project.getBasedir(), "src" + File.separator + "main" + File.separator + "resources" + File.separator + licenseFile.getName());
+ if (target.exists() && keepBackup) {
+ if (verbose) {
+ getLog().info("backup " + target);
+ }
+ target.renameTo(new File(target.getAbsolutePath() + '~'));
+ }
+ FileUtil.copy(licenseFile, target);
+ }
} catch (IOException e) {
throw new MojoExecutionException("could not write license file " + licenseFile + " for reason : " + e.getMessage(), e);
}
@@ -224,7 +241,7 @@
protected void addLicenseToJavaSourceFile(File sourceFile, File processFile) throws IOException {
getLog().warn("no license was found on file " + sourceFile + ", adding one");
String content = FileUtil.readAsString(sourceFile, encoding);
- content = "/**\n * " + LicenseFilter.HEADER+ " " + licenseHeaderContent + " " + LicenseFilter.HEADER+ "\n */\n" + content;
+ content = "/**\n * " + LicenseFilter.HEADER + " " + licenseHeaderContent + " " + LicenseFilter.HEADER + "\n */\n" + content;
FileUtil.writeString(processFile, content, encoding);
}
Copied: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java (from rev 1042, trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java)
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java (rev 0)
+++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/ThirdPartyMojo.java 2008-08-18 14:25:26 UTC (rev 1047)
@@ -0,0 +1,317 @@
+/**
+ * *##% Plugin maven pour switcher les licenses
+ * Copyright (C) 2008 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.codelutin.license;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.model.License;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
+import org.codelutin.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * Le goal pour ecrire le fichier THIRD-PARTY.txt contenant les licenses de toutes les dependances du projet.
+ *
+ * @author chemit
+ * @goal third-party
+ * @requiresDependencyResolution test
+ */
+public class ThirdPartyMojo extends AbstractMojo {
+
+ private static final String unknownLicenseMessage = "Unknown license";
+
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * encoding a utiliser pour lire et ecrire les fichiers.
+ *
+ * @parameter expression="${licence-switcher.encoding}" default-value="${maven.compile.encoding}"
+ * @required
+ */
+ protected String encoding;
+
+ /**
+ * un flag pour conserver un backup des fichiers modifies
+ *
+ * @parameter expression="${license-switcher.keepBackup}" default-value="false"
+ */
+ protected boolean keepBackup;
+
+ /**
+ * un flag pour indiquer la recopie vers le repertoire des resources.
+ *
+ * @parameter expression="${license-switcher.copyToResource}" default-value="true"
+ */
+ protected boolean copyToResource;
+
+ /**
+ * un flag pour avoir les traces
+ *
+ * @parameter expression="${license-switcher.verbose}" default-value="false"
+ */
+ protected boolean verbose;
+
+ /**
+ * Local Repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactRepository localRepository;
+
+
+ /**
+ * Remote repositories used for the project.
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @required
+ * @readonly
+ * @since 2.1
+ */
+ protected List remoteRepositories;
+
+ /**
+ * Fichier ou ecrire les licences des dependances.
+ *
+ * @parameter expression="${license-switcher.thirdPartyFile}" default-value="${basedir}/THIRD-PARTY.txt"
+ * @required
+ * @readonly
+ */
+ protected File thirdPartyFile;
+
+ /**
+ * Dependency tree builder component.
+ *
+ * @component
+ */
+ protected DependencyTreeBuilder dependencyTreeBuilder;
+
+ /**
+ * Artifact Factory component.
+ *
+ * @component
+ */
+ protected ArtifactFactory factory;
+
+ /**
+ * Artifact metadata source component.
+ *
+ * @component
+ */
+ protected ArtifactMetadataSource artifactMetadataSource;
+
+ /**
+ * Artifact collector component.
+ *
+ * @component
+ */
+ protected ArtifactCollector collector;
+
+ /**
+ * Maven Project Builder component.
+ *
+ * @component
+ */
+ protected MavenProjectBuilder mavenProjectBuilder;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ DependencyNode dependencyTreeNode = resolveProject();
+
+ LicenseMap licenseMap = new LicenseMap();
+
+ for (Object o : dependencyTreeNode.getChildren()) {
+
+ buildLicenseMap((DependencyNode) o, licenseMap);
+ }
+
+ String content = buildGroupedLicenses(licenseMap);
+ try {
+ if (verbose) {
+ getLog().info("writing third-party file : " + thirdPartyFile);
+ }
+ if (thirdPartyFile.exists() && keepBackup) {
+ if (verbose) {
+ getLog().info("backup " + thirdPartyFile);
+ }
+ thirdPartyFile.renameTo(new File(thirdPartyFile.getAbsolutePath() + '~'));
+ }
+ FileUtil.writeString(thirdPartyFile, content, encoding);
+ if (copyToResource) {
+ File target = new File(project.getBasedir(), "src" + File.separator + "main" + File.separator + "resources" + File.separator + thirdPartyFile.getName());
+ if (target.exists() && keepBackup) {
+ if (verbose) {
+ getLog().info("backup " + target);
+ }
+ target.renameTo(new File(target.getAbsolutePath() + '~'));
+ }
+ FileUtil.copy(thirdPartyFile, target);
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("could not write file " + thirdPartyFile + " for reason : " + e.getMessage(), e);
+
+ }
+
+ }
+
+ /** @return resolve the dependency tree */
+ protected DependencyNode resolveProject() {
+ try {
+ ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_TEST);
+ return dependencyTreeBuilder.buildDependencyTree(project, localRepository, factory,
+ artifactMetadataSource, artifactFilter, collector);
+ }
+ catch (DependencyTreeBuilderException e) {
+ getLog().error("Unable to build dependency tree.", e);
+ return null;
+ }
+ }
+
+ protected void buildLicenseMap(DependencyNode node, LicenseMap licenseMap) {
+
+ Artifact artifact = node.getArtifact();
+
+ if (!Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
+ try {
+ MavenProject artifactProject = getMavenProjectFromRepository(artifact);
+ String artifactName = getArtifactName(artifactProject);
+
+ List licenses = artifactProject.getLicenses();
+
+ if (licenses.isEmpty()) {
+
+ licenseMap.put(unknownLicenseMessage, artifactName);
+
+ } else {
+ for (Object license : licenses) {
+ License element = (License) license;
+ String licenseName = element.getName();
+
+ licenseMap.put(licenseName, artifactName);
+ }
+ }
+ }
+ catch (ProjectBuildingException e) {
+ getLog().error("ProjectBuildingException error : ", e);
+ }
+ }
+ if (!node.getChildren().isEmpty()) {
+ for (Object o : node.getChildren()) {
+ buildLicenseMap((DependencyNode) o, licenseMap);
+ }
+ }
+ }
+
+ protected String buildGroupedLicenses(LicenseMap licenseMap) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("List of third-party dependencies grouped by their license type.");
+ for (String licenseName : licenseMap.keySet()) {
+ sb.append("\n\n").append(licenseName).append(" : ");
+
+ SortedSet<String> projects = licenseMap.get(licenseName);
+
+ for (String projectName : projects) {
+ sb.append("\n * ").append(projectName);
+ }
+ }
+ return sb.toString();
+ }
+
+ protected String getArtifactName(MavenProject artifactProject) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(artifactProject.getName());
+ sb.append(" (");
+ sb.append(artifactProject.getGroupId());
+ sb.append(":");
+ sb.append(artifactProject.getArtifactId());
+ sb.append(":");
+ sb.append(artifactProject.getVersion());
+ sb.append(" - ");
+ String url = artifactProject.getUrl();
+ sb.append(url == null ? "no url defined" : url);
+ sb.append(")");
+
+ return sb.toString();
+ }
+
+ /**
+ * Get the <code>Maven project</code> from the repository depending the <code>Artifact</code> given.
+ *
+ * @param artifact an artifact
+ * @return the Maven project for the given artifact
+ * @throws ProjectBuildingException if any
+ */
+ protected MavenProject getMavenProjectFromRepository(Artifact artifact)
+ throws ProjectBuildingException {
+ Artifact projectArtifact = artifact;
+
+ boolean allowStubModel = false;
+ if (!"pom".equals(artifact.getType())) {
+ projectArtifact = factory.createProjectArtifact(artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion(), artifact.getScope());
+ allowStubModel = true;
+ }
+
+ // TODO: we should use the MavenMetadataSource instead
+ return mavenProjectBuilder.buildFromRepository(projectArtifact, remoteRepositories, localRepository,
+ allowStubModel);
+ }
+
+ protected class LicenseMap extends java.util.TreeMap<String, SortedSet<String>> {
+ private static final long serialVersionUID = 864199843545688069L;
+
+ /** {@inheritDoc} */
+ public SortedSet<String> put(String key, String value) {
+ // handle multiple values as a set to avoid duplicates
+ SortedSet<String> valueList = get(key);
+ if (valueList == null) {
+ valueList = new TreeSet<String>();
+ }
+ getLog().debug("key:" + key + ",value: " + value);
+ valueList.add(value);
+ return super.put(key, valueList);
+ }
+ }
+}
Added: trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt (rev 0)
+++ trunk/maven-license-switcher-plugin/src/main/resources/LICENSE.txt 2008-08-18 14:25:26 UTC (rev 1047)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt
===================================================================
--- trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt (rev 0)
+++ trunk/maven-license-switcher-plugin/src/main/resources/THIRD-PARTY.txt 2008-08-18 14:25:26 UTC (rev 1047)
@@ -0,0 +1,29 @@
+List of third-party dependencies grouped by their license type.
+
+Common Public License Version 1.0 :
+ * JUnit (junit:junit:3.8.1 - http://junit.org)
+
+LGPL :
+ * Lutin file processor (org.codelutin:lutinprocessor:0.14 - http://labs.libre-entreprise.org/projects/lutinbuilder)
+ * Lutin plugin utilities library (org.codelutin:lutinpluginutil:0.1 - http://labs.libre-entreprise.org/projects/lutinutil)
+
+The Apache Software License, Version 2.0 :
+ * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
+ * Maven Artifact (org.apache.maven:maven-artifact:2.0.4 - http://maven.apache.org/maven-artifact)
+ * Maven Artifact Manager (org.apache.maven:maven-artifact-manager:2.0.4 - http://maven.apache.org/maven-artifact-manager)
+ * Maven Dependency Tree (org.apache.maven.shared:maven-dependency-tree:1.1 - http://maven.apache.org/shared/maven-dependency-tree)
+ * Maven Local Settings Model (org.apache.maven:maven-settings:2.0.4 - http://maven.apache.org/maven-settings)
+ * Maven Model (org.apache.maven:maven-model:2.0.4 - http://maven.apache.org/maven-model)
+ * Maven Plugin API (org.apache.maven:maven-plugin-api:2.0.4 - http://maven.apache.org/maven-plugin-api)
+ * Maven Profile Model (org.apache.maven:maven-profile:2.0.4 - http://maven.apache.org/maven-profile)
+ * Maven Project Builder (org.apache.maven:maven-project:2.0.4 - http://maven.apache.org/maven-project)
+ * Maven Project Builder (org.apache.maven:maven-project:2.0.8 - http://maven.apache.org/maven-project)
+ * Maven Repository Metadata Model (org.apache.maven:maven-repository-metadata:2.0.4 - http://maven.apache.org/maven-repository-metadata)
+ * Maven Wagon API (org.apache.maven.wagon:wagon-provider-api:1.0-alpha-6 - no url defined)
+ * Unnamed - ant:ant:jar:1.6.5 (ant:ant:1.6.5 - http://www.apache.org/ant)
+
+Unknown license :
+ * Default Plexus Container (org.codehaus.plexus:plexus-container-default:1.0-alpha-9 - no url defined)
+ * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.0.4 - no url defined)
+ * Plexus Common Utilities (org.codehaus.plexus:plexus-utils:1.1 - no url defined)
+ * classworlds (classworlds:classworlds:1.1-alpha-2 - http://classworlds.codehaus.org/)
\ No newline at end of file
Modified: trunk/maven-license-switcher-plugin/src/site/apt/index.apt
===================================================================
--- trunk/maven-license-switcher-plugin/src/site/apt/index.apt 2008-08-18 09:47:49 UTC (rev 1046)
+++ trunk/maven-license-switcher-plugin/src/site/apt/index.apt 2008-08-18 14:25:26 UTC (rev 1047)
@@ -16,6 +16,8 @@
* {{{switch-mojo.html}llicense-switcher:switch}} parse Java sources and switch license header.
+ * {{{third-party-mojo.html}license-switcher:third-party}} write the licenses of all third-party libraries used in project.
+
* {{{help-mojo.html}license-switcher:help}} display help about the plugin (goals, usage).
* {{{help-mojo.html}license-switcher:available-licenses}} display the known licenses of the plugin.
Modified: trunk/maven-license-switcher-plugin/src/site/apt/usage.apt
===================================================================
--- trunk/maven-license-switcher-plugin/src/site/apt/usage.apt 2008-08-18 09:47:49 UTC (rev 1046)
+++ trunk/maven-license-switcher-plugin/src/site/apt/usage.apt 2008-08-18 14:25:26 UTC (rev 1047)
@@ -30,6 +30,14 @@
mvn license-switcher:available-licenses
+-----+
+* The <<<third-party>>> Mojo
+
+ The <<<third-party>>> write in the <<<THIRD-PARTY.txt>>> the licenses of all third party librairies used by the project.
+
++-----+
+mvn license-switcher:third-party
++-----+
+
* The <<<help>>> Mojo
The <<<help>>> mojo display in the console the help for the plugin.
1
0