Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #240 Introduce url -> file name mapping #241

Merged
merged 2 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/it/ISSUE-154/expected_licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>Public Domain</name>
<url>http://repository.jboss.org/licenses/cc0-1.0.txt</url>
<distribution>repo</distribution>
<file>public domain - cc0-1.0.txt</file>
<file>public domain - alternative.txt</file>
</license>
</licenses>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/it/ISSUE-154/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ file = new File(basedir, 'target/licenses.xml');
expectedFile = new File(basedir, 'expected_licenses.xml');
assert expectedFile.text.equals(file.text);

licenseFile = new File(basedir, 'target/generated-resources/licenses/public domain - cc0-1.0.txt');
licenseFile = new File(basedir, 'target/generated-resources/licenses/public domain - alternative.txt');
expectedLicenseTxt = new File(basedir, 'src/alternative.txt');
assert expectedLicenseTxt.text.equals(licenseFile.text);
2 changes: 1 addition & 1 deletion src/it/MLICENSE-24/invoker.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
invoker.goals=clean validate
invoker.goals=clean validate -X -e
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = clean license:download-licenses -Dlicense.forceDownload=true -Dlicense.errorRemedy=xmlOutput -Dlicense.sortByGroupIdAndArtifactId=true -e -X
invoker.buildResult=failure
67 changes: 67 additions & 0 deletions src/it/download-licenses-file-names-bad-sha1-force/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<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</groupId>
<artifactId>download-licenses-file-names-bad-sha1</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Integration Test</name>
<url>http://maven.apache.org</url>
<description>
Check -Dlicense.errorRemedy=xmlOutput -Dlicense.sortByGroupIdAndArtifactId=true
</description>

<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
<executions>
<execution>
<goals>
<goal>download-licenses</goal>
</goals>
</execution>
</executions>
<configuration>
<licenseUrlFileNames>
<asl2.txt>
sha1:2b8b815229aa8a61e483fb4ba0588b8b6c491890
\Qhttp://www.apache.org/licenses/LICENSE-2.0.txt\E
\Qhttps://www.apache.org/licenses/LICENSE-2.0.txt\E
\Qhttp://www.antlr.org/license.html\E
</asl2.txt>
</licenseUrlFileNames>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* #%L
* License Maven Plugin
* %%
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, Tony chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

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

final Path basePath = basedir.toPath()

final Path log = basePath.resolve('build.log')
assert Files.exists(log)
assert log.text.contains('URL \'http://www.antlr.org/license.html\' returned content with unexpected sha1 \'074f8d6e91730b40875178666513014472888247\'; expected \'2b8b815229aa8a61e483fb4ba0588b8b6c491890\'')
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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>
</dependencies>
</licenseSummary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.codehaus.mojo;

public class HelloWorld
{

/**
* @param args
*/
public static void main( String[] args )
{
// TODO Auto-generated method stub

}

}
1 change: 1 addition & 0 deletions src/it/download-licenses-file-names/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = clean license:download-licenses -DlicensesConfigFile=./licenses-config.xml -Dlicense.errorRemedy=xmlOutput -Dlicense.sortByGroupIdAndArtifactId=true -e -X
18 changes: 18 additions & 0 deletions src/it/download-licenses-file-names/licenses-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<licenses>
<license>
<name>BSD License</name>
<url>http://www.antlr.org/license.html</url>
<distribution>repo</distribution>
<file>bsd license - license.html</file>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
58 changes: 58 additions & 0 deletions src/it/download-licenses-file-names/licenses.expected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<licenses>
<license>
<name>BSD License</name>
<url>http://www.antlr.org/license.html</url>
<distribution>repo</distribution>
<file>bsd-antlr.html</file>
</license>
</licenses>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
<licenses>
<license>
<name>CDDL/GPLv2+CE</name>
<url>https://github.com/javaee/activation/blob/master/LICENSE.txt</url>
<distribution>repo</distribution>
<file>cddl-gplv2-ce.txt</file>
<comments>CDDL or GPL version 2 plus the Classpath Exception</comments>
</license>
</licenses>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<file>asl2.txt</file>
</license>
</licenses>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<file>asl2.txt</file>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
103 changes: 103 additions & 0 deletions src/it/download-licenses-file-names/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<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</groupId>
<artifactId>download-licenses-file-names</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Integration Test</name>
<url>http://maven.apache.org</url>
<description>
Check -DlicensesConfigFile=./licenses-config.xml -Dlicense.errorRemedy=xmlOutput -Dlicense.sortByGroupIdAndArtifactId=true
</description>

<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
<executions>
<execution>
<goals>
<goal>download-licenses</goal>
</goals>
</execution>
</executions>
<configuration>
<licenseUrlReplacements>
<licenseUrlReplacement>
<regexp>^https?://github\.com/([^/]+)/([^/]+)/blob/(.*)$</regexp>
<replacement>https://raw.githubusercontent.com/$1/$2/$3</replacement>
</licenseUrlReplacement>
</licenseUrlReplacements>
<licenseUrlFileNames>
<bsd-antlr.html>
sha1:074f8d6e91730b40875178666513014472888247
\Qhttp://www.antlr.org/license.html\E
</bsd-antlr.html>
<asl2.txt>
sha1:2b8b815229aa8a61e483fb4ba0588b8b6c491890
\Qhttp://www.apache.org/licenses/LICENSE-2.0.txt\E
\Qhttps://www.apache.org/licenses/LICENSE-2.0.txt\E
</asl2.txt>
<cddl-gplv2-ce.txt>
sha1:c27730aef98e1d50e937d808654daad00b258f90
\Qhttps://raw.githubusercontent.com/javaee/activation/master/LICENSE.txt\E
</cddl-gplv2-ce.txt>
</licenseUrlFileNames>
</configuration>
</plugin>
</plugins>
</build>
</project>
46 changes: 46 additions & 0 deletions src/it/download-licenses-file-names/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* #%L
* License Maven Plugin
* %%
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, Tony chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

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

final Path basePath = basedir.toPath()

assert !Files.exists(basePath.resolve('target/generated-resources/licenses/apache license 2.0 - license-2.0.txt'))
assert !Files.exists(basePath.resolve('target/generated-resources/licenses/bsd license - license.html'))

final Path asl2 = basePath.resolve('target/generated-resources/licenses/asl2.txt')
assert Files.exists(asl2)
assert asl2.text.contains('Version 2.0, January 2004')

final Path bsdAntlr = basePath.resolve('target/generated-resources/licenses/bsd-antlr.html')
assert Files.exists(bsdAntlr)
assert bsdAntlr.text.contains('Copyright (c) 2012 Terence Parr and Sam Harwell')

final Path cddl = basePath.resolve('target/generated-resources/licenses/cddl-gplv2-ce.txt')
assert Files.exists(cddl)
assert new String(Files.readAllBytes(cddl), 'ISO-8859-1').contains('COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1')

final Path expectedLicensesXml = basePath.resolve('licenses.expected.xml')
final Path licensesXml = basePath.resolve('target/generated-resources/licenses.xml')
assert expectedLicensesXml.text.equals(licensesXml.text)