diff --git a/pom.xml b/pom.xml index 52b9531d5..435ad4f28 100644 --- a/pom.xml +++ b/pom.xml @@ -365,6 +365,11 @@ org.apache.maven.plugins maven-invoker-plugin 3.0.0 + + + ${project.version} + + diff --git a/src/it/ISSUE-145/invoker.properties b/src/it/ISSUE-145/invoker.properties new file mode 100644 index 000000000..d1250ecb1 --- /dev/null +++ b/src/it/ISSUE-145/invoker.properties @@ -0,0 +1,23 @@ +### +# #%L +# License Maven Plugin +# %% +# Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit +# %% +# 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 +# . +# #L% +### +invoker.goals=clean package +invoker.failureBehavior=fail-fast \ No newline at end of file diff --git a/src/it/ISSUE-145/pom.xml b/src/it/ISSUE-145/pom.xml new file mode 100644 index 000000000..6acd1dda4 --- /dev/null +++ b/src/it/ISSUE-145/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.0.4.RELEASE + + + org.codehaus.mojo.license.test + test-ISSUE-145 + @pom.version@ + License Test :: ISSUE-145 + pom + + + + The GNU Lesser General Public License, Version 3.0 + http://www.gnu.org/licenses/lgpl-3.0.txt + repo + + + + + UTF-8 + true + true + ${project.build.directory}/licenses.xml + + + + submodule1 + submodule2 + + + + + + org.codehaus.mojo + license-maven-plugin + + + + + + + org.codehaus.mojo + license-maven-plugin + @pom.version@ + + + aggregate-add-third-party + + aggregate-add-third-party + + + + + + + + + diff --git a/src/it/ISSUE-145/postbuild.groovy b/src/it/ISSUE-145/postbuild.groovy new file mode 100644 index 000000000..5fc05b6ba --- /dev/null +++ b/src/it/ISSUE-145/postbuild.groovy @@ -0,0 +1,27 @@ +/* + * #%L + * License Maven Plugin + * %% + * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit + * %% + * 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 + * . + * #L% + */ +import java.util.jar.JarFile + +file = new JarFile(new File(basedir, 'submodule1/target/test-ISSUE-145-submodule1-' + projectVersion + '.jar')); +expectedLibPath = 'BOOT-INF/lib/test-ISSUE-145-submodule2-' + projectVersion + '.jar'; +assert file.getJarEntry(expectedLibPath) != null; +return true; \ No newline at end of file diff --git a/src/it/ISSUE-145/submodule1/pom.xml b/src/it/ISSUE-145/submodule1/pom.xml new file mode 100644 index 000000000..4d2f0b369 --- /dev/null +++ b/src/it/ISSUE-145/submodule1/pom.xml @@ -0,0 +1,46 @@ + + + + org.codehaus.mojo.license.test + test-ISSUE-145 + @pom.version@ + + + 4.0.0 + jar + + test-ISSUE-145-submodule1 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.codehaus.mojo.license.test + test-ISSUE-145-submodule2 + @pom.version@ + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + src/main/resources + true + + + + + \ No newline at end of file diff --git a/src/it/ISSUE-145/submodule1/src/main/java/de/jotb/playground/Application.java b/src/it/ISSUE-145/submodule1/src/main/java/de/jotb/playground/Application.java new file mode 100644 index 000000000..ae51ba88b --- /dev/null +++ b/src/it/ISSUE-145/submodule1/src/main/java/de/jotb/playground/Application.java @@ -0,0 +1,12 @@ +package de.jotb.playground; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/src/it/ISSUE-145/submodule2/pom.xml b/src/it/ISSUE-145/submodule2/pom.xml new file mode 100644 index 000000000..1cc422ba9 --- /dev/null +++ b/src/it/ISSUE-145/submodule2/pom.xml @@ -0,0 +1,13 @@ + + + + org.codehaus.mojo.license.test + test-ISSUE-145 + @pom.version@ + + 4.0.0 + + test-ISSUE-145-submodule2 + \ No newline at end of file diff --git a/src/it/ISSUE-145/submodule2/src/index.html b/src/it/ISSUE-145/submodule2/src/index.html new file mode 100644 index 000000000..8ec009156 --- /dev/null +++ b/src/it/ISSUE-145/submodule2/src/index.html @@ -0,0 +1,27 @@ + + + + + Text-Service + + + + + + + + + + + + This page requires JavaScript to work properly. Please enable JavaScript in your browser. + + + + + diff --git a/src/it/ISSUE-80/pom.xml b/src/it/ISSUE-80/pom.xml index 87f322196..4d8c406b7 100644 --- a/src/it/ISSUE-80/pom.xml +++ b/src/it/ISSUE-80/pom.xml @@ -31,7 +31,7 @@ test-ISSUE-59 @pom.version@ - License Test :: ISSUE-59 + License Test :: ISSUE-80 jar diff --git a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java index cf61086d5..527d8fcbc 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java @@ -39,6 +39,8 @@ import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.license.api.LoadedProjectDependencies; /* * #%L @@ -559,6 +561,12 @@ public abstract class AbstractAddThirdPartyMojo * @since 1.4 */ private Map globalKnownLicenses; + + boolean isAggregatorBuild; + + Map> reactorProjectDependencies; + + LoadedProjectDependencies dependencyArtifacts; // ---------------------------------------------------------------------- // Abstract Methods @@ -634,6 +642,12 @@ protected void init() // not generating bundled file doGenerateBundle = false; } + + if (isAggregatorBuild) { + dependencyArtifacts = dependenciesTool.loadProjectArtifacts( localRepository, remoteRepositories, project, reactorProjectDependencies ); + } else { + dependencyArtifacts = new LoadedProjectDependencies(project.getArtifacts(), project.getDependencyArtifacts()); + } projectDependencies = loadDependencies(); diff --git a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java index b4c533f42..70be2224e 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; +import org.codehaus.mojo.license.api.LoadedProjectDependencies; /** * Created on 23/05/16. @@ -263,7 +264,9 @@ protected MavenProject getProject() protected SortedMap getDependencies( MavenProject project ) { - return dependenciesTool.loadProjectDependencies( project, this, localRepository, remoteRepositories, null ); + return dependenciesTool.loadProjectDependencies( + new LoadedProjectDependencies(project.getArtifacts(), project.getDependencyArtifacts()), + this, localRepository, remoteRepositories, null ); } /** diff --git a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java index 1e24c7313..530462426 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java @@ -60,6 +60,8 @@ import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeSet; +import org.apache.maven.artifact.Artifact; +import org.codehaus.mojo.license.api.LoadedProjectDependencies; /** * Base class for third-party reports. @@ -516,16 +518,19 @@ Collection createThirdPartyDetails( MavenProject project, boo DependenciesToolException, MojoExecutionException { - if ( loadArtifacts ) - { - dependenciesTool.loadProjectArtifacts( localRepository, project.getRemoteArtifactRepositories(), project , null); + LoadedProjectDependencies loadedDependencies; + if ( loadArtifacts ) { + loadedDependencies = dependenciesTool.loadProjectArtifacts( localRepository, licenseMerges, project, null ); } - + else { + loadedDependencies = new LoadedProjectDependencies(getProject().getArtifacts(), getProject().getDependencyArtifacts()); + } + ThirdPartyHelper thirdPartyHelper = new DefaultThirdPartyHelper( project, encoding, verbose, dependenciesTool, thirdPartyTool, localRepository, project.getRemoteArtifactRepositories(), getLog() ); // load dependencies of the project - SortedMap projectDependencies = thirdPartyHelper.loadDependencies( this ); + SortedMap projectDependencies = thirdPartyHelper.loadDependencies( this, loadedDependencies ); // create licenseMap from it LicenseMap licenseMap = thirdPartyHelper.createLicenseMap( projectDependencies ); @@ -547,7 +552,7 @@ Collection createThirdPartyDetails( MavenProject project, boo { // Resolve unsafe dependencies using missing files, this will update licenseMap and unsafeDependencies thirdPartyHelper.createUnsafeMapping( licenseMap, missingFile, missingFileUrl, useRepositoryMissingFiles, - dependenciesWithNoLicense, projectDependencies ); + dependenciesWithNoLicense, projectDependencies, loadedDependencies.getAllDependencies() ); } } diff --git a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java index 35e4cb1cb..6d750a0ad 100644 --- a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import org.apache.commons.collections.CollectionUtils; @@ -21,6 +22,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; +import org.codehaus.mojo.license.api.LoadedProjectDependencies; import org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator; import org.codehaus.mojo.license.api.ThirdPartyToolException; import org.codehaus.mojo.license.model.LicenseMap; @@ -192,7 +194,7 @@ protected void doAction() @Override protected SortedMap loadDependencies() { - return getHelper().loadDependencies( this ); + return getHelper().loadDependencies( this, dependencyArtifacts ); } /** @@ -202,13 +204,13 @@ protected SortedMap loadDependencies() protected SortedProperties createUnsafeMapping() throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException { - + SortedSet unsafeDependencies = getUnsafeDependencies(); SortedProperties unsafeMappings = getHelper().createUnsafeMapping( getLicenseMap(), getMissingFile(), missingFileUrl, useRepositoryMissingFiles, unsafeDependencies, - getProjectDependencies() ); + getProjectDependencies(), dependencyArtifacts.getAllDependencies() ); if ( isVerbose() ) { getLog().info( "found " + unsafeMappings.size() + " unsafe mappings" ); @@ -443,7 +445,7 @@ void initFromMojo(AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, M missingLicensesFileArtifact = mojo.missingLicensesFileArtifact; localRepository = mojo.localRepository; remoteRepositories = mojo.remoteRepositories; - dependencies = new HashSet(mavenProject.getDependencies()); + dependencies = new HashSet<>(mavenProject.getDependencies()); licenseMerges = mojo.licenseMerges; licenseMergesFile = mojo.licenseMergesFile; includedLicenses = mojo.includedLicenses; @@ -462,8 +464,9 @@ void initFromMojo(AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, M setLog(mojo.getLog()); - dependenciesTool.loadProjectArtifacts( localRepository, project.getRemoteArtifactRepositories(), project ,reactorProjects); - + isAggregatorBuild = true; + reactorProjectDependencies = reactorProjects; + init(); consolidate(); diff --git a/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java index f08708015..41760e04c 100644 --- a/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java @@ -4,16 +4,15 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -21,6 +20,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; +import org.codehaus.mojo.license.api.LoadedProjectDependencies; import org.codehaus.mojo.license.model.LicenseMap; import org.codehaus.mojo.license.utils.SortedProperties; @@ -157,6 +157,11 @@ protected void init() throws Exception { missingLicensesFileArtifact = aggregateMissingLicensesFileArtifact; } + isAggregatorBuild = true; + reactorProjectDependencies = new TreeMap<>(); + for (MavenProject reactorProject : this.reactorProjects) { + reactorProjectDependencies.put(String.format("%s:%s", reactorProject.getGroupId(), reactorProject.getArtifactId()), reactorProject.getDependencies()); + } super.init(); } @@ -198,21 +203,16 @@ protected void doAction() } String addThirdPartyRoleHint = groupId + ":" + artifactId + ":" + version + ":" + "add-third-party"; - Map> reactorProjectDependencies = new TreeMap<>(); - for (MavenProject reactorProject : this.reactorProjects) { - reactorProjectDependencies.put(String.format("%s:%s", reactorProject.getGroupId(), reactorProject.getArtifactId()), reactorProject.getDependencies()); - } - for (Object reactorProject : reactorProjects) { + for (MavenProject reactorProject : reactorProjects) { if (getProject().equals(reactorProject)) { // do not process pom continue; } - AddThirdPartyMojo mojo = (AddThirdPartyMojo) getSession().lookup(AddThirdPartyMojo.ROLE, addThirdPartyRoleHint); - mojo.initFromMojo(this, (MavenProject) reactorProject, reactorProjectDependencies); + mojo.initFromMojo(this, reactorProject, reactorProjectDependencies); LicenseMap childLicenseMap = mojo.getLicenseMap(); if (isVerbose()) { diff --git a/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java b/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java index 618ddbe17..6a1cab6be 100644 --- a/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java +++ b/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java @@ -23,7 +23,9 @@ */ import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -93,7 +95,7 @@ public class DefaultDependenciesTool /** * {@inheritDoc} */ - public SortedMap loadProjectDependencies( MavenProject project, + public SortedMap loadProjectDependencies( LoadedProjectDependencies artifacts, MavenProjectDependenciesConfigurator configuration, ArtifactRepository localRepository, List remoteRepositories, @@ -135,12 +137,12 @@ public SortedMap loadProjectDependencies( MavenProject pro if ( configuration.isIncludeTransitiveDependencies() ) { // All project dependencies - depArtifacts = project.getArtifacts(); + depArtifacts = Collections.unmodifiableSet(artifacts.getAllDependencies()); } else { // Only direct project dependencies - depArtifacts = project.getDependencyArtifacts(); + depArtifacts = Collections.unmodifiableSet(artifacts.getDirectDependencies()); } List includedScopes = configuration.getIncludedScopes(); @@ -306,19 +308,17 @@ public SortedMap loadProjectDependencies( MavenProject pro /** * {@inheritDoc} */ - public void loadProjectArtifacts( ArtifactRepository localRepository, List remoteRepositories, - MavenProject project , Map> reactorProjectDependencies ) + public LoadedProjectDependencies loadProjectArtifacts( ArtifactRepository localRepository, List remoteRepositories, + MavenProject project, Map> reactorProjectDependencies ) throws DependenciesToolException { - + Set projectDependencyArtifacts = Collections.emptySet(); if ( CollectionUtils.isEmpty( project.getDependencyArtifacts() ) ) { - - Set dependenciesArtifacts; try { - List dependencies = new ArrayList(project.getDependencies()); + List dependencies = new ArrayList<>(project.getDependencies()); if (reactorProjectDependencies!=null) { for (Dependency dependency : new ArrayList<>( dependencies )) { @@ -330,7 +330,7 @@ public void loadProjectArtifacts( ArtifactRepository localRepository, List remot } } } - dependenciesArtifacts = + projectDependencyArtifacts = MavenMetadataSource.createArtifacts(artifactFactory, dependencies, null, null, project ); } @@ -338,25 +338,24 @@ public void loadProjectArtifacts( ArtifactRepository localRepository, List remot { throw new DependenciesToolException( e ); } - project.setDependencyArtifacts( dependenciesArtifacts ); - - } - + Artifact artifact = project.getArtifact(); Set reactorArtifacts = new LinkedHashSet<>(); if (reactorProjectDependencies != null) { // let's not include sibling dependencies, since artifact files may not be generated // (aggregate mode without forking mode) - Iterator artifacts = project.getDependencyArtifacts().iterator(); - while (artifacts.hasNext()) { - Artifact artifact1 = (Artifact) artifacts.next(); - String artifactKey = artifact1.getGroupId() + ":" + artifact1.getArtifactId(); + HashSet dependencyArtifacts = new HashSet<>(); + for (Object dependencyArtifact : project.getDependencyArtifacts()) { + Artifact dependencyArtifactAsArtifact = (Artifact) dependencyArtifact; + String artifactKey = dependencyArtifactAsArtifact.getGroupId() + ":" + dependencyArtifactAsArtifact.getArtifactId(); if (reactorProjectDependencies.containsKey(artifactKey)) { - artifacts.remove(); - reactorArtifacts.add(artifact1); + reactorArtifacts.add(dependencyArtifactAsArtifact); + } else { + dependencyArtifacts.add(dependencyArtifactAsArtifact); } } + projectDependencyArtifacts = dependencyArtifacts; } ArtifactResolutionResult result; try @@ -374,8 +373,7 @@ public void loadProjectArtifacts( ArtifactRepository localRepository, List remot } reactorArtifacts.addAll(result.getArtifacts()); - project.setArtifacts( reactorArtifacts ); - + return new LoadedProjectDependencies(reactorArtifacts, projectDependencyArtifacts); } /** diff --git a/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java b/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java index b7f768af7..c41ea6a71 100644 --- a/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java +++ b/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java @@ -148,9 +148,10 @@ public SortedMap getArtifactCache() /** * {@inheritDoc} */ - public SortedMap loadDependencies( MavenProjectDependenciesConfigurator configuration ) + public SortedMap loadDependencies( MavenProjectDependenciesConfigurator configuration, + LoadedProjectDependencies dependencyArtifacts ) { - return dependenciesTool.loadProjectDependencies( project, configuration, localRepository, remoteRepositories, + return dependenciesTool.loadProjectDependencies( dependencyArtifacts, configuration, localRepository, remoteRepositories, getArtifactCache() ); } @@ -218,7 +219,8 @@ public SortedSet getProjectsWithNoLicense( LicenseMap licenseMap ) public SortedProperties createUnsafeMapping( LicenseMap licenseMap, File missingFile, String missingFileUrl, boolean useRepositoryMissingFiles, SortedSet unsafeDependencies, - SortedMap projectDependencies ) + SortedMap projectDependencies, + Set dependencyArtifacts ) throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException { @@ -240,7 +242,7 @@ public SortedProperties createUnsafeMapping( LicenseMap licenseMap, File missing projects.removeAll( unsafeDependencies ); SortedProperties resolvedUnsafeMapping = - loadThirdPartyDescriptorForUnsafeMapping( project.getArtifacts(), unsafeDependencies, projects, + loadThirdPartyDescriptorForUnsafeMapping( dependencyArtifacts, unsafeDependencies, projects, licenseMap ); // push back resolved unsafe mappings (only for project dependencies) diff --git a/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java b/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java index fc803ec4f..8e671aa16 100644 --- a/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java +++ b/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java @@ -45,7 +45,7 @@ public interface DependenciesTool * * Result is given in a map where keys are unique artifact id * - * @param project the project to scann + * @param dependencies the project dependencies * @param configuration the configuration * @param localRepository local repository used to resolv dependencies * @param remoteRepositories remote repositories used to resolv dependencies @@ -53,7 +53,7 @@ public interface DependenciesTool * @return the map of resolved dependencies indexed by their unique id. * @see MavenProjectDependenciesConfigurator */ - SortedMap loadProjectDependencies( MavenProject project, + SortedMap loadProjectDependencies( LoadedProjectDependencies dependencies, MavenProjectDependenciesConfigurator configuration, ArtifactRepository localRepository, List remoteRepositories, @@ -64,10 +64,11 @@ SortedMap loadProjectDependencies( MavenProject project, * * @param localRepository local repository used to resolv dependencies * @param remoteRepositories remote repositories used to resolv dependencies - * @param project the project to scann + * @param project the project to scan * @param reactorProjectDependencies optional reactor projects dependencies indexed by their gav to resolve artifacts without fork mode (means artifacts may not exist) + * @return the loaded project dependency artifacts * @throws DependenciesToolException if could not load project dependencies */ - void loadProjectArtifacts(ArtifactRepository localRepository, List remoteRepositories, MavenProject project , Map> reactorProjectDependencies ) + LoadedProjectDependencies loadProjectArtifacts(ArtifactRepository localRepository, List remoteRepositories, MavenProject project, Map> reactorProjectDependencies ) throws DependenciesToolException; } diff --git a/src/main/java/org/codehaus/mojo/license/api/LoadedProjectDependencies.java b/src/main/java/org/codehaus/mojo/license/api/LoadedProjectDependencies.java new file mode 100644 index 000000000..a4b30abb6 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/license/api/LoadedProjectDependencies.java @@ -0,0 +1,28 @@ + +package org.codehaus.mojo.license.api; + +import java.util.Set; + +@SuppressWarnings("rawtypes") +public class LoadedProjectDependencies { + + private final Set allDependencies; + private final Set directDependencies; + + public LoadedProjectDependencies( Set allDependencies, Set directDependencies ) + { + this.allDependencies = allDependencies; + this.directDependencies = directDependencies; + } + + public Set getAllDependencies() + { + return allDependencies; + } + + public Set getDirectDependencies() + { + return directDependencies; + } + +} diff --git a/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java b/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java index 2e4d7f34f..8a3f0b18a 100644 --- a/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java +++ b/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java @@ -50,10 +50,12 @@ public interface ThirdPartyHelper /** * Load all dependencies given the configuration as {@link MavenProject}. * - * @param configuration the configuration of the project and include/exclude to do on his dependencies + * @param configuration the configuration of the project and include/exclude to do on its dependencies + * @param dependencyArtifacts the dependency artifacts of the project * @return the dictionary of loaded dependencies as {@link MavenProject} indexed by their gav. */ - SortedMap loadDependencies( MavenProjectDependenciesConfigurator configuration ); + SortedMap loadDependencies( MavenProjectDependenciesConfigurator configuration, + LoadedProjectDependencies dependencyArtifacts ); /** @@ -142,6 +144,7 @@ SortedProperties loadUnsafeMapping( LicenseMap licenseMap, File missingFile, Str * @param useRepositoryMissingFiles flag to use or not third-party descriptors via the 'third-party' classifier from maven repositories * @param unsafeDependencies all unsafe dependencies * @param projectDependencies all project dependencies + * @param dependencyArtifacts all project dependency artifacts * @return the loaded unsafe mapping * @throws ProjectBuildingException if could not build some dependencies maven project * @throws IOException if could not load missing file @@ -150,7 +153,8 @@ SortedProperties loadUnsafeMapping( LicenseMap licenseMap, File missingFile, Str SortedProperties createUnsafeMapping( LicenseMap licenseMap, File missingFile, String missingFileUrl, boolean useRepositoryMissingFiles, SortedSet unsafeDependencies, - SortedMap projectDependencies ) + SortedMap projectDependencies, + Set dependencyArtifacts) throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException; /**
+ This page requires JavaScript to work properly. Please enable JavaScript in your browser. +