File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
smoke-tests/images/spring-boot Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 11import com.google.cloud.tools.jib.gradle.JibTask
2+ import org.gradle.api.tasks.Sync
3+ import org.gradle.jvm.tasks.Jar
24import java.time.LocalDateTime
35import java.time.format.DateTimeFormatter
46
@@ -56,15 +58,34 @@ springBoot {
5658}
5759
5860val 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
6071jib {
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
6686tasks {
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 }
You can’t perform that action at this time.
0 commit comments