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
November 2008
- 4 participants
- 40 discussions
[Lutinutil-commits] r1259 - in commandline/trunk: . commandline-core commandline-demo commandline-ui commandline-ui-action maven-plugin
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 14:42:32 +0000 (Sun, 30 Nov 2008)
New Revision: 1259
Removed:
commandline/trunk/THIRD-PARTY.txt
commandline/trunk/commandline-core/THIRD-PARTY.txt
commandline/trunk/commandline-demo/THIRD-PARTY.txt
commandline/trunk/commandline-ui-action/THIRD-PARTY.txt
commandline/trunk/commandline-ui/THIRD-PARTY.txt
commandline/trunk/maven-plugin/THIRD-PARTY.txt
Log:
no more THIRD-PATY file on vcs
Deleted: commandline/trunk/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,17 +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 utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
-
-Unknown license :
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
\ No newline at end of file
Deleted: commandline/trunk/commandline-core/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/commandline-core/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/commandline-core/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,17 +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 utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
-
-Unknown license :
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
\ No newline at end of file
Deleted: commandline/trunk/commandline-demo/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/commandline-demo/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/commandline-demo/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,38 +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)
-
-GPL :
- * Graphical Widget (lutinlib:lutinwidget:0.10-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinwidget/lutinwidget)
-
-LGPL :
- * Lutin utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
- * commandine-ui-action (org.codelutin.commandline:commandline-ui-action:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-ui-action)
- * core (org.codelutin.commandline:commandline-core:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-core)
- * core (org.codelutin.jaxx:core:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/core)
- * jaxx-swing (org.codelutin.jaxx:jaxx-swing:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/jaxx-swing)
- * jaxx-swing-action (org.codelutin.jaxx:jaxx-swing-action:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/jaxx-swing-action)
- * runtime (org.codelutin.jaxx:runtime:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/runtime)
- * ui (org.codelutin.commandline:commandline-ui:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-ui)
- * util (org.codelutin.jaxx:util:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/util)
-
-MPL 1.1 :
- * Javassist (jboss:javassist:3.7.ga - http://labs.jboss.com/javassist/)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
- * Logging (commons-logging:commons-logging:1.1 - http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/)
-
-Unknown license :
- * JavaBeans Activation Framework (JAF) (javax.activation:activation:1.0.2 - http://java.sun.com/products/javabeans/jaf/index.jsp)
- * JavaHelp API (javax.help:javahelp:2.0.02 - http://java.sun.com/products/javahelp/index.jsp)
- * JavaMail API (javax.mail:mail:1.3.3 - http://java.sun.com/products/javamail/index.jsp)
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * Looks (jgoodies:looks:1.2.2 - no url defined)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
- * Unnamed - externallib:l2fprod-common:jar:0.1 (externallib:l2fprod-common:0.1 - no url defined)
- * Unnamed - sdoc:sdoc:jar:0.5.0-beta (sdoc:sdoc:0.5.0-beta - no url defined)
\ No newline at end of file
Deleted: commandline/trunk/commandline-ui/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/commandline-ui/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/commandline-ui/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,23 +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 utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
- * core (org.codelutin.commandline:commandline-core:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-core)
- * core (org.codelutin.jaxx:core:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/core)
- * jaxx-swing (org.codelutin.jaxx:jaxx-swing:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/jaxx-swing)
- * runtime (org.codelutin.jaxx:runtime:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/runtime)
- * util (org.codelutin.jaxx:util:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/util)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
-
-Unknown license :
- * JavaHelp API (javax.help:javahelp:2.0.02 - http://java.sun.com/products/javahelp/index.jsp)
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
\ No newline at end of file
Deleted: commandline/trunk/commandline-ui-action/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/commandline-ui-action/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/commandline-ui-action/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,28 +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 utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
- * core (org.codelutin.commandline:commandline-core:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-core)
- * core (org.codelutin.jaxx:core:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/core)
- * jaxx-swing (org.codelutin.jaxx:jaxx-swing:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/jaxx-swing)
- * jaxx-swing-action (org.codelutin.jaxx:jaxx-swing-action:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/jaxx-swing-action)
- * runtime (org.codelutin.jaxx:runtime:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/runtime)
- * ui (org.codelutin.commandline:commandline-ui:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-ui)
- * util (org.codelutin.jaxx:util:0.4 - http://labs.libre-entreprise.org/projects/buix/pom/util)
-
-MPL 1.1 :
- * Javassist (jboss:javassist:3.7.ga - http://labs.jboss.com/javassist/)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
-
-Unknown license :
- * JavaHelp API (javax.help:javahelp:2.0.02 - http://java.sun.com/products/javahelp/index.jsp)
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
\ No newline at end of file
Deleted: commandline/trunk/maven-plugin/THIRD-PARTY.txt
===================================================================
--- commandline/trunk/maven-plugin/THIRD-PARTY.txt 2008-11-27 09:59:24 UTC (rev 1258)
+++ commandline/trunk/maven-plugin/THIRD-PARTY.txt 2008-11-30 14:42:32 UTC (rev 1259)
@@ -1,32 +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 utilities library (org.codelutin:lutinutil:0.30-SNAPSHOT - http://labs.libre-entreprise.org/projects/lutinutil)
- * core (org.codelutin.commandline:commandline-core:0.9 - http://labs.libre-entreprise.org/projects/lutinutil/commandline-core)
-
-The Apache Software License, Version 2.0 :
- * Commons Collections (commons-collections:commons-collections:3.2.1 - http://commons.apache.org/collections/)
- * Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
- * Lang (commons-lang:commons-lang:2.1 - http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/)
- * Log4j (log4j:log4j:1.2.14 - http://logging.apache.org/log4j/docs/)
- * 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 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 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)
-
-Unknown license :
- * Default Plexus Container (org.codehaus.plexus:plexus-container-default:1.0-alpha-9 - no url defined)
- * Logging (commons-logging:commons-logging:1.0.3 - http://jakarta.apache.org/commons/logging/)
- * 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)
- * Unnamed - commons-beanutils:commons-beanutils:jar:1.7.0 (commons-beanutils:commons-beanutils:1.7.0 - no url defined)
- * Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)
- * classworlds (classworlds:classworlds:1.1-alpha-2 - http://classworlds.codehaus.org/)
\ No newline at end of file
1
0
[Lutinutil-commits] r1258 - lutinutil/tags/0.29.1
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
27 Nov '08
Author: schorlet
Date: 2008-11-27 09:59:24 +0000 (Thu, 27 Nov 2008)
New Revision: 1258
Modified:
lutinutil/tags/0.29.1/pom.xml
Log:
maj de la version du pom
Modified: lutinutil/tags/0.29.1/pom.xml
===================================================================
--- lutinutil/tags/0.29.1/pom.xml 2008-11-27 09:57:52 UTC (rev 1257)
+++ lutinutil/tags/0.29.1/pom.xml 2008-11-27 09:59:24 UTC (rev 1258)
@@ -20,7 +20,7 @@
<packaging>jar</packaging>
<!--Version-->
- <version>0.29-SNAPSHOT</version>
+ <version>0.29.1</version>
<!--Description-->
<description>
1
0
[Lutinutil-commits] r1257 - in lutinutil/tags: . 0.29.1 0.29.1/src/java/org/codelutin/util
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
27 Nov '08
Author: schorlet
Date: 2008-11-27 09:57:52 +0000 (Thu, 27 Nov 2008)
New Revision: 1257
Added:
lutinutil/tags/0.29.1/
lutinutil/tags/0.29.1/src/
lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java
Removed:
lutinutil/tags/0.29.1/src/
lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java
Log:
version de maintenance pour simexplorer
Copied: lutinutil/tags/0.29.1 (from rev 1254, lutinutil/branches/0.29-SNAPSHOT)
Copied: lutinutil/tags/0.29.1/src (from rev 1253, lutinutil/branches/0.29-SNAPSHOT/src)
Deleted: lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java
===================================================================
--- lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java 2008-11-21 15:51:51 UTC (rev 1253)
+++ lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java 2008-11-27 09:57:52 UTC (rev 1257)
@@ -1,522 +0,0 @@
-/**##%%
-* Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau, 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.
-*##%%**/
-
-/**
-* Resource.java
-*
-* Created: Sun Apr 14 2002
-*
-* @author POUSSIN Benjamin <bpoussin(a)free.fr>
-* Copyright Code Lutin
-* @version $Revision$
-*
-* Mise a jour: $Date$
-* par : $Author$
-*/
-
-package org.codelutin.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import javax.swing.ImageIcon;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
-* Cette class permet de recherche un fichier en indiquant son nom
-* avec son chemin. Cette librairie ira ensuite chercher ce fichier
-* sur le syst�me de fichier, et s'il n'est pas trouv� dans le
-* classpath. Le fichier peut donc �tre dans un fichier .jar ou .zip.
-*/
-public class Resource { // Resource
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(Resource.class);
-
- protected Resource() {
-
- }
-
- /**
- * Permet d'ajouter dans le classloader par defaut une nouvelle URL
- * dans lequel il faut rechercher les fichiers.
- * @param url l'url a ajouter
- */
- static public void addDefaultClassLoader(URL url){
- try{
- ClassLoader classLoader = ClassLoader.getSystemClassLoader();
-
- Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
- method.setAccessible(true);
- method.invoke(classLoader, url);
- }catch(Exception eee){
- throw new RuntimeException("Can't add url in default classloader", eee);
- }
- }
-
- /**
- * recherche la ressource nom
- * @param name nom de la ressource
- * @return l'url de la ressource
- * @throws ResourceNotFoundException si la resource n'a pas ete trouvee
- */
- static public URL getURL(String name) {
- URL url = getURLOrNull(name);
- if (url != null){
- return url;
- }
-
- throw new ResourceNotFoundException("La resource " + name +
- " n'a pas �t� trouv�e");
- }
-
- /**
- * recherche la ressource nom
- * @param name le nom de la ressource
- * @return l'url de la ressource ou null
- */
- static public URL getURLOrNull(String name) {
- // on recherche d'abord sur le filesystem
- File file = new File(name);
- if (file.exists()){
- try{
- return file.toURI().toURL();
- }catch(MalformedURLException eee){
- log.warn("Le fichier '" + file + "' a �t� trouv�, mais il n'a pas pu etre converti en URL");
- }
- }
-
- //on ne l'a pas trouve on recherche dans le classpath
-
- // on supprime le / devant le nom de la ressource, sinon elle
- // n'est pas trouve (pas de recherche dans les differents
- // element du classpath.
- if(name.length() > 1 && name.startsWith("/")){
- name = name.substring(1);
- }
- URL url = ClassLoader.getSystemClassLoader().getResource(name);
- if (url != null){
- return url;
- }
-
- ClassLoader cl = Resource.class.getClassLoader();
- url = cl.getResource(name);
- return url;
- }
-
- /**
- * Retourne l'icon demande
- * @param name le nom de l'icone
- * @return Retourne l'icon demande ou null s'il n'est pas trouv�
- */
- static public ImageIcon getIcon(String name){
- try{
- return new ImageIcon(getURL(name));
- }catch(Exception eee){
- log.warn("Can't find icon: " + name, eee);
- return null;
- }
- }
-
-
- /**
- * Recherche et retourne l'objet properties de configuration � utiliser.
- * Les diff�rents fichiers trouv� sont chain�. L'ordre de recherche est
- * le classpath, le fichier dans /etc et enfin le chemin sur le filesystem
- * @param filename le nom du fichier � rechercher
- * @return l'objet Properties de configuration
- * @throws java.io.IOException si pb
- */
- static public Properties getConfigProperties(String filename) throws IOException {
- Properties result;
- result = getConfigProperties(filename, null);
- return result;
- }
-
- static public Properties getConfigProperties(String filename, Properties parent) throws IOException {
- Properties result;
- if (parent != null) {
- result = new Properties(parent);
- } else {
- result = new Properties();
- }
-
- URL inClasspath = ClassLoader.getSystemClassLoader().getResource(filename);
- if (inClasspath == null) {
- inClasspath = Resource.class.getResource(filename);
- }
- if (inClasspath == null) {
- inClasspath = getURLOrNull(filename);
- }
- if(inClasspath != null){
- log.info("Chargement du fichier de config: " + inClasspath);
- result.load(inClasspath.openStream());
- result = new Properties(result);
- }
-
- File etcConfig = new File("/etc/" + filename);
- if(etcConfig.exists()){
- log.info("Chargement du fichier de config: " + etcConfig);
- result.load(etcConfig.toURI().toURL().openStream());
- result = new Properties(result);
- }
-
- File config = new File(filename);
- if(config.exists()){
- log.info("Chargement du fichier de config: " + config);
- result.load(config.toURI().toURL().openStream());
- result = new Properties(result);
- }
-
- return result;
- }
-
- /**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- * @param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- * @return la liste des urls correspondant au pattern
- */
- static public List<URL> getURLs(String pattern) {
- return getURLs(pattern, (URLClassLoader) null);
- }
-
- static private URL[] getURLs(URLClassLoader classLoader) {
- Method m;
- try {
- // Essai de r�cup�ration de la m�thode getAllURLs() de RepositoryClassLoader (JBoss)
- m = classLoader.getClass().getMethod("getAllURLs");
- } catch (Exception e) {
- m = null;
- }
- URL[] result;
- if (m == null) {
- result = classLoader.getURLs();
- } else {
- try {
- result = (URL[]) m.invoke(classLoader);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
- return result;
- }
-
- /**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- *@param classLoader le classLoader
- *@param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- *@return la liste des urls correspondant au pattern
- */
- static public List<URL> getURLs(String pattern, URLClassLoader classLoader) {
- if(classLoader == null){
- classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
- }
- URL[] arrayURL = getURLs(classLoader);
- return getURLs(pattern,arrayURL);
- }
-
- /**
- * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
- * correspondent au pattern donne
- *
- *@param arrayURL les urls ou chercher
- *@param pattern le nom du fichier a extraire du
- * fichier compress� ou durepertoire doit correspondre
- * au pattern (repertoire + nom compris).
- *@return la liste des urls correspondant au pattern
- */
- static public List<URL> getURLs(String pattern, URL... arrayURL ) {
- long t0 = System.nanoTime();
-
- HashList<URL> urlList = new HashList<URL>();
-
- if (arrayURL.length == 1) {
- URL jarURL = arrayURL[0];
- if (isJar(jarURL.toString())) {
- // jar invocation
- try {
- arrayURL = getClassPathURLsFromJarManifest(jarURL);
- } catch (Exception e) {
- log.warn(e);
- arrayURL = new URL[]{jarURL};
- }
- }
- }
- if (log.isDebugEnabled()) {
- for (URL url : arrayURL) {
- log.debug("found url " + url);
- }
- }
-
- for (URL urlFile : arrayURL) {
- String fileName = urlFile.getFile();
- //TODO deal with encoding in windows, this is very durty, but it works...
- File file= new File(fileName.replaceAll("%20", " "));
- // cas ou le ichier du classLoader est un fichier jar ou zip
- if (file.exists() && (isJar(fileName) || isZip(fileName))) {
- if (log.isDebugEnabled()) {
- log.debug("jar to search " + file);
- }
- urlList.addAll(Resource.getURLsFromJar(file, pattern));
-
- // cas ou le ichier du classLoader est un repertoire
- } else if (file.exists() && file.isDirectory()) {
- if (log.isDebugEnabled()) {
- log.debug("file to search " + file);
- }
- // on traite le cas ou il peut y avoir des repertoire dans ce repertoire
- urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
- }
- }
- if (log.isInfoEnabled()) {
- log.info("search URLs pattern: " + pattern + " in " + arrayURL.length+" urls in "+StringUtil.convertTime(System.nanoTime()-t0));
- }
- return urlList;
- }
-
- static public URL[] getClassPathURLsFromJarManifest(URL jarURL) throws IOException, URISyntaxException {
- JarFile jar=null;
- URL[] result;
- try {
- String jarPath = jarURL.toURI().getPath();
- File jarFile = new File(jarPath);
- if (log.isInfoEnabled()) {
- log.info("class-path jar to scan " + jarPath);
- }
- jar = new JarFile(jarFile);
- File container = jarFile.getParentFile();
- Manifest mf = jar.getManifest();
- String classPath = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
- String[] paths = classPath.split(" ");
- result = new URL[paths.length + 1];
- result[0] = jarURL;
- File path;
- for (int i = 0; i < paths.length; i++) {
- String s = paths[i];
- if (s.startsWith(".") || !s.startsWith("/")) {
- // relative url
- path =new File(container,s);
- } else {
- path =new File(s);
- }
- if (log.isDebugEnabled()) {
- log.debug(path);
- }
- result[i + 1] = path.toURI().toURL();
- }
- jar.close();
- } finally {
- if (jar!=null) {
- jar.close();
- }
- }
- return result;
- }
-
- static public List<URL> getURLsFromJar(File jarfile, String pattern) {
- try{
- if(log.isTraceEnabled()) {
- log.trace("search '" + pattern + "' in " + jarfile);
- }
-
- ArrayList<URL> result = new ArrayList<URL>();
- InputStream in = new FileInputStream(jarfile);
- ZipInputStream zis = new ZipInputStream(in);
- while (zis.available() != 0) {
- ZipEntry entry = zis.getNextEntry();
-
- if (entry == null) {
- break;
- }
-
- String name = entry.getName();
- if(log.isTraceEnabled()) {
- log.trace("jarfile: " + jarfile + " name: " + name);
- }
- if (pattern == null || name.matches(pattern)) {
- // on recupere le fichier correspondant au pattern dans le classloader
- URL url = Resource.getURL(name);
- // on ajoute le fichier correspondant au pattern dans la liste
- if(log.isTraceEnabled()) {
- log.trace("jarfile: " + jarfile + " url: " + url);
- }
- result.add(url);
- }
- }
- if(log.isTraceEnabled()) {
- log.trace("found with pattern '" + pattern + "' : " + result);
- }
- return result;
- }catch(IOException eee){
- throw new ResourceException("Erreur lors de la lecture du fichier compress�", eee);
- }
- }
-
- /**
- * Retourner la liste des fichiers correspondant au pattern donne, aucun
- * ordre ne doit sur le fichier ne doit �tre suppos�.
- *
- *@param repository repertoire dans lequel on recherche les fichiers
- *@param pattern le nom du fichier a extraire du
- * fichier du repertoire doit correspondre
- * au pattern (repertoire + nom compris).
- * si le pattern est null, tous les fichiers trouv�
- * sont retourn�.
- *
- *@return la liste des urls correspondant au pattern
- */
- static public List<URL> getURLsFromDirectory(File repository, String pattern) {
- try{
- if(log.isTraceEnabled()) {
- log.trace("search '" + pattern + "' in " + repository);
- }
-
- HashList<URL> urlList = new HashList<URL>();
- File[] filesList = repository.listFiles();
-
- if (filesList != null) {
-
- for (File file : filesList) {
-
- String name = file.getAbsolutePath();
-
- if (log.isTraceEnabled()) {
- log.trace("directory: " + repository + " name: " + name);
- }
-
- // cas de recursivite : repertoire dans un repertoire
- if (file.exists() && file.isDirectory()) {
- urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
- // si le fichier du repertoire n'est pas un repertoire on verifie s'il correspond au pattern
- } else if (pattern == null || name.matches(pattern)) {
- URL url = file.toURI().toURL();
- if (log.isTraceEnabled()) {
- log.trace("directory: " + repository + " url: " + url);
- }
- urlList.add(url);
- }
- }
- }
- if(log.isTraceEnabled()) {
- log.trace("found with pattern '" + pattern + "' : " + urlList);
- }
- return urlList;
- }catch(MalformedURLException eee){
- throw new ResourceException("Le fichier n'a pu �tre converti en URL", eee);
- }
- }
-
- /**
- * Verifie si le fichier est un fichier jar
- * @param name nom du fichier a tester
- * @return vrai si le fichier se termine par .jar faux sinon
- */
- static public boolean isJar(String name){
- if (name != null && name.length() > 4) {
- String ext = name.substring(name.length() - 4, name.length());
- return ".jar".equalsIgnoreCase(ext);
- }
- return false;
- }
-
- /**
- * Verifie si le fichier est un fichier zip
- * @param name nom du fichier a tester
- * @return vrai si le fichier se termine par .zip faux sinon
- */
- static public boolean isZip(String name){
- if (name != null && name.length() > 4) {
- String ext = name.substring(name.length() - 4, name.length());
- return ".zip".equalsIgnoreCase(ext);
- }
- return false;
- }
-
- /**
- * Verifie si la classe est de type primtif
- * @param clazz nom de la classe a tester
- * @return vrai si le classe est de type primitif faux sinon
- */
- static public boolean isPrimitive(Class clazz){
- return clazz.isPrimitive()
- || clazz == Boolean.class
- || clazz == Byte.class
- || clazz == Character.class
- || clazz == Short.class
- || clazz == Integer.class
- || clazz == Long.class
- || clazz == Float.class
- || clazz == Double.class;
- }
-
- /**
- * Retourne la classe du type primitf associ� avec la classe de de l'objet
- * pass� en parametre. Par exemple si la classe pass�e en param�tre est
- * Integer alors le resultat sera la classe de int.
- * @param clazz la classe dont on souhaite le type primitf
- * @return le type primitif associ� a la classe en param�tre, ou null
- * s'il n'y a pas de type primitif associ�.
- */
- static public Class getPrimitiveClass(Class clazz) {
- if (clazz == Boolean.class) return Boolean.TYPE;
- if (clazz == Byte.class) return Byte.TYPE;
- if (clazz == Character.class) return Character.TYPE;
- if (clazz == Short.class) return Short.TYPE;
- if (clazz == Integer.class) return Integer.TYPE;
- if (clazz == Long.class) return Long.TYPE;
- if (clazz == Float.class) return Float.TYPE;
- if (clazz == Double.class) return Double.TYPE;
- if (clazz == Void.class) return Void.TYPE;
- return null;
- }
-
-// /**
-// * Test
-// */
-// static public void main(String [] args) throws Exception {
-// String r = args.length>0?args[0]:"/org/codelutin/lutinbuilder/LutinBuilder.class";
-// System.out.println(getURL(r));
-// }
-
-} // Resource
Copied: lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java (from rev 1254, lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java)
===================================================================
--- lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java (rev 0)
+++ lutinutil/tags/0.29.1/src/java/org/codelutin/util/Resource.java 2008-11-27 09:57:52 UTC (rev 1257)
@@ -0,0 +1,528 @@
+/**##%%
+* Copyright (C) 2002, 2003, 2004 Code Lutin, C�dric Pineau, 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.
+*##%%**/
+
+/**
+* Resource.java
+*
+* Created: Sun Apr 14 2002
+*
+* @author POUSSIN Benjamin <bpoussin(a)free.fr>
+* Copyright Code Lutin
+* @version $Revision$
+*
+* Mise a jour: $Date$
+* par : $Author$
+*/
+
+package org.codelutin.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.swing.ImageIcon;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+* Cette class permet de recherche un fichier en indiquant son nom
+* avec son chemin. Cette librairie ira ensuite chercher ce fichier
+* sur le syst�me de fichier, et s'il n'est pas trouv� dans le
+* classpath. Le fichier peut donc �tre dans un fichier .jar ou .zip.
+*/
+public class Resource { // Resource
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(Resource.class);
+
+ protected Resource() {
+
+ }
+
+ /**
+ * Permet d'ajouter dans le classloader par defaut une nouvelle URL
+ * dans lequel il faut rechercher les fichiers.
+ * @param url l'url a ajouter
+ */
+ static public void addDefaultClassLoader(URL url){
+ try{
+ ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+
+ Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
+ method.setAccessible(true);
+ method.invoke(classLoader, url);
+ }catch(Exception eee){
+ throw new RuntimeException("Can't add url in default classloader", eee);
+ }
+ }
+
+ /**
+ * recherche la ressource nom
+ * @param name nom de la ressource
+ * @return l'url de la ressource
+ * @throws ResourceNotFoundException si la resource n'a pas ete trouvee
+ */
+ static public URL getURL(String name) {
+ URL url = getURLOrNull(name);
+ if (url != null){
+ return url;
+ }
+
+ throw new ResourceNotFoundException("La resource " + name +
+ " n'a pas �t� trouv�e");
+ }
+
+ /**
+ * recherche la ressource nom
+ * @param name le nom de la ressource
+ * @return l'url de la ressource ou null
+ */
+ static public URL getURLOrNull(String name) {
+ // on recherche d'abord sur le filesystem
+ File file = new File(name);
+ if (file.exists()){
+ try{
+ return file.toURI().toURL();
+ }catch(MalformedURLException eee){
+ log.warn("Le fichier '" + file + "' a �t� trouv�, mais il n'a pas pu etre converti en URL");
+ }
+ }
+
+ //on ne l'a pas trouve on recherche dans le classpath
+
+ // on supprime le / devant le nom de la ressource, sinon elle
+ // n'est pas trouve (pas de recherche dans les differents
+ // element du classpath.
+ if(name.length() > 1 && name.startsWith("/")){
+ name = name.substring(1);
+ }
+ URL url = ClassLoader.getSystemClassLoader().getResource(name);
+ if (url != null){
+ return url;
+ }
+
+ ClassLoader cl = Resource.class.getClassLoader();
+ url = cl.getResource(name);
+ return url;
+ }
+
+ /**
+ * Retourne l'icon demande
+ * @param name le nom de l'icone
+ * @return Retourne l'icon demande ou null s'il n'est pas trouv�
+ */
+ static public ImageIcon getIcon(String name){
+ try{
+ return new ImageIcon(getURL(name));
+ }catch(Exception eee){
+ log.warn("Can't find icon: " + name, eee);
+ return null;
+ }
+ }
+
+
+ /**
+ * Recherche et retourne l'objet properties de configuration � utiliser.
+ * Les diff�rents fichiers trouv� sont chain�. L'ordre de recherche est
+ * le classpath, le fichier dans /etc et enfin le chemin sur le filesystem
+ * @param filename le nom du fichier � rechercher
+ * @return l'objet Properties de configuration
+ * @throws java.io.IOException si pb
+ */
+ static public Properties getConfigProperties(String filename) throws IOException {
+ Properties result;
+ result = getConfigProperties(filename, null);
+ return result;
+ }
+
+ static public Properties getConfigProperties(String filename, Properties parent) throws IOException {
+ Properties result;
+ if (parent != null) {
+ result = new Properties(parent);
+ } else {
+ result = new Properties();
+ }
+
+ URL inClasspath = ClassLoader.getSystemClassLoader().getResource(filename);
+ if (inClasspath == null) {
+ inClasspath = Resource.class.getResource(filename);
+ }
+ if (inClasspath == null) {
+ inClasspath = getURLOrNull(filename);
+ }
+ if(inClasspath != null){
+ log.info("Chargement du fichier de config: " + inClasspath);
+ result.load(inClasspath.openStream());
+ result = new Properties(result);
+ }
+
+ File etcConfig = new File("/etc/" + filename);
+ if(etcConfig.exists()){
+ log.info("Chargement du fichier de config: " + etcConfig);
+ result.load(etcConfig.toURI().toURL().openStream());
+ result = new Properties(result);
+ }
+
+ File config = new File(filename);
+ if(config.exists()){
+ log.info("Chargement du fichier de config: " + config);
+ result.load(config.toURI().toURL().openStream());
+ result = new Properties(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondent au pattern donne
+ *
+ * @param pattern le nom du fichier a extraire du
+ * fichier compress� ou durepertoire doit correspondre
+ * au pattern (repertoire + nom compris).
+ * @return la liste des urls correspondant au pattern
+ */
+ static public List<URL> getURLs(String pattern) {
+ return getURLs(pattern, (URLClassLoader) null);
+ }
+
+ static private URL[] getURLs(URLClassLoader classLoader) {
+ Method m;
+ try {
+ // Essai de r�cup�ration de la m�thode getAllURLs() de RepositoryClassLoader (JBoss)
+ m = classLoader.getClass().getMethod("getAllURLs");
+ } catch (Exception e) {
+ m = null;
+ }
+ URL[] result;
+ if (m == null) {
+ result = classLoader.getURLs();
+ } else {
+ try {
+ result = (URL[]) m.invoke(classLoader);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondent au pattern donne
+ *
+ *@param classLoader le classLoader
+ *@param pattern le nom du fichier a extraire du
+ * fichier compress� ou durepertoire doit correspondre
+ * au pattern (repertoire + nom compris).
+ *@return la liste des urls correspondant au pattern
+ */
+ static public List<URL> getURLs(String pattern, URLClassLoader classLoader) {
+ if(classLoader == null){
+ classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+ }
+ URL[] arrayURL = getURLs(classLoader);
+ return getURLs(pattern,arrayURL);
+ }
+
+ /**
+ * Retourner la liste des fichiers du classLoader. Ces fichiers doivent
+ * correspondent au pattern donne
+ *
+ *@param arrayURL les urls ou chercher
+ *@param pattern le nom du fichier a extraire du
+ * fichier compress� ou durepertoire doit correspondre
+ * au pattern (repertoire + nom compris).
+ *@return la liste des urls correspondant au pattern
+ */
+ static public List<URL> getURLs(String pattern, URL... arrayURL ) {
+ long t0 = System.nanoTime();
+
+ HashList<URL> urlList = new HashList<URL>();
+
+ if (arrayURL.length == 1) {
+ URL jarURL = arrayURL[0];
+ if (isJar(jarURL.toString())) {
+ // jar invocation
+ try {
+ arrayURL = getClassPathURLsFromJarManifest(jarURL);
+ } catch (Exception e) {
+ log.warn(e);
+ arrayURL = new URL[]{jarURL};
+ }
+ }
+ }
+ if (log.isDebugEnabled()) {
+ for (URL url : arrayURL) {
+ log.debug("found url " + url);
+ }
+ }
+
+ for (URL urlFile : arrayURL) {
+ String fileName = urlFile.getFile();
+ //TODO deal with encoding in windows, this is very durty, but it works...
+ File file= new File(fileName.replaceAll("%20", " "));
+ // cas ou le ichier du classLoader est un fichier jar ou zip
+ if (file.exists() && (isJar(fileName) || isZip(fileName))) {
+ if (log.isDebugEnabled()) {
+ log.debug("jar to search " + file);
+ }
+ urlList.addAll(Resource.getURLsFromJar(file, pattern));
+
+ // cas ou le ichier du classLoader est un repertoire
+ } else if (file.exists() && file.isDirectory()) {
+ if (log.isDebugEnabled()) {
+ log.debug("file to search " + file);
+ }
+ // on traite le cas ou il peut y avoir des repertoire dans ce repertoire
+ urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
+ }
+ }
+ if (log.isInfoEnabled()) {
+ log.info("search URLs pattern: " + pattern + " in " + arrayURL.length+" urls in "+StringUtil.convertTime(System.nanoTime()-t0));
+ }
+ return urlList;
+ }
+
+ static public URL[] getClassPathURLsFromJarManifest(URL jarURL) throws IOException, URISyntaxException {
+ JarFile jar=null;
+ URL[] result;
+ try {
+ String jarPath = jarURL.toURI().getPath();
+ File jarFile = new File(jarPath);
+ if (log.isInfoEnabled()) {
+ log.info("class-path jar to scan " + jarPath);
+ }
+ jar = new JarFile(jarFile);
+ File container = jarFile.getParentFile();
+ Manifest mf = jar.getManifest();
+ String classPath = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+ String[] paths = classPath.split(" ");
+ result = new URL[paths.length + 1];
+ result[0] = jarURL;
+ File path;
+ for (int i = 0; i < paths.length; i++) {
+ String s = paths[i];
+ // test de l'existence d'un protocole dans le path (genre file:...)
+ if (s.indexOf(':') != -1) {
+ result[i + 1] = new URL(s);
+ continue;
+ }
+
+ if (s.startsWith(".") || !s.startsWith("/")) {
+ // relative url
+ path =new File(container,s);
+ } else {
+ path =new File(s);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(path);
+ }
+ result[i + 1] = path.toURI().toURL();
+ }
+ jar.close();
+ } finally {
+ if (jar!=null) {
+ jar.close();
+ }
+ }
+ return result;
+ }
+
+ static public List<URL> getURLsFromJar(File jarfile, String pattern) {
+ try{
+ if(log.isTraceEnabled()) {
+ log.trace("search '" + pattern + "' in " + jarfile);
+ }
+
+ ArrayList<URL> result = new ArrayList<URL>();
+ InputStream in = new FileInputStream(jarfile);
+ ZipInputStream zis = new ZipInputStream(in);
+ while (zis.available() != 0) {
+ ZipEntry entry = zis.getNextEntry();
+
+ if (entry == null) {
+ break;
+ }
+
+ String name = entry.getName();
+ if(log.isTraceEnabled()) {
+ log.trace("jarfile: " + jarfile + " name: " + name);
+ }
+ if (pattern == null || name.matches(pattern)) {
+ // on recupere le fichier correspondant au pattern dans le classloader
+ URL url = Resource.getURL(name);
+ // on ajoute le fichier correspondant au pattern dans la liste
+ if(log.isTraceEnabled()) {
+ log.trace("jarfile: " + jarfile + " url: " + url);
+ }
+ result.add(url);
+ }
+ }
+ if(log.isTraceEnabled()) {
+ log.trace("found with pattern '" + pattern + "' : " + result);
+ }
+ return result;
+ }catch(IOException eee){
+ throw new ResourceException("Erreur lors de la lecture du fichier compress�", eee);
+ }
+ }
+
+ /**
+ * Retourner la liste des fichiers correspondant au pattern donne, aucun
+ * ordre ne doit sur le fichier ne doit �tre suppos�.
+ *
+ *@param repository repertoire dans lequel on recherche les fichiers
+ *@param pattern le nom du fichier a extraire du
+ * fichier du repertoire doit correspondre
+ * au pattern (repertoire + nom compris).
+ * si le pattern est null, tous les fichiers trouv�
+ * sont retourn�.
+ *
+ *@return la liste des urls correspondant au pattern
+ */
+ static public List<URL> getURLsFromDirectory(File repository, String pattern) {
+ try{
+ if(log.isTraceEnabled()) {
+ log.trace("search '" + pattern + "' in " + repository);
+ }
+
+ HashList<URL> urlList = new HashList<URL>();
+ File[] filesList = repository.listFiles();
+
+ if (filesList != null) {
+
+ for (File file : filesList) {
+
+ String name = file.getAbsolutePath();
+
+ if (log.isTraceEnabled()) {
+ log.trace("directory: " + repository + " name: " + name);
+ }
+
+ // cas de recursivite : repertoire dans un repertoire
+ if (file.exists() && file.isDirectory()) {
+ urlList.addAll(Resource.getURLsFromDirectory(file, pattern));
+ // si le fichier du repertoire n'est pas un repertoire on verifie s'il correspond au pattern
+ } else if (pattern == null || name.matches(pattern)) {
+ URL url = file.toURI().toURL();
+ if (log.isTraceEnabled()) {
+ log.trace("directory: " + repository + " url: " + url);
+ }
+ urlList.add(url);
+ }
+ }
+ }
+ if(log.isTraceEnabled()) {
+ log.trace("found with pattern '" + pattern + "' : " + urlList);
+ }
+ return urlList;
+ }catch(MalformedURLException eee){
+ throw new ResourceException("Le fichier n'a pu �tre converti en URL", eee);
+ }
+ }
+
+ /**
+ * Verifie si le fichier est un fichier jar
+ * @param name nom du fichier a tester
+ * @return vrai si le fichier se termine par .jar faux sinon
+ */
+ static public boolean isJar(String name){
+ if (name != null && name.length() > 4) {
+ String ext = name.substring(name.length() - 4, name.length());
+ return ".jar".equalsIgnoreCase(ext);
+ }
+ return false;
+ }
+
+ /**
+ * Verifie si le fichier est un fichier zip
+ * @param name nom du fichier a tester
+ * @return vrai si le fichier se termine par .zip faux sinon
+ */
+ static public boolean isZip(String name){
+ if (name != null && name.length() > 4) {
+ String ext = name.substring(name.length() - 4, name.length());
+ return ".zip".equalsIgnoreCase(ext);
+ }
+ return false;
+ }
+
+ /**
+ * Verifie si la classe est de type primtif
+ * @param clazz nom de la classe a tester
+ * @return vrai si le classe est de type primitif faux sinon
+ */
+ static public boolean isPrimitive(Class clazz){
+ return clazz.isPrimitive()
+ || clazz == Boolean.class
+ || clazz == Byte.class
+ || clazz == Character.class
+ || clazz == Short.class
+ || clazz == Integer.class
+ || clazz == Long.class
+ || clazz == Float.class
+ || clazz == Double.class;
+ }
+
+ /**
+ * Retourne la classe du type primitf associ� avec la classe de de l'objet
+ * pass� en parametre. Par exemple si la classe pass�e en param�tre est
+ * Integer alors le resultat sera la classe de int.
+ * @param clazz la classe dont on souhaite le type primitf
+ * @return le type primitif associ� a la classe en param�tre, ou null
+ * s'il n'y a pas de type primitif associ�.
+ */
+ static public Class getPrimitiveClass(Class clazz) {
+ if (clazz == Boolean.class) return Boolean.TYPE;
+ if (clazz == Byte.class) return Byte.TYPE;
+ if (clazz == Character.class) return Character.TYPE;
+ if (clazz == Short.class) return Short.TYPE;
+ if (clazz == Integer.class) return Integer.TYPE;
+ if (clazz == Long.class) return Long.TYPE;
+ if (clazz == Float.class) return Float.TYPE;
+ if (clazz == Double.class) return Double.TYPE;
+ if (clazz == Void.class) return Void.TYPE;
+ return null;
+ }
+
+// /**
+// * Test
+// */
+// static public void main(String [] args) throws Exception {
+// String r = args.length>0?args[0]:"/org/codelutin/lutinbuilder/LutinBuilder.class";
+// System.out.println(getURL(r));
+// }
+
+} // Resource
1
0
27 Nov '08
Author: schorlet
Date: 2008-11-27 09:57:18 +0000 (Thu, 27 Nov 2008)
New Revision: 1256
Removed:
lutinutil/tags/0.29.1/
Log:
1
0
27 Nov '08
Author: schorlet
Date: 2008-11-27 09:55:46 +0000 (Thu, 27 Nov 2008)
New Revision: 1255
Added:
lutinutil/tags/0.29.1/
Log:
version de maintenance pour simexplorer
ssCette ligne, et les suivantes ci-dessous, seront ignor?\195?\169es--
A svn+ssh://schorlet@labs.libre-entreprise.org/svnroot/lutinutil/lutinutil/tags/0.29.1
1
0
[Lutinutil-commits] r1254 - in lutinutil/branches/0.29-SNAPSHOT: . src/java/org/codelutin/util
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
by schorlet@users.labs.libre-entreprise.org 27 Nov '08
27 Nov '08
Author: schorlet
Date: 2008-11-27 09:48:25 +0000 (Thu, 27 Nov 2008)
New Revision: 1254
Modified:
lutinutil/branches/0.29-SNAPSHOT/
lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java
Log:
modif de Resource.getClassPathURLsFromJarManifest() pour lire le MANIFEST compos?\195?\169 de file:... file:...
Property changes on: lutinutil/branches/0.29-SNAPSHOT
___________________________________________________________________
Name: svn:ignore
- target
velocity.log
maven.log
.eclipse
.classpath
lutinutil.iml
lutinutil.ipr
+ target
velocity.log
maven.log
.eclipse
.classpath
lutinutil.iml
lutinutil.ipr
.project
.settings
Modified: lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java
===================================================================
--- lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java 2008-11-21 15:51:51 UTC (rev 1253)
+++ lutinutil/branches/0.29-SNAPSHOT/src/java/org/codelutin/util/Resource.java 2008-11-27 09:48:25 UTC (rev 1254)
@@ -334,6 +334,12 @@
File path;
for (int i = 0; i < paths.length; i++) {
String s = paths[i];
+ // test de l'existence d'un protocole dans le path (genre file:...)
+ if (s.indexOf(':') != -1) {
+ result[i + 1] = new URL(s);
+ continue;
+ }
+
if (s.startsWith(".") || !s.startsWith("/")) {
// relative url
path =new File(container,s);
1
0
[Lutinutil-commits] r1253 - maven-license-switcher-plugin/trunk
by chemit@users.labs.libre-entreprise.org 21 Nov '08
by chemit@users.labs.libre-entreprise.org 21 Nov '08
21 Nov '08
Author: chemit
Date: 2008-11-21 15:51:51 +0000 (Fri, 21 Nov 2008)
New Revision: 1253
Modified:
maven-license-switcher-plugin/trunk/pom.xml
Log:
push back scm generic values
Modified: maven-license-switcher-plugin/trunk/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:48:01 UTC (rev 1252)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:51:51 UTC (rev 1253)
@@ -98,9 +98,9 @@
<!--Source control management-->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/trunk</connection>
- <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/trunk</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/maven-license-s…</url>
+ <connection>${maven.scm.connection}</connection>
+ <developerConnection>${maven.scm.developerConnection}</developerConnection>
+ <url>${maven.scm.url}</url>
</scm>
</project>
1
0
[Lutinutil-commits] r1252 - maven-license-switcher-plugin/trunk
by tchemit@users.labs.libre-entreprise.org 21 Nov '08
by tchemit@users.labs.libre-entreprise.org 21 Nov '08
21 Nov '08
Author: tchemit
Date: 2008-11-21 15:48:01 +0000 (Fri, 21 Nov 2008)
New Revision: 1252
Modified:
maven-license-switcher-plugin/trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: maven-license-switcher-plugin/trunk/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:47:55 UTC (rev 1251)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:48:01 UTC (rev 1252)
@@ -14,7 +14,7 @@
<artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
<dependencies>
@@ -98,9 +98,9 @@
<!--Source control management-->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/tags/0.5</connection>
- <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/tags/0.5</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/maven-license-s…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/trunk</connection>
+ <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/trunk</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/maven-license-s…</url>
</scm>
</project>
1
0
[Lutinutil-commits] r1251 - in maven-license-switcher-plugin/tags: . 0.5 0.5/src/main/java/org/codelutin/license/plugin
by tchemit@users.labs.libre-entreprise.org 21 Nov '08
by tchemit@users.labs.libre-entreprise.org 21 Nov '08
21 Nov '08
Author: tchemit
Date: 2008-11-21 15:47:55 +0000 (Fri, 21 Nov 2008)
New Revision: 1251
Added:
maven-license-switcher-plugin/tags/0.5/
maven-license-switcher-plugin/tags/0.5/changelog
maven-license-switcher-plugin/tags/0.5/pom.xml
maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java
Removed:
maven-license-switcher-plugin/tags/0.5/changelog
maven-license-switcher-plugin/tags/0.5/pom.xml
maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java
Log:
[maven-release-plugin] copy for tag 0.5
Copied: maven-license-switcher-plugin/tags/0.5 (from rev 1234, maven-license-switcher-plugin/trunk)
Deleted: maven-license-switcher-plugin/tags/0.5/changelog
===================================================================
--- maven-license-switcher-plugin/trunk/changelog 2008-11-17 11:45:24 UTC (rev 1234)
+++ maven-license-switcher-plugin/tags/0.5/changelog 2008-11-21 15:47:55 UTC (rev 1251)
@@ -1,7 +0,0 @@
-ver-0-4 chemit 20081013
- * 20081013 [chemit] Improve third-party goal : onyl keep included dependencies
-
-ver-0-3 chemit 20081013
- * 20081013 [chemit] Improve licence resolving
- * 20080922 [thimel] Modified version of jrst and plugin's groupId
- * 20080922 [chemit] Using lutinpluginproject 3.0
Copied: maven-license-switcher-plugin/tags/0.5/changelog (from rev 1244, maven-license-switcher-plugin/trunk/changelog)
===================================================================
--- maven-license-switcher-plugin/tags/0.5/changelog (rev 0)
+++ maven-license-switcher-plugin/tags/0.5/changelog 2008-11-21 15:47:55 UTC (rev 1251)
@@ -0,0 +1,11 @@
+ver-0-5 chemit 200811??
+ * 20081121 [chemit] fix bug when no name is defined in license
+ * 20081118 [chemit] use lutinpluginproject 3.1
+
+ver-0-4 chemit 20081013
+ * 20081013 [chemit] Improve third-party goal : onyl keep included dependencies
+
+ver-0-3 chemit 20081013
+ * 20081013 [chemit] Improve licence resolving
+ * 20080922 [thimel] Modified version of jrst and plugin's groupId
+ * 20080922 [chemit] Using lutinpluginproject 3.0
Deleted: maven-license-switcher-plugin/tags/0.5/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-17 11:45:24 UTC (rev 1234)
+++ maven-license-switcher-plugin/tags/0.5/pom.xml 2008-11-21 15:47:55 UTC (rev 1251)
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinpluginproject</artifactId>
- <version>3.0</version>
- </parent>
-
- <artifactId>maven-license-switcher-plugin</artifactId>
-
- <dependencies>
-
- <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.15</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinpluginutil</artifactId>
- <version>0.2</version>
- <scope>compile</scope>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
- <name>Plugin maven pour switcher les licenses</name>
- <version>0.5-SNAPSHOT</version>
- <description>Plugin pour switcher de license dans un module maven 2</description>
- <inceptionYear>2008</inceptionYear>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>maven-plugin</packaging>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!--Copy licenses files for site-->
- <execution>
- <id>CopySiteFiles2</id>
- <phase>pre-site</phase>
- <configuration>
- <tasks>
- <mkdir dir="${maven.site.gen.dir}/resources" />
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" overwrite="false">
- <fileset dir="${maven.src.dir}/main/resources/META-INF">
- <include name="licenses/**" />
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <properties>
-
- <!-- id du projet du labs -->
- <labs.id>12</labs.id>
-
- <!-- nom du projet sur le labs -->
- <labs.project>lutinutil</labs.project>
-
- </properties>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
-
- <!--Source control management-->
- <scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
- </scm>
-
-</project>
Copied: maven-license-switcher-plugin/tags/0.5/pom.xml (from rev 1249, maven-license-switcher-plugin/trunk/pom.xml)
===================================================================
--- maven-license-switcher-plugin/tags/0.5/pom.xml (rev 0)
+++ maven-license-switcher-plugin/tags/0.5/pom.xml 2008-11-21 15:47:55 UTC (rev 1251)
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinpluginproject</artifactId>
+ <version>3.1</version>
+ </parent>
+
+ <artifactId>maven-license-switcher-plugin</artifactId>
+
+ <version>0.5</version>
+
+ <dependencies>
+
+ <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.15</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinpluginutil</artifactId>
+ <version>0.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>Plugin maven pour switcher les licenses</name>
+
+ <description>Plugin pour switcher de license dans un module maven 2</description>
+ <inceptionYear>2008</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>maven-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!--Copy licenses files for site-->
+ <execution>
+ <id>CopySiteFiles2</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" overwrite="false">
+ <fileset dir="${maven.src.dir}/main/resources/META-INF">
+ <include name="licenses/**" />
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+
+ <!-- id du projet du labs -->
+ <labs.id>12</labs.id>
+
+ <!-- nom du projet sur le labs -->
+ <labs.project>lutinutil</labs.project>
+
+ </properties>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <!--Source control management-->
+ <scm>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/tags/0.5</connection>
+ <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/lutinutil/maven-license-switcher-plugin/tags/0.5</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/maven-license-s…</url>
+ </scm>
+
+</project>
Deleted: maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java
===================================================================
--- maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-17 11:45:24 UTC (rev 1234)
+++ maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-21 15:47:55 UTC (rev 1251)
@@ -1,324 +0,0 @@
-/**
- * *##% 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.plugin;
-
-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.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 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 AbstractLicenseMojo {
-
- private static final String unknownLicenseMessage = "Unknown license";
-
- /**
- * Local Repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- */
- protected ArtifactRepository localRepository;
-
-
- /**
- * Remote repositories used for the project.
- *
- * @parameter expression="${project.remoteArtifactRepositories}"
- * @required
- * @readonly
- */
- protected List remoteRepositories;
-
- /**
- * Fichier ou ecrire les licences des dependances.
- *
- * @parameter expression="${license-switcher.thirdPartyFile}" default-value="${project.build.outputDirectory}/THIRD-PARTY.txt"
- * @required
- */
- 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;
-
- /**
- * Un flag pour indiquer la regeneration des fichiers.
- *
- * @parameter expression="${license-switcher.doGenerate}" default-value="true"
- */
- 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;
-
- protected void init() throws Exception {
-
- // must generate if file does not exist
- doGenerate = doGenerate || !thirdPartyFile.exists();
-
- if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
- // nothing to be done for this type of packaging
- doGenerate = false;
- getLog().info("skip third-party goal for packaging " + project.getPackaging());
- return;
- }
-
- if (doGenerate) {
-
- // prepare thirdPartyFileContent
-
- DependencyNode dependencyTreeNode = resolveProject();
-
- LicenseMap licenseMap = new LicenseMap();
-
- for (Object o : dependencyTreeNode.getChildren()) {
-
- buildLicenseMap((DependencyNode) o, licenseMap);
- }
-
- thirdPartyFileContent = buildGroupedLicenses(licenseMap);
-
- // log dependencies with no license
- SortedSet<String> dependenciesWithNoLicense = licenseMap.get(unknownLicenseMessage);
- if (dependenciesWithNoLicense != null) {
- for (String dep : dependenciesWithNoLicense) {
- // no license found for the dependency
- getLog().warn("no license found for dependency " + dep);
- }
- }
- }
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- super.execute();
-
- if (doGenerate) {
- if (verbose) {
- getLog().info("writing third-party file : " + thirdPartyFile);
- }
- if (keepBackup && thirdPartyFile.exists()) {
- if (verbose) {
- getLog().info("backup " + thirdPartyFile);
- }
- thirdPartyFile.renameTo(new File(thirdPartyFile.getAbsolutePath() + '~'));
- }
- try {
- FileUtil.writeString(thirdPartyFile, thirdPartyFileContent, encoding);
- } 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) {
- if (node.getState() != DependencyNode.INCLUDED) {
- // this dependency is not included, so do not treate it
- if (verbose) {
- getLog().info("do not include this dependency " + node.toNodeString());
- }
- return;
- }
- Artifact artifact = node.getArtifact();
-
- if (verbose && getLog().isDebugEnabled()) {
- getLog().debug("treate node " + node.toNodeString());
- }
-
- if (!Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
- try {
- MavenProject artifactProject = getMavenProjectFromRepository(artifact);
- String artifactName = getArtifactName(artifactProject);
-
- List licenses = artifactProject.getLicenses();
-
- if (licenses.isEmpty()) {
- // no license found for the dependency
- licenseMap.put(unknownLicenseMessage, artifactName);
-
- } else {
- for (Object license : licenses) {
- licenseMap.put(((License) license).getName(), 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 {
-
- boolean allowStubModel = false;
-
- if (!"pom".equals(artifact.getType())) {
- artifact = factory.createProjectArtifact(artifact.getGroupId(), artifact.getArtifactId(),
- artifact.getVersion(), artifact.getScope());
- allowStubModel = true;
- }
-
- // TODO: we should use the MavenMetadataSource instead
- return mavenProjectBuilder.buildFromRepository(artifact, 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>();
- }
- if (getLog().isDebugEnabled()) {
- getLog().debug("key:" + key + ",value: " + value);
- }
- valueList.add(value);
- return put(key, valueList);
- }
- }
-}
Copied: maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java (from rev 1244, maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java)
===================================================================
--- maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java (rev 0)
+++ maven-license-switcher-plugin/tags/0.5/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-21 15:47:55 UTC (rev 1251)
@@ -0,0 +1,333 @@
+/**
+ * *##% 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.plugin;
+
+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.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 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 AbstractLicenseMojo {
+
+ private static final String unknownLicenseMessage = "Unknown license";
+
+ /**
+ * Local Repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactRepository localRepository;
+
+
+ /**
+ * Remote repositories used for the project.
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @required
+ * @readonly
+ */
+ protected List remoteRepositories;
+
+ /**
+ * Fichier ou ecrire les licences des dependances.
+ *
+ * @parameter expression="${license-switcher.thirdPartyFile}" default-value="${project.build.outputDirectory}/THIRD-PARTY.txt"
+ * @required
+ */
+ 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;
+
+ /**
+ * Un flag pour indiquer la regeneration des fichiers.
+ *
+ * @parameter expression="${license-switcher.doGenerate}" default-value="true"
+ */
+ 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;
+
+ protected void init() throws Exception {
+
+ // must generate if file does not exist
+ doGenerate = doGenerate || !thirdPartyFile.exists();
+
+ if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+ // nothing to be done for this type of packaging
+ doGenerate = false;
+ getLog().info("skip third-party goal for packaging " + project.getPackaging());
+ return;
+ }
+
+ if (doGenerate) {
+
+ // prepare thirdPartyFileContent
+
+ DependencyNode dependencyTreeNode = resolveProject();
+
+ LicenseMap licenseMap = new LicenseMap();
+
+ for (Object o : dependencyTreeNode.getChildren()) {
+
+ buildLicenseMap((DependencyNode) o, licenseMap);
+ }
+
+ thirdPartyFileContent = buildGroupedLicenses(licenseMap);
+
+ // log dependencies with no license
+ SortedSet<String> dependenciesWithNoLicense = licenseMap.get(unknownLicenseMessage);
+ if (dependenciesWithNoLicense != null) {
+ for (String dep : dependenciesWithNoLicense) {
+ // no license found for the dependency
+ getLog().warn("no license found for dependency " + dep);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ super.execute();
+
+ if (doGenerate) {
+ if (verbose) {
+ getLog().info("writing third-party file : " + thirdPartyFile);
+ }
+ if (keepBackup && thirdPartyFile.exists()) {
+ if (verbose) {
+ getLog().info("backup " + thirdPartyFile);
+ }
+ thirdPartyFile.renameTo(new File(thirdPartyFile.getAbsolutePath() + '~'));
+ }
+ try {
+ FileUtil.writeString(thirdPartyFile, thirdPartyFileContent, encoding);
+ } 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) {
+ if (node.getState() != DependencyNode.INCLUDED) {
+ // this dependency is not included, so do not treate it
+ if (verbose) {
+ getLog().info("do not include this dependency " + node.toNodeString());
+ }
+ return;
+ }
+ Artifact artifact = node.getArtifact();
+
+ if (verbose && getLog().isDebugEnabled()) {
+ getLog().debug("treate node " + node.toNodeString());
+ }
+
+ if (!Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
+ try {
+ MavenProject artifactProject = getMavenProjectFromRepository(artifact);
+ String artifactName = getArtifactName(artifactProject);
+
+ List licenses = artifactProject.getLicenses();
+
+ if (licenses.isEmpty()) {
+ // no license found for the dependency
+ licenseMap.put(unknownLicenseMessage, artifactName);
+
+ } else {
+ for (Object o : licenses) {
+ if (o == null) {
+ getLog().warn("could not acquire the license for " + artifactName);
+ continue;
+ }
+ License license = (License) o;
+ String licenseKey = license.getName();
+ if (license.getName() == null) {
+ licenseKey = license.getUrl();
+ }
+ licenseMap.put(licenseKey, 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 {
+
+ boolean allowStubModel = false;
+
+ if (!"pom".equals(artifact.getType())) {
+ artifact = factory.createProjectArtifact(artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion(), artifact.getScope());
+ allowStubModel = true;
+ }
+
+ // TODO: we should use the MavenMetadataSource instead
+ return mavenProjectBuilder.buildFromRepository(artifact, 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>();
+ }
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("key:" + key + ",value: " + value);
+ }
+ valueList.add(value);
+ return put(key, valueList);
+ }
+ }
+}
1
0
[Lutinutil-commits] r1250 - maven-license-switcher-plugin/tags
by chemit@users.labs.libre-entreprise.org 21 Nov '08
by chemit@users.labs.libre-entreprise.org 21 Nov '08
21 Nov '08
Author: chemit
Date: 2008-11-21 15:47:44 +0000 (Fri, 21 Nov 2008)
New Revision: 1250
Removed:
maven-license-switcher-plugin/tags/0.5/
Log:
[maven-release-plugin] rollback
1
0