Skip to content

Commit

Permalink
Merge pull request #304 from elballa/feature/303
Browse files Browse the repository at this point in the history
Fix #303 Aggregate-add-third-party mojo is not including optional dependencies by default
  • Loading branch information
ppalaga committed Mar 2, 2019
2 parents 1a890f1 + 487daa1 commit 98b26ee
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/it/aggregate-add-third-party-include-optional/child1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
License Maven Plugin
%%
Copyright (C) 2019 Alessandro Ballarin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Lesser Public License for more details.
You should have received a copy of the GNU General Lesser Public
License along with this program. If not, see
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.codehaus.mojo.license.test</groupId>
<artifactId>test-aggregate-add-third-party-include-optional</artifactId>
<version>1.0</version>
</parent>
<artifactId>test-aggregate-add-third-party-include-optional-child1</artifactId>

<dependencies>

<!-- use license 'Apache License, Version 2.0' -->
<dependency>
<groupId>com.jhlabs</groupId>
<artifactId>filters</artifactId>
<version>2.0.235</version>
</dependency>

<!-- use license 'The Apache Software License, Version 2.0' -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<optional>true</optional>
</dependency>

</dependencies>

</project>


Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
###
# #%L
# License Maven Plugin
# %%
# Copyright (C) 2019 Alessandro Ballarin
# %%
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Lesser Public License for more details.
#
# You should have received a copy of the GNU General Lesser Public
# License along with this program. If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
# #L%
###
invoker.goals=clean license:aggregate-add-third-party
invoker.failureBehavior=fail-at-end
80 changes: 80 additions & 0 deletions src/it/aggregate-add-third-party-include-optional/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
License Maven Plugin
%%
Copyright (C) 2019 Alessandro Ballarin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Lesser Public License for more details.
You should have received a copy of the GNU General Lesser Public
License along with this program. If not, see
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo.license.test</groupId>
<artifactId>test-aggregate-add-third-party-include-optional</artifactId>
<version>1.0</version>

<modules>
<module>child1</module>
</modules>

<name>Test: aggregate-add-third-party-include-optional</name>

<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<executions>
<execution>
<id>include-optional</id>
<goals>
<goal>aggregate-add-third-party</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>


29 changes: 29 additions & 0 deletions src/it/aggregate-add-third-party-include-optional/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* #%L
* License Maven Plugin
* %%
* Copyright (C) 2019 Alessandro Ballarin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt');
assert file.exists();
content = file.text;

assert !content.contains('the project has no dependencies.');
assert content.contains('com.jhlabs:filters:2.0.235');
assert content.contains('commons-logging:commons-logging:1.1.1');
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ void initFromMojo( AggregatorAddThirdPartyMojo mojo, MavenProject mavenProject,
deployMissingFile = mojo.deployMissingFile;
useRepositoryMissingFiles = mojo.useRepositoryMissingFiles;
acceptPomPackaging = mojo.acceptPomPackaging;
includeOptional = mojo.includeOptional;
excludedScopes = mojo.excludedScopes;
includedScopes = mojo.includedScopes;
excludedGroups = mojo.excludedGroups;
Expand Down

0 comments on commit 98b26ee

Please sign in to comment.