Skip to content

Commit e9b0fdf

Browse files
authored
Merge pull request #230 from ppalaga/i229
Fix #229 Structured output for failed license downloads
2 parents 42d3679 + 33cc2b0 commit e9b0fdf

File tree

18 files changed

+477
-33
lines changed

18 files changed

+477
-33
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
invoker.goals = clean license:download-licenses -Dlicense.errorRemedy=failFast
2+
invoker.buildResult=failure
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.codehaus.mojo.license</groupId>
8+
<artifactId>download-licenses-failFast</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<name>Integration Test</name>
11+
<url>http://maven.apache.org</url>
12+
<description>
13+
Check -Dlicense.errorRemedy=failFast
14+
</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>commons-logging</groupId>
19+
<artifactId>commons-logging</artifactId>
20+
<version>1.0</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>groovy</groupId>
24+
<artifactId>groovy-all</artifactId>
25+
<version>1.0-jsr-04</version>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.codehaus.mojo</groupId>
33+
<artifactId>license-maven-plugin</artifactId>
34+
<version>@pom.version@</version>
35+
<executions>
36+
<execution>
37+
<goals>
38+
<goal>download-licenses</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* #%L
3+
* License Maven Plugin
4+
* %%
5+
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, Tony chemit
6+
* %%
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Lesser Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Lesser Public
18+
* License along with this program. If not, see
19+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
20+
* #L%
21+
*/
22+
23+
import java.nio.file.Path;
24+
import java.nio.file.Files;
25+
26+
final Path basePath = basedir.toPath()
27+
28+
final Path log = basePath.resolve('build.log')
29+
assert Files.exists(log)
30+
assert log.text.contains('No license information available for: groovy:groovy-all')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<licenseSummary>
2+
<dependencies>
3+
<dependency>
4+
<groupId>commons-logging</groupId>
5+
<artifactId>commons-logging</artifactId>
6+
<licenses>
7+
<license>
8+
<name>Apache License 2.0</name>
9+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
10+
</license>
11+
</licenses>
12+
</dependency>
13+
</dependencies>
14+
</licenseSummary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.codehaus.mojo;
2+
3+
public class HelloWorld
4+
{
5+
6+
/**
7+
* @param args
8+
*/
9+
public static void main( String[] args )
10+
{
11+
// TODO Auto-generated method stub
12+
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals = clean license:download-licenses -Dlicense.forceDownload=true -Dlicense.errorRemedy=xmlOutput
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<licenseSummary>
3+
<dependencies>
4+
<dependency>
5+
<groupId>groovy</groupId>
6+
<artifactId>groovy-all</artifactId>
7+
<version>1.0-jsr-04</version>
8+
<licenses>
9+
<!--No license information available. -->
10+
</licenses>
11+
<downloaderMessages>
12+
<downloaderMessage>No license information available for: groovy:groovy-all</downloaderMessage>
13+
</downloaderMessages>
14+
</dependency>
15+
</dependencies>
16+
</licenseSummary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<licenseSummary>
3+
<dependencies>
4+
<dependency>
5+
<groupId>commons-logging</groupId>
6+
<artifactId>commons-logging</artifactId>
7+
<version>1.0</version>
8+
<licenses>
9+
<license>
10+
<name>Apache License 2.0</name>
11+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
12+
<file>apache license 2.0 - license-2.0.txt</file>
13+
</license>
14+
</licenses>
15+
</dependency>
16+
</dependencies>
17+
</licenseSummary>
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.codehaus.mojo.license</groupId>
8+
<artifactId>download-licenses-force</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<name>Integration Test</name>
11+
<url>http://maven.apache.org</url>
12+
<description>
13+
Check -Dlicense.forceDownload=true -Dlicense.errorRemedy=xmlOutput
14+
</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>commons-logging</groupId>
19+
<artifactId>commons-logging</artifactId>
20+
<version>1.0</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>groovy</groupId>
24+
<artifactId>groovy-all</artifactId>
25+
<version>1.0-jsr-04</version>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.codehaus.mojo</groupId>
33+
<artifactId>license-maven-plugin</artifactId>
34+
<version>@pom.version@</version>
35+
<executions>
36+
<execution>
37+
<goals>
38+
<goal>download-licenses</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* #%L
3+
* License Maven Plugin
4+
* %%
5+
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, Tony chemit
6+
* %%
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Lesser Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Lesser Public
18+
* License along with this program. If not, see
19+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
20+
* #L%
21+
*/
22+
23+
import java.nio.file.Path;
24+
import java.nio.file.Files;
25+
26+
final Path basePath = basedir.toPath()
27+
28+
final Path asl2 = basePath.resolve('target/generated-resources/licenses/apache license 2.0 - license-2.0.txt')
29+
assert Files.exists(asl2)
30+
assert !asl2.text.contains('This content is fake.')
31+
assert asl2.text.contains('Version 2.0, January 2004')
32+
33+
final Path expectedLicensesXml = basePath.resolve('licenses.expected.xml')
34+
final Path licensesXml = basePath.resolve('target/generated-resources/licenses.xml')
35+
assert expectedLicensesXml.text.equals(licensesXml.text)
36+
37+
final Path expectedLicensesErrorsXml = basePath.resolve('licenses-errors.expected.xml')
38+
final Path licensesErrorsXml = basePath.resolve('target/generated-resources/licenses-errors.xml')
39+
assert expectedLicensesErrorsXml.text.equals(licensesErrorsXml.text)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* #%L
3+
* License Maven Plugin
4+
* %%
5+
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, Tony chemit
6+
* %%
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Lesser Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Lesser Public
18+
* License along with this program. If not, see
19+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
20+
* #L%
21+
*/
22+
23+
import java.nio.file.Path;
24+
import java.nio.file.Files;
25+
26+
Path basePath = basedir.toPath()
27+
28+
Files.move(basePath.resolve('target-initial'), basePath.resolve('target'))
29+
30+
Path asl2 = basePath.resolve('target/generated-resources/licenses/apache license 2.0 - license-2.0.txt')
31+
assert Files.exists(asl2)
32+
assert asl2.text.contains('This content is fake.')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<licenseSummary>
2+
<dependencies>
3+
<dependency>
4+
<groupId>commons-logging</groupId>
5+
<artifactId>commons-logging</artifactId>
6+
<licenses>
7+
<license>
8+
<name>Apache License 2.0</name>
9+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
10+
</license>
11+
</licenses>
12+
</dependency>
13+
</dependencies>
14+
</licenseSummary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.codehaus.mojo;
2+
3+
public class HelloWorld
4+
{
5+
6+
/**
7+
* @param args
8+
*/
9+
public static void main( String[] args )
10+
{
11+
// TODO Auto-generated method stub
12+
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<licenseSummary>
3+
<dependencies>
4+
<dependency>
5+
<groupId>commons-logging</groupId>
6+
<artifactId>commons-logging</artifactId>
7+
<version>1.0</version>
8+
<licenses>
9+
<license>
10+
<name>Apache License 2.0</name>
11+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
12+
<file>apache license 2.0 - license-2.0.txt</file>
13+
</license>
14+
</licenses>
15+
</dependency>
16+
</dependencies>
17+
</licenseSummary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This content is fake.
2+
-Dlicense.forceDownload should cause the plugin to overwrite this file.

0 commit comments

Comments
 (0)