Skip to content

Commit 4d47391

Browse files
jbachorikclaude
andcommitted
Fix Gradle 9 idiomaticity and consistency issues
- Add javaLauncher workaround for Test tasks (musl compatibility) - Fix configurations to be resolvable-only (Gradle 9 requirement) - Upgrade plugins: ben-manes.versions 0.51.0, download 5.6.0 - Use lazy configuration for Javadoc tasks - Fix eager task resolution in publishing assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 36a5640 commit 4d47391

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class ProfilerTestPlugin : Plugin<Project> {
6161
// Create base configurations eagerly so they can be extended by build scripts
6262
// without needing afterEvaluate
6363
project.configurations.maybeCreate("testCommon").apply {
64-
isCanBeConsumed = true
64+
isCanBeConsumed = false
6565
isCanBeResolved = true
6666
}
6767
project.configurations.maybeCreate("mainCommon").apply {
68-
isCanBeConsumed = true
68+
isCanBeConsumed = false
6969
isCanBeResolved = true
7070
}
7171

@@ -93,7 +93,12 @@ class ProfilerTestPlugin : Plugin<Project> {
9393
// Use JUnit Platform
9494
task.useJUnitPlatform()
9595

96-
// Configure Java executable - use centralized utility for JAVA_TEST_HOME/JAVA_HOME resolution
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?)
97102
task.setExecutable(PlatformUtils.testJavaExecutable())
98103

99104
// Standard environment variables
@@ -183,7 +188,7 @@ class ProfilerTestPlugin : Plugin<Project> {
183188

184189
// Create test configuration
185190
val testCfg = project.configurations.maybeCreate("test${configName.replaceFirstChar { it.uppercaseChar() }}Implementation").apply {
186-
isCanBeConsumed = true
191+
isCanBeConsumed = false
187192
isCanBeResolved = true
188193
extendsFrom(testCommon)
189194
}
@@ -223,7 +228,7 @@ class ProfilerTestPlugin : Plugin<Project> {
223228
if (configName in applicationConfigs && appMainClass.isNotEmpty()) {
224229
// Create main configuration
225230
val mainCfg = project.configurations.maybeCreate("${configName}Implementation").apply {
226-
isCanBeConsumed = true
231+
isCanBeConsumed = false
227232
isCanBeResolved = true
228233
extendsFrom(mainCommon)
229234
}

ddprof-lib/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ plugins {
77
java
88
`maven-publish`
99
signing
10-
id("com.github.ben-manes.versions") version "0.27.0"
11-
id("de.undercouch.download") version "4.1.1"
10+
id("com.github.ben-manes.versions") version "0.51.0"
11+
id("de.undercouch.download") version "5.6.0"
1212
id("com.datadoghq.native-build")
1313
id("com.datadoghq.gtest")
1414
id("com.datadoghq.scanbuild")
@@ -174,7 +174,7 @@ val sourcesJar by tasks.registering(Jar::class) {
174174
}
175175

176176
// Javadoc configuration
177-
tasks.withType<Javadoc> {
177+
tasks.withType<Javadoc>().configureEach {
178178
// Allow javadoc to access internal sun.nio.ch package used by BufferWriter8
179179
(options as StandardJavadocDocletOptions).addStringOption("-add-exports", "java.base/sun.nio.ch=ALL-UNNAMED")
180180
}
@@ -252,7 +252,7 @@ tasks.withType<Sign>().configureEach {
252252

253253
// Publication assertions
254254
gradle.taskGraph.whenReady {
255-
if (hasTask(tasks.named("publish").get()) || hasTask(":publishToSonatype")) {
255+
if (hasTask(":ddprof-lib:publish") || hasTask(":publishToSonatype")) {
256256
check(project.findProperty("removeJarVersionNumbers") != true) {
257257
"Cannot publish with removeJarVersionNumbers=true"
258258
}

0 commit comments

Comments
 (0)