Skip to content

Commit

Permalink
Fix #265 Let AbstractDownloadLicensesMojo.licensesConfigFile match by…
Browse files Browse the repository at this point in the history
… regular expressions
  • Loading branch information
ppalaga committed Feb 20, 2019
1 parent 9ae1c6b commit 003a107
Show file tree
Hide file tree
Showing 27 changed files with 1,240 additions and 299 deletions.

This file was deleted.

14 changes: 0 additions & 14 deletions src/it/download-licenses-configured-alt-location/licenses.xml

This file was deleted.

40 changes: 0 additions & 40 deletions src/it/download-licenses-configured-alt-location/pom.xml

This file was deleted.

48 changes: 0 additions & 48 deletions src/it/download-licenses-configured-alt-location/postbuild.groovy

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/it/download-licenses-configured/invoker.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
invoker.goals = clean license:download-licenses
invoker.goals = clean validate
39 changes: 39 additions & 0 deletions src/it/download-licenses-configured/licenses-pre-1.18.expected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
<licenses>
<license>
<name>Public Domain</name>
</license>
</licenses>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
<licenses>
<license>
<name>BSD 3-Clause ASM</name>
<url>https://gitlab.ow2.org/asm/asm/raw/ASM_3_1_MVN/LICENSE.txt</url>
<file>bsd 3-clause asm - license.txt</file>
</license>
</licenses>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0</version>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<file>apache license 2.0 - license-2.0.txt</file>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
<licenses>
<license>
<name>Public Domain</name>
</license>
</licenses>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
<licenses>
<license>
<name>BSD 3-Clause ASM</name>
<url>https://gitlab.ow2.org/asm/asm/raw/ASM_3_1_MVN/LICENSE.txt</url>
<file>bsd 3-clause asm - license.txt</file>
</license>
</licenses>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0</version>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<file>apache license 2.0 - license-2.0.txt</file>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
31 changes: 31 additions & 0 deletions src/it/download-licenses-configured/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
<artifactId>commons-logging</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>
</dependencies>

<build>
Expand All @@ -29,9 +39,30 @@
<version>@pom.version@</version>
<executions>
<execution>
<id>pre-1.18</id>
<phase>validate</phase>
<goals>
<goal>download-licenses</goal>
</goals>
<configuration>
<licensesConfigFile>${basedir}/src/license/licenses-config-pre-1.18.xml</licensesConfigFile>
<licensesOutputDirectory>${project.build.directory}/pre-1.18/licenses</licensesOutputDirectory>
<licensesOutputFile>${project.build.directory}/pre-1.18/licenses.xml</licensesOutputFile>
<sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
</configuration>
</execution>
<execution>
<id>since-1.18</id>
<phase>validate</phase>
<goals>
<goal>download-licenses</goal>
</goals>
<configuration>
<licensesConfigFile>${basedir}/src/license/licenses-config-since-1.18.xml</licensesConfigFile>
<licensesOutputDirectory>${project.build.directory}/since-1.18/licenses</licensesOutputDirectory>
<licensesOutputFile>${project.build.directory}/since-1.18/licenses.xml</licensesOutputFile>
<sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
66 changes: 39 additions & 27 deletions src/it/download-licenses-configured/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,42 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
def assertExistsFile(file)
{
if ( !file.exists() || file.isDirectory() )
{
println(file.getAbsolutePath() + " file is missing or a directory.")
assert false
}
assert true
}

def assertContains(file, content, expected)
{
if ( !content.contains(expected) )
{
println(expected + " was not found in file [" + file + "]\n :" + content)
assert false
}
assert true
}

file = new File(basedir, 'target/generated-resources/licenses/apache license 2.0 - license-2.0.txt');
assertExistsFile(file);

file = new File(basedir, 'target/generated-resources/licenses.xml');
assertExistsFile(file);

return true;

import java.nio.file.Path;
import java.nio.file.Files;

final Path basePath = basedir.toPath()

return {
final String id = 'pre-1.18'
final Path outputBase = basePath.resolve('target/' + id)

final Path asl2 = outputBase.resolve('licenses/apache license 2.0 - license-2.0.txt')
assert Files.exists(asl2)
assert asl2.text.contains('Version 2.0, January 2004')

final Path bsdAsm = outputBase.resolve('licenses/bsd 3-clause asm - license.txt')
assert Files.exists(bsdAsm)
assert bsdAsm.text.contains('ASM: a very small and fast Java bytecode manipulation framework')

final Path expectedLicensesXml = basePath.resolve('licenses-'+ id +'.expected.xml')
final Path licensesXml = outputBase.resolve('licenses.xml')
assert expectedLicensesXml.text.equals(licensesXml.text)
return true
}() && {
final String id = 'since-1.18'
final Path outputBase = basePath.resolve('target/' + id)

final Path asl2 = outputBase.resolve('licenses/apache license 2.0 - license-2.0.txt')
assert Files.exists(asl2)
assert asl2.text.contains('Version 2.0, January 2004')

final Path bsdAsm = outputBase.resolve('licenses/bsd 3-clause asm - license.txt')
assert Files.exists(bsdAsm)
assert bsdAsm.text.contains('ASM: a very small and fast Java bytecode manipulation framework')

final Path expectedLicensesXml = basePath.resolve('licenses-'+ id +'.expected.xml')
final Path licensesXml = outputBase.resolve('licenses.xml')
assert expectedLicensesXml.text.equals(licensesXml.text)
return true
}()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<licenseSummary>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<licenses approved="true" />
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<licenses>
<license>
<name>BSD 3-Clause ASM</name>
<url>https://gitlab.ow2.org/asm/asm/raw/ASM_3_1_MVN/LICENSE.txt</url>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>\Qcommons-logging</groupId>
<artifactId>\Qcommons-logging</artifactId>
<matchLicenses>
<!-- match empty license list -->
</matchLicenses>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</dependency>
<dependency>
<groupId>\Qaopalliance\E</groupId>
<artifactId>\Qaopalliance\E</artifactId>
<matchLicenses>
<license>
<name>\QPublic Domain\E</name>
</license>
</matchLicenses>
<licenses approved="true" />
</dependency>
<dependency>
<groupId>\Qasm\E</groupId>
<artifactId>\Qasm\E</artifactId>
<matchLicenses>
<!-- match empty license list -->
</matchLicenses>
<licenses>
<license>
<name>BSD 3-Clause ASM</name>
<url>https://gitlab.ow2.org/asm/asm/raw/ASM_3_1_MVN/LICENSE.txt</url>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>

0 comments on commit 003a107

Please sign in to comment.