Skip to content

Commit

Permalink
Merge pull request #262 from elballa/feature/253
Browse files Browse the repository at this point in the history
Fix #253 Add licenseMergesUrl also in report goals
  • Loading branch information
ppalaga committed Feb 19, 2019
2 parents d53c2eb + a91eb3d commit 9ae1c6b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
<name>License Test :: aggregate-third-party-report - child 1</name>

<dependencies>

<!-- use license 'The Apache Software License, Version 2.0' -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
# #L%
###
invoker.goals=clean license:aggregate-third-party-report
invoker.goals=clean license:aggregate-third-party-report@nourl license:aggregate-third-party-report@url
invoker.failureBehavior=fail-fast
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APACHE|The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache Public License 2.0
24 changes: 18 additions & 6 deletions src/it/aggregate-third-party-report-merge-licences/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.generateBundle>true</license.generateBundle>
<license.verbose>true</license.verbose>
</properties>

Expand All @@ -55,11 +54,24 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<licenseMerges>
<licenseMerge>The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
</licenseMerges>
</configuration>
<executions>
<execution>
<id>nourl</id>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}/nourl</outputDirectory>
<licenseMerges>
<licenseMerge>The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
</licenseMerges>
</configuration>
</execution>
<execution>
<id>url</id>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}/url</outputDirectory>
<licenseMergesUrl>${project.baseUri}license.merges</licenseMergesUrl>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* #L%
*/

file = new File(basedir, 'target/site/aggregate-third-party-report.html');
file = new File(basedir, 'target/site/nourl/aggregate-third-party-report.html');
assert file.exists();
content = file.text;
assert !content.contains('the project has no dependencies.');
Expand All @@ -30,4 +30,17 @@ assert content.contains('<a href="#com.jhlabs:filters:2.0.235">com.jhlabs:filter
assert content.contains('<a href="#org.sonatype.plexus:plexus-cipher:1.4">org.sonatype.plexus:plexus-cipher:1.4</a>');
assert content.contains('<td>The Apache Software License, Version 2.0</td>');
assert !content.contains('<td>Apache License, Version 2.0</td>');
assert !content.contains('<td>Apache Public License 2.0</td>');
assert !content.contains('<td>Apache Public License 2.0</td>');

file = new File(basedir, 'target/site/url/aggregate-third-party-report.html');
assert file.exists();
content = file.text;
assert !content.contains('the project has no dependencies.');
assert !content.contains('/third-party-report.html#');
assert content.contains('<a href="#commons-logging:commons-logging:1.1.1">commons-logging:commons-logging:1.1.1</a>');
assert content.contains('<a href="#com.jhlabs:filters:2.0.235">com.jhlabs:filters:2.0.235</a>');
assert content.contains('<a href="#org.sonatype.plexus:plexus-cipher:1.4">org.sonatype.plexus:plexus-cipher:1.4</a>');
assert content.contains('<td>APACHE</td>');
assert !content.contains('<td>The Apache Software License, Version 2.0</td>');
assert !content.contains('<td>Apache License, Version 2.0</td>');
assert !content.contains('<td>Apache Public License 2.0</td>');
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
import org.codehaus.mojo.license.api.ThirdPartyToolException;
import org.codehaus.mojo.license.model.LicenseMap;
import org.codehaus.mojo.license.utils.MojoHelper;
import org.codehaus.mojo.license.utils.UrlRequester;
import org.codehaus.plexus.i18n.I18N;

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;
Expand Down Expand Up @@ -242,11 +244,21 @@ public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
* &lt;/licenseMerges&gt;
* &lt;/pre&gt;
*
* <b>Note:</b> This option will be overridden by {@link #licenseMergesUrl} if it is used by command line.
* @since 1.0
*/
@Parameter
private List<String> licenseMerges;

/**
* Location of file with the merge licenses in order to be used by command line.
* <b>Note:</b> 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
Expand Down Expand Up @@ -344,6 +356,27 @@ protected abstract Collection<ThirdPartyDetails> createThirdPartyDetails()
// AbstractMavenReport Implementation
// ----------------------------------------------------------------------

/**
* Method to initialize the mojo before doing any concrete actions.
*
* <b>Note:</b> The method is invoked before the {@link #executeReport()} method.
* @throws IOException
*/
protected void init()
throws IOException
{
if ( licenseMergesUrl != null )
{
getLog().warn( "" );
getLog().warn( "licenseMerges will be overridden by licenseMergesUrl." );
getLog().warn( "" );
if ( UrlRequester.isStringUrl( licenseMergesUrl ) )
{
licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ) );
}
}
}

/**
* {@inheritDoc}
*/
Expand All @@ -357,6 +390,7 @@ protected void executeReport( Locale locale )

try
{
init();
details = createThirdPartyDetails();
}
catch ( IOException e )
Expand Down

0 comments on commit 9ae1c6b

Please sign in to comment.