@@ -93,12 +93,8 @@ class ProfilerTestPlugin : Plugin<Project> {
9393 // Use JUnit Platform
9494 task.useJUnitPlatform()
9595
96- // Disable Gradle 9 toolchain probing (fails on musl with glibc probe binary)
97- // Use explicit executable path instead
98- @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
99- task.javaLauncher.convention(null as org.gradle.jvm.toolchain.JavaLauncher ? )
100- @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
101- task.javaLauncher.value(null as org.gradle.jvm.toolchain.JavaLauncher ? )
96+ // Disable toolchain probing and set explicit executable
97+ disableToolchainProbing(task)
10298 task.setExecutable(PlatformUtils .testJavaExecutable())
10399
104100 // Standard environment variables
@@ -125,13 +121,8 @@ class ProfilerTestPlugin : Plugin<Project> {
125121 }
126122
127123 private fun configureJavaExecTask (task : JavaExec , extension : ProfilerTestExtension , project : Project ) {
128- // Disable Gradle 9 toolchain probing (fails on musl with glibc probe binary)
129- // Use explicit executable path instead
130- // Note: Must clear convention AND set value to prevent toolchain resolution
131- @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
132- task.javaLauncher.convention(null as org.gradle.jvm.toolchain.JavaLauncher ? )
133- @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
134- task.javaLauncher.value(null as org.gradle.jvm.toolchain.JavaLauncher ? )
124+ // Disable toolchain probing and set explicit executable
125+ disableToolchainProbing(task)
135126 task.setExecutable(PlatformUtils .testJavaExecutable())
136127
137128 // JVM arguments for JavaExec tasks
@@ -143,6 +134,31 @@ class ProfilerTestPlugin : Plugin<Project> {
143134 }
144135 }
145136
137+ /* *
138+ * Disables Gradle 9 toolchain probing for tasks with javaLauncher property.
139+ *
140+ * Gradle 9's toolchain probing uses a glibc-compiled probe binary that fails on musl (Alpine).
141+ * This workaround clears both the convention and value to prevent any toolchain resolution.
142+ *
143+ * Must set both convention(null) AND value(null) because:
144+ * - convention(null) clears the default toolchain convention
145+ * - value(null) clears any provider-based value
146+ * Without both, Gradle may still attempt to resolve the toolchain.
147+ */
148+ private fun disableToolchainProbing (task : org.gradle.api.tasks.JavaExec ) {
149+ @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
150+ task.javaLauncher.convention(null as org.gradle.jvm.toolchain.JavaLauncher ? )
151+ @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
152+ task.javaLauncher.value(null as org.gradle.jvm.toolchain.JavaLauncher ? )
153+ }
154+
155+ private fun disableToolchainProbing (task : org.gradle.api.tasks.testing.Test ) {
156+ @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
157+ task.javaLauncher.convention(null as org.gradle.jvm.toolchain.JavaLauncher ? )
158+ @Suppress(" NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS" )
159+ task.javaLauncher.value(null as org.gradle.jvm.toolchain.JavaLauncher ? )
160+ }
161+
146162 private fun generateMultiConfigTasks (project : Project , extension : ProfilerTestExtension ) {
147163 val nativeBuildExt = project.rootProject.extensions.findByType(NativeBuildExtension ::class .java)
148164 ? : return // No native build extension, nothing to generate
0 commit comments