From 2333835395bb18380a8c711f78da24f94f96be41 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Fri, 4 Oct 2024 16:28:20 -0400 Subject: [PATCH] Special case another license name --- .../app/cash/licensee/GenerateSpdxIdTask.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gradle/build-logic/src/main/kotlin/app/cash/licensee/GenerateSpdxIdTask.kt b/gradle/build-logic/src/main/kotlin/app/cash/licensee/GenerateSpdxIdTask.kt index d6bd1b70..dd395701 100644 --- a/gradle/build-logic/src/main/kotlin/app/cash/licensee/GenerateSpdxIdTask.kt +++ b/gradle/build-logic/src/main/kotlin/app/cash/licensee/GenerateSpdxIdTask.kt @@ -67,14 +67,18 @@ private fun SpdxLicenses.generate(): FileSpec { private val SpdxId: ClassName = ClassName("app.cash.licensee", "SpdxId") private val SpdxIdCompanion: ClassName = SpdxId.nestedClass("Companion") -private val SpdxLicenseJson.identifier: String get() = if (id == "0BSD") { - "ZeroBSD" // hardcoded because it is the only id starting with a digit. -} else { - id - .replace("-", "_") - .replace(".", "") - .replace("+", "Plus") -} +private val SpdxLicenseJson.identifier: String + get() = when (id) { + // Special-case IDs which start with a digit: + "0BSD" -> "ZeroBSD" + "3D-Slicer-1.0" -> "ThreeD_Slicer_10" + else -> { + id + .replace("-", "_") + .replace(".", "") + .replace("+", "Plus") + } + } private fun SpdxLicenses.addSpdxIdInterface(): TypeSpec = TypeSpec.classBuilder("SpdxId").apply { primaryConstructor(