Skip to content

Commit 75e292e

Browse files
Run tests with custom JRE (#339)
Co-authored-by: Enrico Martelli <[email protected]>
1 parent d52e624 commit 75e292e

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ RUN curl -L --fail --retry 3 --retry-delay 5 "$LIBWEBP_URL" -o libwebp.tar.gz &&
1212
tar -xzf libwebp.tar.gz --one-top-level=libwebp --strip-components=1
1313
COPY settings.gradle build.gradle gradlew ./
1414
COPY gradle ./gradle
15-
RUN --mount=type=cache,target=/home/gradle/.gradle/caches \
16-
./gradlew dependencies --no-daemon
15+
RUN --mount=type=cache,target=/home/gradle/.gradle/caches ./gradlew dependencies --no-daemon
1716
COPY . .
1817
RUN ./gradlew runtime --no-daemon
1918

@@ -23,9 +22,10 @@ FROM gcr.io/distroless/base-nossl:nonroot AS bot
2322
COPY --from=mwader/static-ffmpeg:7.0.2 /ffmpeg /usr/local/bin/
2423
ENV FFMPEG_PATH=/usr/local/bin/ffmpeg
2524

26-
COPY --from=builder /app/build/jre ./jre
27-
COPY --from=builder /app/build/libs/Stickerify-shadow.jar .
2825
COPY --from=builder /app/libwebp/bin/cwebp /usr/local/bin/
2926
COPY --from=builder /app/libwebp/bin/dwebp /usr/local/bin/
3027

31-
CMD ["jre/bin/java", "-XX:+UseZGC", "-Dcom.sksamuel.scrimage.webp.binary.dir=/usr/local/bin/", "-jar", "Stickerify-shadow.jar"]
28+
COPY --from=builder /app/build/jre jre
29+
COPY --from=builder /app/build/libs/Stickerify-1.0-all.jar Stickerify.jar
30+
31+
CMD ["jre/bin/java", "-XX:+UseZGC", "-Dcom.sksamuel.scrimage.webp.binary.dir=/usr/local/bin/", "-jar", "Stickerify.jar"]

build.gradle

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
2+
13
plugins {
24
alias(libs.plugins.runtime)
35
alias(libs.plugins.shadow)
@@ -36,24 +38,6 @@ dependencies {
3638
}
3739
}
3840

39-
jacocoTestReport {
40-
reports {
41-
html.required = false
42-
xml.required = true
43-
xml.outputLocation = file(".qodana/code-coverage/report.xml")
44-
}
45-
46-
afterEvaluate {
47-
classDirectories = files(classDirectories.files.collect {
48-
fileTree(dir: it, exclude: ['**/MediaConstraints.class',
49-
'**/stickerify/exception/**',
50-
'**/stickerify/process/**',
51-
'**/stickerify/runner**',
52-
'**/stickerify/telegram/**'])
53-
})
54-
}
55-
}
56-
5741
group = 'com.github.stickerifier'
5842
version = '1.0'
5943
description = 'Telegram bot to convert medias in the format required to be used as Telegram stickers'
@@ -69,26 +53,49 @@ tasks.withType(JavaCompile).configureEach {
6953
}
7054

7155
test {
56+
dependsOn jre
57+
inputs.dir tasks.jre.jreDir
58+
59+
def file = DefaultNativePlatform.currentOperatingSystem.isWindows() ? 'java.exe' : 'java'
60+
executable = tasks.jre.jreDir.file('bin/' + file)
61+
7262
useJUnitPlatform()
73-
finalizedBy(jacocoTestReport)
63+
finalizedBy jacocoTestReport
7464
}
7565

76-
application {
77-
mainClass = 'com.github.stickerifier.stickerify.runner.Main'
66+
jacocoTestReport {
67+
reports {
68+
html.required = false
69+
xml.required = true
70+
xml.outputLocation = file(".qodana/code-coverage/report.xml")
71+
}
72+
73+
afterEvaluate {
74+
classDirectories = files(classDirectories.files.collect {
75+
fileTree(dir: it, exclude: ['**/MediaConstraints.class',
76+
'**/stickerify/exception/**',
77+
'**/stickerify/process/**',
78+
'**/stickerify/runner**',
79+
'**/stickerify/telegram/**'])
80+
})
81+
}
7882
}
7983

80-
runtime {
81-
options = ['--strip-debug', '--no-header-files', '--no-man-pages']
82-
modules = ['java.desktop', 'java.naming', 'java.sql', 'jdk.crypto.ec', 'jdk.unsupported']
84+
application {
85+
mainClass = 'com.github.stickerifier.stickerify.runner.Main'
8386
}
8487

8588
shadowJar {
86-
archiveBaseName = 'Stickerify'
87-
archiveClassifier = 'shadow'
88-
archiveVersion = ''
8989
mergeServiceFiles()
9090

9191
dependencies {
9292
exclude('dist_webp_binaries/')
9393
}
9494
}
95+
96+
runtime {
97+
options = ['--strip-debug', '--no-header-files', '--no-man-pages']
98+
modules = ['java.desktop', 'java.instrument', 'java.naming', 'java.sql', 'jdk.crypto.ec', 'jdk.unsupported']
99+
}
100+
101+
suggestModules.dependsOn shadowJar

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ telegram-bot-api = "com.github.pengrad:java-telegram-bot-api:8.3.0"
2424
tika = "org.apache.tika:tika-core:3.1.0"
2525

2626
[plugins]
27-
runtime = "org.beryx.runtime:1.13.1"
27+
runtime = "com.dua3.gradle.runtime:1.13.1-patch-1"
2828
shadow = "com.gradleup.shadow:8.3.6"

0 commit comments

Comments
 (0)