Skip to content

Commit 086d30f

Browse files
committed
refactor(tools/curations): Generalize overriding license categories
This allows to easily correct any license category. Signed-off-by: Frank Viernau <[email protected]>
1 parent a43f452 commit 086d30f

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

tools/curations/buildSrc/src/main/kotlin/ScanCodeLicenseDbClassifications.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ private val JSON_MAPPER = JsonMapper().apply {
4444
propertyNamingStrategy = PropertyNamingStrategies.SNAKE_CASE
4545
}
4646

47-
private val CONTRIBUTOR_LICENSE_AGREEMENT_IDS = listOf(
48-
"LicenseRef-scancode-cncf-corporate-cla-1.0",
49-
"LicenseRef-scancode-cncf-individual-cla-1.0",
50-
"LicenseRef-scancode-google-cla",
51-
"LicenseRef-scancode-google-corporate-cla",
52-
"LicenseRef-scancode-jetty-ccla-1.1",
53-
"LicenseRef-scancode-ms-cla",
54-
"LicenseRef-scancode-newton-king-cla",
55-
"LicenseRef-scancode-owf-cla-1.0-copyright",
56-
"LicenseRef-scancode-owf-cla-1.0-copyright-patent",
57-
"LicenseRef-scancode-square-cla"
58-
).map { SpdxSingleLicenseExpression.parse(it) }.toSet()
59-
6047
private const val CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT = "contributor-license-agreement"
6148
private const val CATEGORY_GENERIC = "generic"
6249
private const val CATEGORY_UNKNOWN = "unknown"
6350

51+
private val OVERRIDE_LICENSE_CATEGORIES = mapOf(
52+
"LicenseRef-scancode-cncf-corporate-cla-1.0" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
53+
"LicenseRef-scancode-cncf-individual-cla-1.0" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
54+
"LicenseRef-scancode-google-cla" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
55+
"LicenseRef-scancode-google-corporate-cla" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
56+
"LicenseRef-scancode-jetty-ccla-1.1" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
57+
"LicenseRef-scancode-ms-cla" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
58+
"LicenseRef-scancode-newton-king-cla" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
59+
"LicenseRef-scancode-owf-cla-1.0-copyright" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
60+
"LicenseRef-scancode-owf-cla-1.0-copyright-patent" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT,
61+
"LicenseRef-scancode-square-cla" to CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT
62+
).mapKeys { (license, _) -> SpdxSingleLicenseExpression.parse(license) }
63+
6464
private data class License(
6565
val licenseKey: String,
6666
val spdxLicenseKey: String? = null,
@@ -150,10 +150,11 @@ private fun LicenseDetails.getLicenseId(): SpdxSingleLicenseExpression {
150150
}
151151

152152
private fun LicenseDetails.getCategories(): Set<String> {
153+
val overrideLicenseCategory = OVERRIDE_LICENSE_CATEGORIES[getLicenseId()]
153154
val mappedCategory = when {
154155
isUnknown -> CATEGORY_UNKNOWN
155156
isGeneric -> CATEGORY_GENERIC
156-
getLicenseId() in CONTRIBUTOR_LICENSE_AGREEMENT_IDS -> CATEGORY_CONTRIBUTOR_LICENSE_AGREEMENT
157+
overrideLicenseCategory != null -> overrideLicenseCategory
157158
else -> category.replace(' ', '-').lowercase()
158159
}
159160

0 commit comments

Comments
 (0)