From 9f04f1f571b4903e4c0675214d0f5599f8e5b5a2 Mon Sep 17 00:00:00 2001 From: Nikolas Falco Date: Thu, 21 Feb 2019 11:05:39 +0100 Subject: [PATCH] Fix #134 when missingFileUrl contains more lines --- .../missing-licenses.properties | 3 ++- src/it/add-third-party-missing-file/pom.xml | 5 +++++ src/it/add-third-party-missing-file/postbuild.groovy | 4 +++- src/it/add-third-party-missing-file/prebuild.groovy | 6 ++++-- .../codehaus/mojo/license/AbstractAddThirdPartyMojo.java | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/it/add-third-party-missing-file/missing-licenses.properties b/src/it/add-third-party-missing-file/missing-licenses.properties index ae37210de..a1bfddfdc 100644 --- a/src/it/add-third-party-missing-file/missing-licenses.properties +++ b/src/it/add-third-party-missing-file/missing-licenses.properties @@ -1 +1,2 @@ -org.json--json--20070829=The JSON License by file url \ No newline at end of file +org.json--json--20070829=The JSON License by file url +javax.resource--connector-api--1.5=CDDL + GPLv2 with classpath exception by file url \ No newline at end of file diff --git a/src/it/add-third-party-missing-file/pom.xml b/src/it/add-third-party-missing-file/pom.xml index 102ce3e31..0c35f5e71 100644 --- a/src/it/add-third-party-missing-file/pom.xml +++ b/src/it/add-third-party-missing-file/pom.xml @@ -53,6 +53,11 @@ json 20070829 + + javax.resource + connector-api + 1.5 + diff --git a/src/it/add-third-party-missing-file/postbuild.groovy b/src/it/add-third-party-missing-file/postbuild.groovy index 31fac96df..d6e9431e9 100644 --- a/src/it/add-third-party-missing-file/postbuild.groovy +++ b/src/it/add-third-party-missing-file/postbuild.groovy @@ -24,8 +24,10 @@ file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY-by-classp assert file.exists(); content = file.text; assert content.contains('The JSON License by classpath url'); +assert content.contains('CDDL + GPLv2 with classpath exception by classpath url'); file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY-by-file.txt'); assert file.exists(); content = file.text; -assert content.contains('The JSON License by file url'); \ No newline at end of file +assert content.contains('The JSON License by file url'); +assert content.contains('CDDL + GPLv2 with classpath exception by file url'); \ No newline at end of file diff --git a/src/it/add-third-party-missing-file/prebuild.groovy b/src/it/add-third-party-missing-file/prebuild.groovy index 8f7aa37f3..3d080049b 100644 --- a/src/it/add-third-party-missing-file/prebuild.groovy +++ b/src/it/add-third-party-missing-file/prebuild.groovy @@ -27,10 +27,12 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.zip.ZipEntry; -JarOutputStream licenseRepo = new JarOutputStream(new FileOutputStream(new File(basedir, "license-repo.jar"))); +String missingLicences = "org.json--json--20070829=The JSON License by classpath url\n" + + "javax.resource--connector-api--1.5=CDDL + GPLv2 with classpath exception by classpath url"; +JarOutputStream licenseRepo = new JarOutputStream(new FileOutputStream(new File(basedir, "license-repo.jar"))); licenseRepo.putNextEntry(new ZipEntry("missing-licenses.properties")); -licenseRepo.write("org.json--json--20070829=The JSON License by classpath url".getBytes("UTF-8")); +licenseRepo.write(missingLicences.getBytes("UTF-8")); licenseRepo.closeEntry(); licenseRepo.close(); \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java index 01c30bf2a..402ee2a3a 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java @@ -695,7 +695,7 @@ else if ( licenseMergesUrl != null ) getLog().warn( "" ); if ( UrlRequester.isStringUrl( licenseMergesUrl ) ) { - licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ) ); + licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "\n" ) ); } }