Skip to content

Commit 1f72887

Browse files
bric3devflow.devflow-routing-intake
andauthored
Convert test-published-dependencies to Gradle Kotlin DSL (#11445)
refactor(build): convert test-published-dependencies to Gradle Kotlin DSL Convert the test-published-dependencies build scripts from Groovy to Kotlin DSL: root settings/build, plus the four subprojects (all-deps-exist, ot-pulls-in-api, ot-is-shaded, agent-logs-on-java-7). In ot-is-shaded, the CheckJarContentsTask is rewritten with managed Property/ListProperty inputs and idiomatic Kotlin. Verified locally by reproducing the GitLab `test_published_artifacts` job: publishToMavenLocal then `./gradlew check` in the subproject. All modules pass; the Java 7 sub-test of agent-logs-on-java-7 is skipped locally only because no JDK 7 build exists for arm64 macOS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Merge branch 'master' into bdu/migrate-test-published-artifacts-to-kotlin-dsl fix(test-published-dependencies): declare JUnit launcher Update the published dependency test builds to use Kotlin DSL task accessors and provider-backed configuration resolution. Add junit-platform-launcher alongside the JUnit BOM update because the missing launcher caused test execution problems at least on Gradle 9.5. Fixed the size assert, replaced by a simpler if statement. Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent de65673 commit 1f72887

12 files changed

Lines changed: 257 additions & 237 deletions

File tree

test-published-dependencies/agent-logs-on-java-7/build.gradle

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import org.gradle.api.file.ConfigurableFileCollection
2+
import org.gradle.api.file.RegularFileProperty
3+
import org.gradle.api.tasks.Classpath
4+
import org.gradle.api.tasks.InputFile
5+
import org.gradle.api.tasks.PathSensitive
6+
import org.gradle.api.tasks.PathSensitivity
7+
import org.gradle.kotlin.dsl.application
8+
import org.gradle.kotlin.dsl.invoke
9+
import org.gradle.kotlin.dsl.java
10+
import org.gradle.process.CommandLineArgumentProvider
11+
12+
plugins {
13+
java
14+
application
15+
}
16+
17+
java {
18+
disableAutoTargetJvm()
19+
20+
toolchain {
21+
languageVersion = JavaLanguageVersion.of(8)
22+
}
23+
24+
sourceCompatibility = JavaVersion.VERSION_1_7
25+
targetCompatibility = JavaVersion.VERSION_1_7
26+
}
27+
28+
val agent = configurations.register("agent")
29+
30+
dependencies {
31+
agent("com.datadoghq:dd-java-agent:$version")
32+
testImplementation(platform("org.junit:junit-bom:5.14.1"))
33+
testImplementation("org.junit.jupiter:junit-jupiter")
34+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
35+
}
36+
37+
abstract class AgentLogsOnJava7JvmArguments : CommandLineArgumentProvider {
38+
@get:Classpath
39+
abstract val agentClasspath: ConfigurableFileCollection
40+
41+
@get:InputFile
42+
@get:PathSensitive(PathSensitivity.RELATIVE)
43+
abstract val appJar: RegularFileProperty
44+
45+
override fun asArguments(): Iterable<String> = listOf(
46+
"-Dtest.published.dependencies.agent=${agentClasspath.singleFile}",
47+
"-Dtest.published.dependencies.jar=${appJar.get().asFile}",
48+
)
49+
}
50+
51+
val jarTask = tasks.jar
52+
53+
tasks.test {
54+
dependsOn(jarTask)
55+
useJUnitPlatform()
56+
testLogging {
57+
events("passed", "skipped", "failed")
58+
}
59+
jvmArgumentProviders.add(
60+
objects.newInstance(AgentLogsOnJava7JvmArguments::class.java).apply {
61+
agentClasspath.from(agent)
62+
appJar.set(jarTask.flatMap { it.archiveFile })
63+
}
64+
)
65+
}
66+
67+
tasks.jar {
68+
manifest {
69+
attributes("Main-Class" to "test.published.dependencies.App")
70+
}
71+
}
72+
73+
application {
74+
mainClass = "test.published.dependencies.App"
75+
}
76+
77+
tasks.compileTestJava {
78+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
79+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
80+
}

test-published-dependencies/all-deps-exist/build.gradle

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
plugins {
2+
java
3+
application
4+
}
5+
6+
java {
7+
disableAutoTargetJvm()
8+
}
9+
10+
dependencies {
11+
implementation("com.datadoghq:dd-java-agent:$version")
12+
implementation("com.datadoghq:dd-trace-api:$version")
13+
implementation("com.datadoghq:dd-trace-ot:$version")
14+
}
15+
16+
application {
17+
mainClass = "test.published.dependencies.App"
18+
}

test-published-dependencies/build.gradle

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id("com.diffplug.spotless") version "8.4.0"
3+
}
4+
5+
val sharedConfigDirectory = "$rootDir/../gradle"
6+
rootProject.extra["sharedConfigDirectory"] = sharedConfigDirectory
7+
8+
val isCI = providers.environmentVariable("CI").isPresent
9+
val versionFromFile = file("$rootDir/${if (isCI) "../workspace" else ".."}/build/main.version").readLines().first()
10+
11+
allprojects {
12+
group = "com.datadoghq"
13+
version = versionFromFile
14+
15+
apply(from = "$sharedConfigDirectory/repositories.gradle")
16+
apply(from = "$sharedConfigDirectory/spotless.gradle")
17+
}

test-published-dependencies/ot-is-shaded/build.gradle

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)