From 1a4b2f0115893edbae12e5eea85885a97f83c172 Mon Sep 17 00:00:00 2001 From: Bitbucket Pipeline Date: Sun, 12 Apr 2020 22:46:12 +1200 Subject: [PATCH 1/5] Fix #358 NPE on site generation caused by null returned by deprecated MavenProject.getDependencyArtifacts() --- pom.xml | 0 src/it/ISSUE-358/child-1/pom.xml | 11 + src/it/ISSUE-358/invoker.properties | 2 + src/it/ISSUE-358/pom.xml | 51 +++ .../license/AbstractThirdPartyReportMojo.java | 324 +++++++++--------- .../mojo/license/AddThirdPartyMojo.java | 9 +- .../AggregateDownloadLicensesMojo.java | 4 +- .../mojo/license/DownloadLicensesMojo.java | 3 +- .../LicensesXmlInsertVersionsMojo.java | 6 +- .../mojo/license/utils/MojoHelper.java | 170 +++++---- 10 files changed, 347 insertions(+), 233 deletions(-) mode change 100644 => 100755 pom.xml create mode 100755 src/it/ISSUE-358/child-1/pom.xml create mode 100755 src/it/ISSUE-358/invoker.properties create mode 100755 src/it/ISSUE-358/pom.xml mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/DownloadLicensesMojo.java mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java mode change 100644 => 100755 src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java diff --git a/pom.xml b/pom.xml old mode 100644 new mode 100755 diff --git a/src/it/ISSUE-358/child-1/pom.xml b/src/it/ISSUE-358/child-1/pom.xml new file mode 100755 index 000000000..6a94c1b55 --- /dev/null +++ b/src/it/ISSUE-358/child-1/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + net.tomred + ISSUE-358 + 0.0.1-SNAPSHOT + + child-1 + \ No newline at end of file diff --git a/src/it/ISSUE-358/invoker.properties b/src/it/ISSUE-358/invoker.properties new file mode 100755 index 000000000..c586cbd63 --- /dev/null +++ b/src/it/ISSUE-358/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=clean site +invoker.failureBehavior=fail-fast \ No newline at end of file diff --git a/src/it/ISSUE-358/pom.xml b/src/it/ISSUE-358/pom.xml new file mode 100755 index 000000000..79b8b32f6 --- /dev/null +++ b/src/it/ISSUE-358/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + net.tomred + ISSUE-358 + 0.0.1-SNAPSHOT + + pom + + + child-1 + + + + + + org.codehaus.mojo + license-maven-plugin + @pom.version@ + + + org.apache.maven.plugins + maven-site-plugin + 3.9.0 + + + org.apache.maven.doxia + doxia-site-renderer + 1.9.2 + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + + + + + org.codehaus.mojo + license-maven-plugin + @pom.version@ + + + + \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java old mode 100644 new mode 100755 index 61c529c90..284928ced --- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java @@ -22,6 +22,19 @@ * #L% */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeSet; + import org.apache.commons.collections.CollectionUtils; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -41,6 +54,7 @@ import org.codehaus.mojo.license.api.DependenciesTool; import org.codehaus.mojo.license.api.DependenciesToolException; import org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator; +import org.codehaus.mojo.license.api.ResolvedProjectDependencies; import org.codehaus.mojo.license.api.ThirdPartyDetails; import org.codehaus.mojo.license.api.ThirdPartyHelper; import org.codehaus.mojo.license.api.ThirdPartyTool; @@ -52,20 +66,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeSet; -import org.codehaus.mojo.license.api.ResolvedProjectDependencies; - /** * Base class for third-party reports. * @@ -73,9 +73,9 @@ * @since 1.1 */ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport - implements MavenProjectDependenciesConfigurator + implements MavenProjectDependenciesConfigurator { - private static final Logger LOG = LoggerFactory.getLogger( AbstractThirdPartyReportMojo.class ); + private static final Logger LOG = LoggerFactory.getLogger ( AbstractThirdPartyReportMojo.class ); // ---------------------------------------------------------------------- // Mojo Parameters @@ -86,15 +86,16 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.excludedScopes", defaultValue = "system" ) + @Parameter ( property = "license.excludedScopes", defaultValue = "system" ) private String excludedScopes; /** - * A filter to include only some scopes, if let empty then all scopes will be used (no filter). + * A filter to include only some scopes, if let empty then all scopes will be + * used (no filter). * * @since 1.1 */ - @Parameter( property = "license.includedScopes" ) + @Parameter ( property = "license.includedScopes" ) private String includedScopes; /** @@ -102,15 +103,16 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.15 */ - @Parameter( property = "license.excludedTypes" ) + @Parameter ( property = "license.excludedTypes" ) private String excludedTypes; /** - * A filter to include only some types, if let empty then all types will be used (no filter). + * A filter to include only some types, if let empty then all types will be used + * (no filter). * * @since 1.15 */ - @Parameter( property = "license.includedTypes" ) + @Parameter ( property = "license.includedTypes" ) private String includedTypes; /** @@ -118,7 +120,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.excludedGroups" ) + @Parameter ( property = "license.excludedGroups" ) private String excludedGroups; /** @@ -126,7 +128,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.includedGroups" ) + @Parameter ( property = "license.includedGroups" ) private String includedGroups; /** @@ -134,7 +136,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.excludedArtifacts" ) + @Parameter ( property = "license.excludedArtifacts" ) private String excludedArtifacts; /** @@ -142,15 +144,16 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.includedArtifacts" ) + @Parameter ( property = "license.includedArtifacts" ) private String includedArtifacts; /** - * Include transitive dependencies when looking for missing licenses and downloading license files. + * Include transitive dependencies when looking for missing licenses and + * downloading license files. * * @since 1.1 */ - @Parameter( property = "license.includeTransitiveDependencies", defaultValue = "true" ) + @Parameter ( property = "license.includeTransitiveDependencies", defaultValue = "true" ) private boolean includeTransitiveDependencies; /** @@ -158,16 +161,17 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.13 */ - @Parameter( property = "license.excludeTransitiveDependencies", defaultValue = "false" ) + @Parameter ( property = "license.excludeTransitiveDependencies", defaultValue = "false" ) private boolean excludeTransitiveDependencies; /** - * If {@code true} both optional and non-optional dependencies will be included in the list of artifacts for - * creating the license report; otherwise only non-optional dependencies will be considered. + * If {@code true} both optional and non-optional dependencies will be included + * in the list of artifacts for creating the license report; otherwise only + * non-optional dependencies will be considered. * * @since 1.19 */ - @Parameter( property = "license.includeOptional", defaultValue = "true" ) + @Parameter ( property = "license.includeOptional", defaultValue = "true" ) boolean includeOptional; /** @@ -175,7 +179,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.useMissingFile", defaultValue = "false" ) + @Parameter ( property = "license.useMissingFile", defaultValue = "false" ) private boolean useMissingFile; /** @@ -183,53 +187,59 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( property = "license.missingFile", defaultValue = "src/license/THIRD-PARTY.properties" ) + @Parameter ( property = "license.missingFile", defaultValue = "src/license/THIRD-PARTY.properties" ) private File missingFile; /** - * The Url that holds the missing license dependency entries. This is an extension to {@link #missingFile}. - * If set then the entries that will be found at this URL will be added additionally to the entries of the - * missing file.
+ * The Url that holds the missing license dependency entries. This is an + * extension to {@link #missingFile}. If set then the entries that will be found + * at this URL will be added additionally to the entries of the missing + * file.
*
* NOTE:
- * the response of the URL endpoint must return content that matches the THIRD-PARTY.properties file! + * the response of the URL endpoint must return content that matches the + * THIRD-PARTY.properties file! * * @since 1.15 */ - @Parameter( property = "license.missingFileUrl" ) + @Parameter ( property = "license.missingFileUrl" ) String missingFileUrl; /** * A file containing the override license information for dependencies. - * Note: Specify either {@link #overrideUrl} (preferred) or {@link #overrideFile}. - * If none of these is specified, then {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against + * Note: Specify either {@link #overrideUrl} (preferred) or + * {@link #overrideFile}. If none of these is specified, then + * {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against * ${basedir} will be used if it exists. * * @since 1.11 * @deprecated Use {@link #overrideUrl} instead */ @Deprecated - @Parameter( property = "license.overrideFile" ) + @Parameter ( property = "license.overrideFile" ) private File overrideFile; /** - * A URL pointing at a property file with the override license information for dependencies. - * Note: Specify either {@link #overrideUrl} (preferred) or {@link #overrideFile}. - * If none of these is specified, then {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against + * A URL pointing at a property file with the override license information for + * dependencies. Note: Specify either {@link #overrideUrl} (preferred) or + * {@link #overrideFile}. If none of these is specified, then + * {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against * ${basedir} will be used if it exists. *

* An example of the file content: + * *

      * org.jboss.xnio--xnio-api--3.3.6.Final=The Apache Software License, Version 2.0
      * 
* * @since 1.17 */ - @Parameter( property = "license.overrideUrl" ) + @Parameter ( property = "license.overrideUrl" ) private String overrideUrl; /** - * A {@link URL} prepared either our of {@link #overrideFile} or {@link #overrideUrl} or the default value. + * A {@link URL} prepared either our of {@link #overrideFile} or + * {@link #overrideUrl} or the default value. * * @see LicenseMojoUtils#prepareThirdPartyOverrideUrl(URL, File, String, File) */ @@ -240,45 +250,49 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.0 */ - @Parameter( property = "license.useRepositoryMissingFiles", defaultValue = "true" ) + @Parameter ( property = "license.useRepositoryMissingFiles", defaultValue = "true" ) private boolean useRepositoryMissingFiles; /** * To merge licenses in final file. *

- * Each entry represents a merge (first license is main license to keep), licenses are separated by {@code |}. + * Each entry represents a merge (first license is main license to keep), + * licenses are separated by {@code |}. *

* Example : *

+ * *

-     * <licenseMerges>
-     * <licenseMerge>The Apache Software License|Version 2.0,Apache License, Version 2.0</licenseMerge>
-     * </licenseMerges>
+     * <licenseMerges> <licenseMerge>The Apache Software License|Version
+     * 2.0,Apache License, Version 2.0</licenseMerge> </licenseMerges>
      * </pre>
      *
-     * Note: This option will be overridden by {@link #licenseMergesUrl} if it is used by command line.
+     * Note: This option will be overridden by {@link #licenseMergesUrl} if
+     * it is used by command line.
+     *
      * @since 1.0
      */
     @Parameter
     private List licenseMerges;
 
     /**
-      * Location of file with the merge licenses in order to be used by command line.
-      * Note: This option overrides {@link #licenseMerges}.
-      *
-      * @since 1.18
-      */
-     @Parameter( property = "license.licenseMergesUrl" )
-     protected String licenseMergesUrl;
+     * Location of file with the merge licenses in order to be used by command line.
+     * Note: This option overrides {@link #licenseMerges}.
+     *
+     * @since 1.18
+     */
+    @Parameter ( property = "license.licenseMergesUrl" )
+    protected String licenseMergesUrl;
 
     /**
-     * The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from
-     * the command line. If the goal is run indirectly as part of a site generation, the output directory configured in
-     * the Maven Site Plugin is used instead.
+     * The output directory for the report. Note that this parameter is only
+     * evaluated if the goal is run directly from the command line. If the goal is
+     * run indirectly as part of a site generation, the output directory configured
+     * in the Maven Site Plugin is used instead.
      *
      * @since 1.1
      */
-    @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true )
+    @Parameter ( defaultValue = "${project.reporting.outputDirectory}", required = true )
     private File outputDirectory;
 
     /**
@@ -289,18 +303,18 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
      *
      * @since 1.0
      */
-    @Parameter( property = "license.verbose", defaultValue = "${maven.verbose}" )
+    @Parameter ( property = "license.verbose", defaultValue = "${maven.verbose}" )
     private boolean verbose;
 
     /**
      * Encoding used to read and writes files.
      * 

- * Note: If nothing is filled here, we will use the system - * property {@code file.encoding}. + * Note: If nothing is filled here, we will use the system property + * {@code file.encoding}. * * @since 1.0 */ - @Parameter( property = "license.encoding", defaultValue = "${project.build.sourceEncoding}" ) + @Parameter ( property = "license.encoding", defaultValue = "${project.build.sourceEncoding}" ) private String encoding; /** @@ -308,7 +322,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter( defaultValue = "${project}", readonly = true ) + @Parameter ( defaultValue = "${project}", readonly = true ) private MavenProject project; // ---------------------------------------------------------------------- @@ -348,7 +362,9 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport private ThirdPartyTool thirdPartyTool; /** - * A URL returning a plain text file that contains include/exclude artifact filters in the following format: + * A URL returning a plain text file that contains include/exclude artifact + * filters in the following format: + * *

      * {@code
      * # this is a comment
@@ -360,11 +376,12 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
      * exclude scope system
      * include type jar
      * exclude type war
-     * }
+ * } + *
* * @since 1.18 */ - @Parameter( property = "license.artifactFiltersUrl" ) + @Parameter ( property = "license.artifactFiltersUrl" ) private String artifactFiltersUrl; private ArtifactFilters artifactFilters; @@ -373,10 +390,9 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport // Protected Abstract Methods // ---------------------------------------------------------------------- - protected abstract Collection createThirdPartyDetails() - throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, - InvalidDependencyVersionException, ArtifactNotFoundException, ArtifactResolutionException, - DependenciesToolException, MojoExecutionException; + protected abstract Collection createThirdPartyDetails () throws IOException, + ThirdPartyToolException, ProjectBuildingException, MojoFailureException, InvalidDependencyVersionException, + ArtifactNotFoundException, ArtifactResolutionException, DependenciesToolException, MojoExecutionException; // ---------------------------------------------------------------------- // AbstractMavenReport Implementation @@ -385,20 +401,21 @@ protected abstract Collection createThirdPartyDetails() /** * Method to initialize the mojo before doing any concrete actions. * - * Note: The method is invoked before the {@link #executeReport()} method. + * Note: The method is invoked before the {@link #executeReport()} + * method. + * * @throws IOException */ - protected void init() - throws IOException + protected void init () throws IOException { if ( licenseMergesUrl != null ) { - LOG.warn( "" ); - LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." ); - LOG.warn( "" ); - if ( UrlRequester.isStringUrl( licenseMergesUrl ) ) + LOG.warn ( "" ); + LOG.warn ( "licenseMerges will be overridden by licenseMergesUrl." ); + LOG.warn ( "" ); + if ( UrlRequester.isStringUrl ( licenseMergesUrl ) ) { - licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) ); + licenseMerges = Arrays.asList ( UrlRequester.getFromUrl ( licenseMergesUrl ).split ( "[\n\r]+" ) ); } } } @@ -406,62 +423,61 @@ protected void init() /** * {@inheritDoc} */ - protected void executeReport( Locale locale ) - throws MavenReportException + protected void executeReport ( Locale locale ) throws MavenReportException { - resolvedOverrideUrl = LicenseMojoUtils.prepareThirdPartyOverrideUrl( resolvedOverrideUrl, overrideFile, - overrideUrl, project.getBasedir() ); + resolvedOverrideUrl = LicenseMojoUtils.prepareThirdPartyOverrideUrl ( resolvedOverrideUrl, overrideFile, + overrideUrl, project.getBasedir () ); Collection details; try { - init(); - details = createThirdPartyDetails(); + init (); + details = createThirdPartyDetails (); } catch ( IOException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( ThirdPartyToolException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( ProjectBuildingException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( ArtifactNotFoundException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( ArtifactResolutionException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( MojoFailureException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( DependenciesToolException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } catch ( MojoExecutionException e ) { - throw new MavenReportException( e.getMessage(), e ); + throw new MavenReportException ( e.getMessage (), e ); } - ThirdPartyReportRenderer renderer = - new ThirdPartyReportRenderer( getSink(), i18n, getOutputName(), locale, details ); - renderer.render(); + ThirdPartyReportRenderer renderer = new ThirdPartyReportRenderer ( getSink (), i18n, getOutputName (), locale, + details ); + renderer.render (); } /** * {@inheritDoc} */ - protected MavenProject getProject() + protected MavenProject getProject () { return project; } @@ -469,20 +485,20 @@ protected MavenProject getProject() /** * {@inheritDoc} */ - protected String getOutputDirectory() + protected String getOutputDirectory () { - if ( !outputDirectory.isAbsolute() ) + if ( !outputDirectory.isAbsolute () ) { - outputDirectory = new File( project.getBasedir(), outputDirectory.getPath() ); + outputDirectory = new File ( project.getBasedir (), outputDirectory.getPath () ); } - return outputDirectory.getAbsolutePath(); + return outputDirectory.getAbsolutePath (); } /** * {@inheritDoc} */ - protected Renderer getSiteRenderer() + protected Renderer getSiteRenderer () { return siteRenderer; } @@ -490,17 +506,17 @@ protected Renderer getSiteRenderer() /** * {@inheritDoc} */ - public String getDescription( Locale locale ) + public String getDescription ( Locale locale ) { - return i18n.getString( getOutputName(), locale, "report.description" ); + return i18n.getString ( getOutputName (), locale, "report.description" ); } /** * {@inheritDoc} */ - public String getName( Locale locale ) + public String getName ( Locale locale ) { - return i18n.getString( getOutputName(), locale, "report.title" ); + return i18n.getString ( getOutputName (), locale, "report.title" ); } // ---------------------------------------------------------------------- @@ -510,7 +526,7 @@ public String getName( Locale locale ) /** * {@inheritDoc} */ - public boolean isIncludeTransitiveDependencies() + public boolean isIncludeTransitiveDependencies () { return includeTransitiveDependencies; } @@ -518,19 +534,19 @@ public boolean isIncludeTransitiveDependencies() /** * {@inheritDoc} */ - public boolean isExcludeTransitiveDependencies() + public boolean isExcludeTransitiveDependencies () { return excludeTransitiveDependencies; } /** {@inheritDoc} */ - public ArtifactFilters getArtifactFilters() + public ArtifactFilters getArtifactFilters () { if ( artifactFilters == null ) { - artifactFilters = ArtifactFilters.of( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts, - includedScopes, excludedScopes, includedTypes, excludedTypes, - includeOptional, artifactFiltersUrl , getEncoding() ); + artifactFilters = ArtifactFilters.of ( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts, + includedScopes, excludedScopes, includedTypes, excludedTypes, includeOptional, artifactFiltersUrl, + getEncoding () ); } return artifactFilters; } @@ -538,7 +554,7 @@ public ArtifactFilters getArtifactFilters() /** * {@inheritDoc} */ - public boolean isVerbose() + public boolean isVerbose () { return verbose; } @@ -547,95 +563,93 @@ public boolean isVerbose() // Protected Methods // ---------------------------------------------------------------------- - Collection createThirdPartyDetails( MavenProject project, boolean loadArtifacts ) - throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, - DependenciesToolException, MojoExecutionException + Collection createThirdPartyDetails ( MavenProject project, boolean loadArtifacts ) + throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, + DependenciesToolException, MojoExecutionException { ResolvedProjectDependencies loadedDependencies; if ( loadArtifacts ) { - loadedDependencies = - new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() ); + loadedDependencies = new ResolvedProjectDependencies ( project.getArtifacts (), + MojoHelper.getDependencyArtifacts ( project ) ); } else { - loadedDependencies = new ResolvedProjectDependencies( getProject().getArtifacts(), - getProject().getDependencyArtifacts() ); + loadedDependencies = new ResolvedProjectDependencies ( getProject ().getArtifacts (), + MojoHelper.getDependencyArtifacts ( project ) ); } - ThirdPartyHelper thirdPartyHelper = - new DefaultThirdPartyHelper( project, encoding, verbose, - dependenciesTool, thirdPartyTool, - project.getRemoteArtifactRepositories(), project.getRemoteProjectRepositories() ); + ThirdPartyHelper thirdPartyHelper = new DefaultThirdPartyHelper ( project, encoding, verbose, dependenciesTool, + thirdPartyTool, project.getRemoteArtifactRepositories (), project.getRemoteProjectRepositories () ); // 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 ); + LicenseMap licenseMap = thirdPartyHelper.createLicenseMap ( projectDependencies ); // Get unsafe dependencies (dependencies with no license in pom) - SortedSet dependenciesWithNoLicense = thirdPartyHelper.getProjectsWithNoLicense( licenseMap ); + SortedSet dependenciesWithNoLicense = thirdPartyHelper.getProjectsWithNoLicense ( licenseMap ); // compute safe dependencies (with pom licenses) - Set dependenciesWithPomLicense = - new TreeSet<>( MojoHelper.newMavenProjectComparator() ); - dependenciesWithPomLicense.addAll( projectDependencies.values() ); + Set dependenciesWithPomLicense = new TreeSet<> ( MojoHelper.newMavenProjectComparator () ); + dependenciesWithPomLicense.addAll ( projectDependencies.values () ); - if ( CollectionUtils.isNotEmpty( dependenciesWithNoLicense ) ) + if ( CollectionUtils.isNotEmpty ( dependenciesWithNoLicense ) ) { // there is some unsafe dependencies, remove them from safe dependencies - dependenciesWithPomLicense.removeAll( dependenciesWithNoLicense ); + dependenciesWithPomLicense.removeAll ( dependenciesWithNoLicense ); if ( useMissingFile ) { - // Resolve unsafe dependencies using missing files, this will update licenseMap and unsafeDependencies - thirdPartyHelper.createUnsafeMapping( licenseMap, missingFile, missingFileUrl, - useRepositoryMissingFiles, dependenciesWithNoLicense, - projectDependencies, loadedDependencies.getAllDependencies() ); + // Resolve unsafe dependencies using missing files, this will update licenseMap + // and unsafeDependencies + thirdPartyHelper.createUnsafeMapping ( licenseMap, missingFile, missingFileUrl, + useRepositoryMissingFiles, dependenciesWithNoLicense, projectDependencies, + loadedDependencies.getAllDependencies () ); } } // LicenseMap is now complete, let's merge licenses if necessary - thirdPartyHelper.mergeLicenses( licenseMerges, licenseMap ); + thirdPartyHelper.mergeLicenses ( licenseMerges, licenseMap ); // Add override licenses - thirdPartyTool.overrideLicenses( licenseMap, projectDependencies, encoding, resolvedOverrideUrl ); + thirdPartyTool.overrideLicenses ( licenseMap, projectDependencies, encoding, resolvedOverrideUrl ); // let's build third party details for each dependencies - Collection details = new ArrayList<>(); + Collection details = new ArrayList<> (); - for ( Map.Entry entry : licenseMap.toDependencyMap().entrySet() ) + for ( Map.Entry entry : licenseMap.toDependencyMap ().entrySet () ) { - MavenProject dependency = entry.getKey(); - String[] licenses = entry.getValue(); - ThirdPartyDetails detail = new DefaultThirdPartyDetails( dependency ); - details.add( detail ); - if ( dependenciesWithPomLicense.contains( dependency ) ) + MavenProject dependency = entry.getKey (); + String[] licenses = entry.getValue (); + ThirdPartyDetails detail = new DefaultThirdPartyDetails ( dependency ); + details.add ( detail ); + if ( dependenciesWithPomLicense.contains ( dependency ) ) { // this is a pom licenses - detail.setPomLicenses( licenses ); + detail.setPomLicenses ( licenses ); } - else if ( !dependenciesWithNoLicense.contains( dependency ) ) + else if ( !dependenciesWithNoLicense.contains ( dependency ) ) { // this is a third-party licenses - detail.setThirdPartyLicenses( licenses ); + detail.setThirdPartyLicenses ( licenses ); } } return details; } /** {@inheritDoc} */ - public String getArtifactFiltersUrl() + public String getArtifactFiltersUrl () { return artifactFiltersUrl; } /** {@inheritDoc} */ - public String getEncoding() + public String getEncoding () { return encoding; } diff --git a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java old mode 100644 new mode 100755 index 1e5bec0d5..367243bde --- a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java @@ -47,6 +47,7 @@ import org.codehaus.mojo.license.api.ThirdPartyToolException; import org.codehaus.mojo.license.model.LicenseMap; import org.codehaus.mojo.license.utils.FileUtil; +import org.codehaus.mojo.license.utils.MojoHelper; import org.codehaus.mojo.license.utils.SortedProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -240,13 +241,13 @@ protected ResolvedProjectDependencies resolveDependencyArtifacts() throws Depend } if ( isAggregatorBuild ) { - dependencyArtifacts = - new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() ); + dependencyArtifacts = new ResolvedProjectDependencies( project.getArtifacts(), + MojoHelper.getDependencyArtifacts( project ) ); } else { dependencyArtifacts = new ResolvedProjectDependencies( project.getArtifacts(), - project.getDependencyArtifacts() ); + MojoHelper.getDependencyArtifacts( project ) ); } return dependencyArtifacts; } @@ -442,7 +443,7 @@ void initFromMojo( AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject, resolvedOverrideUrl = mojo.resolvedOverrideUrl; missingLicensesFileArtifact = mojo.missingLicensesFileArtifact; localRepository = mojo.localRepository; - dependencies = new HashSet<>( mavenProject.getDependencyArtifacts() ); + dependencies = new HashSet<>( MojoHelper.getDependencyArtifacts( mavenProject ) ); licenseMerges = mojo.licenseMerges; licenseMergesFile = mojo.licenseMergesFile; includedLicenses = mojo.includedLicenses; diff --git a/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java old mode 100644 new mode 100755 index fd44d576f..86bda94d0 --- a/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java @@ -29,6 +29,7 @@ import org.apache.maven.project.MavenProject; import org.codehaus.mojo.license.api.ResolvedProjectDependencies; import org.codehaus.mojo.license.download.LicensedArtifact; +import org.codehaus.mojo.license.utils.MojoHelper; import java.util.List; import java.util.Map; @@ -115,8 +116,7 @@ protected Map getDependencies() for ( MavenProject p : reactorProjects ) { licensedArtifactResolver.loadProjectDependencies( new ResolvedProjectDependencies( p.getArtifacts(), - p.getDependencyArtifacts() ), - this, remoteRepositories, result ); + MojoHelper.getDependencyArtifacts( p ) ), this, remoteRepositories, result ); } return result; } diff --git a/src/main/java/org/codehaus/mojo/license/DownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/DownloadLicensesMojo.java old mode 100644 new mode 100755 index b0a6bebed..6c7455f34 --- a/src/main/java/org/codehaus/mojo/license/DownloadLicensesMojo.java +++ b/src/main/java/org/codehaus/mojo/license/DownloadLicensesMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.codehaus.mojo.license.api.ResolvedProjectDependencies; import org.codehaus.mojo.license.download.LicensedArtifact; +import org.codehaus.mojo.license.utils.MojoHelper; /** * Download the license files of all the current project's dependencies, and generate a summary file containing a list @@ -86,7 +87,7 @@ protected Map getDependencies() { final Map result = new TreeMap<>(); licensedArtifactResolver.loadProjectDependencies( - new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() ), + new ResolvedProjectDependencies( project.getArtifacts(), MojoHelper.getDependencyArtifacts( project ) ), this, remoteRepositories, result ); return result; } diff --git a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java old mode 100644 new mode 100755 index fddcb50e9..a6b5d6804 --- a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java @@ -42,6 +42,7 @@ import org.codehaus.mojo.license.download.LicensedArtifact; import org.codehaus.mojo.license.download.ProjectLicenseInfo; import org.codehaus.mojo.license.utils.FileUtil; +import org.codehaus.mojo.license.utils.MojoHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -140,8 +141,9 @@ public ArtifactFilters getArtifactFilters() }; final Map resolvedDeps = new TreeMap(); licensedArtifactResolver.loadProjectDependencies( - new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() ), - config, remoteRepositories, resolvedDeps ); + new ResolvedProjectDependencies( project.getArtifacts(), + MojoHelper.getDependencyArtifacts( project ) ), config, remoteRepositories, + resolvedDeps ); final Map resolvedDepsMap = new HashMap<>( resolvedDeps.size() ); for ( LicensedArtifact dep : resolvedDeps.values() ) { diff --git a/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java b/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java old mode 100644 new mode 100755 index 112b6849d..a0b79f509 --- a/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java +++ b/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java @@ -25,6 +25,8 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Resource; import org.apache.maven.project.MavenProject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.net.MalformedURLException; @@ -32,7 +34,9 @@ import java.text.MessageFormat; import java.util.Arrays; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * Mojo helper methods. @@ -42,6 +46,7 @@ */ public class MojoHelper { + private static final Logger LOG = LoggerFactory.getLogger ( MojoHelper.class ); /** * Add the directory as a resource of the given project. @@ -51,10 +56,10 @@ public class MojoHelper * @param includes the includes of the resource * @return {@code true} if the resources was added (not already existing) */ - public static boolean addResourceDir( File dir, MavenProject project, String... includes ) + public static boolean addResourceDir ( File dir, MavenProject project, String... includes ) { - List resources = project.getResources(); - return addResourceDir( dir, project, resources, includes ); + List resources = project.getResources (); + return addResourceDir ( dir, project, resources, includes ); } /** @@ -66,23 +71,23 @@ public static boolean addResourceDir( File dir, MavenProject project, String... * @param includes includes of the new resources * @return {@code true} if the resource was added (not already existing) */ - public static boolean addResourceDir( File dir, MavenProject project, List resources, String... includes ) + public static boolean addResourceDir ( File dir, MavenProject project, List resources, String... includes ) { - String newresourceDir = dir.getAbsolutePath(); + String newresourceDir = dir.getAbsolutePath (); boolean shouldAdd = true; for ( Object o : resources ) { Resource r = (Resource) o; - if ( !r.getDirectory().equals( newresourceDir ) ) + if ( !r.getDirectory ().equals ( newresourceDir ) ) { continue; } for ( String i : includes ) { - if ( !r.getIncludes().contains( i ) ) + if ( !r.getIncludes ().contains ( i ) ) { - r.addInclude( i ); + r.addInclude ( i ); } } shouldAdd = false; @@ -90,70 +95,72 @@ public static boolean addResourceDir( File dir, MavenProject project, List re } if ( shouldAdd ) { - Resource r = new Resource(); - r.setDirectory( newresourceDir ); + Resource r = new Resource (); + r.setDirectory ( newresourceDir ); for ( String i : includes ) { - if ( !r.getIncludes().contains( i ) ) + if ( !r.getIncludes ().contains ( i ) ) { - r.addInclude( i ); + r.addInclude ( i ); } } - project.addResource( r ); + project.addResource ( r ); } return shouldAdd; } - public static Comparator newMavenProjectComparator() + public static Comparator newMavenProjectComparator () { - return new Comparator() + return new Comparator () { /** * {@inheritDoc} */ - public int compare( MavenProject o1, MavenProject o2 ) + public int compare ( MavenProject o1, MavenProject o2 ) { - String id1 = getArtifactId( o1.getArtifact() ); - String id2 = getArtifactId( o2.getArtifact() ); - return id1.compareTo( id2 ); + String id1 = getArtifactId ( o1.getArtifact () ); + String id2 = getArtifactId ( o2.getArtifact () ); + return id1.compareTo ( id2 ); } }; } - public static Comparator newMavenProjectComparatorByName() + public static Comparator newMavenProjectComparatorByName () { - return new Comparator() + return new Comparator () { /** * {@inheritDoc} */ - public int compare( MavenProject o1, MavenProject o2 ) + public int compare ( MavenProject o1, MavenProject o2 ) { - String id1 = getProjectName( o1 ); - String id2 = getProjectName( o2 ); - return id1.compareToIgnoreCase( id2 ); + String id1 = getProjectName ( o1 ); + String id2 = getProjectName ( o2 ); + return id1.compareToIgnoreCase ( id2 ); } }; } - protected static final double[] TIME_FACTORS = { 1000000, 1000, 60, 60, 24 }; + protected static final double[] TIME_FACTORS = + { 1000000, 1000, 60, 60, 24 }; - protected static final String[] TIME_UNITES = { "ns", "ms", "s", "m", "h", "d" }; + protected static final String[] TIME_UNITES = + { "ns", "ms", "s", "m", "h", "d" }; - public static String convertTime( long value ) + public static String convertTime ( long value ) { - return convert( value, TIME_FACTORS, TIME_UNITES ); + return convert ( value, TIME_FACTORS, TIME_UNITES ); } - public static String convert( long value, double[] factors, String[] unites ) + public static String convert ( long value, double[] factors, String[] unites ) { - long sign = value == 0 ? 1 : value / Math.abs( value ); + long sign = value == 0 ? 1 : value / Math.abs ( value ); int i = 0; - double tmp = Math.abs( value ); + double tmp = Math.abs ( value ); while ( i < factors.length && i < unites.length && tmp > factors[i] ) { tmp = tmp / factors[i++]; @@ -161,7 +168,7 @@ public static String convert( long value, double[] factors, String[] unites ) tmp *= sign; String result; - result = MessageFormat.format( "{0,number,0.###}{1}", tmp, unites[i] ); + result = MessageFormat.format ( "{0,number,0.###}{1}", tmp, unites[i] ); return result; } @@ -172,77 +179,102 @@ public static String convert( long value, double[] factors, String[] unites ) * @param suffix suffix to add * @return the new url */ - public static URL getUrl( URL baseUrl, String suffix ) + public static URL getUrl ( URL baseUrl, String suffix ) { - String url = baseUrl.toString() + "/" + suffix; + String url = baseUrl.toString () + "/" + suffix; try { - return new URL( url ); + return new URL ( url ); } catch ( MalformedURLException ex ) { - throw new IllegalArgumentException( "could not obtain url " + url, ex ); + throw new IllegalArgumentException ( "could not obtain url " + url, ex ); } } - public static String getArtifactId( Artifact artifact ) + public static String getArtifactId ( Artifact artifact ) { - StringBuilder sb = new StringBuilder(); - sb.append( artifact.getGroupId() ); - sb.append( "--" ); - sb.append( artifact.getArtifactId() ); - sb.append( "--" ); - sb.append( artifact.getVersion() ); - return sb.toString(); + StringBuilder sb = new StringBuilder (); + sb.append ( artifact.getGroupId () ); + sb.append ( "--" ); + sb.append ( artifact.getArtifactId () ); + sb.append ( "--" ); + sb.append ( artifact.getVersion () ); + return sb.toString (); } - public static String getArtifactName( MavenProject project ) + public static String getArtifactName ( MavenProject project ) { - StringBuilder sb = new StringBuilder(); - if ( project.getName().startsWith( "Unnamed -" ) ) + StringBuilder sb = new StringBuilder (); + if ( project.getName ().startsWith ( "Unnamed -" ) ) { // as in Maven 3, let's use the artifact id - sb.append( project.getArtifactId() ); + sb.append ( project.getArtifactId () ); } else { - sb.append( project.getName() ); + sb.append ( project.getName () ); } - sb.append( " (" ); - sb.append( project.getGroupId() ); - sb.append( ":" ); - sb.append( project.getArtifactId() ); - sb.append( ":" ); - sb.append( project.getVersion() ); - sb.append( " - " ); - String url = project.getUrl(); - sb.append( url == null ? "no url defined" : url ); - sb.append( ")" ); - - return sb.toString(); + sb.append ( " (" ); + sb.append ( project.getGroupId () ); + sb.append ( ":" ); + sb.append ( project.getArtifactId () ); + sb.append ( ":" ); + sb.append ( project.getVersion () ); + sb.append ( " - " ); + String url = project.getUrl (); + sb.append ( url == null ? "no url defined" : url ); + sb.append ( ")" ); + + return sb.toString (); } - public static String getProjectName( MavenProject project ) + public static String getProjectName ( MavenProject project ) { String sb; - if ( project.getName().startsWith( "Unnamed" ) ) + if ( project.getName ().startsWith ( "Unnamed" ) ) { // as in Maven 3, let's use the artifact id - sb = project.getArtifactId(); + sb = project.getArtifactId (); } else { - sb = project.getName(); + sb = project.getName (); } return sb; } - public static List getParams( String params ) + public static List getParams ( String params ) { - String[] split = params == null ? new String[0] : params.split( "," ); - return Arrays.asList( split ); + String[] split = params == null ? new String[0] : params.split ( "," ); + return Arrays.asList ( split ); } + + /** + * {@link MavenProject#getDependencyArtifacts()} is deprecated. + * + *

+ * This method checks if the dependency artifacts is {@code null} and returns an + * empty {@code HashSet} to avoid the {@code NullPointerException}s caused by + * the {@link MavenProject#getDependencyArtifacts()} returning {@code null}. + *

+ * + * @param project the MavenProject to retrieve artifacts from + * @return a HashSet of dependencies or an empty set + */ + public static Set getDependencyArtifacts ( MavenProject project ) + { + if ( project == null || project.getDependencyArtifacts () == null ) + { + LOG.warn ( "" ); + LOG.warn ( "Non-transitive dependencies cannot be found. " ); + LOG.warn ( "" ); + return new HashSet (); + } + return project.getDependencyArtifacts (); + } + } From 4df1c160baa77df82bee12f52a2358441ec4b4ad Mon Sep 17 00:00:00 2001 From: Bitbucket Pipeline Date: Sun, 12 Apr 2020 22:53:15 +1200 Subject: [PATCH 2/5] Fix #358 NPE on site generation caused by null returned by deprecated MavenProject.getDependencyArtifacts() --- .../license/AbstractThirdPartyReportMojo.java | 324 +++++++++--------- .../LicensesXmlInsertVersionsMojo.java | 6 +- .../mojo/license/utils/MojoHelper.java | 160 +++++---- 3 files changed, 235 insertions(+), 255 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java index 284928ced..7c581c697 100755 --- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java @@ -22,19 +22,6 @@ * #L% */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeSet; - import org.apache.commons.collections.CollectionUtils; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -54,7 +41,6 @@ import org.codehaus.mojo.license.api.DependenciesTool; import org.codehaus.mojo.license.api.DependenciesToolException; import org.codehaus.mojo.license.api.MavenProjectDependenciesConfigurator; -import org.codehaus.mojo.license.api.ResolvedProjectDependencies; import org.codehaus.mojo.license.api.ThirdPartyDetails; import org.codehaus.mojo.license.api.ThirdPartyHelper; import org.codehaus.mojo.license.api.ThirdPartyTool; @@ -66,6 +52,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeSet; +import org.codehaus.mojo.license.api.ResolvedProjectDependencies; + /** * Base class for third-party reports. * @@ -73,9 +73,9 @@ * @since 1.1 */ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport - implements MavenProjectDependenciesConfigurator + implements MavenProjectDependenciesConfigurator { - private static final Logger LOG = LoggerFactory.getLogger ( AbstractThirdPartyReportMojo.class ); + private static final Logger LOG = LoggerFactory.getLogger( AbstractThirdPartyReportMojo.class ); // ---------------------------------------------------------------------- // Mojo Parameters @@ -86,16 +86,15 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.excludedScopes", defaultValue = "system" ) + @Parameter( property = "license.excludedScopes", defaultValue = "system" ) private String excludedScopes; /** - * A filter to include only some scopes, if let empty then all scopes will be - * used (no filter). + * A filter to include only some scopes, if let empty then all scopes will be used (no filter). * * @since 1.1 */ - @Parameter ( property = "license.includedScopes" ) + @Parameter( property = "license.includedScopes" ) private String includedScopes; /** @@ -103,16 +102,15 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.15 */ - @Parameter ( property = "license.excludedTypes" ) + @Parameter( property = "license.excludedTypes" ) private String excludedTypes; /** - * A filter to include only some types, if let empty then all types will be used - * (no filter). + * A filter to include only some types, if let empty then all types will be used (no filter). * * @since 1.15 */ - @Parameter ( property = "license.includedTypes" ) + @Parameter( property = "license.includedTypes" ) private String includedTypes; /** @@ -120,7 +118,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.excludedGroups" ) + @Parameter( property = "license.excludedGroups" ) private String excludedGroups; /** @@ -128,7 +126,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.includedGroups" ) + @Parameter( property = "license.includedGroups" ) private String includedGroups; /** @@ -136,7 +134,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.excludedArtifacts" ) + @Parameter( property = "license.excludedArtifacts" ) private String excludedArtifacts; /** @@ -144,16 +142,15 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.includedArtifacts" ) + @Parameter( property = "license.includedArtifacts" ) private String includedArtifacts; /** - * Include transitive dependencies when looking for missing licenses and - * downloading license files. + * Include transitive dependencies when looking for missing licenses and downloading license files. * * @since 1.1 */ - @Parameter ( property = "license.includeTransitiveDependencies", defaultValue = "true" ) + @Parameter( property = "license.includeTransitiveDependencies", defaultValue = "true" ) private boolean includeTransitiveDependencies; /** @@ -161,17 +158,16 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.13 */ - @Parameter ( property = "license.excludeTransitiveDependencies", defaultValue = "false" ) + @Parameter( property = "license.excludeTransitiveDependencies", defaultValue = "false" ) private boolean excludeTransitiveDependencies; /** - * If {@code true} both optional and non-optional dependencies will be included - * in the list of artifacts for creating the license report; otherwise only - * non-optional dependencies will be considered. + * If {@code true} both optional and non-optional dependencies will be included in the list of artifacts for + * creating the license report; otherwise only non-optional dependencies will be considered. * * @since 1.19 */ - @Parameter ( property = "license.includeOptional", defaultValue = "true" ) + @Parameter( property = "license.includeOptional", defaultValue = "true" ) boolean includeOptional; /** @@ -179,7 +175,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.useMissingFile", defaultValue = "false" ) + @Parameter( property = "license.useMissingFile", defaultValue = "false" ) private boolean useMissingFile; /** @@ -187,59 +183,53 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( property = "license.missingFile", defaultValue = "src/license/THIRD-PARTY.properties" ) + @Parameter( property = "license.missingFile", defaultValue = "src/license/THIRD-PARTY.properties" ) private File missingFile; /** - * The Url that holds the missing license dependency entries. This is an - * extension to {@link #missingFile}. If set then the entries that will be found - * at this URL will be added additionally to the entries of the missing - * file.
+ * The Url that holds the missing license dependency entries. This is an extension to {@link #missingFile}. + * If set then the entries that will be found at this URL will be added additionally to the entries of the + * missing file.
*
* NOTE:
- * the response of the URL endpoint must return content that matches the - * THIRD-PARTY.properties file! + * the response of the URL endpoint must return content that matches the THIRD-PARTY.properties file! * * @since 1.15 */ - @Parameter ( property = "license.missingFileUrl" ) + @Parameter( property = "license.missingFileUrl" ) String missingFileUrl; /** * A file containing the override license information for dependencies. - * Note: Specify either {@link #overrideUrl} (preferred) or - * {@link #overrideFile}. If none of these is specified, then - * {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against + * Note: Specify either {@link #overrideUrl} (preferred) or {@link #overrideFile}. + * If none of these is specified, then {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against * ${basedir} will be used if it exists. * * @since 1.11 * @deprecated Use {@link #overrideUrl} instead */ @Deprecated - @Parameter ( property = "license.overrideFile" ) + @Parameter( property = "license.overrideFile" ) private File overrideFile; /** - * A URL pointing at a property file with the override license information for - * dependencies. Note: Specify either {@link #overrideUrl} (preferred) or - * {@link #overrideFile}. If none of these is specified, then - * {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against + * A URL pointing at a property file with the override license information for dependencies. + * Note: Specify either {@link #overrideUrl} (preferred) or {@link #overrideFile}. + * If none of these is specified, then {@value LicenseMojoUtils#DEFAULT_OVERRIDE_THIRD_PARTY} resolved against * ${basedir} will be used if it exists. *

* An example of the file content: - * *

      * org.jboss.xnio--xnio-api--3.3.6.Final=The Apache Software License, Version 2.0
      * 
* * @since 1.17 */ - @Parameter ( property = "license.overrideUrl" ) + @Parameter( property = "license.overrideUrl" ) private String overrideUrl; /** - * A {@link URL} prepared either our of {@link #overrideFile} or - * {@link #overrideUrl} or the default value. + * A {@link URL} prepared either our of {@link #overrideFile} or {@link #overrideUrl} or the default value. * * @see LicenseMojoUtils#prepareThirdPartyOverrideUrl(URL, File, String, File) */ @@ -250,49 +240,45 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.0 */ - @Parameter ( property = "license.useRepositoryMissingFiles", defaultValue = "true" ) + @Parameter( property = "license.useRepositoryMissingFiles", defaultValue = "true" ) private boolean useRepositoryMissingFiles; /** * To merge licenses in final file. *

- * Each entry represents a merge (first license is main license to keep), - * licenses are separated by {@code |}. + * Each entry represents a merge (first license is main license to keep), licenses are separated by {@code |}. *

* Example : *

- * *

-     * <licenseMerges> <licenseMerge>The Apache Software License|Version
-     * 2.0,Apache License, Version 2.0</licenseMerge> </licenseMerges>
+     * <licenseMerges>
+     * <licenseMerge>The Apache Software License|Version 2.0,Apache License, Version 2.0</licenseMerge>
+     * </licenseMerges>
      * </pre>
      *
-     * Note: This option will be overridden by {@link #licenseMergesUrl} if
-     * it is used by command line.
-     *
+     * Note: This option will be overridden by {@link #licenseMergesUrl} if it is used by command line.
      * @since 1.0
      */
     @Parameter
     private List licenseMerges;
 
     /**
-     * Location of file with the merge licenses in order to be used by command line.
-     * Note: This option overrides {@link #licenseMerges}.
-     *
-     * @since 1.18
-     */
-    @Parameter ( property = "license.licenseMergesUrl" )
-    protected String licenseMergesUrl;
+      * Location of file with the merge licenses in order to be used by command line.
+      * Note: This option overrides {@link #licenseMerges}.
+      *
+      * @since 1.18
+      */
+     @Parameter( property = "license.licenseMergesUrl" )
+     protected String licenseMergesUrl;
 
     /**
-     * The output directory for the report. Note that this parameter is only
-     * evaluated if the goal is run directly from the command line. If the goal is
-     * run indirectly as part of a site generation, the output directory configured
-     * in the Maven Site Plugin is used instead.
+     * The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from
+     * the command line. If the goal is run indirectly as part of a site generation, the output directory configured in
+     * the Maven Site Plugin is used instead.
      *
      * @since 1.1
      */
-    @Parameter ( defaultValue = "${project.reporting.outputDirectory}", required = true )
+    @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true )
     private File outputDirectory;
 
     /**
@@ -303,18 +289,18 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
      *
      * @since 1.0
      */
-    @Parameter ( property = "license.verbose", defaultValue = "${maven.verbose}" )
+    @Parameter( property = "license.verbose", defaultValue = "${maven.verbose}" )
     private boolean verbose;
 
     /**
      * Encoding used to read and writes files.
      * 

- * Note: If nothing is filled here, we will use the system property - * {@code file.encoding}. + * Note: If nothing is filled here, we will use the system + * property {@code file.encoding}. * * @since 1.0 */ - @Parameter ( property = "license.encoding", defaultValue = "${project.build.sourceEncoding}" ) + @Parameter( property = "license.encoding", defaultValue = "${project.build.sourceEncoding}" ) private String encoding; /** @@ -322,7 +308,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport * * @since 1.1 */ - @Parameter ( defaultValue = "${project}", readonly = true ) + @Parameter( defaultValue = "${project}", readonly = true ) private MavenProject project; // ---------------------------------------------------------------------- @@ -362,9 +348,7 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport private ThirdPartyTool thirdPartyTool; /** - * A URL returning a plain text file that contains include/exclude artifact - * filters in the following format: - * + * A URL returning a plain text file that contains include/exclude artifact filters in the following format: *

      * {@code
      * # this is a comment
@@ -376,12 +360,11 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
      * exclude scope system
      * include type jar
      * exclude type war
-     * }
-     * 
+ * }
* * @since 1.18 */ - @Parameter ( property = "license.artifactFiltersUrl" ) + @Parameter( property = "license.artifactFiltersUrl" ) private String artifactFiltersUrl; private ArtifactFilters artifactFilters; @@ -390,9 +373,10 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport // Protected Abstract Methods // ---------------------------------------------------------------------- - protected abstract Collection createThirdPartyDetails () throws IOException, - ThirdPartyToolException, ProjectBuildingException, MojoFailureException, InvalidDependencyVersionException, - ArtifactNotFoundException, ArtifactResolutionException, DependenciesToolException, MojoExecutionException; + protected abstract Collection createThirdPartyDetails() + throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, + InvalidDependencyVersionException, ArtifactNotFoundException, ArtifactResolutionException, + DependenciesToolException, MojoExecutionException; // ---------------------------------------------------------------------- // AbstractMavenReport Implementation @@ -401,21 +385,20 @@ protected abstract Collection createThirdPartyDetails () thro /** * Method to initialize the mojo before doing any concrete actions. * - * Note: The method is invoked before the {@link #executeReport()} - * method. - * + * Note: The method is invoked before the {@link #executeReport()} method. * @throws IOException */ - protected void init () throws IOException + protected void init() + throws IOException { if ( licenseMergesUrl != null ) { - LOG.warn ( "" ); - LOG.warn ( "licenseMerges will be overridden by licenseMergesUrl." ); - LOG.warn ( "" ); - if ( UrlRequester.isStringUrl ( licenseMergesUrl ) ) + LOG.warn( "" ); + LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." ); + LOG.warn( "" ); + if ( UrlRequester.isStringUrl( licenseMergesUrl ) ) { - licenseMerges = Arrays.asList ( UrlRequester.getFromUrl ( licenseMergesUrl ).split ( "[\n\r]+" ) ); + licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) ); } } } @@ -423,61 +406,62 @@ protected void init () throws IOException /** * {@inheritDoc} */ - protected void executeReport ( Locale locale ) throws MavenReportException + protected void executeReport( Locale locale ) + throws MavenReportException { - resolvedOverrideUrl = LicenseMojoUtils.prepareThirdPartyOverrideUrl ( resolvedOverrideUrl, overrideFile, - overrideUrl, project.getBasedir () ); + resolvedOverrideUrl = LicenseMojoUtils.prepareThirdPartyOverrideUrl( resolvedOverrideUrl, overrideFile, + overrideUrl, project.getBasedir() ); Collection details; try { - init (); - details = createThirdPartyDetails (); + init(); + details = createThirdPartyDetails(); } catch ( IOException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( ThirdPartyToolException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( ProjectBuildingException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( MojoFailureException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( DependenciesToolException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } catch ( MojoExecutionException e ) { - throw new MavenReportException ( e.getMessage (), e ); + throw new MavenReportException( e.getMessage(), e ); } - ThirdPartyReportRenderer renderer = new ThirdPartyReportRenderer ( getSink (), i18n, getOutputName (), locale, - details ); - renderer.render (); + ThirdPartyReportRenderer renderer = + new ThirdPartyReportRenderer( getSink(), i18n, getOutputName(), locale, details ); + renderer.render(); } /** * {@inheritDoc} */ - protected MavenProject getProject () + protected MavenProject getProject() { return project; } @@ -485,20 +469,20 @@ protected MavenProject getProject () /** * {@inheritDoc} */ - protected String getOutputDirectory () + protected String getOutputDirectory() { - if ( !outputDirectory.isAbsolute () ) + if ( !outputDirectory.isAbsolute() ) { - outputDirectory = new File ( project.getBasedir (), outputDirectory.getPath () ); + outputDirectory = new File( project.getBasedir(), outputDirectory.getPath() ); } - return outputDirectory.getAbsolutePath (); + return outputDirectory.getAbsolutePath(); } /** * {@inheritDoc} */ - protected Renderer getSiteRenderer () + protected Renderer getSiteRenderer() { return siteRenderer; } @@ -506,17 +490,17 @@ protected Renderer getSiteRenderer () /** * {@inheritDoc} */ - public String getDescription ( Locale locale ) + public String getDescription( Locale locale ) { - return i18n.getString ( getOutputName (), locale, "report.description" ); + return i18n.getString( getOutputName(), locale, "report.description" ); } /** * {@inheritDoc} */ - public String getName ( Locale locale ) + public String getName( Locale locale ) { - return i18n.getString ( getOutputName (), locale, "report.title" ); + return i18n.getString( getOutputName(), locale, "report.title" ); } // ---------------------------------------------------------------------- @@ -526,7 +510,7 @@ public String getName ( Locale locale ) /** * {@inheritDoc} */ - public boolean isIncludeTransitiveDependencies () + public boolean isIncludeTransitiveDependencies() { return includeTransitiveDependencies; } @@ -534,19 +518,19 @@ public boolean isIncludeTransitiveDependencies () /** * {@inheritDoc} */ - public boolean isExcludeTransitiveDependencies () + public boolean isExcludeTransitiveDependencies() { return excludeTransitiveDependencies; } /** {@inheritDoc} */ - public ArtifactFilters getArtifactFilters () + public ArtifactFilters getArtifactFilters() { if ( artifactFilters == null ) { - artifactFilters = ArtifactFilters.of ( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts, - includedScopes, excludedScopes, includedTypes, excludedTypes, includeOptional, artifactFiltersUrl, - getEncoding () ); + artifactFilters = ArtifactFilters.of( includedGroups, excludedGroups, includedArtifacts, excludedArtifacts, + includedScopes, excludedScopes, includedTypes, excludedTypes, + includeOptional, artifactFiltersUrl , getEncoding() ); } return artifactFilters; } @@ -554,7 +538,7 @@ public ArtifactFilters getArtifactFilters () /** * {@inheritDoc} */ - public boolean isVerbose () + public boolean isVerbose() { return verbose; } @@ -563,93 +547,95 @@ public boolean isVerbose () // Protected Methods // ---------------------------------------------------------------------- - Collection createThirdPartyDetails ( MavenProject project, boolean loadArtifacts ) - throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, - DependenciesToolException, MojoExecutionException + Collection createThirdPartyDetails( MavenProject project, boolean loadArtifacts ) + throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, + DependenciesToolException, MojoExecutionException { ResolvedProjectDependencies loadedDependencies; if ( loadArtifacts ) { - loadedDependencies = new ResolvedProjectDependencies ( project.getArtifacts (), - MojoHelper.getDependencyArtifacts ( project ) ); + loadedDependencies = new ResolvedProjectDependencies( project.getArtifacts(), + MojoHelper.getDependencyArtifacts( project ) ); } else { - loadedDependencies = new ResolvedProjectDependencies ( getProject ().getArtifacts (), - MojoHelper.getDependencyArtifacts ( project ) ); + loadedDependencies = new ResolvedProjectDependencies( getProject().getArtifacts(), + MojoHelper.getDependencyArtifacts( project ) ); } - ThirdPartyHelper thirdPartyHelper = new DefaultThirdPartyHelper ( project, encoding, verbose, dependenciesTool, - thirdPartyTool, project.getRemoteArtifactRepositories (), project.getRemoteProjectRepositories () ); + ThirdPartyHelper thirdPartyHelper = + new DefaultThirdPartyHelper( project, encoding, verbose, + dependenciesTool, thirdPartyTool, + project.getRemoteArtifactRepositories(), project.getRemoteProjectRepositories() ); // 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 ); + LicenseMap licenseMap = thirdPartyHelper.createLicenseMap( projectDependencies ); // Get unsafe dependencies (dependencies with no license in pom) - SortedSet dependenciesWithNoLicense = thirdPartyHelper.getProjectsWithNoLicense ( licenseMap ); + SortedSet dependenciesWithNoLicense = thirdPartyHelper.getProjectsWithNoLicense( licenseMap ); // compute safe dependencies (with pom licenses) - Set dependenciesWithPomLicense = new TreeSet<> ( MojoHelper.newMavenProjectComparator () ); - dependenciesWithPomLicense.addAll ( projectDependencies.values () ); + Set dependenciesWithPomLicense = + new TreeSet<>( MojoHelper.newMavenProjectComparator() ); + dependenciesWithPomLicense.addAll( projectDependencies.values() ); - if ( CollectionUtils.isNotEmpty ( dependenciesWithNoLicense ) ) + if ( CollectionUtils.isNotEmpty( dependenciesWithNoLicense ) ) { // there is some unsafe dependencies, remove them from safe dependencies - dependenciesWithPomLicense.removeAll ( dependenciesWithNoLicense ); + dependenciesWithPomLicense.removeAll( dependenciesWithNoLicense ); if ( useMissingFile ) { - // Resolve unsafe dependencies using missing files, this will update licenseMap - // and unsafeDependencies - thirdPartyHelper.createUnsafeMapping ( licenseMap, missingFile, missingFileUrl, - useRepositoryMissingFiles, dependenciesWithNoLicense, projectDependencies, - loadedDependencies.getAllDependencies () ); + // Resolve unsafe dependencies using missing files, this will update licenseMap and unsafeDependencies + thirdPartyHelper.createUnsafeMapping( licenseMap, missingFile, missingFileUrl, + useRepositoryMissingFiles, dependenciesWithNoLicense, + projectDependencies, loadedDependencies.getAllDependencies() ); } } // LicenseMap is now complete, let's merge licenses if necessary - thirdPartyHelper.mergeLicenses ( licenseMerges, licenseMap ); + thirdPartyHelper.mergeLicenses( licenseMerges, licenseMap ); // Add override licenses - thirdPartyTool.overrideLicenses ( licenseMap, projectDependencies, encoding, resolvedOverrideUrl ); + thirdPartyTool.overrideLicenses( licenseMap, projectDependencies, encoding, resolvedOverrideUrl ); // let's build third party details for each dependencies - Collection details = new ArrayList<> (); + Collection details = new ArrayList<>(); - for ( Map.Entry entry : licenseMap.toDependencyMap ().entrySet () ) + for ( Map.Entry entry : licenseMap.toDependencyMap().entrySet() ) { - MavenProject dependency = entry.getKey (); - String[] licenses = entry.getValue (); - ThirdPartyDetails detail = new DefaultThirdPartyDetails ( dependency ); - details.add ( detail ); - if ( dependenciesWithPomLicense.contains ( dependency ) ) + MavenProject dependency = entry.getKey(); + String[] licenses = entry.getValue(); + ThirdPartyDetails detail = new DefaultThirdPartyDetails( dependency ); + details.add( detail ); + if ( dependenciesWithPomLicense.contains( dependency ) ) { // this is a pom licenses - detail.setPomLicenses ( licenses ); + detail.setPomLicenses( licenses ); } - else if ( !dependenciesWithNoLicense.contains ( dependency ) ) + else if ( !dependenciesWithNoLicense.contains( dependency ) ) { // this is a third-party licenses - detail.setThirdPartyLicenses ( licenses ); + detail.setThirdPartyLicenses( licenses ); } } return details; } /** {@inheritDoc} */ - public String getArtifactFiltersUrl () + public String getArtifactFiltersUrl() { return artifactFiltersUrl; } /** {@inheritDoc} */ - public String getEncoding () + public String getEncoding() { return encoding; } diff --git a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java index a6b5d6804..bfc7a37b6 100755 --- a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java @@ -140,10 +140,8 @@ public ArtifactFilters getArtifactFilters() } }; final Map resolvedDeps = new TreeMap(); - licensedArtifactResolver.loadProjectDependencies( - new ResolvedProjectDependencies( project.getArtifacts(), - MojoHelper.getDependencyArtifacts( project ) ), config, remoteRepositories, - resolvedDeps ); + licensedArtifactResolver.loadProjectDependencies( new ResolvedProjectDependencies( project.getArtifacts(), + MojoHelper.getDependencyArtifacts( project ) ), config, remoteRepositories, resolvedDeps ); final Map resolvedDepsMap = new HashMap<>( resolvedDeps.size() ); for ( LicensedArtifact dep : resolvedDeps.values() ) { diff --git a/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java b/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java index a0b79f509..3e6fd524f 100755 --- a/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java +++ b/src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java @@ -46,7 +46,7 @@ */ public class MojoHelper { - private static final Logger LOG = LoggerFactory.getLogger ( MojoHelper.class ); + private static final Logger LOG = LoggerFactory.getLogger( MojoHelper.class ); /** * Add the directory as a resource of the given project. @@ -56,10 +56,10 @@ public class MojoHelper * @param includes the includes of the resource * @return {@code true} if the resources was added (not already existing) */ - public static boolean addResourceDir ( File dir, MavenProject project, String... includes ) + public static boolean addResourceDir( File dir, MavenProject project, String... includes ) { - List resources = project.getResources (); - return addResourceDir ( dir, project, resources, includes ); + List resources = project.getResources(); + return addResourceDir( dir, project, resources, includes ); } /** @@ -71,23 +71,23 @@ public static boolean addResourceDir ( File dir, MavenProject project, String... * @param includes includes of the new resources * @return {@code true} if the resource was added (not already existing) */ - public static boolean addResourceDir ( File dir, MavenProject project, List resources, String... includes ) + public static boolean addResourceDir( File dir, MavenProject project, List resources, String... includes ) { - String newresourceDir = dir.getAbsolutePath (); + String newresourceDir = dir.getAbsolutePath(); boolean shouldAdd = true; for ( Object o : resources ) { Resource r = (Resource) o; - if ( !r.getDirectory ().equals ( newresourceDir ) ) + if ( !r.getDirectory().equals( newresourceDir ) ) { continue; } for ( String i : includes ) { - if ( !r.getIncludes ().contains ( i ) ) + if ( !r.getIncludes().contains( i ) ) { - r.addInclude ( i ); + r.addInclude( i ); } } shouldAdd = false; @@ -95,72 +95,70 @@ public static boolean addResourceDir ( File dir, MavenProject project, List r } if ( shouldAdd ) { - Resource r = new Resource (); - r.setDirectory ( newresourceDir ); + Resource r = new Resource(); + r.setDirectory( newresourceDir ); for ( String i : includes ) { - if ( !r.getIncludes ().contains ( i ) ) + if ( !r.getIncludes().contains( i ) ) { - r.addInclude ( i ); + r.addInclude( i ); } } - project.addResource ( r ); + project.addResource( r ); } return shouldAdd; } - public static Comparator newMavenProjectComparator () + public static Comparator newMavenProjectComparator() { - return new Comparator () + return new Comparator() { /** * {@inheritDoc} */ - public int compare ( MavenProject o1, MavenProject o2 ) + public int compare( MavenProject o1, MavenProject o2 ) { - String id1 = getArtifactId ( o1.getArtifact () ); - String id2 = getArtifactId ( o2.getArtifact () ); - return id1.compareTo ( id2 ); + String id1 = getArtifactId( o1.getArtifact() ); + String id2 = getArtifactId( o2.getArtifact() ); + return id1.compareTo( id2 ); } }; } - public static Comparator newMavenProjectComparatorByName () + public static Comparator newMavenProjectComparatorByName() { - return new Comparator () + return new Comparator() { /** * {@inheritDoc} */ - public int compare ( MavenProject o1, MavenProject o2 ) + public int compare( MavenProject o1, MavenProject o2 ) { - String id1 = getProjectName ( o1 ); - String id2 = getProjectName ( o2 ); - return id1.compareToIgnoreCase ( id2 ); + String id1 = getProjectName( o1 ); + String id2 = getProjectName( o2 ); + return id1.compareToIgnoreCase( id2 ); } }; } - protected static final double[] TIME_FACTORS = - { 1000000, 1000, 60, 60, 24 }; + protected static final double[] TIME_FACTORS = { 1000000, 1000, 60, 60, 24 }; - protected static final String[] TIME_UNITES = - { "ns", "ms", "s", "m", "h", "d" }; + protected static final String[] TIME_UNITES = { "ns", "ms", "s", "m", "h", "d" }; - public static String convertTime ( long value ) + public static String convertTime( long value ) { - return convert ( value, TIME_FACTORS, TIME_UNITES ); + return convert( value, TIME_FACTORS, TIME_UNITES ); } - public static String convert ( long value, double[] factors, String[] unites ) + public static String convert( long value, double[] factors, String[] unites ) { - long sign = value == 0 ? 1 : value / Math.abs ( value ); + long sign = value == 0 ? 1 : value / Math.abs( value ); int i = 0; - double tmp = Math.abs ( value ); + double tmp = Math.abs( value ); while ( i < factors.length && i < unites.length && tmp > factors[i] ) { tmp = tmp / factors[i++]; @@ -168,7 +166,7 @@ public static String convert ( long value, double[] factors, String[] unites ) tmp *= sign; String result; - result = MessageFormat.format ( "{0,number,0.###}{1}", tmp, unites[i] ); + result = MessageFormat.format( "{0,number,0.###}{1}", tmp, unites[i] ); return result; } @@ -179,102 +177,100 @@ public static String convert ( long value, double[] factors, String[] unites ) * @param suffix suffix to add * @return the new url */ - public static URL getUrl ( URL baseUrl, String suffix ) + public static URL getUrl( URL baseUrl, String suffix ) { - String url = baseUrl.toString () + "/" + suffix; + String url = baseUrl.toString() + "/" + suffix; try { - return new URL ( url ); + return new URL( url ); } catch ( MalformedURLException ex ) { - throw new IllegalArgumentException ( "could not obtain url " + url, ex ); + throw new IllegalArgumentException( "could not obtain url " + url, ex ); } } - public static String getArtifactId ( Artifact artifact ) + public static String getArtifactId( Artifact artifact ) { - StringBuilder sb = new StringBuilder (); - sb.append ( artifact.getGroupId () ); - sb.append ( "--" ); - sb.append ( artifact.getArtifactId () ); - sb.append ( "--" ); - sb.append ( artifact.getVersion () ); - return sb.toString (); + StringBuilder sb = new StringBuilder(); + sb.append( artifact.getGroupId() ); + sb.append( "--" ); + sb.append( artifact.getArtifactId() ); + sb.append( "--" ); + sb.append( artifact.getVersion() ); + return sb.toString(); } - public static String getArtifactName ( MavenProject project ) + public static String getArtifactName( MavenProject project ) { - StringBuilder sb = new StringBuilder (); - if ( project.getName ().startsWith ( "Unnamed -" ) ) + StringBuilder sb = new StringBuilder(); + if ( project.getName().startsWith( "Unnamed -" ) ) { // as in Maven 3, let's use the artifact id - sb.append ( project.getArtifactId () ); + sb.append( project.getArtifactId() ); } else { - sb.append ( project.getName () ); + sb.append( project.getName() ); } - sb.append ( " (" ); - sb.append ( project.getGroupId () ); - sb.append ( ":" ); - sb.append ( project.getArtifactId () ); - sb.append ( ":" ); - sb.append ( project.getVersion () ); - sb.append ( " - " ); - String url = project.getUrl (); - sb.append ( url == null ? "no url defined" : url ); - sb.append ( ")" ); + sb.append( " (" ); + sb.append( project.getGroupId() ); + sb.append( ":" ); + sb.append( project.getArtifactId() ); + sb.append( ":" ); + sb.append( project.getVersion() ); + sb.append( " - " ); + String url = project.getUrl(); + sb.append( url == null ? "no url defined" : url ); + sb.append( ")" ); - return sb.toString (); + return sb.toString(); } - public static String getProjectName ( MavenProject project ) + public static String getProjectName( MavenProject project ) { String sb; - if ( project.getName ().startsWith ( "Unnamed" ) ) + if ( project.getName().startsWith( "Unnamed" ) ) { // as in Maven 3, let's use the artifact id - sb = project.getArtifactId (); + sb = project.getArtifactId(); } else { - sb = project.getName (); + sb = project.getName(); } return sb; } - public static List getParams ( String params ) + public static List getParams( String params ) { - String[] split = params == null ? new String[0] : params.split ( "," ); - return Arrays.asList ( split ); + String[] split = params == null ? new String[0] : params.split( "," ); + return Arrays.asList( split ); } /** * {@link MavenProject#getDependencyArtifacts()} is deprecated. * *

- * This method checks if the dependency artifacts is {@code null} and returns an - * empty {@code HashSet} to avoid the {@code NullPointerException}s caused by - * the {@link MavenProject#getDependencyArtifacts()} returning {@code null}. + * This method checks if the dependency artifacts is {@code null} and returns an empty {@code HashSet} to avoid the + * {@code NullPointerException}s caused by the {@link MavenProject#getDependencyArtifacts()} returning {@code null}. *

* * @param project the MavenProject to retrieve artifacts from * @return a HashSet of dependencies or an empty set */ - public static Set getDependencyArtifacts ( MavenProject project ) + public static Set getDependencyArtifacts( MavenProject project ) { - if ( project == null || project.getDependencyArtifacts () == null ) + if ( project == null || project.getDependencyArtifacts() == null ) { - LOG.warn ( "" ); - LOG.warn ( "Non-transitive dependencies cannot be found. " ); - LOG.warn ( "" ); - return new HashSet (); + LOG.warn( "" ); + LOG.warn( "Non-transitive dependencies cannot be found. " ); + LOG.warn( "" ); + return new HashSet(); } - return project.getDependencyArtifacts (); + return project.getDependencyArtifacts(); } - } From e435ad8ab95eb9ffafe77d01a82bb500b0da388d Mon Sep 17 00:00:00 2001 From: Dermot Butterfield Date: Mon, 22 Nov 2021 09:55:48 +1300 Subject: [PATCH 3/5] aligning wrapped text with previous pattern --- .../codehaus/mojo/license/AbstractThirdPartyReportMojo.java | 4 ++-- .../java/org/codehaus/mojo/license/AddThirdPartyMojo.java | 4 ++-- .../codehaus/mojo/license/AggregateDownloadLicensesMojo.java | 5 +++-- .../codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java index 7c581c697..190117ef6 100755 --- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java @@ -555,8 +555,8 @@ Collection createThirdPartyDetails( MavenProject project, boo ResolvedProjectDependencies loadedDependencies; if ( loadArtifacts ) { - loadedDependencies = new ResolvedProjectDependencies( project.getArtifacts(), - MojoHelper.getDependencyArtifacts( project ) ); + loadedDependencies = + new ResolvedProjectDependencies( project.getArtifacts(), MojoHelper.getDependencyArtifacts( project ) ); } else { diff --git a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java index 367243bde..206d6b4a3 100755 --- a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java @@ -241,8 +241,8 @@ protected ResolvedProjectDependencies resolveDependencyArtifacts() throws Depend } if ( isAggregatorBuild ) { - dependencyArtifacts = new ResolvedProjectDependencies( project.getArtifacts(), - MojoHelper.getDependencyArtifacts( project ) ); + dependencyArtifacts = + new ResolvedProjectDependencies( project.getArtifacts(), MojoHelper.getDependencyArtifacts( project ) ); } else { diff --git a/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java index 86bda94d0..9ec0b68c9 100755 --- a/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AggregateDownloadLicensesMojo.java @@ -115,8 +115,9 @@ protected Map getDependencies() for ( MavenProject p : reactorProjects ) { - licensedArtifactResolver.loadProjectDependencies( new ResolvedProjectDependencies( p.getArtifacts(), - MojoHelper.getDependencyArtifacts( p ) ), this, remoteRepositories, result ); + licensedArtifactResolver.loadProjectDependencies( new ResolvedProjectDependencies( p.getArtifacts(), + MojoHelper.getDependencyArtifacts( p ) ), + this, remoteRepositories, result ); } return result; } diff --git a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java index bfc7a37b6..a215f77e8 100755 --- a/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/license/LicensesXmlInsertVersionsMojo.java @@ -140,8 +140,9 @@ public ArtifactFilters getArtifactFilters() } }; final Map resolvedDeps = new TreeMap(); - licensedArtifactResolver.loadProjectDependencies( new ResolvedProjectDependencies( project.getArtifacts(), - MojoHelper.getDependencyArtifacts( project ) ), config, remoteRepositories, resolvedDeps ); + licensedArtifactResolver.loadProjectDependencies( + new ResolvedProjectDependencies( project.getArtifacts(), MojoHelper.getDependencyArtifacts( project ) ), + config, remoteRepositories, resolvedDeps ); final Map resolvedDepsMap = new HashMap<>( resolvedDeps.size() ); for ( LicensedArtifact dep : resolvedDeps.values() ) { From d501b53e66bae123a97ec0a97e50d63171d30248 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 2 Jul 2023 16:46:08 +0200 Subject: [PATCH 4/5] Fix CRLF --- .mvn/wrapper/maven-wrapper.jar | Bin 48336 -> 48335 bytes mvnw.cmd | 322 +++++++++--------- .../src/files/properties/test.crlf.sh | 4 +- .../META-INF/licenses/epl_only_v2/header.txt | 8 +- .../META-INF/licenses/epl_v2/header.txt | 20 +- 5 files changed, 177 insertions(+), 177 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 08ebbb67f088c53eac9a4e2cb019b93f69a1e49c..a817247a6a026c5d3ff383cf7df71ada27f556cf 100755 GIT binary patch delta 14 Wcmccclj;0VrVX#fHop;jvJ?P8D+q-E delta 16 YcmX^Alj*`wrVX#f7&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% -) else ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" - echo Finished downloading %WRAPPER_JAR% -) -@REM End of extension - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/src/it/update-file-header-test-mojo/src/files/properties/test.crlf.sh b/src/it/update-file-header-test-mojo/src/files/properties/test.crlf.sh index aefc77241..0711e4cb1 100644 --- a/src/it/update-file-header-test-mojo/src/files/properties/test.crlf.sh +++ b/src/it/update-file-header-test-mojo/src/files/properties/test.crlf.sh @@ -1,3 +1,3 @@ -#!/bin/sh - +#!/bin/sh + ls ~/* \ No newline at end of file diff --git a/src/main/resources/META-INF/licenses/epl_only_v2/header.txt b/src/main/resources/META-INF/licenses/epl_only_v2/header.txt index 7248abcf3..fe21c469e 100644 --- a/src/main/resources/META-INF/licenses/epl_only_v2/header.txt +++ b/src/main/resources/META-INF/licenses/epl_only_v2/header.txt @@ -1,5 +1,5 @@ -This program and the accompanying materials are made -available under the terms of the Eclipse Public License 2.0 -which is available at https://www.eclipse.org/legal/epl-2.0/ - +This program and the accompanying materials are made +available under the terms of the Eclipse Public License 2.0 +which is available at https://www.eclipse.org/legal/epl-2.0/ + SPDX-License-Identifier: EPL-2.0 \ No newline at end of file diff --git a/src/main/resources/META-INF/licenses/epl_v2/header.txt b/src/main/resources/META-INF/licenses/epl_v2/header.txt index 9f1b8cc7d..494345104 100644 --- a/src/main/resources/META-INF/licenses/epl_v2/header.txt +++ b/src/main/resources/META-INF/licenses/epl_v2/header.txt @@ -1,11 +1,11 @@ -This program and the accompanying materials are made available under the -terms of the Eclipse Public License 2.0 which is available at -http://www.eclipse.org/legal/epl-2.0. - -This Source Code may also be made available under the following Secondary -Licenses when the conditions for such availability set forth in the Eclipse -Public License, v. 2.0 are satisfied: GNU General Public License, version 2 -with the GNU Classpath Exception which is -available at https://www.gnu.org/software/classpath/license.html. - +This program and the accompanying materials are made available under the +terms of the Eclipse Public License 2.0 which is available at +http://www.eclipse.org/legal/epl-2.0. + +This Source Code may also be made available under the following Secondary +Licenses when the conditions for such availability set forth in the Eclipse +Public License, v. 2.0 are satisfied: GNU General Public License, version 2 +with the GNU Classpath Exception which is +available at https://www.gnu.org/software/classpath/license.html. + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 \ No newline at end of file From d249b42504434a89bd2b282889f1bea1f7df8a74 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 3 Jul 2023 09:50:20 +0200 Subject: [PATCH 5/5] Cleanups in IT --- src/it/ISSUE-358/child-1/pom.xml | 2 +- src/it/ISSUE-358/invoker.properties | 1 - src/it/ISSUE-358/pom.xml | 17 +++++------------ 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/it/ISSUE-358/child-1/pom.xml b/src/it/ISSUE-358/child-1/pom.xml index 6a94c1b55..eba09b602 100755 --- a/src/it/ISSUE-358/child-1/pom.xml +++ b/src/it/ISSUE-358/child-1/pom.xml @@ -8,4 +8,4 @@ 0.0.1-SNAPSHOT child-1 - \ No newline at end of file + diff --git a/src/it/ISSUE-358/invoker.properties b/src/it/ISSUE-358/invoker.properties index c586cbd63..ed68a8b63 100755 --- a/src/it/ISSUE-358/invoker.properties +++ b/src/it/ISSUE-358/invoker.properties @@ -1,2 +1 @@ invoker.goals=clean site -invoker.failureBehavior=fail-fast \ No newline at end of file diff --git a/src/it/ISSUE-358/pom.xml b/src/it/ISSUE-358/pom.xml index 79b8b32f6..476bebd6a 100755 --- a/src/it/ISSUE-358/pom.xml +++ b/src/it/ISSUE-358/pom.xml @@ -17,24 +17,17 @@ org.codehaus.mojo license-maven-plugin - @pom.version@ + @project.version@ org.apache.maven.plugins maven-site-plugin - 3.9.0 - - - org.apache.maven.doxia - doxia-site-renderer - 1.9.2 - - + @maven-site-plugin.version@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.0.0 + @maven-project-info-reports-plugin.version@ @@ -44,8 +37,8 @@ org.codehaus.mojo license-maven-plugin - @pom.version@ + @project.version@ - \ No newline at end of file +