Skip to content

Commit cd7012d

Browse files
committed
* Fixed Dockerfile
* Mapping of versions: rc.1, beta.1, alpha.1 are mapped to -SNAPSHOT when publishing Signed-off-by: Marcin Kuszczak <[email protected]>
1 parent 7e56914 commit cd7012d

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-14
lines changed

build.gradle.kts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22
import com.github.jengelman.gradle.plugins.shadow.transformers.ComponentsXmlResourceTransformer
3+
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
34
import java.time.ZoneOffset
45
import java.time.ZonedDateTime
56

@@ -26,7 +27,7 @@ repositories {
2627
}
2728

2829
group = "io.github.kscripting"
29-
version = "4.2.0-SNAPSHOT"
30+
version = "4.2.0-rc.2"
3031

3132
buildConfig {
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

178203
val shadowDistTar: Task by tasks.getting {
179204
enabled = false
@@ -202,8 +227,13 @@ val test: Task by tasks.getting {
202227
publishing {
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")

misc/Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
FROM bellsoft/liberica-openjdk-alpine:11
1+
FROM alpine:latest
22

3-
MAINTAINER holgerbrandl@gmail.com
3+
MAINTAINER go.kscripting@gmail.com
44

5-
ARG KSCRIPT_VERSION=4.0.0
6-
ARG KOTLIN_VERSION=1.6.20
5+
ARG KSCRIPT_VERSION=4.1.1
6+
ARG KOTLIN_VERSION=1.7.21
77

8-
RUN cd $(mktemp -d) && \
8+
RUN \
9+
# Install bash & Java \
10+
apk add bash openjdk11 && \
11+
\
12+
# Create temp dir
13+
cd $(mktemp -d) && \
14+
\
915
# Install kscript \
1016
wget https://github.com/holgerbrandl/kscript/releases/download/v${KSCRIPT_VERSION}/kscript-${KSCRIPT_VERSION}-bin.zip -q -O - | \
1117
unzip - && \
@@ -18,9 +24,6 @@ RUN cd $(mktemp -d) && \
1824
chmod a+x kotlinc/bin/kotlin kotlinc/bin/kotlinc && \
1925
mv kotlinc /opt && \
2026
\
21-
# Install bash
22-
apk add bash && \
23-
\
2427
# Done
2528
rm -rf $PWD
2629

@@ -30,4 +33,4 @@ ENTRYPOINT KOTLIN_HOME=/opt/kotlinc \
3033
PATH=/opt/kotlinc/bin:$PATH \
3134
kscript "$0" "$@"
3235

33-
CMD [ "--help" ]
36+
CMD [ "--help" ]

0 commit comments

Comments
 (0)