Skip to content

Commit 814c574

Browse files
authored
Switch spring-boot-2.7-webflux to the smoke-test plugin (#11407)
chore(build-logic): add smoke-test plugin for nested Gradle builds Adds a new included build `build-logic/` hosting a single subproject `smoke-test` that exposes the `dd-trace-java.smoke-test-app` plugin. The plugin contributes: - `NestedGradleBuild` task type that runs a nested Gradle build via the Gradle Tooling API. It pins the nested Gradle version (no committed per-application wrappers), uses the configured Java toolchain for the nested daemon, forwards artifact paths from the root build as `-P<name>=<path>`, and redirects the nested `buildDir` via `-PappBuildDir=<path>` so outputs land under the outer project's build directory. - `smokeTestApp` project extension with an `application { ... }` block that registers the `NestedGradleBuild` task, wires it into every `Test` task via `dependsOn` + a `jvmArgumentProvider` for the produced artifact's system property. Consumers can also register `NestedGradleBuild` directly when they need more control; the plugin is a no-op until `application` or a manual registration is done. - `projectJar(name, project)` helper that forwards a sibling project's jar to the nested build through a resolvable `Configuration` (avoids `evaluationDependsOn` and the cross-project access ordering issues). The plugin is verified with JUnit 5 unit tests (`ProjectBuilder`) and end-to-end tests that drive the Tooling API path through the Gradle Test Kit with a temporary Kotlin-DSL test project. `build-logic/settings.gradle.kts` references the existing `gradle/libs.versions.toml` catalog (mirroring `buildSrc/`) so the plugin can use the same library coordinates as the rest of the repo. The Gradle libs Maven repository (`https://repo.gradle.org/gradle/libs-releases`, scoped to `org.gradle:`) is added to the root build's `pluginManagement` and to `gradle/repositories.gradle` so the Tooling API jar resolves. Smoke-test modules with Spring Boot plugin versions incompatible with Gradle 9 will use this plugin in follow-up PRs instead of a committed Gradle 8 wrapper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> chore(build-logic): default smokeTestApp to JDK 21 daemon + Gradle 8.14.5 Set conventions on `smokeTestApp`: - `gradleVersion` defaults to `"8.14.5"` (Gradle 8 last release; pinned because Spring Boot plugin pre-3.5 calls `Configuration.getUploadTaskName()`, removed in Gradle 9). - `javaLauncher` defaults to a JDK 21 toolchain (the version the root build requires for its own Gradle 9 migration; standardising the nested daemon on the same JDK avoids requiring an extra toolchain on dev machines and CI runners). Consumers that need a different JDK or Gradle version still override explicitly. The inner build script is responsible for pinning the produced bytecode level (`java { sourceCompatibility = JavaVersion.VERSION_1_8 }` or similar) — Gradle adds `--release N` automatically when source/target differs from the daemon JVM. `JavaToolchainService` is now injected into the extension; this works in any project where a `java*` (or related) plugin is applied. Smoke-test modules already apply `gradle/java.gradle`, which applies `java`, so the convention resolves on first read. Public defaults exposed as `DEFAULT_NESTED_GRADLE_VERSION` and `DEFAULT_NESTED_JAVA_VERSION` constants so the values are discoverable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> chore(build-logic): use org.gradle.kotlin.dsl idioms in smoke-test plugin Switch the plugin sources and unit tests over to the typed `org.gradle.kotlin.dsl` extension functions where they replace `::class.java` boilerplate: - `tasks.register(name, Type::class.java) { … }` → `tasks.register<Type>(name) { … }` - `tasks.withType(Type::class.java).configureEach { … }` → `tasks.withType<Type>().configureEach { … }` - `extensions.create("name", Type::class.java)` → `extensions.create<Type>("name")` - `extensions.getByType(Type::class.java)` → `extensions.getByType<Type>()` - `extensions.findByName("name")` (followed by `isInstanceOf`) → `extensions.findByType<Type>()` - `project.plugins.apply(Plugin::class.java)` → `project.apply<Plugin>()` (PluginAware) - `objects.newInstance(Type::class.java)` → `objects.newInstance<Type>()` Also drop the six `captured*` local variables in `SmokeTestAppExtension.application` — inside `tasks.register<NestedGradleBuild>(taskName) { … }` the outer extension's properties are now reached via `this@SmokeTestAppExtension.<prop>` directly. No behavioural change; the 9 plugin tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> chore(smoke-tests): switch spring-boot-2.7-webflux to the smoke-test plugin This module already had a nested `application/` Gradle subproject built via an `Exec` task that invoked the root `gradlew`. With the root build moving to Gradle 9 (incompatible with Spring Boot plugin 2.x), the nested build must pin its own Gradle version. Swap the `Exec` task for the `smokeTestApp { application { … } }` DSL from the `build-logic:smoke-test` plugin: Gradle 8.14.5 is pinned via the Tooling API, the Java 8 toolchain is applied to the nested daemon, and `dd-trace-api.jar` is forwarded via `projectJar('apiJar', …)` (resolved through a `Configuration`, so no `evaluationDependsOn` is needed). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Merge branch 'master' into bdu/smoke-test-pattern-c-webflux docs(smoke-tests): document nested-build settings.gradle config choices Match the review feedback applied on #11408: expand the terse comments in the spring-boot-2.7-webflux nested settings.gradle to explain the CI Maven mirror proxies and the CI-only shared build cache (f6ec1f5 / #982, b34ccbc). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> docs(smoke-tests): shorten Java 8 bytecode comment Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Merge branch 'master' into bdu/smoke-test-pattern-c-webflux Co-authored-by: brice.dutheil <brice.dutheil@datadoghq.com>
1 parent 85fb033 commit 814c574

3 files changed

Lines changed: 29 additions & 37 deletions

File tree

dd-smoke-tests/spring-boot-2.7-webflux/application/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ if (hasProperty('appBuildDir')) {
1616

1717
version = ""
1818

19+
// Target Java 8 bytecode as daemon can run on JDK 21
20+
java {
21+
sourceCompatibility = JavaVersion.VERSION_1_8
22+
}
23+
1924
dependencies {
2025
implementation 'org.springframework.boot:spring-boot-starter-webflux'
2126
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

dd-smoke-tests/spring-boot-2.7-webflux/application/settings.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven
2+
// mirrors used by CI when the public repos are unreachable; they are forwarded from the
3+
// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the
4+
// mirrors are reached over plain HTTP inside the CI network.
15
pluginManagement {
26
repositories {
37
mavenLocal()
@@ -20,12 +24,16 @@ pluginManagement {
2024

2125
def isCI = providers.environmentVariable("CI").isPresent()
2226

23-
// Don't pollute the dependency cache with the build cache
27+
// On CI, point the local Gradle build cache to the shared workspace directory under the
28+
// repository root, so cache entries are reused across the many smoke-test nested builds
29+
// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the
30+
// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default
31+
// per-user cache to avoid leaking entries into the repo tree.
32+
// The directory must line up with the outer project's settings.gradle.
2433
if (isCI) {
2534
def sharedRootDir = "$rootDir/../../../"
2635
buildCache {
2736
local {
28-
// This needs to line up with the code in the outer project settings.gradle
2937
directory = "$sharedRootDir/workspace/build-cache"
3038
}
3139
}

dd-smoke-tests/spring-boot-2.7-webflux/build.gradle

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,23 @@
1-
apply from: "$rootDir/gradle/java.gradle"
2-
3-
description = 'Spring Boot 2.7 Webflux Smoke Tests.'
4-
5-
dependencies {
6-
testImplementation project(':dd-smoke-tests')
1+
plugins {
2+
id 'dd-trace-java.smoke-test-app'
73
}
84

9-
def appDir = "$projectDir/application"
10-
def appBuildDir = "$buildDir/application"
11-
def isWindows = System.getProperty("os.name").toLowerCase().contains("win")
12-
def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
13-
14-
// define the task that builds the project
15-
tasks.register('webfluxBuild', Exec) {
16-
workingDir "$appDir"
17-
environment += [
18-
"GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'",
19-
"JAVA_HOME": getLazyJavaHomeFor(8)
20-
]
21-
commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"
22-
23-
outputs.cacheIf { true }
5+
apply from: "$rootDir/gradle/java.gradle"
246

25-
outputs.dir(appBuildDir)
26-
.withPropertyName("applicationJar")
7+
description = 'Spring Boot 2.7 Webflux Smoke Tests.'
278

28-
inputs.files(fileTree(appDir) {
29-
include '**/*'
30-
exclude '.gradle/**'
31-
})
32-
.withPropertyName("application")
33-
.withPathSensitivity(PathSensitivity.RELATIVE)
9+
smokeTestApp {
10+
application {
11+
taskName = 'webfluxBuild'
12+
nestedTasks = ['bootJar']
13+
artifactPath = 'libs/webflux-2.7-smoketest.jar'
14+
sysProperty = 'datadog.smoketest.webflux.uberJar.path'
15+
}
16+
projectJar('apiJar', project(':dd-trace-api'))
3417
}
3518

36-
tasks.named("webfluxBuild", Exec) {
37-
dependsOn project(':dd-trace-api').tasks.named("jar")
19+
dependencies {
20+
testImplementation project(':dd-smoke-tests')
3821
}
3922

4023
tasks.named("compileTestGroovy", GroovyCompile) {
@@ -44,10 +27,6 @@ tasks.named("compileTestGroovy", GroovyCompile) {
4427
}
4528
}
4629

47-
tasks.withType(Test).configureEach {
48-
jvmArgs "-Ddatadog.smoketest.webflux.uberJar.path=$appBuildDir/libs/webflux-2.7-smoketest.jar"
49-
}
50-
5130
spotless {
5231
java {
5332
target "**/*.java"

0 commit comments

Comments
 (0)