diff --git a/src/it/ISSUE-145-2/README.txt b/src/it/ISSUE-145-2/README.txt
index 9afdb7b7e..0cad7f2c7 100644
--- a/src/it/ISSUE-145-2/README.txt
+++ b/src/it/ISSUE-145-2/README.txt
@@ -1,3 +1,3 @@
-Demonstrates that the aggregateAddThirdParty goal can handle long sibling project dependency chains in the same reactor, and that it resolves dependencies based on the right remote repositories list.
-
+Demonstrates that the aggregateAddThirdParty goal can handle long sibling project dependency chains in the same reactor, and that it resolves dependencies based on the right remote repositories list.
+
The project has parent A and children B, C, D, E with B depending on C, C dependending on D and D depending on E. The D dependency has a custom repository specified, and a dependency from that repo. When the plugin generates the license list, it should pick up the license for the dependency from the custom repo. E has a custom license specified, which should also be picked up.
\ No newline at end of file
diff --git a/src/it/ISSUE-145-2/pom.xml b/src/it/ISSUE-145-2/pom.xml
index 36895280d..f521db16a 100644
--- a/src/it/ISSUE-145-2/pom.xml
+++ b/src/it/ISSUE-145-2/pom.xml
@@ -1,66 +1,66 @@
-
-
- 4.0.0
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2
- @pom.version@
- License Test :: ISSUE-145-2
- 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
- submodule3
- submodule4
-
-
-
-
-
- org.codehaus.mojo
- license-maven-plugin
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
-
-
-
-
-
- org.codehaus.mojo
- license-maven-plugin
- @pom.version@
-
-
- aggregate-add-third-party
-
- aggregate-add-third-party
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2
+ @pom.version@
+ License Test :: ISSUE-145-2
+ 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
+ submodule3
+ submodule4
+
+
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+ @pom.version@
+
+
+ aggregate-add-third-party
+
+ aggregate-add-third-party
+
+
+
+
+
+
+
+
+
diff --git a/src/it/ISSUE-145-2/postbuild.groovy b/src/it/ISSUE-145-2/postbuild.groovy
index b4ffc5c63..06532dac1 100644
--- a/src/it/ISSUE-145-2/postbuild.groovy
+++ b/src/it/ISSUE-145-2/postbuild.groovy
@@ -19,7 +19,7 @@
* .
* #L%
*/
-
+
def assertExistsFile(file) {
if (!file.exists() || file.isDirectory()) {
println(file.getAbsolutePath() + " file is missing or a directory.")
diff --git a/src/it/ISSUE-145-2/submodule1/pom.xml b/src/it/ISSUE-145-2/submodule1/pom.xml
index 0210f747d..55205928c 100644
--- a/src/it/ISSUE-145-2/submodule1/pom.xml
+++ b/src/it/ISSUE-145-2/submodule1/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2
- @pom.version@
-
-
- 4.0.0
- jar
-
- test-ISSUE-145-2-submodule1
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2-submodule2
- @pom.version@
-
-
-
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2
+ @pom.version@
+
+
+ 4.0.0
+ jar
+
+ test-ISSUE-145-2-submodule1
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2-submodule2
+ @pom.version@
+
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-145-2/submodule2/pom.xml b/src/it/ISSUE-145-2/submodule2/pom.xml
index a9807e7f8..facbe92fa 100644
--- a/src/it/ISSUE-145-2/submodule2/pom.xml
+++ b/src/it/ISSUE-145-2/submodule2/pom.xml
@@ -1,21 +1,21 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2
- @pom.version@
-
- 4.0.0
-
- test-ISSUE-145-2-submodule2
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2-submodule3
- @pom.version@
-
-
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2
+ @pom.version@
+
+ 4.0.0
+
+ test-ISSUE-145-2-submodule2
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2-submodule3
+ @pom.version@
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-145-2/submodule3/pom.xml b/src/it/ISSUE-145-2/submodule3/pom.xml
index b527b8237..5fd6a3c7d 100644
--- a/src/it/ISSUE-145-2/submodule3/pom.xml
+++ b/src/it/ISSUE-145-2/submodule3/pom.xml
@@ -1,34 +1,34 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2
- @pom.version@
-
- 4.0.0
-
- test-ISSUE-145-2-submodule3
-
-
-
- clojars.org
- https://repo.clojars.org
-
-
-
-
-
-
- org.clojure-android
- tools.logging
- 0.3.2
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2-submodule4
- @pom.version@
-
-
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2
+ @pom.version@
+
+ 4.0.0
+
+ test-ISSUE-145-2-submodule3
+
+
+
+ clojars.org
+ https://repo.clojars.org
+
+
+
+
+
+
+ org.clojure-android
+ tools.logging
+ 0.3.2
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2-submodule4
+ @pom.version@
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-145-2/submodule4/pom.xml b/src/it/ISSUE-145-2/submodule4/pom.xml
index a90f0e445..7527b3a04 100644
--- a/src/it/ISSUE-145-2/submodule4/pom.xml
+++ b/src/it/ISSUE-145-2/submodule4/pom.xml
@@ -1,19 +1,19 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-2
- @pom.version@
-
- 4.0.0
-
- test-ISSUE-145-2-submodule4
-
-
-
- Custom ISSUE-145 license
-
-
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-2
+ @pom.version@
+
+ 4.0.0
+
+ test-ISSUE-145-2-submodule4
+
+
+
+ Custom ISSUE-145 license
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-145/README.txt b/src/it/ISSUE-145/README.txt
index a132d0afb..7d185ddf6 100644
--- a/src/it/ISSUE-145/README.txt
+++ b/src/it/ISSUE-145/README.txt
@@ -1,3 +1,3 @@
-Demonstrates that the aggregateAddThirdParty goal does not cause Maven to drop dependencies.
-
+Demonstrates that the aggregateAddThirdParty goal does not cause Maven to drop dependencies.
+
The project has parent A and children B and C with B depending on C. The bug in the plugin caused B to lose its dependency on C at build time, because the plugin modified Maven's list of dependencies for B. The test verifies that the dependency is preserved.
\ No newline at end of file
diff --git a/src/it/ISSUE-145/pom.xml b/src/it/ISSUE-145/pom.xml
index b08752cb9..4241fddd7 100644
--- a/src/it/ISSUE-145/pom.xml
+++ b/src/it/ISSUE-145/pom.xml
@@ -1,64 +1,64 @@
-
-
- 4.0.0
-
- 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.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
-
-
-
-
-
- org.codehaus.mojo
- license-maven-plugin
- @pom.version@
-
-
- aggregate-add-third-party
-
- aggregate-add-third-party
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ 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.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+ @pom.version@
+
+
+ aggregate-add-third-party
+
+ aggregate-add-third-party
+
+
+
+
+
+
+
+
+
diff --git a/src/it/ISSUE-145/submodule1/pom.xml b/src/it/ISSUE-145/submodule1/pom.xml
index 284341d89..559221a92 100644
--- a/src/it/ISSUE-145/submodule1/pom.xml
+++ b/src/it/ISSUE-145/submodule1/pom.xml
@@ -1,49 +1,49 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145
- @pom.version@
-
-
- 4.0.0
- jar
-
- test-ISSUE-145-submodule1
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145-submodule2
- @pom.version@
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.1
-
-
- package
-
- shade
-
-
-
-
-
-
-
-
- src/main/resources
- true
-
-
-
-
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145
+ @pom.version@
+
+
+ 4.0.0
+ jar
+
+ test-ISSUE-145-submodule1
+
+
+
+ org.codehaus.mojo.license.test
+ test-ISSUE-145-submodule2
+ @pom.version@
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.1
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-145/submodule1/src/main/java/org/codehaus/mojo/license/Application.java b/src/it/ISSUE-145/submodule1/src/main/java/org/codehaus/mojo/license/Application.java
index 09ed10e55..26d2c01eb 100644
--- a/src/it/ISSUE-145/submodule1/src/main/java/org/codehaus/mojo/license/Application.java
+++ b/src/it/ISSUE-145/submodule1/src/main/java/org/codehaus/mojo/license/Application.java
@@ -1,29 +1,29 @@
-package org.codehaus.mojo.license;
-
-/*
- * #%L
- * License Maven Plugin
- * %%
- * Copyright (C) 2017 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%
- */
-
-public class Application {
-
- public static void main(String[] args) {
- }
-}
+package org.codehaus.mojo.license;
+
+/*
+ * #%L
+ * License Maven Plugin
+ * %%
+ * Copyright (C) 2017 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%
+ */
+
+public class Application {
+
+ public static void main(String[] args) {
+ }
+}
diff --git a/src/it/ISSUE-145/submodule2/pom.xml b/src/it/ISSUE-145/submodule2/pom.xml
index 1cc422ba9..31e0428f6 100644
--- a/src/it/ISSUE-145/submodule2/pom.xml
+++ b/src/it/ISSUE-145/submodule2/pom.xml
@@ -1,13 +1,13 @@
-
-
-
- org.codehaus.mojo.license.test
- test-ISSUE-145
- @pom.version@
-
- 4.0.0
-
- test-ISSUE-145-submodule2
+
+
+
+ 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/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
index 334ad75a3..3ad316349 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
@@ -61,9 +61,7 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import org.apache.maven.model.Dependency;
import org.codehaus.mojo.license.api.DependenciesToolException;
-import org.codehaus.mojo.license.api.ResolvedProjectDependencies;
/**
* Abstract mojo for all third-party mojos.
@@ -593,7 +591,8 @@ public abstract class AbstractAddThirdPartyMojo
* @throws DependenciesToolException if the dependencies could not be loaded
*/
protected abstract SortedProperties createUnsafeMapping()
- throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException, DependenciesToolException;
+ throws ProjectBuildingException, IOException, ThirdPartyToolException,
+ MojoExecutionException, DependenciesToolException;
// ----------------------------------------------------------------------
// AbstractLicenseMojo Implementaton
@@ -679,7 +678,8 @@ else if ( licenseMergesUrl != null )
}
void consolidate() throws IOException, ArtifactNotFoundException, ArtifactResolutionException, MojoFailureException,
- ProjectBuildingException, ThirdPartyToolException, MojoExecutionException, DependenciesToolException
+ ProjectBuildingException, ThirdPartyToolException,
+ MojoExecutionException, DependenciesToolException
{
unsafeDependencies = getHelper().getProjectsWithNoLicense( licenseMap );
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
index 338358720..ed8b74d59 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
@@ -286,7 +286,8 @@ protected MavenProject getProject()
protected SortedMap getDependencies( MavenProject project )
{
- return dependenciesTool.loadProjectDependencies(new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() ),
+ return dependenciesTool.loadProjectDependencies(
+ new ResolvedProjectDependencies( 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 62ff4b96e..d08b8c6a5 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java
@@ -97,7 +97,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
*
* @since 1.15
*/
- @Parameter( property = "license.excludedTypes")
+ @Parameter( property = "license.excludedTypes" )
private String excludedTypes;
/**
@@ -361,7 +361,7 @@ protected void executeReport( Locale locale )
{
throw new MavenReportException( e.getMessage(), e );
}
- catch (MojoExecutionException e)
+ catch ( MojoExecutionException e )
{
throw new MavenReportException( e.getMessage(), e );
}
@@ -519,18 +519,23 @@ Collection createThirdPartyDetails( MavenProject project, boo
{
ResolvedProjectDependencies loadedDependencies;
- if ( loadArtifacts ) {
+ if ( loadArtifacts )
+ {
loadedDependencies = dependenciesTool.loadProjectArtifacts( localRepository, licenseMerges, project, null );
}
- else {
- loadedDependencies = new ResolvedProjectDependencies(getProject().getArtifacts(), getProject().getDependencyArtifacts());
+ else
+ {
+ loadedDependencies = new ResolvedProjectDependencies( getProject().getArtifacts(),
+ getProject().getDependencyArtifacts() );
}
ThirdPartyHelper thirdPartyHelper =
- new DefaultThirdPartyHelper( project, encoding, verbose, dependenciesTool, thirdPartyTool,
+ new DefaultThirdPartyHelper( project, encoding, verbose,
+ dependenciesTool, thirdPartyTool,
localRepository, project.getRemoteArtifactRepositories(), getLog() );
// load dependencies of the project
- SortedMap projectDependencies = thirdPartyHelper.loadDependencies( this, loadedDependencies );
+ SortedMap projectDependencies = thirdPartyHelper.loadDependencies( this,
+ loadedDependencies );
// create licenseMap from it
LicenseMap licenseMap = thirdPartyHelper.createLicenseMap( projectDependencies );
@@ -551,8 +556,9 @@ Collection createThirdPartyDetails( MavenProject project, boo
if ( useMissingFile )
{
// Resolve unsafe dependencies using missing files, this will update licenseMap and unsafeDependencies
- thirdPartyHelper.createUnsafeMapping( licenseMap, missingFile, missingFileUrl, useRepositoryMissingFiles,
- dependenciesWithNoLicense, projectDependencies, loadedDependencies.getAllDependencies() );
+ thirdPartyHelper.createUnsafeMapping( licenseMap, missingFile, missingFileUrl,
+ useRepositoryMissingFiles, 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 86f732a09..784ff240d 100644
--- a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
@@ -33,7 +33,6 @@
import java.util.SortedSet;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
-import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -91,7 +90,7 @@ public class AddThirdPartyMojo extends AbstractAddThirdPartyMojo implements Mave
* Internal flag to know if missing file must be generated.
*/
private boolean doGenerateMissing;
-
+
/**
* Whether this is an aggregate build, or a single-project goal. This setting determines which dependency artifacts
* will be examined by the plugin. AddThirdParty needs to load dependencies only for the single project it is run
@@ -99,20 +98,22 @@ public class AddThirdPartyMojo extends AbstractAddThirdPartyMojo implements Mave
* projects in the reactor.
*/
private boolean isAggregatorBuild = false;
-
+
/**
- * The reactor projects. When resolving dependencies, the aggregator goal needs to do custom handling of sibling dependencies for
- * projects in the reactor, to avoid trying to load artifacts for projects that haven't been built/published yet.
+ * The reactor projects. When resolving dependencies, the aggregator goal needs to do custom handling
+ * of sibling dependencies for projects in the reactor,
+ * to avoid trying to load artifacts for projects that haven't been built/published yet.
*/
private List reactorProjectDependencies;
-
+
/**
* Copies of the project's dependency sets. AddThirdParty needs to load dependencies only for the single project it
* is run for, while AggregateAddThirdParty needs to load dependencies for the parent project, as well as all child
* projects in the reactor.
*
- * In cases where one child project A in a reactor depends on another project B in the same reactor, B is not necessarily
- * built/published. The plugin needs to resolve B's dependencies manually. This field stores the result of that manual resolution.
+ * In cases where one child project A in a reactor depends on another project B in the same reactor,
+ * B is not necessarily built/published. The plugin needs to resolve B's dependencies manually.
+ * This field stores the result of that manual resolution.
*/
private ResolvedProjectDependencies dependencyArtifacts;
@@ -175,7 +176,7 @@ protected void doAction()
boolean safeLicense = checkForbiddenLicenses();
- checkBlacklist(safeLicense);
+ checkBlacklist( safeLicense );
writeThirdPartyFile();
@@ -186,8 +187,8 @@ protected void doAction()
}
boolean unsafe = CollectionUtils.isNotEmpty( getUnsafeDependencies() );
-
- checkMissing(unsafe);
+
+ checkMissing( unsafe );
if ( !unsafe && isUseMissingFile() && MapUtils.isEmpty( getUnsafeMappings() ) && getMissingFile().exists() )
{
@@ -225,19 +226,25 @@ protected SortedMap loadDependencies() throws Dependencies
/**
* Resolves the transitive and direct dependency sets for this project.
- *
+ *
* @return The set of all dependencies, and the set of only direct dependency artifacts.
* @throws org.codehaus.mojo.license.api.DependenciesToolException if the dependencies could not be resolved
*/
- protected ResolvedProjectDependencies resolveDependencyArtifacts() throws DependenciesToolException
+ protected ResolvedProjectDependencies resolveDependencyArtifacts() throws DependenciesToolException
{
- if ( dependencyArtifacts != null ) {
+ if ( dependencyArtifacts != null )
+ {
return dependencyArtifacts;
}
- if ( isAggregatorBuild ) {
- dependencyArtifacts = dependenciesTool.loadProjectArtifacts( localRepository, remoteRepositories, project, reactorProjectDependencies );
- } else {
- dependencyArtifacts = new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() );
+ if ( isAggregatorBuild )
+ {
+ dependencyArtifacts = dependenciesTool.loadProjectArtifacts( localRepository, remoteRepositories,
+ project, reactorProjectDependencies );
+ }
+ else
+ {
+ dependencyArtifacts = new ResolvedProjectDependencies( project.getArtifacts(),
+ project.getDependencyArtifacts() );
}
return dependencyArtifacts;
}
@@ -247,15 +254,17 @@ protected ResolvedProjectDependencies resolveDependencyArtifacts() throws Depend
*/
@Override
protected SortedProperties createUnsafeMapping()
- throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException, DependenciesToolException
+ throws ProjectBuildingException, IOException, ThirdPartyToolException,
+ MojoExecutionException, DependenciesToolException
{
-
+
SortedSet unsafeDependencies = getUnsafeDependencies();
SortedProperties unsafeMappings =
getHelper().createUnsafeMapping( getLicenseMap(), getMissingFile(), missingFileUrl,
useRepositoryMissingFiles, unsafeDependencies,
- getProjectDependencies(), resolveDependencyArtifacts().getAllDependencies() );
+ getProjectDependencies(),
+ resolveDependencyArtifacts().getAllDependencies() );
if ( isVerbose() )
{
getLog().info( "found " + unsafeMappings.size() + " unsafe mappings" );
@@ -468,7 +477,9 @@ private void writeMissingFile()
}
}
- void initFromMojo(AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, List reactorProjects) throws Exception {
+ void initFromMojo( AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject,
+ List reactorProjects ) throws Exception
+ {
project = mavenProject;
deployMissingFile = mojo.deployMissingFile;
useRepositoryMissingFiles = mojo.useRepositoryMissingFiles;
@@ -492,7 +503,7 @@ void initFromMojo(AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, L
missingLicensesFileArtifact = mojo.missingLicensesFileArtifact;
localRepository = mojo.localRepository;
remoteRepositories = mavenProject.getRemoteArtifactRepositories();
- dependencies = new HashSet<>(mavenProject.getDependencies());
+ dependencies = new HashSet<>( mavenProject.getDependencies() );
licenseMerges = mojo.licenseMerges;
licenseMergesFile = mojo.licenseMergesFile;
includedLicenses = mojo.includedLicenses;
@@ -509,11 +520,11 @@ void initFromMojo(AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, L
verbose = mojo.verbose;
encoding = mojo.encoding;
- setLog(mojo.getLog());
+ setLog( mojo.getLog() );
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 5f15f438d..f6bb337cd 100644
--- a/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AggregatorAddThirdPartyMojo.java
@@ -24,11 +24,11 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
-import java.util.TreeMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Plugin;
@@ -144,18 +144,18 @@ protected void init() throws Exception
// CHECKSTYLE_OFF: LineLength
if ( aggregateMissingLicensesFile != null && !aggregateMissingLicensesFile.equals( missingFile ) )
{
- getLog().warn("");
- getLog().warn("You should use *missingFile* parameter instead of deprecated *aggregateMissingLicensesFile*.");
- getLog().warn("");
+ getLog().warn( "" );
+ getLog().warn( "You should use *missingFile* parameter instead of deprecated *aggregateMissingLicensesFile*." );
+ getLog().warn( "" );
missingFile = aggregateMissingLicensesFile;
}
if ( aggregateMissingLicensesFileArtifact != null
&& !aggregateMissingLicensesFileArtifact.equals( missingLicensesFileArtifact ) )
{
- getLog().warn("");
- getLog().warn("You should use *missingLicensesFileArtifact* parameter instead of deprecated *aggregateMissingLicensesFileArtifact*.");
- getLog().warn("");
+ getLog().warn( "" );
+ getLog().warn( "You should use *missingLicensesFileArtifact* parameter instead of deprecated *aggregateMissingLicensesFileArtifact*." );
+ getLog().warn( "" );
missingLicensesFileArtifact = aggregateMissingLicensesFileArtifact;
}
// CHECKSTYLE_ON: LineLength
@@ -181,9 +181,9 @@ protected void doAction()
Artifact pluginArtifact = (Artifact) project.getPluginArtifactMap()
.get( "org.codehaus.mojo:license-maven-plugin" );
- String groupId=null;
- String artifactId=null;
- String version=null;
+ String groupId = null;
+ String artifactId = null;
+ String version = null;
if ( pluginArtifact == null )
{
Plugin plugin = (Plugin) project.getPluginManagement().getPluginsAsMap()
@@ -203,13 +203,15 @@ protected void doAction()
}
if ( groupId == null )
{
- throw new IllegalStateException("Can't find license-maven-plugin");
+ throw new IllegalStateException( "Can't find license-maven-plugin" );
}
String addThirdPartyRoleHint = groupId + ":" + artifactId + ":" + version + ":" + "add-third-party";
- for (MavenProject reactorProject : reactorProjects) {
- if (getProject().equals(reactorProject)) {
+ for ( MavenProject reactorProject : reactorProjects )
+ {
+ if ( getProject().equals( reactorProject ) )
+ {
// do not process pom
continue;
}
@@ -217,7 +219,7 @@ protected void doAction()
AddThirdPartyMojo mojo = (AddThirdPartyMojo) getSession()
.lookup( AddThirdPartyMojo.ROLE, addThirdPartyRoleHint );
- mojo.initFromMojo(this, reactorProject, new ArrayList<>(this.reactorProjects));
+ mojo.initFromMojo( this, reactorProject, new ArrayList<>( this.reactorProjects ) );
LicenseMap childLicenseMap = mojo.getLicenseMap();
if ( isVerbose() )
@@ -225,7 +227,7 @@ protected void doAction()
getLog().info( String.format( "Found %d license(s) in module %s:%s",
childLicenseMap.size(), mojo.project.getGroupId(), mojo.project.getArtifactId() ) );
}
- licenseMap.putAll(childLicenseMap);
+ licenseMap.putAll( childLicenseMap );
}
@@ -234,7 +236,7 @@ protected void doAction()
{
for ( Map.Entry> entry: licenseMap.entrySet() )
{
- getLog().info( " - " + entry.getKey()+" for "+entry.getValue().size()+" artifact(s).");
+ getLog().info( " - " + entry.getKey() + " for " + entry.getValue().size() + " artifact(s)." );
}
}
@@ -244,11 +246,11 @@ protected void doAction()
boolean safeLicense = checkForbiddenLicenses();
- checkBlacklist(safeLicense);
+ checkBlacklist( safeLicense );
writeThirdPartyFile();
- checkMissing(CollectionUtils.isNotEmpty( getUnsafeDependencies() ));
+ checkMissing( CollectionUtils.isNotEmpty( getUnsafeDependencies() ) );
}
// ----------------------------------------------------------------------
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 29df7e22d..9f50a4eb3 100644
--- a/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java
+++ b/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java
@@ -160,16 +160,16 @@ public SortedMap loadProjectDependencies( ResolvedProjectD
Map includeArtifacts = new HashMap<>();
SortedMap localCache = new TreeMap<>();
- if (cache != null)
+ if ( cache != null )
{
- localCache.putAll(cache);
+ localCache.putAll( cache );
}
for ( Object o : depArtifacts )
{
Artifact artifact = (Artifact) o;
- excludeArtifacts.put(artifact.getId(), artifact);
+ excludeArtifacts.put( artifact.getId(), artifact );
if ( DefaultThirdPartyTool.LICENSE_DB_TYPE.equals( artifact.getType() ) )
{
@@ -270,14 +270,14 @@ public SortedMap loadProjectDependencies( ResolvedProjectD
}
// store it also in cache
- localCache.put(id, depMavenProject);
+ localCache.put( id, depMavenProject );
}
// keep the project
- result.put(id, depMavenProject);
+ result.put( id, depMavenProject );
- excludeArtifacts.remove(artifact.getId());
- includeArtifacts.put(artifact.getId(), artifact);
+ excludeArtifacts.remove( artifact.getId() );
+ includeArtifacts.put( artifact.getId(), artifact );
}
// exclude artifacts from the result that contain excluded artifacts in the dependency trail
@@ -300,14 +300,14 @@ public SortedMap loadProjectDependencies( ResolvedProjectD
if ( remove )
{
- result.remove(MojoHelper.getArtifactId(entry.getValue()));
+ result.remove( MojoHelper.getArtifactId( entry.getValue() ) );
}
}
}
if ( cache != null )
{
- cache.putAll(result);
+ cache.putAll( result );
}
return result;
@@ -317,31 +317,37 @@ public SortedMap loadProjectDependencies( ResolvedProjectD
/**
* {@inheritDoc}
*/
- public ResolvedProjectDependencies loadProjectArtifacts( ArtifactRepository localRepository, List remoteRepositories,
- MavenProject project, List reactorProjects )
+ public ResolvedProjectDependencies loadProjectArtifacts( ArtifactRepository localRepository,
+ List remoteRepositories, MavenProject project, List reactorProjects )
throws DependenciesToolException
{
Map idToReactorProject = new HashMap<>();
- if ( reactorProjects != null ) {
- for ( MavenProject reactorProject : reactorProjects ) {
- idToReactorProject.put(String.format("%s:%s", reactorProject.getGroupId(), reactorProject.getArtifactId()), reactorProject);
+ if ( reactorProjects != null )
+ {
+ for ( MavenProject reactorProject : reactorProjects )
+ {
+ idToReactorProject.put( String.format( "%s:%s", reactorProject.getGroupId(),
+ reactorProject.getArtifactId() ), reactorProject );
}
}
-
+
/*
* Find the list of dependencies to resolve transitively. Some projects may be in the reactor.
* Reactor projects can't be resolved by the artifact resolver yet.
* In order to still get the complete dependency tree for the project, we will add the transitive
- * dependencies of the reactor project to the list of dependencies to resolve. Since the transitive dependencies could
- * also be reactor projects, we need to repeat this check for each of those. Note that since the dependency reactor
- * project may specify its own list of repositories, we need to keep track of which project the transitive dependency is
- * declared in.
+ * dependencies of the reactor project to the list of dependencies to resolve.
+ * Since the transitive dependencies could
+ * also be reactor projects, we need to repeat this check for each of those.
+ * Note that since the dependency reactor
+ * project may specify its own list of repositories,
+ * we need to keep track of which project the transitive dependency is declared in.
*/
List directDependencies = new ArrayList<>( project.getDependencies() );
Map> reactorProjectToTransitiveDependencies = new HashMap<>();
Queue> dependenciesToCheck = new ArrayDeque<>();
- for (Dependency dependency : directDependencies ) {
+ for ( Dependency dependency : directDependencies )
+ {
dependenciesToCheck.add( Pair.of( project, dependency ) );
}
if ( reactorProjects != null )
@@ -355,63 +361,85 @@ public ResolvedProjectDependencies loadProjectArtifacts( ArtifactRepository loca
if ( dependencyReactorProject != null )
{
/*
- * Since the project is in the reactor, the artifact resolver may not be able to resolve the artifact plus transitive
- * dependencies yet. In order to still get the complete dependency tree for the project, we will add the transitive
- * dependencies of the reactor project to the list of dependencies to resolve. Since the transitive dependencies could
- * also be reactor projects, we need to repeat this check for each of those. Note that since the dependency reactor
- * project may specify its own list of repositories, we need to keep track of which project the transitive dependency is
+ * Since the project is in the reactor, the artifact resolver may not be able to resolve
+ * the artifact plus transitive dependencies yet. In order to still get the
+ * complete dependency tree for the project, we will add the transitive
+ * dependencies of the reactor project to the list of dependencies to resolve.
+ * Since the transitive dependencies could
+ * also be reactor projects, we need to repeat this check for each of those.
+ * Note that since the dependency reactor
+ * project may specify its own list of repositories,
+ * we need to keep track of which project the transitive dependency is
* declared in.
*/
- for (Dependency transitiveDependency : (List)dependencyReactorProject.getDependencies() ) {
- dependenciesToCheck.add( Pair.of( dependencyReactorProject, transitiveDependency ));
+ for ( Dependency transitiveDependency
+ : ( List ) dependencyReactorProject.getDependencies() )
+ {
+ dependenciesToCheck.add( Pair.of( dependencyReactorProject, transitiveDependency ) );
}
}
if ( !directDependencies.contains( dependency ) )
{
- List transitiveForSameProject = reactorProjectToTransitiveDependencies.get( pair.getLeft() );
- if ( transitiveForSameProject == null ) {
+ List transitiveForSameProject =
+ reactorProjectToTransitiveDependencies.get( pair.getLeft() );
+ if ( transitiveForSameProject == null )
+ {
transitiveForSameProject = new ArrayList<>();
- reactorProjectToTransitiveDependencies.put( pair.getLeft(), transitiveForSameProject);
+ reactorProjectToTransitiveDependencies.put( pair.getLeft(), transitiveForSameProject );
}
transitiveForSameProject.add( dependency );
}
}
}
- //Create artifacts for all dependencies, keep the transitive dependencies grouped by project they are declared in
+ //Create artifacts for all dependencies,
+ //keep the transitive dependencies grouped by project they are declared in
Set directDependencyArtifacts = createDependencyArtifacts( project, directDependencies );
Map> reactorProjectToDependencyArtifacts = new HashMap<>();
- for ( Entry> entry : reactorProjectToTransitiveDependencies.entrySet() ) {
- reactorProjectToDependencyArtifacts.put( entry.getKey(), createDependencyArtifacts( entry.getKey(), entry.getValue()));
+ for ( Entry> entry : reactorProjectToTransitiveDependencies.entrySet() )
+ {
+ reactorProjectToDependencyArtifacts.put( entry.getKey(),
+ createDependencyArtifacts( entry.getKey(), entry.getValue() ) );
}
-
+
//Resolve artifacts. Transitive dependencies are resolved with the settings of the POM they are declared in.
- //Skip reactor projects, since they can't necessarily be resolved yet. The transitive handling above ensures we still get a complete list of dependencies.
+ //Skip reactor projects, since they can't necessarily be resolved yet.
+ //The transitive handling above ensures we still get a complete list of dependencies.
Set reactorArtifacts = new HashSet<>();
Set directArtifactsToResolve = new HashSet<>();
- if ( reactorProjects == null ) {
+ if ( reactorProjects == null )
+ {
directArtifactsToResolve.addAll( directDependencyArtifacts );
- } else {
- partitionByIsReactorProject( directDependencyArtifacts, reactorArtifacts, directArtifactsToResolve, idToReactorProject.keySet() );
- for ( Entry> entry : reactorProjectToDependencyArtifacts.entrySet() ) {
+ }
+ else
+ {
+ partitionByIsReactorProject( directDependencyArtifacts, reactorArtifacts,
+ directArtifactsToResolve, idToReactorProject.keySet() );
+ for ( Entry> entry : reactorProjectToDependencyArtifacts.entrySet() )
+ {
Set nonReactorArtifacts = new HashSet<>();
- partitionByIsReactorProject( entry.getValue(), reactorArtifacts, nonReactorArtifacts, idToReactorProject.keySet() );
+ partitionByIsReactorProject( entry.getValue(), reactorArtifacts,
+ nonReactorArtifacts, idToReactorProject.keySet() );
entry.setValue( nonReactorArtifacts );
- }
+ }
}
Set allDependencies = new HashSet<>( reactorArtifacts );
- allDependencies.addAll( resolve( directArtifactsToResolve, project.getArtifact(), localRepository, remoteRepositories ).getArtifacts() );
- for ( Entry> entry : reactorProjectToDependencyArtifacts.entrySet() ) {
+ allDependencies.addAll( resolve( directArtifactsToResolve, project.getArtifact(), localRepository,
+ remoteRepositories ).getArtifacts() );
+ for ( Entry> entry : reactorProjectToDependencyArtifacts.entrySet() )
+ {
MavenProject reactorProject = entry.getKey();
Set toResolve = entry.getValue();
Artifact reactorProjectArtifact = reactorProject.getArtifact();
List reactorRemoteRepositories = reactorProject.getRemoteArtifactRepositories();
- allDependencies.addAll( resolve( toResolve, reactorProjectArtifact, localRepository, reactorRemoteRepositories ).getArtifacts() );
+ allDependencies.addAll(
+ resolve( toResolve, reactorProjectArtifact, localRepository,
+ reactorRemoteRepositories ).getArtifacts() );
}
return new ResolvedProjectDependencies( allDependencies, directDependencyArtifacts );
}
-
+
private Set createDependencyArtifacts( MavenProject project, List dependencies )
throws DependenciesToolException
{
@@ -424,25 +452,31 @@ private Set createDependencyArtifacts( MavenProject project, List artifacts, Set reactorArtifacts, Set nonReactorArtifacts, Set reactorProjectIds )
+
+ private void partitionByIsReactorProject( Set artifacts, Set reactorArtifacts,
+ Set nonReactorArtifacts, Set reactorProjectIds )
{
- for (Artifact dependencyArtifact : artifacts) {
- String artifactKey = String.format( "%s:%s", dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId() );
- if (reactorProjectIds.contains(artifactKey)) {
- reactorArtifacts.add(dependencyArtifact);
- } else {
- nonReactorArtifacts.add(dependencyArtifact);
+ for ( Artifact dependencyArtifact : artifacts )
+ {
+ String artifactKey = String.format( "%s:%s", dependencyArtifact.getGroupId(),
+ dependencyArtifact.getArtifactId() );
+ if ( reactorProjectIds.contains( artifactKey ) )
+ {
+ reactorArtifacts.add( dependencyArtifact );
+ }
+ else
+ {
+ nonReactorArtifacts.add( dependencyArtifact );
}
}
}
-
- private ArtifactResolutionResult resolve( Set artifacts, Artifact projectArtifact, ArtifactRepository localRepository, List remoteRepositories )
+
+ private ArtifactResolutionResult resolve( Set artifacts, Artifact projectArtifact,
+ ArtifactRepository localRepository, List remoteRepositories )
throws DependenciesToolException
{
try
{
- getLogger().info(" resolving for project " + projectArtifact.getArtifactId() + " from remotes " + remoteRepositories);
return artifactResolver.resolveTransitively( artifacts, projectArtifact, remoteRepositories,
localRepository, artifactMetadataSource );
}
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 a4ee62708..e5b0159a2 100644
--- a/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java
+++ b/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyHelper.java
@@ -153,8 +153,8 @@ public SortedMap getArtifactCache()
public SortedMap loadDependencies( MavenProjectDependenciesConfigurator configuration,
ResolvedProjectDependencies dependencyArtifacts )
{
- return dependenciesTool.loadProjectDependencies( dependencyArtifacts, configuration, localRepository, remoteRepositories,
- getArtifactCache() );
+ return dependenciesTool.loadProjectDependencies( dependencyArtifacts, configuration, localRepository,
+ remoteRepositories, getArtifactCache() );
}
/**
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 8f881df88..972cdf608 100644
--- a/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java
+++ b/src/main/java/org/codehaus/mojo/license/api/DependenciesTool.java
@@ -22,9 +22,7 @@
* #L%
*/
-import java.util.Map;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import java.util.List;
@@ -69,6 +67,7 @@ SortedMap loadProjectDependencies( ResolvedProjectDependen
* @return the loaded project dependency artifacts
* @throws DependenciesToolException if could not load project dependencies
*/
- ResolvedProjectDependencies loadProjectArtifacts(ArtifactRepository localRepository, List remoteRepositories, MavenProject project, List reactorProjectDependencies )
+ ResolvedProjectDependencies loadProjectArtifacts( ArtifactRepository localRepository, List remoteRepositories,
+ MavenProject project, List reactorProjectDependencies )
throws DependenciesToolException;
}
diff --git a/src/main/java/org/codehaus/mojo/license/api/ResolvedProjectDependencies.java b/src/main/java/org/codehaus/mojo/license/api/ResolvedProjectDependencies.java
index e5f0cf930..3ba71f77d 100644
--- a/src/main/java/org/codehaus/mojo/license/api/ResolvedProjectDependencies.java
+++ b/src/main/java/org/codehaus/mojo/license/api/ResolvedProjectDependencies.java
@@ -1,11 +1,5 @@
-
package org.codehaus.mojo.license.api;
-import edu.emory.mathcs.backport.java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.maven.artifact.Artifact;
-
/*
* #%L
* License Maven Plugin
@@ -28,6 +22,11 @@
* #L%
*/
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.maven.artifact.Artifact;
+
/**
* Copies of the project's dependency sets. AddThirdParty needs to load dependencies only for the single project it is
* run for, while AggregateAddThirdParty needs to load dependencies for the parent project, as well as all child
@@ -39,7 +38,8 @@
* replace B with its dependencies when processing A. This field stores that modified view of the project's
* dependencies.
*/
-public class ResolvedProjectDependencies {
+public class ResolvedProjectDependencies
+{
private final Set allDependencies;
private final Set directDependencies;
@@ -59,5 +59,5 @@ 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 898674936..4f6c9ced2 100644
--- a/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java
+++ b/src/main/java/org/codehaus/mojo/license/api/ThirdPartyHelper.java
@@ -84,8 +84,8 @@ SortedProperties loadThirdPartyDescriptorForUnsafeMapping( Set topLeve
* @param missingFile location of an optional missing fille (says where you fix missing license).
* @param missingFileUrl location of an optional missing file extension that can be downloaded from some
* resource hoster and that will be merged with the content of the missing file.
- * @param projectDependencies project dependencies used to detect which dependencies in the missing file are unknown
- * to the project.
+ * @param projectDependencies project dependencies used to detect which dependencies in the missing file
+ * are unknown to the project.
* @return the map of all unsafe mapping
* @throws IOException if could not load missing file
*/
@@ -156,7 +156,7 @@ SortedProperties createUnsafeMapping( LicenseMap licenseMap, File missingFile, S
boolean useRepositoryMissingFiles,
SortedSet unsafeDependencies,
SortedMap projectDependencies,
- Set dependencyArtifacts)
+ Set dependencyArtifacts )
throws ProjectBuildingException, IOException, ThirdPartyToolException, MojoExecutionException;
/**