r1774 - in trunk: . src/it/add-third-party/no-deps src/it/add-third-party/with-deps src/main/java/org/nuiton/license/plugin
Author: tchemit Date: 2010-06-20 23:22:09 +0200 (Sun, 20 Jun 2010) New Revision: 1774 Url: http://nuiton.org/repositories/revision/maven-license-plugin/1774 Log: Evolution #693: Improve Third-party generation (add a fallback file to push unknown license for dependencies) Evolution #694: Add a failIfWarning propeprty in add-third-party mojo Simplify its Modified: trunk/pom.xml trunk/src/it/add-third-party/no-deps/invoker.properties trunk/src/it/add-third-party/no-deps/verify.groovy trunk/src/it/add-third-party/with-deps/invoker.properties trunk/src/it/add-third-party/with-deps/verify.groovy trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/pom.xml 2010-06-20 21:22:09 UTC (rev 1774) @@ -412,7 +412,11 @@ <artifactId>maven-invoker-plugin</artifactId> <configuration> <pomIncludes> - <pomInclude>**/pom.xml</pomInclude> + <pomInclude>add-third-party/no-deps/pom.xml</pomInclude> + <pomInclude>add-third-party/with-deps/pom.xml</pomInclude> + <pomInclude>update-file-header/pom.xml</pomInclude> + <pomInclude>update-project-license/pom.xml</pomInclude> + <!--<pomInclude>**/pom.xml</pomInclude>--> </pomIncludes> <postBuildHookScript>verify</postBuildHookScript> <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath> Modified: trunk/src/it/add-third-party/no-deps/invoker.properties =================================================================== --- trunk/src/it/add-third-party/no-deps/invoker.properties 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/src/it/add-third-party/no-deps/invoker.properties 2010-06-20 21:22:09 UTC (rev 1774) @@ -1,6 +1,6 @@ # A comma or space separated list of goals/phases to execute, may # specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile +invoker.goals=clean generate-resources # Optionally, a list of goals to run during further invocations of Maven #invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run Modified: trunk/src/it/add-third-party/no-deps/verify.groovy =================================================================== --- trunk/src/it/add-third-party/no-deps/verify.groovy 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/src/it/add-third-party/no-deps/verify.groovy 2010-06-20 21:22:09 UTC (rev 1774) @@ -9,16 +9,4 @@ content = file.text; assert content.contains( 'the project has no dependencies.' ); -file = new File(basedir, 'target/classes/THIRD-PARTY.txt'); -assert file.exists(); - -content = file.text; -assert content.contains( 'the project has no dependencies.' ); - -file = new File(basedir, 'target/classes/META-INF/test-add-third-party-THIRD-PARTY.txt'); -assert file.exists(); - -content = file.text; -assert content.contains( 'the project has no dependencies.' ); - return true; Modified: trunk/src/it/add-third-party/with-deps/invoker.properties =================================================================== --- trunk/src/it/add-third-party/with-deps/invoker.properties 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/src/it/add-third-party/with-deps/invoker.properties 2010-06-20 21:22:09 UTC (rev 1774) @@ -1,6 +1,6 @@ # A comma or space separated list of goals/phases to execute, may # specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile +invoker.goals=clean generate-resources # Optionally, a list of goals to run during further invocations of Maven #invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run Modified: trunk/src/it/add-third-party/with-deps/verify.groovy =================================================================== --- trunk/src/it/add-third-party/with-deps/verify.groovy 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/src/it/add-third-party/with-deps/verify.groovy 2010-06-20 21:22:09 UTC (rev 1774) @@ -9,14 +9,4 @@ content = file.text; assert !content.contains( 'the project has no dependencies.' ); -file = new File(basedir, 'target/classes/third.txt'); -assert file.exists(); -content = file.text; -assert !content.contains( 'the project has no dependencies.' ); - -file = new File(basedir, 'target/classes/test/third.txt'); -assert file.exists(); -content = file.text; -assert !content.contains( 'the project has no dependencies.' ); - return true; Modified: trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java 2010-06-19 18:56:11 UTC (rev 1773) +++ trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java 2010-06-20 21:22:09 UTC (rev 1774) @@ -25,24 +25,31 @@ package org.nuiton.license.plugin; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; 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.MojoFailureException; +import org.apache.maven.plugin.logging.Log; 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.nuiton.io.SortedProperties; import org.nuiton.plugin.PluginHelper; import java.io.File; -import java.util.*; +import java.io.FileWriter; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; /** * Le goal pour copier le fichier THIRD-PARTY.txt (contenant les licenses de @@ -80,6 +87,25 @@ protected String thirdPartyFilename; /** + * The path of the bundled third party file to produce when + * {@link #generateBundle} is on. + * <p/> + * <b>Note:</b> This option is not available for {@code pom} module types. + * + * @parameter expression="${license.bundleThirdPartyPath}" default-value="META-INF/${project.artifactId}-THIRD-PARTY.txt" + * @since 2.2 + */ + protected String bundleThirdPartyPath; + + /** + * The file where to fill the license for dependencies with unknwon license. + * + * @parameter expression="${license.missingFile}" default-value="src/license/THIRD-PARTY.properties" + * @since 1.0.0 + */ + protected File missingFile; + + /** * Un flag pour faire une copie nommé dans META-INF (prefixe avec le nom de * l'artifact). * @@ -89,15 +115,12 @@ protected boolean generateBundle; /** - * The path of the bundled third party file to produce when - * {@link #generateBundle} is on. - * <p/> - * <b>Note:</b> This option is not available for {@code pom} module types. + * A flag to generate or update the missing licenses file. * - * @parameter expression="${license.bundleThirdPartyPath}" default-value="META-INF/${project.artifactId}-THIRD-PARTY.txt" - * @since 2.2 + * @parameter expression="${license.generateMissing}" default-value="true" + * @since 1.0.0 */ - protected String bundleThirdPartyPath; + protected boolean generateMissing; /** * Un flag pour forcer la generation. @@ -108,6 +131,14 @@ protected boolean force; /** + * A flag to fail the build if there is some unknown license for some dependencies. + * + * @parameter expression="${license.failIfWarning}" default-value="false" + * @since 1.0.0 + */ + protected boolean failIfWarning; + + /** * Un flag pour conserver un backup des fichiers modifies. * * @parameter expression="${license.keepBackup}" default-value="false" @@ -142,44 +173,67 @@ */ protected DependencyTreeBuilder dependencyTreeBuilder; - /** - * Artifact Factory component. - * - * @component - */ - protected ArtifactFactory factory; +// /** +// * Artifact Factory component. +// * +// * @component +// */ +// protected ArtifactFactory factory; /** * Artifact metadata source component. * * @component + * @required + * @readonly + * @since 1.0.0 */ protected ArtifactMetadataSource artifactMetadataSource; - /** - * Artifact collector component. - * - * @component - */ - protected ArtifactCollector collector; +// /** +// * Artifact collector component. +// * +// * @component +// * @required +// * @readonly +// * @since 1.0.0 +// */ +// protected ArtifactCollector collector; /** * Maven Project Builder component. * * @component + * @required + * @readonly + * @since 1.0.0 */ protected MavenProjectBuilder mavenProjectBuilder; - /** - * content of third party file (only computed if {@link #force} is active or - * the {@link #thirdPartyFile} does not exist, or is not up-to-date. - */ - protected String thirdPartyFileContent; - protected File thirdPartyFile; + private File thirdPartyFile; - boolean doGenerate; + private LicenseMap licenseMap; + private SortedSet<MavenProject> unsafeDependencies; + + private SortedProperties unsafeMappings; + + private boolean doGenerate; + + private boolean doGenerateBundle; + + private boolean doGenerateMissing; + + private static SortedMap<String, MavenProject> artifactCache; + + public static SortedMap<String, MavenProject> getArtifactCache() { + if (artifactCache == null) { + artifactCache = new TreeMap<String, MavenProject>(); + } + return artifactCache; + } + public static final String NO_DEPENDENCIES_MESSAGE = "the project has no dependencies."; @Override @@ -189,219 +243,356 @@ @Override protected void init() throws Exception { - if (getLog().isDebugEnabled()) { + Log log = getLog(); + if (log.isDebugEnabled()) { // always be verbose in debug mode setVerbose(true); } + licenseMap = new LicenseMap(); + File file = new File(getOutputDirectory(), getThirdPartyFilename()); setThirdPartyFile(file); setDoGenerate(isForce() || !file.exists() || !isFileNewerThanPomFile(file)); - String content; - if (isDoGenerate()) { + if (isGenerateBundle()) { - if (isVerbose()) { - getLog().info("will generate third-party content..."); + File bundleFile = + PluginHelper.getFile(getOutputDirectory(), getBundleThirdPartyPath()); + + setDoGenerateBundle(isForce() || + !bundleFile.exists() || + !isFileNewerThanPomFile(bundleFile) || + file.lastModified() > bundleFile.lastModified()); + } else { + + // not generating bundled file + setDoGenerateBundle(false); + } + + if (!isDoGenerate() && !isDoGenerateBundle()) { + + // nothing to do + return; + } + + // build the license map for the dependencies of the project + + for (Object o : getProject().getArtifacts()) { + + Artifact artifact = (Artifact) o; + + String id = getArtifactId(artifact); + + MavenProject project = addArtifact(id, artifact); + + addLicense(project, project.getLicenses()); + } + + // get unsafe dependencies (says with no license) + unsafeDependencies = licenseMap.get(getUnknownLicenseMessage()); + + if (CollectionUtils.isEmpty(unsafeDependencies)) { + + // no unsafe dependencies, so no need to generate missing file + setDoGenerateMissing(false); + return; + } + + if (log.isDebugEnabled()) { + log.debug("There is " + unsafeDependencies.size() + " dependencies with no license from poms : "); + for (MavenProject dep : unsafeDependencies) { + + // no license found for the dependency + log.debug(" - " + getArtifactId(dep.getArtifact())); } + } - // build thirdPartyFileContent - content = buildThirdPartyFilecontent(); + if (!isGenerateMissing()) { - } else { - // read it from existing third party file - content = PluginHelper.readAsString(getThirdPartyFile(), getEncoding()); + // user does not ask to generate missing file + // so no more thing to do + return; } - setThirdPartyFileContent(content); + unsafeMappings = new SortedProperties(getEncoding()); + + // there is some unsafe dependencies + if (missingFile.exists()) { + + // load the missing file + unsafeMappings.load(missingFile); + } + + // push back loaded dependencies + for (Object o : unsafeMappings.keySet()) { + String id = (String) o; + + MavenProject project = getArtifactCache().get(id); + if (project == null) { + log.warn("dependency [" + id + "] does not exists in project."); + continue; + } + + String license = (String) unsafeMappings.get(id); + if (StringUtils.isEmpty(license)) { + + // empty license means not fill, skip it + continue; + } + + // add license in map + License l = new License(); + l.setName(license.trim()); + l.setUrl(license.trim()); + + // add license + addLicense(project, Arrays.asList(l)); + + // remove unknown license + unsafeDependencies.remove(project); + } + + if (unsafeDependencies.isEmpty()) { + + // no unsafe dependencies, so no need to generate missing file + setDoGenerateMissing(false); + + // no more unknown license in map + licenseMap.remove(getUnknownLicenseMessage()); + return; + } + + // mark to regenerate the file (if anything has changed) + setDoGenerateMissing(true); + + for (MavenProject project : unsafeDependencies) { + String id = getArtifactId(project.getArtifact()); + unsafeMappings.setProperty(id, ""); + } } @Override + protected boolean checkSkip() { + if (!isDoGenerate() && + !isDoGenerateBundle() && + !isDoGenerateMissing()) { + + getLog().info("All files are up to date, skip goal execution."); + return false; + } + return super.checkSkip(); + } + + @Override protected void doAction() throws Exception { + Log log = getLog(); + File target = getThirdPartyFile(); + File output = getOutputDirectory(); + + boolean unsafe = !CollectionUtils.isEmpty(unsafeDependencies); + if (unsafe) { + + log.warn("There is " + unsafeDependencies.size() + " dependencies with no license :"); + for (MavenProject dep : unsafeDependencies) { + + // no license found for the dependency + log.warn(" - " + getArtifactId(dep.getArtifact())); + } + } if (isDoGenerate()) { + + // build thirdPartyFileContent + String content = buildThirdPartyFilecontent(); + if (isVerbose()) { - getLog().info("writing third-party file : " + target); + log.info("writing third-party file : " + target + "\n" + content); } + if (isKeepBackup() && target.exists()) { if (isVerbose()) { - getLog().info("backup " + target); + log.info("backup " + target); } backupFile(target); } - writeFile(target, getThirdPartyFileContent(), getEncoding()); + writeFile(target, content, getEncoding()); } - File output = getOutputDirectory(); - if (isGenerateBundle()) { + if (isDoGenerateBundle()) { + // creates the bundled license file File bundleTarget = PluginHelper.getFile(output, getBundleThirdPartyPath()); copyFile(target, bundleTarget); } + + if (isDoGenerateMissing()) { + + File file = getMissingFile(); + createDirectoryIfNecessary(file.getParentFile()); + if (isVerbose()) { + log.info("regenerate missing license file " + file); + } + FileWriter writer = new FileWriter(file); + try { + StringBuilder sb = new StringBuilder(" Generated by " + getClass().getName()); + Set<String> licenses = licenseMap.keySet(); + if (!licenses.isEmpty()) { + sb.append("\n-------------------------------------------------------------------------------"); + sb.append("\n Already used licenses in project :"); + for (String license : licenses) { + if (getUnknownLicenseMessage().equals(license)) { + continue; + } + sb.append("\n - ").append(license); + } + } + sb.append("\n-------------------------------------------------------------------------------"); + sb.append("\n Please fill the missing licenses for dependencies :\n\n"); + unsafeMappings.store(writer, sb.toString()); + } finally { + writer.close(); + } + } + + if (unsafe && isFailIfWarning()) { + throw new MojoFailureException("There is some dependencies with no license, please fill the file " + getMissingFile()); + } + addResourceDir(output, "**/*.txt"); } - protected String buildThirdPartyFilecontent() throws DependencyTreeBuilderException { - DependencyNode dependencyTreeNode; - ArtifactFilter artifactFilter = - new ScopeArtifactFilter(Artifact.SCOPE_TEST); - dependencyTreeNode = dependencyTreeBuilder.buildDependencyTree( - getProject(), - localRepository, - factory, - artifactMetadataSource, - artifactFilter, - collector - ); - LicenseMap licenseMap = new LicenseMap(); + protected void addLicense(MavenProject project, + List<?> licenses) throws ProjectBuildingException { - for (Object o : dependencyTreeNode.getChildren()) { + if (Artifact.SCOPE_SYSTEM.equals(project.getArtifact().getScope())) { - buildLicenseMap((DependencyNode) o, licenseMap); + // do NOT treate system dependency + return; } - // log dependencies with no license - Set<String> unsafeDependencies = - licenseMap.get(getUnknownLicenseMessage()); + if (CollectionUtils.isEmpty(licenses)) { - if (unsafeDependencies != null) { - for (String dep : unsafeDependencies) { - // no license found for the dependency - getLog().warn("no license found for dependency " + dep); - } + // no license found for the dependency + licenseMap.put(getUnknownLicenseMessage(), project); + return; } - StringBuilder sb = new StringBuilder(); - if (licenseMap.isEmpty()) { - sb.append(NO_DEPENDENCIES_MESSAGE); - } else { - 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); - } + for (Object o : licenses) { + if (o == null) { + getLog().warn("could not acquire the license for " + getArtifactId(project.getArtifact())); + continue; } + License license = (License) o; + String licenseKey = license.getName(); + if (license.getName() == null) { + licenseKey = license.getUrl(); + } + licenseMap.put(licenseKey, project); } - String content = sb.toString(); - if (getLog().isDebugEnabled()) { - getLog().debug("third-party file content :\n" + content); - } - return content; } - protected void buildLicenseMap(DependencyNode node, LicenseMap licenseMap) { - if (node.getState() != DependencyNode.INCLUDED) { - // this dependency is not included, so do not treate it + protected MavenProject addArtifact(String id, + Artifact artifact) throws ProjectBuildingException { + + MavenProject project; + + Log log = getLog(); + if (getArtifactCache().containsKey(id)) { + project = getArtifactCache().get(id); if (isVerbose()) { - getLog().info("do not include this dependency " + - node.toNodeString()); + log.info("add dependency [" + id + "] (from cache)"); } - return; + return project; } - Artifact artifact = node.getArtifact(); +// boolean allowStubModel = false; - if (isVerbose() && getLog().isDebugEnabled()) { - getLog().debug("treate node " + node.toNodeString()); +// if (!"pom".equals(artifact.getType())) { +// artifact = factory.createProjectArtifact( +// artifact.getGroupId(), +// artifact.getArtifactId(), +// artifact.getVersion(), +// artifact.getScope() +// ); +// allowStubModel = true; +// } + + project = mavenProjectBuilder.buildFromRepository( + artifact, + remoteRepositories, + localRepository, + false + ); + if (isVerbose()) { + log.info("add dependency [" + id + "]"); } + getArtifactCache().put(id, project); + return project; + } - 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(getUnknownLicenseMessage(), 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); - } + protected String getArtifactId(Artifact artifact) { + StringBuilder sb = new StringBuilder(); + sb.append(artifact.getGroupId()); + sb.append("--"); + sb.append(artifact.getArtifactId()); + sb.append("--"); + sb.append(artifact.getVersion()); + if (!StringUtils.isEmpty(artifact.getClassifier())) { + sb.append("--"); + sb.append(artifact.getClassifier()); } - if (!node.getChildren().isEmpty()) { - for (Object o : node.getChildren()) { - buildLicenseMap((DependencyNode) o, licenseMap); - } - } + return sb.toString(); } - protected String getArtifactName(MavenProject artifactProject) { + protected String getArtifactName(MavenProject project) { StringBuilder sb = new StringBuilder(); - - sb.append(artifactProject.getName()); + sb.append(project.getName()); sb.append(" ("); - sb.append(artifactProject.getGroupId()); + sb.append(project.getGroupId()); sb.append(":"); - sb.append(artifactProject.getArtifactId()); + sb.append(project.getArtifactId()); sb.append(":"); - sb.append(artifactProject.getVersion()); + sb.append(project.getVersion()); sb.append(" - "); - String url = artifactProject.getUrl(); + String url = project.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 { + protected String buildThirdPartyFilecontent() { + StringBuilder sb = new StringBuilder(); + if (licenseMap.isEmpty()) { + sb.append(NO_DEPENDENCIES_MESSAGE); + } else { + sb.append("List of third-party dependencies grouped by " + + "their license type."); + for (String licenseName : licenseMap.keySet()) { + SortedSet<MavenProject> projects = licenseMap.get(licenseName); + sb.append("\n\n").append(licenseName).append(" : "); - boolean allowStubModel = false; - if (!"pom".equals(artifact.getType())) { - artifact = factory.createProjectArtifact( - artifact.getGroupId(), - artifact.getArtifactId(), - artifact.getVersion(), - artifact.getScope() - ); - allowStubModel = true; + for (MavenProject mavenProject : projects) { + String s = getArtifactName(mavenProject); + sb.append("\n * ").append(s); + } + } } - - // TODO: we should use the MavenMetadataSource instead - return mavenProjectBuilder.buildFromRepository( - artifact, - remoteRepositories, - localRepository, - allowStubModel - ); + String content = sb.toString(); + if (getLog().isDebugEnabled()) { + getLog().debug("third-party file content :\n" + content); + } + return content; } + public static String getUnknownLicenseMessage() { return unknownLicenseMessage; } @@ -434,14 +625,23 @@ return bundleThirdPartyPath; } + public File getThirdPartyFile() { return thirdPartyFile; } - public String getThirdPartyFileContent() { - return thirdPartyFileContent; + public File getMissingFile() { + return missingFile; } + public boolean isGenerateMissing() { + return generateMissing; + } + + public boolean isFailIfWarning() { + return failIfWarning; + } + public void setThirdPartyFilename(String thirdPartyFilename) { this.thirdPartyFilename = thirdPartyFilename; } @@ -466,10 +666,6 @@ this.bundleThirdPartyPath = bundleThirdPartyPath; } - public void setThirdPartyFileContent(String thirdPartyFileContent) { - this.thirdPartyFileContent = thirdPartyFileContent; - } - public void setDoGenerate(boolean doGenerate) { this.doGenerate = doGenerate; } @@ -478,15 +674,51 @@ this.thirdPartyFile = thirdPartyFile; } - protected class LicenseMap extends TreeMap<String, SortedSet<String>> { + public void setMissingFile(File missingFile) { + this.missingFile = missingFile; + } + public void setGenerateMissing(boolean generateMissing) { + this.generateMissing = generateMissing; + } + + public void setFailIfWarning(boolean failIfWarning) { + this.failIfWarning = failIfWarning; + } + + public boolean isDoGenerateBundle() { + return doGenerateBundle; + } + + public void setDoGenerateBundle(boolean doGenerateBundle) { + this.doGenerateBundle = doGenerateBundle; + } + + public boolean isDoGenerateMissing() { + return doGenerateMissing; + } + + public void setDoGenerateMissing(boolean doGenerateMissing) { + this.doGenerateMissing = doGenerateMissing; + } + + protected class LicenseMap extends TreeMap<String, SortedSet<MavenProject>> { + private static final long serialVersionUID = 864199843545688069L; - public SortedSet<String> put(String key, String value) { + public SortedSet<MavenProject> put(String key, MavenProject value) { // handle multiple values as a set to avoid duplicates - SortedSet<String> valueList = get(key); + SortedSet<MavenProject> valueList = get(key); if (valueList == null) { - valueList = new TreeSet<String>(); + valueList = new TreeSet<MavenProject>(new Comparator<MavenProject>() { + @Override + public int compare(MavenProject o1, MavenProject o2) { + + String id1 = getArtifactId(o1.getArtifact()); + String id2 = getArtifactId(o2.getArtifact()); + return id1.compareTo(id2); + } + }); } if (getLog().isDebugEnabled()) { getLog().debug("key:" + key + ",value: " + value);
participants (1)
-
tchemit@users.nuiton.org