Skip to content

Commit

Permalink
Publishing: SNAPSHOT suffix should always be last
Browse files Browse the repository at this point in the history
  • Loading branch information
Walingar committed Oct 13, 2023
1 parent afd5d4a commit 799fd86
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
}

/**
* 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"
}

0 comments on commit 799fd86

Please sign in to comment.