Description
I have a Spring Boot App with Gradle and Kotlin including id("org.graalvm.buildtools.native") version "0.9.26"
and a META-INF/native-image
folder in Resources. When running bootBuildImage with paketo base builder, it builds a native image. This is fine for prod uses. For some debugging I want to build a java based image, not a native image. When I now set BP_NATIVE_IMAGE=false
, still a native image is build. I did try to exclude the plugin and also to exclude the META-INF folder, but regardless of what I try, the builder always builds a native image with liberica nik.
Expected Behavior
When setting BP_NATIVE_IMAGE=false
I would expect to not build a native-image but rather a normal jvm based image.
Current Behavior
The builder builds a native image, regardless of which variables I set.
Possible Solution
Steps to Reproduce
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
val kotlinVersion = "1.9.10"
kotlin("jvm") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion
id("org.springframework.boot") version "3.1.3"
id("io.spring.dependency-management") version "1.1.3"
id("org.graalvm.buildtools.native") version "0.9.26"
application
id("org.flywaydb.flyway") version "9.22.0"
}
group = "com.example"
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
}
dependencies {
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.4"))
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.cloud:spring-cloud-starter-gateway")
implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
runtimeOnly("io.r2dbc:r2dbc-h2")
runtimeOnly("com.h2database:h2")
runtimeOnly(kotlin("reflect"))
// Kotlin
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
// Flyway
implementation("org.flywaydb:flyway-core")
}
tasks {
bootBuildImage {
builder.set("paketobuildpacks/builder:base")
environment.set(
mapOf(
"BP_JVM_VERSION" to "17",
"BP_NATIVE_IMAGE" to "false",
"BPE_SPRING_PROFILES_ACTIVE" to "prod",
"BP_SPRING_CLOUD_BINDINGS_DISABLED" to "true",
"BPE_APPEND_JAVA_TOOL_OPTIONS" to "-XX:+ExtensiveErrorReports",
"BPE_DELIM_JAVA_TOOL_OPTIONS" to " ",
),
)
imageName.set("registry.gitlab.com/etalytics/infrastructure/eta-central")
tags.set(listOf("${project.version}"))
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
javaParameters = true
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xemit-jvm-type-annotations", "-Xjvm-default=all", "-Xcontext-receivers")
}
}
tasks.test {
useJUnitPlatform()
}
graalvmNative {
agent {
defaultMode.set("standard")
}
toolchainDetection.set(false)
binaries {
all {
resources.autodetect()
buildArgs("--enable-monitoring=heapdump", "-march=native", "--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback,org.apache.logging")
}
named("main") {
when {
project.hasProperty("static") -> buildArgs("--static", "--libc=musl")
else -> buildArgs("-H:+StaticExecutableWithDynamicLibC")
}
}
}
metadataRepository {
enabled.set(true)
}
}