diff --git a/buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts b/buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts index cb83ff39a..1219a5a1b 100644 --- a/buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts @@ -33,11 +33,31 @@ publishing { IJ_232 -> "232" IJ_233 -> "233" } - version = "${project.version}-ij-$ijVersionRaw" + version = project.version.toString().withVersionSuffix("ij-$ijVersionRaw") artifactId = "jewel-${project.name}" pom { configureJewelPom() } } } -} \ No newline at end of file +} + +/** + * Adds suffix to the version taking SNAPSHOT suffix into account + * + * For example, if [this] is "0.0.1-SNAPSHOT" and [suffix] is "ij-233" + * then result will be "0.0.1-ij-233-SNAPSHOT" + */ +fun String.withVersionSuffix(suffix: String): String { + val splitString = this.split('-') + val snapshotRaw = "SNAPSHOT" + val withSnapshot = splitString.contains(snapshotRaw) + + if (!withSnapshot) { + return "$this-$suffix" + } + + val withoutSnapshot = splitString.filter { it != snapshotRaw }.joinToString("-") + + return "$withoutSnapshot-$suffix-$snapshotRaw" +}