diff --git a/src/it/ISSUE-195/invoker.properties b/src/it/ISSUE-195/invoker.properties
new file mode 100644
index 000000000..c1f3c82f3
--- /dev/null
+++ b/src/it/ISSUE-195/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = clean license:download-licenses -Dlicense.organizeLicensesByDependencies=true
\ No newline at end of file
diff --git a/src/it/ISSUE-195/pom.xml b/src/it/ISSUE-195/pom.xml
new file mode 100644
index 000000000..d8a84023e
--- /dev/null
+++ b/src/it/ISSUE-195/pom.xml
@@ -0,0 +1,53 @@
+
+
+ 4.0.0
+
+ org.codehaus.mojo.license
+ ISSUE-195
+ 1.0-SNAPSHOT
+ Integration Test ISSUE-195
+ http://maven.apache.org
+
+ ISSUE-195
+
+
+
+
+ commons-logging
+ commons-logging
+ 1.0
+
+
+ javax.activation
+ javax.activation-api
+ 1.2.0
+
+
+
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+ @pom.version@
+
+
+
+ download-licenses
+
+
+
+
+
+
+ https://github.com/javaee/activation/blob/master/LICENSE.txt
+ https://raw.githubusercontent.com/javaee/activation/master/LICENSE.txt
+
+
+
+
+
+
+
diff --git a/src/it/ISSUE-195/postbuild.groovy b/src/it/ISSUE-195/postbuild.groovy
new file mode 100644
index 000000000..035d44e2e
--- /dev/null
+++ b/src/it/ISSUE-195/postbuild.groovy
@@ -0,0 +1,25 @@
+/*
+ * #%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
+ * .
+ * #L%
+ */
+
+assert new File(basedir, 'target/generated-resources/licenses.xml').exists()
+assert new File(basedir, 'target/generated-resources/licenses/commons-logging.commons-logging_apache_license_2.0.txt').exists()
+assert new File(basedir, 'target/generated-resources/licenses/javax.activation.javax.activation-api_cddl_gplv2+ce.txt').exists()
diff --git a/src/it/ISSUE-195/src/license/licenses.xml b/src/it/ISSUE-195/src/license/licenses.xml
new file mode 100644
index 000000000..0c3d63fa2
--- /dev/null
+++ b/src/it/ISSUE-195/src/license/licenses.xml
@@ -0,0 +1,14 @@
+
+
+
+ commons-logging
+ commons-logging
+
+
+ Apache License 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+
\ No newline at end of file
diff --git a/src/it/ISSUE-195/src/main/java/org/codehaus/mojo/HelloWorld.java b/src/it/ISSUE-195/src/main/java/org/codehaus/mojo/HelloWorld.java
new file mode 100644
index 000000000..16aaa7fed
--- /dev/null
+++ b/src/it/ISSUE-195/src/main/java/org/codehaus/mojo/HelloWorld.java
@@ -0,0 +1,15 @@
+package org.codehaus.mojo;
+
+public class HelloWorld
+{
+
+ /**
+ * @param args
+ */
+ public static void main( String[] args )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
index 0aa02342a..e1b0b0171 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
@@ -55,6 +55,7 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
@@ -737,7 +738,7 @@ private String getLicenseFileName( ProjectLicenseInfo depProject, final URL lice
licenseFileName = String.format( "%s.%s%s", depProject.getGroupId(), depProject.getArtifactId(),
licenseName != null
? "_" + licenseName
- : "" ).toLowerCase().replaceAll( "\\s+", "_" );
+ : "" );
}
else
{
@@ -756,10 +757,11 @@ private String getLicenseFileName( ProjectLicenseInfo depProject, final URL lice
// This means it isn't a valid file extension, so append the default
licenseFileName = licenseFileName + defaultExtension;
}
-
- // Force lower case so we don't end up with multiple copies of the same license
- licenseFileName = licenseFileName.toLowerCase();
}
+
+ // sanitize
+ licenseFileName = licenseFileName.toLowerCase( Locale.US ).replaceAll( "[\\\\/\\s]+", "_" );
+
return licenseFileName;
}
@@ -811,7 +813,7 @@ private void downloadLicenses( ProjectLicenseInfo depProject )
if ( !downloadedLicenseURLs.containsKey( licenseUrl ) || organizeLicensesByDependencies )
{
licenseOutputFile = LicenseDownloader.downloadLicense( licenseUrl, proxyLoginPasswordEncoded,
- licenseOutputFile );
+ licenseOutputFile, getLog() );
downloadedLicenseURLs.put( licenseUrl, licenseOutputFile );
}
}
diff --git a/src/main/java/org/codehaus/mojo/license/utils/LicenseDownloader.java b/src/main/java/org/codehaus/mojo/license/utils/LicenseDownloader.java
index 061b79536..cf37477b9 100644
--- a/src/main/java/org/codehaus/mojo/license/utils/LicenseDownloader.java
+++ b/src/main/java/org/codehaus/mojo/license/utils/LicenseDownloader.java
@@ -31,6 +31,8 @@
import java.net.URL;
import java.net.URLConnection;
+import org.apache.maven.plugin.logging.Log;
+
/**
* Utilities for downloading remote license files.
*
@@ -54,10 +56,11 @@ public class LicenseDownloader
* @param licenseUrlString the URL
* @param loginPassword the credentials part for the URL, can be {@code null}
* @param outputFile a hint where to store the license file
+ * @param log
* @return the path to the file where the downloaded license file was stored
* @throws IOException
*/
- public static File downloadLicense( String licenseUrlString, String loginPassword, File outputFile )
+ public static File downloadLicense( String licenseUrlString, String loginPassword, File outputFile, Log log )
throws IOException
{
if ( licenseUrlString == null || licenseUrlString.length() == 0 )
@@ -72,6 +75,8 @@ public static File downloadLicense( String licenseUrlString, String loginPasswor
{
int status = ( (HttpURLConnection) connection ).getResponseCode();
+ log.debug( String.format( "Got HTTP response %d for URL '%s'", status, licenseUrlString ) );
+
redirect = HttpURLConnection.HTTP_MOVED_TEMP == status || HttpURLConnection.HTTP_MOVED_PERM == status
|| HttpURLConnection.HTTP_SEE_OTHER == status;
}
@@ -84,6 +89,12 @@ public static File downloadLicense( String licenseUrlString, String loginPasswor
// open the new connnection again
connection = newConnection( newUrl, loginPassword );
+ if ( connection instanceof HttpURLConnection )
+ {
+ int status = ( (HttpURLConnection) connection ).getResponseCode();
+ log.debug( String.format( "Got HTTP response %d for URL '%s'", status, licenseUrlString ) );
+ }
+
}
try ( InputStream licenseInputStream = connection.getInputStream() )