Skip to content

Commit

Permalink
Merge pull request #230 from ppalaga/i229
Browse files Browse the repository at this point in the history
Fix #229 Structured output for failed license downloads
  • Loading branch information
ppalaga authored Feb 4, 2019
2 parents 42d3679 + 33cc2b0 commit e9b0fdf
Show file tree
Hide file tree
Showing 18 changed files with 477 additions and 33 deletions.
2 changes: 2 additions & 0 deletions src/it/download-licenses-failFast/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = clean license:download-licenses -Dlicense.errorRemedy=failFast
invoker.buildResult=failure
45 changes: 45 additions & 0 deletions src/it/download-licenses-failFast/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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-failFast</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Integration Test</name>
<url>http://maven.apache.org</url>
<description>
Check -Dlicense.errorRemedy=failFast
</description>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0-jsr-04</version>
</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>
</plugin>
</plugins>
</build>
</project>
30 changes: 30 additions & 0 deletions src/it/download-licenses-failFast/postbuild.groovy
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('No license information available for: groovy:groovy-all')
14 changes: 14 additions & 0 deletions src/it/download-licenses-failFast/src/license/licenses.xml
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-force/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = clean license:download-licenses -Dlicense.forceDownload=true -Dlicense.errorRemedy=xmlOutput
16 changes: 16 additions & 0 deletions src/it/download-licenses-force/licenses-errors.expected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0-jsr-04</version>
<licenses>
<!--No license information available. -->
</licenses>
<downloaderMessages>
<downloaderMessage>No license information available for: groovy:groovy-all</downloaderMessage>
</downloaderMessages>
</dependency>
</dependencies>
</licenseSummary>
17 changes: 17 additions & 0 deletions src/it/download-licenses-force/licenses.expected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<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>
45 changes: 45 additions & 0 deletions src/it/download-licenses-force/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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-force</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Integration Test</name>
<url>http://maven.apache.org</url>
<description>
Check -Dlicense.forceDownload=true -Dlicense.errorRemedy=xmlOutput
</description>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0-jsr-04</version>
</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>
</plugin>
</plugins>
</build>
</project>
39 changes: 39 additions & 0 deletions src/it/download-licenses-force/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* #%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 asl2 = basePath.resolve('target/generated-resources/licenses/apache license 2.0 - license-2.0.txt')
assert Files.exists(asl2)
assert !asl2.text.contains('This content is fake.')
assert asl2.text.contains('Version 2.0, January 2004')

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

final Path expectedLicensesErrorsXml = basePath.resolve('licenses-errors.expected.xml')
final Path licensesErrorsXml = basePath.resolve('target/generated-resources/licenses-errors.xml')
assert expectedLicensesErrorsXml.text.equals(licensesErrorsXml.text)
32 changes: 32 additions & 0 deletions src/it/download-licenses-force/prebuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* #%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;

Path basePath = basedir.toPath()

Files.move(basePath.resolve('target-initial'), basePath.resolve('target'))

Path asl2 = basePath.resolve('target/generated-resources/licenses/apache license 2.0 - license-2.0.txt')
assert Files.exists(asl2)
assert asl2.text.contains('This content is fake.')
14 changes: 14 additions & 0 deletions src/it/download-licenses-force/src/license/licenses.xml
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

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<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,2 @@
This content is fake.
-Dlicense.forceDownload should cause the plugin to overwrite this file.
Loading

0 comments on commit e9b0fdf

Please sign in to comment.