Skip to content

Commit 9dff72f

Browse files
committed
Change spring boot packaging
1 parent f7cd5a1 commit 9dff72f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

smoke-tests/images/spring-boot/build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import com.google.cloud.tools.jib.gradle.JibTask
2+
import org.gradle.api.tasks.Sync
3+
import org.gradle.jvm.tasks.Jar
24
import java.time.LocalDateTime
35
import java.time.format.DateTimeFormatter
46

@@ -56,15 +58,34 @@ springBoot {
5658
}
5759

5860
val repo = System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation"
61+
val bootJarTask = tasks.named<Jar>("bootJar")
62+
63+
val prepareBootJarForImage by tasks.registering(Sync::class) {
64+
// Preserve Spring Boot's packaged runtime instead of Jib's default exploded layout so
65+
// smoke tests exercise the typical bootJar launcher/classloader behavior used by java -jar.
66+
from(bootJarTask)
67+
into(layout.buildDirectory.dir("jib-extra/app"))
68+
rename { "app.jar" }
69+
}
5970

6071
jib {
6172
from.image = "eclipse-temurin:$targetJDK"
6273
to.image = "ghcr.io/$repo/smoke-test-spring-boot:jdk$targetJDK-$tag"
74+
container.entrypoint = listOf("java", "-jar", "/app/app.jar")
6375
container.ports = listOf("8080")
76+
extraDirectories {
77+
paths {
78+
path {
79+
setFrom(layout.buildDirectory.dir("jib-extra").get().asFile.toPath())
80+
into = "/"
81+
}
82+
}
83+
}
6484
}
6585

6686
tasks {
6787
withType<JibTask>().configureEach {
88+
dependsOn(prepareBootJarForImage)
6889
// Jib tasks access Task.project at execution time which is not compatible with configuration cache
6990
notCompatibleWithConfigurationCache("Jib task accesses Task.project at execution time")
7091
}

0 commit comments

Comments
 (0)