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
- 3157 discussions
[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
[Lutinutil-commits] r1249 - 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:46:55 +0000 (Fri, 21 Nov 2008)
New Revision: 1249
Modified:
maven-license-switcher-plugin/trunk/pom.xml
Log:
[maven-release-plugin] prepare release 0.5
Modified: maven-license-switcher-plugin/trunk/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:44:22 UTC (rev 1248)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:46:55 UTC (rev 1249)
@@ -1,6 +1,5 @@
<?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">
+<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>
@@ -15,7 +14,7 @@
<artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
<dependencies>
@@ -66,11 +65,10 @@
<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">
+ <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/**"/>
+ <include name="licenses/**" />
</fileset>
</copy>
</tasks>
@@ -100,9 +98,9 @@
<!--Source control management-->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <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>
1
0
[Lutinutil-commits] r1248 - 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:44:22 +0000 (Fri, 21 Nov 2008)
New Revision: 1248
Modified:
maven-license-switcher-plugin/trunk/pom.xml
Log:
[maven-release-plugin] rollback the release of 0.5
Modified: maven-license-switcher-plugin/trunk/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:40:00 UTC (rev 1247)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:44:22 UTC (rev 1248)
@@ -1,5 +1,6 @@
<?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">
+<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>
@@ -14,7 +15,7 @@
<artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.6-SNAPSHOT</version>
+ <version>0.5-SNAPSHOT</version>
<dependencies>
@@ -65,10 +66,11 @@
<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">
+ <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/**" />
+ <include name="licenses/**"/>
</fileset>
</copy>
</tasks>
@@ -98,9 +100,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] r1247 - 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:40:00 +0000 (Fri, 21 Nov 2008)
New Revision: 1247
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:39:57 UTC (rev 1246)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:40:00 UTC (rev 1247)
@@ -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] r1246 - 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:39:57 +0000 (Fri, 21 Nov 2008)
New Revision: 1246
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:39:57 UTC (rev 1246)
@@ -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:39:57 UTC (rev 1246)
@@ -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:39:57 UTC (rev 1246)
@@ -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 1245, 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:39:57 UTC (rev 1246)
@@ -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:39:57 UTC (rev 1246)
@@ -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:39:57 UTC (rev 1246)
@@ -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] r1245 - 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:39:53 +0000 (Fri, 21 Nov 2008)
New Revision: 1245
Modified:
maven-license-switcher-plugin/trunk/pom.xml
Log:
[maven-release-plugin] prepare release 0.5
Modified: maven-license-switcher-plugin/trunk/pom.xml
===================================================================
--- maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:37:49 UTC (rev 1244)
+++ maven-license-switcher-plugin/trunk/pom.xml 2008-11-21 15:39:53 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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>
@@ -15,7 +14,7 @@
<artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</version>
<dependencies>
@@ -66,11 +65,10 @@
<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">
+ <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/**"/>
+ <include name="licenses/**" />
</fileset>
</copy>
</tasks>
@@ -100,9 +98,9 @@
<!--Source control management-->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <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>
1
0
[Lutinutil-commits] r1244 - in maven-license-switcher-plugin/trunk: . src/main/java/org/codelutin/license/plugin
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:37:49 +0000 (Fri, 21 Nov 2008)
New Revision: 1244
Modified:
maven-license-switcher-plugin/trunk/changelog
maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java
Log:
fix bug when no name is defined in license
Modified: maven-license-switcher-plugin/trunk/changelog
===================================================================
--- maven-license-switcher-plugin/trunk/changelog 2008-11-20 14:03:08 UTC (rev 1243)
+++ maven-license-switcher-plugin/trunk/changelog 2008-11-21 15:37:49 UTC (rev 1244)
@@ -1,6 +1,7 @@
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
Modified: maven-license-switcher-plugin/trunk/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-20 14:03:08 UTC (rev 1243)
+++ maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-21 15:37:49 UTC (rev 1244)
@@ -135,7 +135,7 @@
// must generate if file does not exist
doGenerate = doGenerate || !thirdPartyFile.exists();
- if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+ 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());
@@ -232,8 +232,17 @@
licenseMap.put(unknownLicenseMessage, artifactName);
} else {
- for (Object license : licenses) {
- licenseMap.put(((License) license).getName(), artifactName);
+ 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);
}
}
}
1
0
[Lutinutil-commits] r1243 - in lutinutil/trunk: . src/main/java/org/codelutin/util src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 20 Nov '08
by chatellier@users.labs.libre-entreprise.org 20 Nov '08
20 Nov '08
Author: chatellier
Date: 2008-11-20 14:03:08 +0000 (Thu, 20 Nov 2008)
New Revision: 1243
Removed:
lutinutil/trunk/src/main/java/org/codelutin/util/HashMapMultiKey.java
Modified:
lutinutil/trunk/changelog
lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java
lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java
lutinutil/trunk/src/main/java/org/codelutin/util/EnumEditor.java
lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java
lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java
lutinutil/trunk/src/main/java/org/codelutin/util/URLConverter.java
lutinutil/trunk/src/main/java/org/codelutin/util/VersionNumberConverter.java
lutinutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties
lutinutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties
Log:
Update i18n transalation
Modified: lutinutil/trunk/changelog
===================================================================
--- lutinutil/trunk/changelog 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/changelog 2008-11-20 14:03:08 UTC (rev 1243)
@@ -1,8 +1,10 @@
ver 1.0 ??? ???
+ * 20081120 [chatellier] Remove deprecated HashMapMultiKey
+ * 20081120 [chatellier] Fix i18n lutinutil properties files
* 20081118 [chemit] - use lutinproject 3.1
- improve i18n loading : skip urls with no i18n directory
- introduce ClassLoaderUtil class
- * 2008???? [chatellier] Remove deprecated I18n._ and replace by temporary code
+ * 20081101 [chatellier] Remove deprecated I18n._ and replace by temporary code
ver-0-31 chemit 2008????
* always build javadoc
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/ApplicationConfig.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -406,7 +406,9 @@
try {
save(file, false);
} catch (IOException eee) {
- log.warn(_("Can't save config in file %s", file), eee);
+ if (log.isWarnEnabled()) {
+ log.warn(_("lutinutil.error.applicationconfig.save", file), eee);
+ }
}
}
@@ -419,7 +421,9 @@
try {
save(file, false);
} catch (IOException eee) {
- log.warn(_("Can't save config in file %s", file), eee);
+ if (log.isWarnEnabled()) {
+ log.warn(_("lutinutil.error.applicationconfig.save", file), eee);
+ }
}
}
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -57,7 +57,7 @@
if (useDefault) {
return defaultValue;
}
- throw new ConversionException(_("lutin.error.convertor.noValue", this));
+ throw new ConversionException(_("lutinutil.error.convertor.noValue", this));
}
if (isEnabled(aClass, enumType)) {
Object result;
@@ -80,7 +80,7 @@
return result;
}
}
- throw new ConversionException(_("lutin.error.no.convertor", aClass.getName(), value));
+ throw new ConversionException(_("lutinutil.error.no.convertor", aClass.getName(), value));
}
public EnumConverter(Class<?> enumType, Object defaultValue) {
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/EnumEditor.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/EnumEditor.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/EnumEditor.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -29,6 +29,9 @@
*/
public class EnumEditor extends JComboBox {
+ /** serialVersionUID */
+ private static final long serialVersionUID = 2693771553067104538L;
+
protected Class<? extends Enum<?>> type;
public static EnumEditor newEditor(Class<?> type) {
Deleted: lutinutil/trunk/src/main/java/org/codelutin/util/HashMapMultiKey.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/HashMapMultiKey.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/HashMapMultiKey.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -1,454 +0,0 @@
-/* *##% Lutin utilities library
- * Copyright (C) 2004 - 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>. ##%* */
-
-/* *
- * HashMapMultiKey.java
- *
- * Created: 2 nov. 2004
- *
- * @author Benjamin Poussin <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-
-package org.codelutin.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.Serializable;
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Permet de stocker un element suivant un ensemble de cle.
- * <p/>
- * FIXME: pas le temps d'implanter toutes les methodes pour un support
- * complet des References. iterator(), entrySet(), ... peuvent ne pas
- * fonctionner comme il faut, c-a-d qu'il retourne les references et non
- * les objets. Mais les methodes simples fonctionnent: put, remove, get, ...
- *
- * @deprecated Cette classe semble avoir des memory leaks. Mieux vaut ne pas
- * l'utiliser ou alors il faudrait refaire l'implantation complete de facon propre
- */
-@Deprecated
-public class HashMapMultiKey extends HashMap<Object, Object> { // HashMapMultiKey
-
- /** */
- private static final long serialVersionUID = 8455012633585431630L;
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(HashMapMultiKey.class);
-
- public static final Object HARD = null;
- public static final Object SOFT = new Object();
- public static final Object WEAK = new Object();
-
- /** key: un objet, value un Set de key pour la vrai hashmap */
- protected HashMap<Object, Set<Object>> keys = new HashMap<Object, Set<Object>>();
- /**
- * key: la valeur, valeur: la cle. Permet de supprimer rapidement une
- * key lorsque la valeur disparait
- */
- protected Map<Object, Object> valueToKey = new IdentityHashMap<Object, Object>();
- protected ReferenceQueue<Object> refQueueKey = new ReferenceQueue<Object>();
- protected ReferenceQueue<Object> refQueueValue = new ReferenceQueue<Object>();
-
- protected Object keyType = null;
- protected Object valueType = null;
-
- /**
- * Si value est une reference et qu'il disparait alors la cle disparait
- * Si key est une reference et qu'une de ses composantes disparait alors
- * la cle et la valeur disparaissent.
- *
- * @param keyType le type de cle SOFT ou WEAK ou null
- * @param valueType le type de valeur SOFT ou WEAK ou null
- */
- public HashMapMultiKey(Object keyType, Object valueType) {
- super();
- this.keyType = keyType;
- this.valueType = valueType;
- }
-
- public HashMapMultiKey() {
- this(null, null);
- }
-
- /** Encapsule dans un objet Reference si besoin l'objet o */
- protected Object refValue(Object o) {
- Object result = o;
- if (valueType == SOFT) {
- result = new TransparenteSoftReference<Object>(o, refQueueValue, false);
- } else if (valueType == WEAK) {
- result = new TransparenteWeakReference<Object>(o, refQueueValue, false);
- }
- return result;
- }
-
- protected Object derefValue(Object o) {
- Object result = o;
- if (valueType == SOFT && o != null) {
- result = ((TransparenteSoftReference<?>) o).get();
- } else if (valueType == WEAK && o != null) {
- result = ((TransparenteWeakReference<?>) o).get();
- }
- return result;
- }
-
-
- /** Encapsule dans un objet Reference si besoin l'objet o */
- protected Object refKey(Object o) {
- Object result = o;
- if (keyType == SOFT) {
- result = new TransparenteSoftReference<Object>(o, refQueueKey, false);
- } else if (keyType == WEAK) {
- result = new TransparenteWeakReference<Object>(o, refQueueKey, false);
- }
- return result;
- }
-
- protected Object derefKey(Object o) {
- Object result = o;
- if (keyType == SOFT && o != null) {
- result = ((TransparenteSoftReference<?>) o).get();
- } else if (keyType == WEAK && o != null) {
- result = ((TransparenteWeakReference<?>) o).get();
- }
- return result;
- }
-
- /**
- * Look in the queue if reference is available and remove reference in
- * all map
- * ATTENTION: this method not call other method, because all other method
- * call it
- */
- protected void cleanQueue() {
- Reference<?> o = null;
- while (null != (o = refQueueKey.poll())) {
- if (log.isTraceEnabled()) {
- log.trace("clean the refQueueKey : " + o);
- }
- Object val = super.remove(o);
- valueToKey.remove(val);
- }
-
- while (null != (o = refQueueValue.poll())) {
- if (log.isTraceEnabled()) {
- log.trace("clean the refQueueValue : " + o);
- }
- // suppression dans la table des values et recuperation de la cle
- // associé
- Object keyRef = valueToKey.remove(o);
- // suppression dans la table a partir de la cle recuperé
- super.remove(keyRef);
-
- Object key = derefKey(keyRef);
-// System.out.println("++++++++++ key: " + key + " keyRef: " + keyRef + " for value: " + o);
- if (key != null) {
- // suppression dans l'association des objets de la cle
- for (Iterator<Object> i = ((Key) key).iterator(); i.hasNext();) {
- Object k = i.next();
- Set<?> list = keys.get(k);
- // FIXME il arrive que la list soit null, mais cela devrait
- // etre impossible puisqu'on vient de recuperer une cle qui
- // contient cette sous cle qui devrait retourner cette liste
- if (list != null) {
- list.remove(keyRef);
- if (list.size() == 0) {
- keys.remove(k);
- }
- }
- }
- } else {
- if (log.isTraceEnabled()) {
- log.trace("key is null !!! do long task to prevent memory leak " + o);
- }
- // to prevent memory leak we can clean all list in keys Map
- for (Iterator<Object> e = keys.keySet().iterator(); e.hasNext();) {
- Object k = e.next();
- Set<?> list = keys.get(k);
- if (list != null) {
- for (Iterator<?> i = list.iterator(); i.hasNext();) {
- if (derefKey(i.next()) == null) {
- i.remove();
- }
- }
- if (list.size() == 0) {
- e.remove();
- }
- }
- }
- if (log.isTraceEnabled()) {
- log.trace("end of long task to prevent memory leak" + o);
- }
- }
- }
- }
-
- /**
- * Retourne toutes les cles qui contiennent au moins une fois l'élément
- * e.
- *
- * @param e l'element que doivent contenir les cles
- * @return la liste des cles. Si aucune cle ne contient l'element e,
- * alors la liste retourné est vide.
- */
- public Set<Object> getKeys(Object e) {
- Set<Object> list = _getKeys(e);
- return list;
- }
-
- /**
- * Retourne toutes les cles qui contiennent au moins une fois l'élément
- * e.
- *
- * @param e l'element que doivent contenir les cles
- * @return la liste des cles. Si aucune cle ne contient l'element e,
- * alors la liste retourné est vide.
- */
- protected Set<Object> _getKeys(Object e) {
- cleanQueue();
- Set<Object> list = keys.get(e);
- if (list == null) {
- list = new HashSet<Object>();
- }
- return list;
- }
-
- protected Set<Object> getKeysAndAdd(Object e) {
- Set<Object> list = _getKeys(e);
- // il ne faut pas encapsuler e dans une ref, sinon on ne retrouve
- // plus les cles si l'objet etait seulement dans la cle
- keys.put(e, list);
- return list;
- }
-
- /**
- * Method put
- *
- * @param key une collection d'objet
- * @param value la valeur a associer a la cle.
- * @return l'ancienne valeur pour cette cle, ou null, s'il n'y
- * avait pas d'ancienne valeur.
- * @throws IllegalArgumentException si le parametre key n'est pas
- * une collection d'objet.
- */
- @Override
- public Object put(Object key, Object value) {
- if (key == null) {
- if (log.isWarnEnabled()) {
- log.warn("key is null");
- }
- }
- // a chaque fois que l'on ajoute, on nettoie un peu avant
- cleanQueue();
- if (key instanceof Key) {
- // ajout dans la hash des cles
- Key keyObject = (Key) key;
- Object keyRef = refKey(key);
- for (int i = 0; i < keyObject.size(); i++) {
- Object k = keyObject.get(i);
- // on recupere la liste des cles qui contiennent deja cette cle
- Set<Object> list = getKeysAndAdd(k);
- list.add(keyRef);
- }
- // On encapsule la valeur si besoin
- value = refValue(value);
- valueToKey.put(value, keyRef);
- // reelle ajout
- return derefValue(super.put(keyRef, value));
- }
- throw new IllegalArgumentException("L'argument key doit etre un tableau d'objet");
- }
-
-
- @Override
- public boolean containsValue(Object value) {
- cleanQueue();
- return valueToKey.containsKey(value);
- }
-
- @Override
- public Object get(Object key) {
- // a chaque fois que l'on prend, on nettoie un peu avant
- cleanQueue();
- return derefValue(super.get(key));
- }
-
- /* (non-Javadoc)
- * @see java.util.HashMap#size()
- */
- @Override
- public int size() {
- cleanQueue();
- return super.size();
- }
-
- /**
- * Method remove permet de supprimer un element suivant une cle
- * qui a permit d'ajouter l'element, on bien une composant d'une
- * cle qui a permis d'ajouter l'element. Si un tableau d'objet est
- * donne, alors au maximum un element est supprime. Si un objet
- * est passe alors 0 à N element sont supprimes. En fait tous les
- * valeurs qui ont dans leur cle, l'objet sont supprime.
- *
- * @param key soit un tableau d'objet soit un objet
- * @return si un objet Key a ete passe, alors retourne la
- * valeur associée a cette cle. Si un objet a ete passe, retourne la liste
- * des cles qui contient cet objet et qui ont été supprimées.
- */
- @Override
- public Object remove(Object key) {
- // on nettoie un peu avant
- cleanQueue();
- if (key instanceof Key) {
- // suppression de la cle
- // on pourrait aussi mettre la cle dans un WeakRef, ca eviterait
- // de devoir le supprimer dans les lists de keys, le
- // GC le ferait pour nous.
- Object keyRef = refKey(key);
- for (Iterator<Object> i = ((Key) key).iterator(); i.hasNext();) {
- Object k = i.next();
- Set<Object> list = _getKeys(k);
- if (list != null) {
- list.remove(keyRef);
- if (list.size() == 0) {
- keys.remove(k);
- }
- }
- }
-
- Object result = super.remove(keyRef);
- valueToKey.remove(result);
- return derefValue(result);
- } else {
- ArrayList<Key> result = new ArrayList<Key>();
- Set<Object> list = _getKeys(key);
- if (list != null) {
- for (Iterator<Object> i = list.iterator(); i.hasNext();) {
- Object keyRef = i.next();
- Key keyObject = (Key) derefKey(keyRef);
- i.remove();
- if (keyObject != null) { // si la cle existe encore
- result.add(keyObject);
- Object value = super.remove(keyRef);
- valueToKey.remove(value);
- }
- }
- if (list.size() == 0) {
- keys.remove(key);
- }
- }
- return result;
- }
- }
-
- /**
- * Retourne toutes les valeurs associés avec un element de cle
- *
- * @param keyElement un element constituant d'une ou de plusieurs cles
- * @return la liste des valeurs associées aux clés contenant keyElement
- */
- public ArrayList<Object> getValues(Object keyElement) {
- cleanQueue();
- ArrayList<Object> result = new ArrayList<Object>();
- Set<Object> list = _getKeys(keyElement);
- if (list != null) {
- for (Iterator<Object> i = list.iterator(); i.hasNext();) {
- Key keyObject = (Key) derefKey(i.next());
- if (keyObject != null) { // si la cle existe encore
- Object val = super.get(keyObject);
- result.add(derefValue(val));
- }
- }
- }
- return result;
- }
-
- static public class Key implements Serializable {
- /** */
- private static final long serialVersionUID = -2297846844678010597L;
- ArrayList<Object> keys = new ArrayList<Object>();
-
- public Key add(Object o) {
- keys.add(o);
- return this;
- }
-
- public int size() {
- return keys.size();
- }
-
- public Object get(int index) {
- return keys.get(index);
- }
-
- public Iterator<Object> iterator() {
- return keys.iterator();
- }
-
- @Override
- public boolean equals(Object o) {
- if (o != null && o instanceof Reference) {
- // on inverse l'egalite pour que la Key soit egal a la ref
- // si la ref contient la Key
- return o.equals(this);
- } else {
- return (o instanceof Key) &&
- keys.equals(((Key) o).keys);
- }
- }
-
- @Override
- public int hashCode() {
- int result = 0;
- for (int i = 0; i < keys.size(); i++) {
- Object key = keys.get(i);
- if (key != null) {
- result += keys.get(i).hashCode();
- }
- }
- return result;
- }
-
- @Override
- public String toString() {
- StringBuffer result = new StringBuffer("[");
- String v = "";
- for (int i = 0; i < keys.size(); i++) {
- result.append(v);
- result.append("" + keys.get(i));
- v = ",";
- }
- result.append("]");
- return result.toString();
- }
- }
-
-} // HashMapMultiKey
-
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -162,7 +162,7 @@
}
if (log.isDebugEnabled()) {
- log.debug(_("Invoke %s with %s", m, Arrays.toString(parameters)));
+ log.debug(_("lutinutil.debug.objectutil.invoke", m, Arrays.toString(parameters)));
}
Object result = m.invoke(o, parameters);
return result;
@@ -253,7 +253,7 @@
}
if (log.isDebugEnabled()) {
- log.debug(_("Try to create %s with %s", clazz, Arrays.toString(parameters)));
+ log.debug(_("lutinutil.debug.objectutil.create", clazz, Arrays.toString(parameters)));
}
T result = c.newInstance(parameters);
@@ -265,7 +265,7 @@
}
}
}
- throw new IllegalArgumentException(_("Can't instantiate %s with params %s",
+ throw new IllegalArgumentException(_("lutinutil.debug.objectutil.instantiate",
clazz, Arrays.toString(params)));
}
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -38,7 +38,7 @@
public Object convert(Class aClass, Object value) {
if (value == null) {
- throw new ConversionException(_("lutin.error.convertor.noValue", this));
+ throw new ConversionException(_("lutinutil.error.convertor.noValue", this));
}
if (isEnabled(aClass)) {
Object result;
@@ -51,7 +51,7 @@
return result;
}
}
- throw new ConversionException(_("lutin.error.no.convertor", aClass.getName(), value));
+ throw new ConversionException(_("lutinutil.error.no.convertor", aClass.getName(), value));
}
protected URI valueOf(String value) {
@@ -60,7 +60,7 @@
result = new URI(value);
return result;
} catch (URISyntaxException e) {
- throw new ConversionException(_("lutin.error.url.convertor", value, this, e.getMessage()));
+ throw new ConversionException(_("lutinutil.error.url.convertor", value, this, e.getMessage()));
}
}
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/URLConverter.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/URLConverter.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/URLConverter.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -38,7 +38,7 @@
public Object convert(Class aClass, Object value) {
if (value == null) {
- throw new ConversionException(_("lutin.error.convertor.noValue", this));
+ throw new ConversionException(_("lutinutil.error.convertor.noValue", this));
}
if (isEnabled(aClass)) {
Object result;
@@ -51,7 +51,7 @@
return result;
}
}
- throw new ConversionException(_("lutin.error.no.convertor", aClass.getName(), value));
+ throw new ConversionException(_("lutinutil.error.no.convertor", aClass.getName(), value));
}
protected URL valueOf(String value) {
@@ -60,7 +60,7 @@
result = new URL(value);
return result;
} catch (MalformedURLException e) {
- throw new ConversionException(_("lutin.error.url.convertor", value, this, e.getMessage()));
+ throw new ConversionException(_("lutinutil.error.url.convertor", value, this, e.getMessage()));
}
}
Modified: lutinutil/trunk/src/main/java/org/codelutin/util/VersionNumberConverter.java
===================================================================
--- lutinutil/trunk/src/main/java/org/codelutin/util/VersionNumberConverter.java 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/java/org/codelutin/util/VersionNumberConverter.java 2008-11-20 14:03:08 UTC (rev 1243)
@@ -36,7 +36,7 @@
public Object convert(Class aClass, Object value) {
if (value == null) {
- throw new ConversionException(_("lutin.error.convertor.noValue", this));
+ throw new ConversionException(_("lutinutil.error.convertor.noValue", this));
}
if (isEnabled(aClass)) {
Object result;
@@ -49,7 +49,7 @@
return result;
}
}
- throw new ConversionException(_("lutin.error.no.convertor", aClass.getName(), value));
+ throw new ConversionException(_("lutinutil.error.no.convertor", aClass.getName(), value));
}
public VersionNumberConverter() {
@@ -73,7 +73,7 @@
result = new VersionNumber(numbers);
return result;
} catch (IllegalArgumentException e) {
- throw new ConversionException(_("lutin.error.url.convertor", value, this, e.getMessage()));
+ throw new ConversionException(_("lutinutil.error.url.convertor", value, this, e.getMessage()));
}
}
Modified: lutinutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties
===================================================================
--- lutinutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties 2008-11-20 14:03:08 UTC (rev 1243)
@@ -1,16 +1,16 @@
-Can't\ instantiate\ %s\ with\ params\ %s=
-Can't\ save\ config\ in\ file\ %s=
-Invoke\ %s\ with\ %s=
-Try\ to\ create\ %s\ with\ %s=
hello\ you\ \!=hello you \!
-lutin.error.convertor.noValue=No value specified for converter {0}
-lutin.error.no.convertor=no convertor found for type {1} and objet ''{0}''
-lutin.error.url.convertor=a problem occurs while converting value ''{0}}'' with url convertor {1} for reason {2}
-lutinutil.error.i18n.unformated.message=Message can't be formatted\: ''{0}'' with arguments {1}
-lutinutil.error.i18n.unfound.country=could not find country from ''{0}'', use default country ''{1}''
-lutinutil.error.i18n.unfound.language=could not find language from ''{0}'', use default language ''{1}''
-lutinutil.error.i18n.untranslated.message=Message can't be translated\: ''{0}''
-lutinutil.error.unfound.month=could not found month from ''{0}'', use default month ''{1}''
+lutinutil.debug.objectutil.create=Try to create %s with %s
+lutinutil.debug.objectutil.instantiate=Can't instantiate %s with params %s
+lutinutil.debug.objectutil.invoke=Invoke %s with %s
+lutinutil.error.applicationconfig.save=Can't save config in file %s
+lutinutil.error.convertor.noValue=No value specified for converter %s
+lutinutil.error.i18n.unformated.message=Message can't be formatted\: '%s' with arguments %s
+lutinutil.error.i18n.unfound.country=could not find country from '%s', use default country '%s'
+lutinutil.error.i18n.unfound.language=could not find language from '%s', use default language '%s'
+lutinutil.error.i18n.untranslated.message=Message can't be translated\: '%s'
+lutinutil.error.no.convertor=no convertor found for type %2$s and objet '%1$s'
+lutinutil.error.unfound.month=could not found month from '%s', use default month '%s'
+lutinutil.error.url.convertor=a problem occurs while converting value '%s' with url convertor %s for reason %s
lutinutil.fileCompletion.cancel=.. to cancel or return to parent directory
lutinutil.fileCompletion.enter=Enter to display file list, or to complete path
lutinutil.fileCompletion.exit=Enter "\!q" to exit
Modified: lutinutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties
===================================================================
--- lutinutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties 2008-11-20 14:02:51 UTC (rev 1242)
+++ lutinutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties 2008-11-20 14:03:08 UTC (rev 1243)
@@ -1,16 +1,16 @@
-Can't\ instantiate\ %s\ with\ params\ %s=
-Can't\ save\ config\ in\ file\ %s=
-Invoke\ %s\ with\ %s=
-Try\ to\ create\ %s\ with\ %s=
-hello\ you\ \!=Salut toi\!
-lutin.error.convertor.noValue=Aucune valeur \u00E0 convertir pour le convertisseur {0}
-lutin.error.no.convertor=Aucun convertisseur trouv\u00E9 pour le type {1} et l''objet ''{0}''
-lutin.error.url.convertor=un probl\u00E8me est apparu lors de la convertion en url de ''{0}}'' avec le convertisseur {1} pour la raison suivante \: {2}
-lutinutil.error.i18n.unformated.message=Le message suivant n''a pas pu \u00EAtre format\u00E9 \: ''{0}'' avec les arguments {1}
-lutinutil.error.i18n.unfound.country=n''a pas pu trouver le pays \u00E0 partir de ''{0}'', utilise le pays par d\u00E9faut ''{1}''
-lutinutil.error.i18n.unfound.language=n''a pas pu trouver la langue \u00E0 partir de ''{0}'', utilise la langue par d\u00E9faut ''{1}''
-lutinutil.error.i18n.untranslated.message=Le message suivant n''a pas pu \u00EAtre traduit \: ''{0}''
-lutinutil.error.unfound.month=n''a pas pu trouv\u00E9 le mois \u00E0 partir de ''{0}'', utilise le mois par d\u00E9faut ''{1}''
+hello\ you\ \!=
+lutinutil.debug.objectutil.create=Essaye de cr\u00E9er %s avec %s
+lutinutil.debug.objectutil.instantiate=Ne peut pas instancier %s avec les param\u00EAtres %s
+lutinutil.debug.objectutil.invoke=Invocation de %s avec %s
+lutinutil.error.applicationconfig.save=Impossible de sauvegarder le fichier de configuration dans %s
+lutinutil.error.convertor.noValue=Aucune valeur \u00E0 convertir pour le convertisseur %s
+lutinutil.error.i18n.unformated.message=Le message suivant n''a pas pu \u00EAtre format\u00E9 \: '%s' avec les arguments %s
+lutinutil.error.i18n.unfound.country=n'a pas pu trouver le pays \u00E0 partir de '%s', utilise le pays par d\u00E9faut '%s'
+lutinutil.error.i18n.unfound.language=n'a pas pu trouver la langue \u00E0 partir de '%s', utilise la langue par d\u00E9faut '%s'
+lutinutil.error.i18n.untranslated.message=Le message suivant n'a pas pu \u00EAtre traduit \: '%s'
+lutinutil.error.no.convertor=Aucun convertisseur trouv\u00E9 pour le type %2$s et l''objet '%1$s'
+lutinutil.error.unfound.month=n'a pas pu trouv\u00E9 le mois \u00E0 partir de '%s', utilise le mois par d\u00E9faut '%s'
+lutinutil.error.url.convertor=Un probl\u00E8me est apparu lors de la convertion en url de '%s' avec le convertisseur %s pour la raison suivante \: %s
lutinutil.fileCompletion.cancel=.. pour annuler ou pour revenir au repertoire pr\u00E9c\u00E9dent
lutinutil.fileCompletion.enter=Entrer pour afficher la liste des fichiers, ou pour compl\u00E9ter le chemin
lutinutil.fileCompletion.exit=Saisir "\!q" pour quitter
@@ -23,7 +23,7 @@
lutinutil.month.july=juillet
lutinutil.month.june=juin
lutinutil.month.march=mars
-lutinutil.month.may=mars
+lutinutil.month.may=mai
lutinutil.month.november=novembre
lutinutil.month.october=octobre
lutinutil.month.september=septembre
1
0