Skip to content

Commit e728927

Browse files
committed
feat(version-catalog): Only prefix reserved words
Shorten most aliases by omitting the "ort" level and only add it where needed to disambiguate reserved words. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 71268de commit e728927

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

version-catalog/build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
21+
2022
plugins {
2123
// Apply core plugins.
2224
`version-catalog`
@@ -30,6 +32,7 @@ gradle.projectsEvaluated {
3032
catalog {
3133
versionCatalog {
3234
val hyphenRegex = Regex("([a-z])-([a-z])")
35+
val reservedPrefixes = setOf("bundles", "plugins", "versions")
3336

3437
rootProject.subprojects.filter { subproject ->
3538
subproject.pluginManager.hasPlugin("ort-publication-conventions")
@@ -40,8 +43,15 @@ gradle.projectsEvaluated {
4043
}
4144
.replace(File.separatorChar, '-')
4245

46+
val safeAlias = if (reservedPrefixes.any { alias.startsWith("$it-") }) {
47+
// Add a prefix to work around reserved words e.g. for ORT's own plugins.
48+
"ort${alias.uppercaseFirstChar()}"
49+
} else {
50+
alias
51+
}
52+
4353
with(subproject) {
44-
library("ort-$alias", "$group:$name:$version")
54+
library(safeAlias, "$group:$name:$version")
4555
}
4656
}
4757
}

0 commit comments

Comments
 (0)