diff --git a/utils/spdx/src/main/kotlin/Utils.kt b/utils/spdx/src/main/kotlin/Utils.kt index 1c3ed6cd1eb44..74bb4bad13749 100644 --- a/utils/spdx/src/main/kotlin/Utils.kt +++ b/utils/spdx/src/main/kotlin/Utils.kt @@ -150,7 +150,7 @@ fun getLicenseTextReader( getLicenseTextFile(id, it)?.let { file -> { file.readText() } } } } else { - SpdxLicense.forId(id)?.let { { it.text } } + SpdxLicense.forId(id.removeSuffix("+"))?.let { { it.text } } ?: SpdxLicenseException.forId(id)?.takeIf { handleExceptions }?.let { { it.text } } } } diff --git a/utils/spdx/src/test/kotlin/UtilsTest.kt b/utils/spdx/src/test/kotlin/UtilsTest.kt index eb729580270fd..70328509ab628 100644 --- a/utils/spdx/src/test/kotlin/UtilsTest.kt +++ b/utils/spdx/src/test/kotlin/UtilsTest.kt @@ -142,6 +142,13 @@ class UtilsTest : WordSpec() { text should endWith("limitations under the License.") } + "return the full license text for a valid SPDX license id with the '+' operator" { + val text = getLicenseText("Apache-2.0+")?.trim() + + text should startWith("Apache License") + text should endWith("limitations under the License.") + } + "return null for an invalid SPDX license id" { getLicenseText("FooBar-1.0") should beNull() }