11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22import com.github.jengelman.gradle.plugins.shadow.transformers.ComponentsXmlResourceTransformer
3+ import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
34import java.time.ZoneOffset
45import java.time.ZonedDateTime
56
@@ -26,7 +27,7 @@ repositories {
2627}
2728
2829group = " io.github.kscripting"
29- version = " 4.2.0-SNAPSHOT "
30+ version = " 4.2.0-rc.2 "
3031
3132buildConfig {
3233 packageName(project.group.toString() + " ." + project.name)
@@ -173,7 +174,31 @@ application {
173174 mainClass.set(project.group.toString() + " .KscriptKt" )
174175}
175176
176- val jar: Task by tasks.getting {}
177+ fun adjustVersion (archiveVersion : String ): String {
178+ var newVersion = archiveVersion.toLowerCaseAsciiOnly()
179+
180+ val temporaryVersion = newVersion.substringBeforeLast(" ." )
181+
182+ if (temporaryVersion.endsWith(" -rc" ) || temporaryVersion.endsWith(" -beta" ) || temporaryVersion.endsWith(" -alpha" ) ||
183+ temporaryVersion.endsWith(" -snapshot" )
184+ ) {
185+ newVersion = temporaryVersion.substringBeforeLast(" -" ) + " -SNAPSHOT"
186+ }
187+
188+ return newVersion
189+ }
190+
191+ val jar: Jar by tasks.getting(Jar ::class ) {
192+ archiveVersion.set(adjustVersion(archiveVersion.get()))
193+ }
194+
195+ val sourcesJar: Jar by tasks.getting(Jar ::class ) {
196+ archiveVersion.set(adjustVersion(archiveVersion.get()))
197+ }
198+
199+ val javadocJar: Jar by tasks.getting(Jar ::class ) {
200+ archiveVersion.set(adjustVersion(archiveVersion.get()))
201+ }
177202
178203val shadowDistTar: Task by tasks.getting {
179204 enabled = false
@@ -202,8 +227,13 @@ val test: Task by tasks.getting {
202227publishing {
203228 publications {
204229 create<MavenPublication >(" mavenJava" ) {
205- artifactId = " kscript"
230+ groupId = project.group.toString()
231+ artifactId = project.name
232+ version = adjustVersion(project.version.toString())
233+
206234 artifact(jar)
235+ artifact(javadocJar)
236+ artifact(sourcesJar)
207237
208238 pom {
209239 name.set(" kscript" )
@@ -242,8 +272,8 @@ publishing {
242272 maven {
243273 val releasesRepoUrl = " https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
244274 val snapshotsRepoUrl = " https://s01.oss.sonatype.org/content/repositories/snapshots/"
245- val projectVersion = project.version.toString()
246- url = uri(if (projectVersion .endsWith(" -SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
275+ val adjustedVersion = adjustVersion( project.version.toString() )
276+ url = uri(if (adjustedVersion .endsWith(" -SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
247277
248278 credentials {
249279 username = project.findProperty(" sonatype.user" ) as String? ? : System .getenv(" SONATYPE_USER" )
0 commit comments