Skip to content

Commit

Permalink
Merge pull request #37 from jmatsu/fix/licenses_contain_ws_or_lr
Browse files Browse the repository at this point in the history
Fixed licenses that contain whitespaces and/or CR/LF/CRLF
  • Loading branch information
jmatsu authored Jun 11, 2020
2 parents bec2479 + 0b7864c commit 0c23f79
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/ignore_test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

./gradlew clean initLicenseList -Poverwrite=true --rerun-tasks

if ! diff app/license-list/artifact-definition.yml fixtures/nothing-ignored-artifact-definition.yml; then
if diff app/license-list/artifact-definition.yml fixtures/nothing-ignored-artifact-definition.yml; then
echo "diff has not been generated. .customartifactignore might be wrong or artifact-definition is wrong"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
3 changes: 3 additions & 0 deletions example/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ dependencies {
// orphanConfiguration is not included by any other configurations, so you need to add this to targetConfigurations. See licenseList block.
orphanConfiguration("com.android.support.test:runner:1.0.2")

// the license text contains line-return else...
implementation("org.jvnet.staxex:stax-ex:1.7.8")

testImplementation("junit:junit:4.12")
androidTestImplementation("com.android.support.test:runner:1.0.2")
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
Expand Down
22 changes: 22 additions & 0 deletions example/app/license-list/artifact-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,19 @@ yellowBlueRelease:
- Jumpei Matsuda
licenses:
- mit
javax.activation:
- key: activation
displayName: JavaBeans Activation Framework (JAF)
url: http://java.sun.com/products/javabeans/jaf/index.jsp
copyrightHolders: []
licenses:
- Common Development and Distribution License (CDDL) v1.0@51
javax.xml.stream:
- key: stax-api
displayName: stax-api
url: null
copyrightHolders: []
licenses: []
org.antlr:
- key: antlr4
displayName: ANTLR 4 Tool
Expand Down Expand Up @@ -506,6 +519,15 @@ yellowBlueRelease:
- Kotlin Team
licenses:
- apache-2.0
org.jvnet.staxex:
- key: stax-ex
displayName: Extended StAX API
url: http://stax-ex.java.net/
copyrightHolders:
- Jitendra Kotamraju
- Martin Grebac
licenses:
- Dual license consisting of the CDDL v1.1 and GPL v2@55
test:
junit:
- key: junit
Expand Down
6 changes: 6 additions & 0 deletions example/app/license-list/license-catalog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
- key: BSD style@73
name: BSD style
url: http://kxml.cvs.sourceforge.net/viewvc/kxml/kxml2/license.txt?view=markup
- key: Common Development and Distribution License (CDDL) v1.0@51
name: Common Development and Distribution License (CDDL) v1.0
url: https://glassfish.dev.java.net/public/CDDLv1.0.html
- key: Dual license consisting of the CDDL v1.1 and GPL v2@55
name: Dual license consisting of the CDDL v1.1 and GPL v2
url: https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- key: Mozilla Public License 1.1 (MPL 1.1)@39
name: Mozilla Public License 1.1 (MPL 1.1)
url: http://www.mozilla.org/MPL/MPL-1.1.html
Expand Down
22 changes: 22 additions & 0 deletions example/fixtures/merge/expected-artifact-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ yellowBlueRelease:
licenses:
- new-dummy-license
keep: true
javax.activation:
- key: activation
displayName: JavaBeans Activation Framework (JAF)
url: http://java.sun.com/products/javabeans/jaf/index.jsp
copyrightHolders: []
licenses:
- Common Development and Distribution License (CDDL) v1.0@51
javax.xml.stream:
- key: stax-api
displayName: stax-api
url: null
copyrightHolders: []
licenses: []
org.antlr:
- key: antlr4
displayName: ANTLR 4 Tool
Expand Down Expand Up @@ -134,6 +147,15 @@ yellowBlueRelease:
- JetBrains Team
licenses:
- apache-2.0
org.jvnet.staxex:
- key: stax-ex
displayName: Extended StAX API
url: http://stax-ex.java.net/
copyrightHolders:
- Jitendra Kotamraju
- Martin Grebac
licenses:
- Dual license consisting of the CDDL v1.1 and GPL v2@55
test:
junit:
- key: junit
Expand Down
6 changes: 6 additions & 0 deletions example/fixtures/merge/expected-license-catalog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
- key: BSD style@73
name: BSD style
url: http://kxml.cvs.sourceforge.net/viewvc/kxml/kxml2/license.txt?view=markup
- key: Common Development and Distribution License (CDDL) v1.0@51
name: Common Development and Distribution License (CDDL) v1.0
url: https://glassfish.dev.java.net/public/CDDLv1.0.html
- key: Dual license consisting of the CDDL v1.1 and GPL v2@55
name: Dual license consisting of the CDDL v1.1 and GPL v2
url: https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- key: Mozilla Public License 1.1 (MPL 1.1)@39
name: Mozilla Public License 1.1 (MPL 1.1)
url: http://www.mozilla.org/MPL/MPL-1.1.html
Expand Down
22 changes: 22 additions & 0 deletions example/fixtures/validate-artifact-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,19 @@ yellowBlueRelease:
licenses:
- xdefined-license@18
keep: true
javax.activation:
- key: activation
displayName: JavaBeans Activation Framework (JAF)
url: http://java.sun.com/products/javabeans/jaf/index.jsp
copyrightHolders: []
licenses:
- Common Development and Distribution License (CDDL) v1.0@51
javax.xml.stream:
- key: stax-api
displayName: stax-api
url: null
copyrightHolders: []
licenses: []
org.antlr:
- key: antlr4
displayName: ANTLR 4 Tool
Expand Down Expand Up @@ -514,6 +527,15 @@ yellowBlueRelease:
- Kotlin Team
licenses:
- apache-2.0
org.jvnet.staxex:
- key: stax-ex
displayName: Extended StAX API
url: http://stax-ex.java.net/
copyrightHolders:
- Jitendra Kotamraju
- Martin Grebac
licenses:
- Dual license consisting of the CDDL v1.1 and GPL v2@55
test:
junit:
- key: junit
Expand Down
6 changes: 6 additions & 0 deletions example/fixtures/validate-license-catalog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
- key: BSD style@73
name: BSD style
url: http://kxml.cvs.sourceforge.net/viewvc/kxml/kxml2/license.txt?view=markup
- key: Common Development and Distribution License (CDDL) v1.0@51
name: Common Development and Distribution License (CDDL) v1.0
url: https://glassfish.dev.java.net/public/CDDLv1.0.html
- key: Dual license consisting of the CDDL v1.1 and GPL v2@55
name: Dual license consisting of the CDDL v1.1 and GPL v2
url: https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- key: Mozilla Public License 1.1 (MPL 1.1)@39
name: Mozilla Public License 1.1 (MPL 1.1)
url: http://www.mozilla.org/MPL/MPL-1.1.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ class Builder(

private fun ResolvedPomFile.licenses(licenseCapture: MutableSet<PlainLicense>): List<LicenseKey> {
return licenses.map {
when (val guessedLicense = LicenseClassifier(it.name).guess()) {
val licenseName = it.name?.trim { c -> c.isWhitespace() || c == '\n' || c == '\r' }

when (val guessedLicense = LicenseClassifier(licenseName).guess()) {
is LicenseClassifier.GuessedLicense.Undetermined -> {
val name = it.name ?: guessedLicense.name
val name = licenseName ?: guessedLicense.name
val url = it.url.orEmpty()

LicenseKey(value = "$name@${url.length}").also { key ->
Expand Down

0 comments on commit 0c23f79

Please sign in to comment.