diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000000..612ae4b8fdd --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,50 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.extra.has("gradlePluginProxy")) { + maven { + url = uri(settings.extra["gradlePluginProxy"] as String) + isAllowInsecureProtocol = true + } + } + if (settings.extra.has("mavenRepositoryProxy")) { + maven { + url = uri(settings.extra["mavenRepositoryProxy"] as String) + isAllowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } + repositories { + mavenLocal() + if (settings.extra.has("mavenRepositoryProxy")) { + maven { + url = uri(settings.extra["mavenRepositoryProxy"] as String) + isAllowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + // Hosts gradle-tooling-api; used by the smoke-test plugin to run nested Gradle builds + // pinned to older Gradle versions. + maven { + url = uri("https://repo.gradle.org/gradle/libs-releases") + content { + includeGroup("org.gradle") + } + } + } +} + +rootProject.name = "build-logic" + +include(":smoke-test") diff --git a/build-logic/smoke-test/build.gradle.kts b/build-logic/smoke-test/build.gradle.kts new file mode 100644 index 00000000000..2581025425e --- /dev/null +++ b/build-logic/smoke-test/build.gradle.kts @@ -0,0 +1,56 @@ +plugins { + `java-gradle-plugin` + `kotlin-dsl` + `jvm-test-suite` +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +kotlin { + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8) + } +} + +dependencies { + implementation(libs.gradle.tooling.api) + runtimeOnly("org.slf4j:slf4j-simple:1.7.36") +} + +gradlePlugin { + plugins { + create("smoke-test-app") { + id = "dd-trace-java.smoke-test-app" + implementationClass = "datadog.buildlogic.smoketest.SmokeTestAppPlugin" + } + } +} + +@Suppress("UnstableApiUsage") +testing { + suites { + val test by getting(JvmTestSuite::class) { + useJUnitJupiter(libs.versions.junit5) + dependencies { + implementation(libs.junit.jupiter) + implementation(libs.junit.jupiter.params) + implementation(libs.junit.jupiter.engine) + implementation(libs.assertj.core) + implementation(gradleTestKit()) + } + targets.configureEach { + testTask.configure { + // The gradle-test-kit runner shells out to a Gradle daemon, which can be slow on a + // cold cache. Surface stdout/stderr to make CI failures debuggable. + testLogging { + showStandardStreams = true + events("failed", "skipped") + } + } + } + } + } +} diff --git a/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedBuildProjectJar.kt b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedBuildProjectJar.kt new file mode 100644 index 00000000000..503f78c47b4 --- /dev/null +++ b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedBuildProjectJar.kt @@ -0,0 +1,24 @@ +package datadog.buildlogic.smoketest + +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity + +/** + * A jar produced by the root build that needs to be forwarded into a [NestedGradleBuild]. + * + * At execution time the task adds `-P${propertyName}=` to the nested + * Gradle invocation, so the inner build script can pick it up via `findProperty(...)`. + */ +abstract class NestedBuildProjectJar { + + @get:Input + abstract val propertyName: Property + + @get:InputFile + @get:PathSensitive(PathSensitivity.NONE) + abstract val file: RegularFileProperty +} diff --git a/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedGradleBuild.kt b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedGradleBuild.kt new file mode 100644 index 00000000000..e2c1c34f09f --- /dev/null +++ b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/NestedGradleBuild.kt @@ -0,0 +1,128 @@ +package datadog.buildlogic.smoketest + +import org.gradle.api.Action +import org.gradle.api.DefaultTask +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileTree +import org.gradle.api.file.RegularFile +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.IgnoreEmptyDirectories +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.jvm.toolchain.JavaLauncher +import org.gradle.jvm.toolchain.JavaToolchainService +import org.gradle.kotlin.dsl.newInstance +import org.gradle.tooling.GradleConnector +import javax.inject.Inject + +/** + * Runs a nested Gradle build inside [applicationDir] via the Gradle Tooling API. + * + * Lets a smoke test pin a Gradle version (typically older than the root build) and a Java + * toolchain for the nested daemon, without committing per-application `gradlew` wrappers. + * + * The nested build script is expected to honour `-PappBuildDir=` and redirect its + * `buildDir` to that path so the artifact lands in [applicationBuildDir]. Project artifacts + * from the root build can be forwarded via [projectJar]; each entry is passed as + * `-P=` and tracked as a task input so the nested build re-runs + * when the upstream jar changes. + */ +abstract class NestedGradleBuild @Inject constructor( + private val objects: ObjectFactory, + javaToolchains: JavaToolchainService, +) : DefaultTask() { + + init { + gradleVersion.convention(DEFAULT_NESTED_GRADLE_VERSION) + javaLauncher.convention( + javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(DEFAULT_NESTED_JAVA_VERSION)) + }, + ) + } + + @get:Internal + abstract val applicationDir: DirectoryProperty + + @get:InputFiles + @get:IgnoreEmptyDirectories + @get:PathSensitive(PathSensitivity.RELATIVE) + val applicationSources: FileTree = + objects.fileTree().from(applicationDir).matching { + exclude(".gradle/**", "build/**") + } + + @get:Input + abstract val gradleVersion: Property + + @get:Nested + abstract val javaLauncher: Property + + @get:Input + abstract val tasksToRun: ListProperty + + @get:Input + abstract val buildArguments: ListProperty + + @get:Nested + abstract val projectJars: ListProperty + + @get:OutputDirectory + abstract val applicationBuildDir: DirectoryProperty + + /** Forward a root-build jar as `-P=` into the nested build. */ + fun projectJar(name: String, file: Provider) { + projectJars.add( + objects.newInstance().apply { + propertyName.set(name) + this.file.set(file) + }, + ) + } + + /** Configure additional aspects of the nested build via a typed action. */ + fun projectJar(action: Action) { + projectJars.add( + objects.newInstance().also(action::execute), + ) + } + + @TaskAction + fun runNestedBuild() { + val appDir = applicationDir.get().asFile + val appBuildDirFile = applicationBuildDir.get().asFile + val daemonJavaHome = javaLauncher.get().metadata.installationPath.asFile + + val args = buildList { + add("-PappBuildDir=${appBuildDirFile.absolutePath}") + projectJars.get().forEach { entry -> + add("-P${entry.propertyName.get()}=${entry.file.get().asFile.absolutePath}") + } + addAll(buildArguments.get()) + } + + val connector = GradleConnector.newConnector() + .useGradleVersion(gradleVersion.get()) + .forProjectDirectory(appDir) + + connector.connect().use { connection -> + connection.newBuild() + .forTasks(*tasksToRun.get().toTypedArray()) + .withArguments(args) + .setJavaHome(daemonJavaHome) + .setStandardOutput(System.out) + .setStandardError(System.err) + .run() + } + } +} diff --git a/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppExtension.kt b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppExtension.kt new file mode 100644 index 00000000000..ccb5ee838db --- /dev/null +++ b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppExtension.kt @@ -0,0 +1,214 @@ +package datadog.buildlogic.smoketest + +import org.gradle.api.Action +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFile +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.testing.Test +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.jvm.toolchain.JavaLauncher +import org.gradle.jvm.toolchain.JavaToolchainService +import org.gradle.kotlin.dsl.newInstance +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType +import org.gradle.process.CommandLineArgumentProvider +import java.util.Locale +import javax.inject.Inject + +/** + * Project extension that wires a [NestedGradleBuild] task for a smoke-test application. + * + * The plugin only contributes a task when the consumer calls [application]; if the extension + * stays unconfigured, the plugin is a no-op and consumers can register [NestedGradleBuild] + * directly. + */ +abstract class SmokeTestAppExtension @Inject constructor( + private val project: Project, + javaToolchains: JavaToolchainService, +) { + + /** + * Gradle version used by the nested daemon. Defaults to [DEFAULT_NESTED_GRADLE_VERSION] — + * the version pinned for smoke-test applications whose Spring Boot plugin is incompatible + * with Gradle 9. + */ + abstract val gradleVersion: Property + + /** + * JDK used by the nested daemon. Defaults to a [DEFAULT_NESTED_JAVA_VERSION] toolchain; + * override to pin a different JDK if the nested application's plugin chain requires it. + * The inner build script is responsible for pinning the produced bytecode level (e.g. + * `java { sourceCompatibility = JavaVersion.VERSION_1_8 }`). + */ + abstract val javaLauncher: Property + + /** Directory containing the nested project's `settings.gradle` + sources. */ + abstract val applicationDir: DirectoryProperty + + /** + * Directory the nested build writes its outputs to. The nested build script is expected to + * honour `-PappBuildDir=`; see the existing smoke-test inner builds for the pattern. + */ + abstract val applicationBuildDir: DirectoryProperty + + internal abstract val projectJars: ListProperty + + init { + applicationDir.convention(project.layout.projectDirectory.dir("application")) + applicationBuildDir.convention(project.layout.buildDirectory.dir("application")) + gradleVersion.convention(DEFAULT_NESTED_GRADLE_VERSION) + javaLauncher.convention( + javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(DEFAULT_NESTED_JAVA_VERSION)) + }, + ) + } + + /** + * Register the nested-build task and wire the produced artifact into every `Test` task as + * a system property. Calling this triggers task registration; consumers that prefer to + * register [NestedGradleBuild] manually can leave [application] uncalled. + */ + fun application(action: Action) { + val spec = project.objects.newInstance() + action.execute(spec) + val taskName = requireNotNull(spec.taskName.orNull) { + "smokeTestApp.application { taskName = ... } is required" + } + val artifactPath = requireNotNull(spec.artifactPath.orNull) { + "smokeTestApp.application { artifactPath = ... } is required" + } + val sysProperty = requireNotNull(spec.sysProperty.orNull) { + "smokeTestApp.application { sysProperty = ... } is required" + } + val nestedTasks = spec.nestedTasks.orNull?.takeIf { it.isNotEmpty() } ?: listOf(taskName) + + val taskProvider: TaskProvider = + project.tasks.register(taskName) { + applicationDir.set(this@SmokeTestAppExtension.applicationDir) + applicationBuildDir.set(this@SmokeTestAppExtension.applicationBuildDir) + gradleVersion.set(this@SmokeTestAppExtension.gradleVersion) + javaLauncher.set(this@SmokeTestAppExtension.javaLauncher) + tasksToRun.set(nestedTasks) + buildArguments.set(spec.buildArguments) + projectJars.set(this@SmokeTestAppExtension.projectJars) + } + + val artifactProvider: Provider = applicationBuildDir.file(artifactPath) + val extras = spec.additionalSystemProperties.get().mapValues { (_, relativePath) -> + applicationBuildDir.file(relativePath) + } + project.tasks.withType().configureEach { + dependsOn(taskProvider) + jvmArgumentProviders.add(SmokeTestArgProvider(sysProperty, artifactProvider, extras)) + } + } + + /** + * Forward the default `jar` artifact from [sourceProject] into the nested build as + * `-P=`. The jar is consumed via a resolvable [Configuration], + * which both establishes the correct task dependency and lets Gradle resolve the artifact + * lazily — no `evaluationDependsOn` is needed. + */ + fun projectJar(propertyName: String, sourceProject: Project) { + val configurationName = "smokeTestAppExtraJar" + + propertyName.replaceFirstChar { it.titlecase(Locale.ROOT) } + val cfg = project.configurations.maybeCreate(configurationName).apply { + isCanBeConsumed = false + isCanBeResolved = true + isTransitive = false + description = "Jar artifact forwarded as -P$propertyName into the smoke-test nested build" + } + project.dependencies.add(configurationName, sourceProject) + addProjectJarFromConfiguration(propertyName, cfg) + } + + /** + * Lower-level overload for the rare case where the caller already has a provider of the + * file. The caller is responsible for the upstream task dependency. + */ + fun projectJar(propertyName: String, file: Provider) { + projectJars.add( + project.objects.newInstance().apply { + this.propertyName.set(propertyName) + this.file.set(file) + }, + ) + } + + private fun addProjectJarFromConfiguration(propertyName: String, cfg: Configuration) { + projectJars.add( + project.objects.newInstance().apply { + this.propertyName.set(propertyName) + // Configuration.elements yields a Provider that carries the producing task dependency, + // so wiring it into the task's @InputFile both tracks file contents and arranges build + // order. + this.file.set( + cfg.elements.map { files -> + project.objects.fileProperty().fileValue(files.single().asFile).get() + }, + ) + }, + ) + } +} + +/** DSL describing the nested-build invocation for one smoke-test application. */ +abstract class ApplicationSpec @Inject constructor() { + /** Outer task name; the nested daemon runs the same task by default. */ + abstract val taskName: Property + + /** Path to the produced artifact, relative to `applicationBuildDir`. */ + abstract val artifactPath: Property + + /** System property name set on Test tasks to point them at the produced artifact. */ + abstract val sysProperty: Property + + /** Tasks run inside the nested build. Defaults to `[taskName]`. */ + abstract val nestedTasks: ListProperty + + /** Extra arguments passed to the nested Gradle invocation. */ + abstract val buildArguments: ListProperty + + /** + * Additional system properties to forward to every `Test` task, keyed by property name with + * values resolved against `applicationBuildDir`. Use this for smoke tests that need more + * than the single primary artifact path (e.g. a separately unpacked server install). + */ + abstract val additionalSystemProperties: MapProperty +} + +/** + * Default Gradle distribution version for the nested daemon. Pinned to a Gradle 8 release + * because the Spring Boot Gradle plugin pre-3.5.0 calls `Configuration.getUploadTaskName()`, + * removed in Gradle 9. + */ +const val DEFAULT_NESTED_GRADLE_VERSION = "8.14.5" + +/** + * Default JDK language version for the nested daemon. JDK 21 is the version the root build + * requires for Gradle 9; standardising the nested daemon on the same JDK avoids pulling a + * second toolchain onto dev machines and CI runners. Inner build scripts cross-compile down + * to their actual bytecode target via `java { sourceCompatibility = ... }`. + */ +const val DEFAULT_NESTED_JAVA_VERSION = 21 + +private class SmokeTestArgProvider( + private val sysProperty: String, + private val artifact: Provider, + private val extras: Map>, +) : CommandLineArgumentProvider { + override fun asArguments(): Iterable = + buildList { + add("-D$sysProperty=${artifact.get().asFile.absolutePath}") + extras.forEach { (key, value) -> + add("-D$key=${value.get().asFile.absolutePath}") + } + } +} diff --git a/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPlugin.kt b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPlugin.kt new file mode 100644 index 00000000000..b6d6fe6b7ba --- /dev/null +++ b/build-logic/smoke-test/src/main/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPlugin.kt @@ -0,0 +1,21 @@ +package datadog.buildlogic.smoketest + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.create + +/** + * Exposes the [NestedGradleBuild] task type plus a `smokeTestApp` extension that wires the + * nested-build task and Test-side system properties for a smoke-test application. + * + * Consumers can either: + * - configure `smokeTestApp { application { ... } }` to let the plugin register the task and + * wire it into every `Test` task, or + * - leave the extension untouched and register a [NestedGradleBuild] task manually (for cases + * that need more control, e.g. additional `Exec`-like task wiring). + */ +class SmokeTestAppPlugin : Plugin { + override fun apply(project: Project) { + project.extensions.create("smokeTestApp") + } +} diff --git a/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppEndToEndTest.kt b/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppEndToEndTest.kt new file mode 100644 index 00000000000..b3ad87bbaf3 --- /dev/null +++ b/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppEndToEndTest.kt @@ -0,0 +1,204 @@ +package datadog.buildlogic.smoketest + +import org.assertj.core.api.Assertions.assertThat +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.io.File +import java.nio.file.Path + +/** + * End-to-end tests that drive the plugin through the Gradle Test Kit and a temporary, + * self-contained Kotlin-DSL test project. The inner "smoke-test application" is itself a + * minimal Kotlin-DSL Gradle build; the outer build wires it through the `smokeTestApp` DSL. + * + * These tests are slow (each test spins up a Gradle daemon) but they are the only way to + * exercise the Tooling API path end-to-end. + */ +class SmokeTestAppEndToEndTest { + + @TempDir + lateinit var projectDir: Path + + private val outerSettings get() = projectDir.resolve("settings.gradle.kts").toFile() + private val outerBuild get() = projectDir.resolve("build.gradle.kts").toFile() + private val applicationDir get() = projectDir.resolve("application").toFile() + + @BeforeEach + fun setUp() { + applicationDir.mkdirs() + } + + @Test + fun `application block registers a NestedGradleBuild task with the configured name`() { + writeOuterSettings() + outerBuild.writeText( + """ + plugins { + java + id("dd-trace-java.smoke-test-app") + } + + smokeTestApp { + javaLauncher.set( + javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(${currentMajorJdk()})) } + ) + application { + taskName.set("packageApp") + artifactPath.set("libs/test.jar") + sysProperty.set("test.path") + } + } + """.trimIndent(), + ) + + val result = runner("tasks", "--all").build() + + assertThat(result.output).contains("packageApp") + } + + @Test + fun `nested build produces the configured artifact`() { + writeOuterSettings() + outerBuild.writeText( + """ + plugins { + java + id("dd-trace-java.smoke-test-app") + } + + smokeTestApp { + javaLauncher.set( + javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(${currentMajorJdk()})) } + ) + application { + taskName.set("buildJar") + artifactPath.set("libs/sample.jar") + sysProperty.set("sample.path") + } + } + """.trimIndent(), + ) + writeInnerSettings() + writeInnerBuild( + """ + tasks.register("buildJar") { + archiveFileName.set("sample.jar") + from(file("src")) + } + """.trimIndent(), + ) + File(applicationDir, "src").mkdir() + File(applicationDir, "src/hello.txt").writeText("hi") + + val result = runner("buildJar").build() + + assertThat(result.task(":buildJar")?.outcome).isEqualTo(TaskOutcome.SUCCESS) + assertThat(File(projectDir.toFile(), "build/application/libs/sample.jar")).exists() + } + + @Test + fun `plugin is a no-op when the application block is never called`() { + writeOuterSettings() + outerBuild.writeText( + """ + plugins { + java + id("dd-trace-java.smoke-test-app") + } + + smokeTestApp { + // No application block, no javaLauncher — should not blow up. + } + """.trimIndent(), + ) + + val result = runner("help").build() + + assertThat(result.output).contains("BUILD SUCCESSFUL") + } + + @Test + fun `manual NestedGradleBuild task registration works without the application block`() { + writeOuterSettings() + outerBuild.writeText( + """ + import datadog.buildlogic.smoketest.NestedGradleBuild + + plugins { + java + id("dd-trace-java.smoke-test-app") + } + + tasks.register("customBuild") { + applicationDir.set(layout.projectDirectory.dir("application")) + applicationBuildDir.set(layout.buildDirectory.dir("application")) + gradleVersion.set(gradle.gradleVersion) + javaLauncher.set( + javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(${currentMajorJdk()})) } + ) + tasksToRun.set(listOf("buildJar")) + } + """.trimIndent(), + ) + writeInnerSettings() + writeInnerBuild( + """ + tasks.register("buildJar") { + archiveFileName.set("custom.jar") + from(file("src")) + } + """.trimIndent(), + ) + File(applicationDir, "src").mkdir() + File(applicationDir, "src/hello.txt").writeText("hi") + + val result = runner("customBuild").build() + + assertThat(result.task(":customBuild")?.outcome).isEqualTo(TaskOutcome.SUCCESS) + } + + private fun writeOuterSettings() { + outerSettings.writeText( + """ + rootProject.name = "smoke-test-app-fixture" + """.trimIndent(), + ) + } + + private fun writeInnerSettings() { + File(applicationDir, "settings.gradle.kts").writeText( + """ + rootProject.name = "smoke-test-app-fixture-application" + """.trimIndent(), + ) + } + + private fun writeInnerBuild(taskBlock: String) { + File(applicationDir, "build.gradle.kts").writeText( + """ + plugins { + java + } + if (hasProperty("appBuildDir")) { + layout.buildDirectory.set(file(property("appBuildDir") as String)) + } + $taskBlock + """.trimIndent(), + ) + } + + private fun runner(vararg args: String): GradleRunner = + GradleRunner.create() + .withProjectDir(projectDir.toFile()) + .withPluginClasspath() + .withArguments(*args, "--stacktrace") + .forwardOutput() + + private fun currentMajorJdk(): Int = + System.getProperty("java.specification.version").let { + if (it.startsWith("1.")) it.substring(2).toInt() else it.toInt() + } +} diff --git a/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPluginTest.kt b/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPluginTest.kt new file mode 100644 index 00000000000..22fd1ce93fe --- /dev/null +++ b/build-logic/smoke-test/src/test/kotlin/datadog/buildlogic/smoketest/SmokeTestAppPluginTest.kt @@ -0,0 +1,83 @@ +package datadog.buildlogic.smoketest + +import org.assertj.core.api.Assertions.assertThat +import org.gradle.api.plugins.JavaPlugin +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.Test + +/** + * Fast in-process tests that exercise plugin application and extension wiring through + * [ProjectBuilder]. End-to-end task execution lives in [SmokeTestAppEndToEndTest]. + */ +class SmokeTestAppPluginTest { + + @Test + fun `applying the plugin creates the smokeTestApp extension`() { + val project = ProjectBuilder.builder().build() + + project.plugins.apply("dd-trace-java.smoke-test-app") + + assertThat(project.extensions.findByType()).isNotNull + } + + @Test + fun `plugin is a no-op when smokeTestApp_application is never called`() { + val project = ProjectBuilder.builder().build() + + project.plugins.apply("dd-trace-java.smoke-test-app") + + // No task of our type should be registered until `application { }` is invoked. + assertThat(project.tasks.withType()).isEmpty() + } + + @Test + fun `extension defaults applicationDir to projectDir slash application`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("dd-trace-java.smoke-test-app") + + val extension = project.extensions.getByType() + + assertThat(extension.applicationDir.get().asFile) + .isEqualTo(project.layout.projectDirectory.dir("application").asFile) + } + + @Test + fun `extension defaults applicationBuildDir to buildDir slash application`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("dd-trace-java.smoke-test-app") + + val extension = project.extensions.getByType() + + assertThat(extension.applicationBuildDir.get().asFile) + .isEqualTo(project.layout.buildDirectory.dir("application").get().asFile) + } + + @Test + fun `extension defaults gradleVersion to the smoke-test pinned version`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("dd-trace-java.smoke-test-app") + + val extension = project.extensions.getByType() + + assertThat(extension.gradleVersion.get()).isEqualTo(DEFAULT_NESTED_GRADLE_VERSION) + } + + @Test + fun `extension defaults javaLauncher to a JDK 21 toolchain`() { + // JavaToolchainService is contributed by the `java-base` plugin; apply something that + // pulls it in so ProjectBuilder can resolve the convention. + val project = ProjectBuilder.builder().build() + project.apply() + project.plugins.apply("dd-trace-java.smoke-test-app") + + val extension = project.extensions.getByType() + + assertThat(extension.javaLauncher.get().metadata.languageVersion) + .isEqualTo(JavaLanguageVersion.of(DEFAULT_NESTED_JAVA_VERSION)) + } +} diff --git a/dd-smoke-tests/armeria-grpc/application/build.gradle b/dd-smoke-tests/armeria-grpc/application/build.gradle index 1c256936b60..7800b4519a1 100644 --- a/dd-smoke-tests/armeria-grpc/application/build.gradle +++ b/dd-smoke-tests/armeria-grpc/application/build.gradle @@ -17,6 +17,12 @@ if (hasProperty('appBuildDir')) { version = "" +// Pin bytecode target: the nested daemon now runs on JDK 21, but the smoke test launches +// the produced jar on Java 17 (per testJvmConstraints). +java { + sourceCompatibility = JavaVersion.VERSION_17 +} + protobuf { // Configure the protoc executable. protoc { diff --git a/dd-smoke-tests/armeria-grpc/application/settings.gradle b/dd-smoke-tests/armeria-grpc/application/settings.gradle index 40a417ed29c..9ca0c8f80dd 100644 --- a/dd-smoke-tests/armeria-grpc/application/settings.gradle +++ b/dd-smoke-tests/armeria-grpc/application/settings.gradle @@ -1,3 +1,7 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. pluginManagement { repositories { mavenLocal() @@ -20,12 +24,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/armeria-grpc/build.gradle b/dd-smoke-tests/armeria-grpc/build.gradle index ebe341a8190..ffc3ce45789 100644 --- a/dd-smoke-tests/armeria-grpc/build.gradle +++ b/dd-smoke-tests/armeria-grpc/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'dd-trace-java.smoke-test-app' id 'com.google.protobuf' version '0.10.0' } @@ -8,6 +9,8 @@ testJvmConstraints { minJavaVersion = JavaVersion.VERSION_17 } +description = 'Armeria gRPC Smoke Tests.' + sourceSets { main { proto { @@ -39,6 +42,16 @@ protobuf { } } +smokeTestApp { + application { + taskName = 'armeriaBuild' + nestedTasks = ['build'] + artifactPath = 'libs/armeria-smoketest-all.jar' + sysProperty = 'datadog.smoketest.armeria.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) +} + dependencies { testImplementation project(':dd-smoke-tests') @@ -49,49 +62,13 @@ dependencies { testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -// define the task that builds the armeria project -tasks.register('armeriaBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(17) - ] - commandLine "${rootDir}/${gradlewCommand}", "build", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) -} - -evaluationDependsOn ':dd-trace-api' -armeriaBuild { - dependsOn project(':dd-trace-api').tasks.named("jar") -} - tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'armeriaBuild' outputs.upToDateWhen { - !armeriaBuild.didWork + !tasks.named('armeriaBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.armeria.uberJar.path=$appBuildDir/libs/armeria-smoketest-all.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/kafka-3/application/build.gradle b/dd-smoke-tests/kafka-3/application/build.gradle index 2386eab0cf0..1d06a0a53af 100644 --- a/dd-smoke-tests/kafka-3/application/build.gradle +++ b/dd-smoke-tests/kafka-3/application/build.gradle @@ -4,10 +4,11 @@ plugins { id 'io.spring.dependency-management' version '1.1.4' } +// Pin bytecode target: the nested daemon runs on JDK 21, but the smoke test launches the +// produced jar on Java 17. Using sourceCompatibility (vs. toolchain.languageVersion) lets +// Gradle cross-compile via `--release 17` without pulling a separate JDK 17 toolchain. java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) - } + sourceCompatibility = JavaVersion.VERSION_17 } def sharedRootDir = "$rootDir/../../../" diff --git a/dd-smoke-tests/kafka-3/application/settings.gradle b/dd-smoke-tests/kafka-3/application/settings.gradle index d577c762a5c..b0697997e79 100644 --- a/dd-smoke-tests/kafka-3/application/settings.gradle +++ b/dd-smoke-tests/kafka-3/application/settings.gradle @@ -1,3 +1,7 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. pluginManagement { repositories { mavenLocal() @@ -20,12 +24,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/kafka-3/build.gradle b/dd-smoke-tests/kafka-3/build.gradle index 0c92600de50..9ae27138114 100644 --- a/dd-smoke-tests/kafka-3/build.gradle +++ b/dd-smoke-tests/kafka-3/build.gradle @@ -1,5 +1,9 @@ +plugins { + id 'dd-trace-java.smoke-test-app' + id 'java-test-fixtures' +} + apply from: "$rootDir/gradle/java.gradle" -apply plugin: 'java-test-fixtures' testJvmConstraints { minJavaVersion = JavaVersion.VERSION_17 @@ -7,6 +11,14 @@ testJvmConstraints { description = 'Kafka 3.x Smoke Tests.' +smokeTestApp { + application { + taskName = 'bootJar' + artifactPath = 'libs/kafka-3-smoketest.jar' + sysProperty = 'datadog.smoketest.springboot.shadowJar.path' + } +} + dependencies { testImplementation('org.springframework.kafka:spring-kafka-test:2.9.13') @@ -15,45 +27,13 @@ dependencies { testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } -final appDir = "$projectDir/application" -final appBuildDir = "$buildDir/application" -final isWindows = System.getProperty('os.name').toLowerCase().contains('win') -final gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -tasks.register('bootJar', Exec) { - workingDir appDir - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(17) - ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) - - group('build') -} - tasks.named('compileTestGroovy') { dependsOn 'bootJar' outputs.upToDateWhen { - !bootJar.didWork + !tasks.named('bootJar').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.springboot.shadowJar.path=${appBuildDir}/libs/kafka-3-smoketest.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/quarkus/application/build.gradle b/dd-smoke-tests/quarkus/application/build.gradle index 40d01f03d90..7fa5badaf5e 100644 --- a/dd-smoke-tests/quarkus/application/build.gradle +++ b/dd-smoke-tests/quarkus/application/build.gradle @@ -15,6 +15,11 @@ if (hasProperty('appBuildDir')) { version = "" +// Pin bytecode target: the nested daemon now runs on JDK 21, but Quarkus 1.9 supports Java 8. +java { + sourceCompatibility = JavaVersion.VERSION_1_8 +} + dependencies { implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") implementation 'io.quarkus:quarkus-resteasy' diff --git a/dd-smoke-tests/quarkus/application/settings.gradle b/dd-smoke-tests/quarkus/application/settings.gradle index fcd4ec7366b..aaf3ed2bded 100644 --- a/dd-smoke-tests/quarkus/application/settings.gradle +++ b/dd-smoke-tests/quarkus/application/settings.gradle @@ -1,3 +1,9 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. +// The inner `plugins { id 'io.quarkus' ... }` block resolves the Quarkus version from a +// `quarkusPluginVersion` Gradle property forwarded by the outer build. pluginManagement { repositories { mavenLocal() @@ -23,12 +29,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/quarkus/build.gradle b/dd-smoke-tests/quarkus/build.gradle index 56f0cee613a..99eeed80234 100644 --- a/dd-smoke-tests/quarkus/build.gradle +++ b/dd-smoke-tests/quarkus/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'dd-trace-java.smoke-test-app' +} + apply from: "$rootDir/gradle/java.gradle" testJvmConstraints { @@ -5,54 +9,36 @@ testJvmConstraints { maxJavaVersion = JavaVersion.VERSION_21 } -dependencies { - testImplementation project(':dd-smoke-tests') -} - -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -// define the task that builds the quarkus project -tasks.register('quarkusBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(8) - ] - commandLine "${rootDir}/${gradlewCommand}", "build", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } +description = 'Quarkus Smoke Tests.' - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +smokeTestApp { + // Quarkus 1.9.2 (Sep 2020) cannot run on JDK 21; the previous Exec-based setup pinned + // JAVA_HOME=getLazyJavaHomeFor(8) and that is required at runtime, not just for bytecode. + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(8) + } + application { + taskName = 'quarkusBuild' + nestedTasks = ['build'] + // Quarkus' uber-jar is named `-runner.jar`; here the inner project has no + // version, so the artifact name is `quarkus-smoketest--runner.jar`. + artifactPath = 'quarkus-smoketest--runner.jar' + sysProperty = 'datadog.smoketest.quarkus.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -evaluationDependsOn ':dd-trace-api' - -tasks.named("quarkusBuild", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") +dependencies { + testImplementation project(':dd-smoke-tests') } tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'quarkusBuild' outputs.upToDateWhen { - !quarkusBuild.didWork + !tasks.named('quarkusBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.quarkus.uberJar.path=$appBuildDir/quarkus-smoketest--runner.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/build.gradle b/dd-smoke-tests/spring-boot-3.0-webflux/application/build.gradle index 416dea657d2..76dcf9c3da2 100644 --- a/dd-smoke-tests/spring-boot-3.0-webflux/application/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/build.gradle @@ -16,6 +16,12 @@ if (hasProperty('appBuildDir')) { version = "" +// Pin bytecode target: the nested daemon now runs on JDK 21, but the smoke test launches +// the produced jar on Java 17 (per testJvmConstraints). +java { + sourceCompatibility = JavaVersion.VERSION_17 +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/settings.gradle b/dd-smoke-tests/spring-boot-3.0-webflux/application/settings.gradle index 3e4297888f9..a172759b60a 100644 --- a/dd-smoke-tests/spring-boot-3.0-webflux/application/settings.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/settings.gradle @@ -1,3 +1,7 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. pluginManagement { repositories { mavenLocal() @@ -20,12 +24,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle b/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle index 6138aef945d..006f844ab11 100644 --- a/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'dd-trace-java.smoke-test-app' +} + apply from: "$rootDir/gradle/java.gradle" testJvmConstraints { @@ -6,39 +10,18 @@ testJvmConstraints { description = 'Spring Boot 3.0 Webflux Smoke Tests.' -dependencies { - testImplementation project(':dd-smoke-tests') -} - -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -// define the task that builds the project -tasks.register('webfluxBuild30', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(17) - ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +smokeTestApp { + application { + taskName = 'webfluxBuild30' + nestedTasks = ['bootJar'] + artifactPath = 'libs/webflux-3.0-smoketest.jar' + sysProperty = 'datadog.smoketest.webflux.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -tasks.named("webfluxBuild30", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") +dependencies { + testImplementation project(':dd-smoke-tests') } tasks.named("compileTestGroovy", GroovyCompile) { @@ -48,10 +31,6 @@ tasks.named("compileTestGroovy", GroovyCompile) { } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.webflux.uberJar.path=$appBuildDir/libs/webflux-3.0-smoketest.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/build.gradle b/dd-smoke-tests/spring-boot-3.0-webmvc/application/build.gradle index d7cc7b40f60..c94214d70ba 100644 --- a/dd-smoke-tests/spring-boot-3.0-webmvc/application/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/build.gradle @@ -16,6 +16,12 @@ if (hasProperty('appBuildDir')) { version = "" +// Pin bytecode target: the nested daemon now runs on JDK 21, but the smoke test launches +// the produced jar on Java 17 (per testJvmConstraints). +java { + sourceCompatibility = JavaVersion.VERSION_17 +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/settings.gradle b/dd-smoke-tests/spring-boot-3.0-webmvc/application/settings.gradle index 0c9295cedb4..96c76ec6c8b 100644 --- a/dd-smoke-tests/spring-boot-3.0-webmvc/application/settings.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/settings.gradle @@ -1,3 +1,7 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. pluginManagement { repositories { mavenLocal() @@ -20,12 +24,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle b/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle index 46c00fbcec8..f8ec1ce3975 100644 --- a/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'dd-trace-java.smoke-test-app' +} + apply from: "$rootDir/gradle/java.gradle" testJvmConstraints { @@ -6,49 +10,27 @@ testJvmConstraints { description = 'Spring Boot 3.0 WebMvc Smoke Tests.' -dependencies { - testImplementation project(':dd-smoke-tests') +smokeTestApp { + application { + taskName = 'webmvcBuild30' + nestedTasks = ['bootJar'] + artifactPath = 'libs/webmvc-3.0-smoketest.jar' + sysProperty = 'datadog.smoketest.springboot.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -// define the task that builds the project -tasks.register('webmvcBuild30', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(17) - ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +dependencies { + testImplementation project(':dd-smoke-tests') } tasks.named("compileTestGroovy", GroovyCompile) { - dependsOn project(':dd-trace-api').tasks.named("jar") dependsOn 'webmvcBuild30' outputs.upToDateWhen { - !webmvcBuild30.didWork + !tasks.named('webmvcBuild30').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.springboot.uberJar.path=$appBuildDir/libs/webmvc-3.0-smoketest.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/build.gradle b/dd-smoke-tests/spring-boot-3.3-webmvc/application/build.gradle index 1b75d137b24..1b6aae09b00 100644 --- a/dd-smoke-tests/spring-boot-3.3-webmvc/application/build.gradle +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/build.gradle @@ -16,6 +16,12 @@ if (hasProperty('appBuildDir')) { version = "" +// Pin bytecode target: the nested daemon now runs on JDK 21, but the smoke test launches +// the produced jar on Java 17 (per testJvmConstraints). +java { + sourceCompatibility = JavaVersion.VERSION_17 +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/settings.gradle b/dd-smoke-tests/spring-boot-3.3-webmvc/application/settings.gradle index cedaf8d6b03..4f591488834 100644 --- a/dd-smoke-tests/spring-boot-3.3-webmvc/application/settings.gradle +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/settings.gradle @@ -1,3 +1,7 @@ +// The `gradlePluginProxy` / `mavenRepositoryProxy` properties point to internal Maven +// mirrors used by CI when the public repos are unreachable; they are forwarded from the +// outer build via the smoke-test plugin. `allowInsecureProtocol` is required because the +// mirrors are reached over plain HTTP inside the CI network. pluginManagement { repositories { mavenLocal() @@ -20,12 +24,16 @@ pluginManagement { def isCI = providers.environmentVariable("CI").isPresent() -// Don't pollute the dependency cache with the build cache +// On CI, point the local Gradle build cache to the shared workspace directory under the +// repository root, so cache entries are reused across the many smoke-test nested builds +// (and across CI jobs that mount the same workspace). See f6ec1f5cc8 / #982 for the +// root-level cache, and b34ccbc048 for the `isCI` gating — locally we keep the default +// per-user cache to avoid leaking entries into the repo tree. +// The directory must line up with the outer project's settings.gradle. if (isCI) { def sharedRootDir = "$rootDir/../../../" buildCache { local { - // This needs to line up with the code in the outer project settings.gradle directory = "$sharedRootDir/workspace/build-cache" } } diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle b/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle index 484ecfc5668..dc252457801 100644 --- a/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'dd-trace-java.smoke-test-app' +} + apply from: "$rootDir/gradle/java.gradle" testJvmConstraints { @@ -6,49 +10,27 @@ testJvmConstraints { description = 'Spring Boot 3.3 WebMvc Smoke Tests.' -dependencies { - testImplementation project(':dd-smoke-tests') +smokeTestApp { + application { + taskName = 'webmvcBuild3' + nestedTasks = ['bootJar'] + artifactPath = 'libs/webmvc-3.3-smoketest.jar' + sysProperty = 'datadog.smoketest.springboot.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - -// define the task that builds the project -tasks.register('webmvcBuild3', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(17) - ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +dependencies { + testImplementation project(':dd-smoke-tests') } tasks.named("compileTestGroovy", GroovyCompile) { - dependsOn project(':dd-trace-api').tasks.named("jar") dependsOn 'webmvcBuild3' outputs.upToDateWhen { - !webmvcBuild3.didWork + !tasks.named('webmvcBuild3').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.springboot.uberJar.path=$appBuildDir/libs/webmvc-3.3-smoketest.jar" -} - spotless { java { target "**/*.java" diff --git a/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023e..00000000000 Binary files a/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4cf193f638..00000000000 --- a/dd-smoke-tests/vertx-3.4/application/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,8 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/vertx-3.4/application/gradlew b/dd-smoke-tests/vertx-3.4/application/gradlew deleted file mode 100755 index 965aff38453..00000000000 --- a/dd-smoke-tests/vertx-3.4/application/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/vertx-3.4/application/gradlew.bat b/dd-smoke-tests/vertx-3.4/application/gradlew.bat deleted file mode 100644 index 107acd32c4e..00000000000 --- a/dd-smoke-tests/vertx-3.4/application/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/dd-smoke-tests/vertx-3.4/build.gradle b/dd-smoke-tests/vertx-3.4/build.gradle index a912e7b34e4..77ae03e703d 100644 --- a/dd-smoke-tests/vertx-3.4/build.gradle +++ b/dd-smoke-tests/vertx-3.4/build.gradle @@ -1,57 +1,36 @@ plugins { + id 'dd-trace-java.smoke-test-app' id 'idea' id 'java-test-fixtures' } apply from: "$rootDir/gradle/java.gradle" +description = 'Vert.x 3.4 Smoke Tests.' + +smokeTestApp { + application { + taskName = 'vertxBuild' + nestedTasks = ['assemble'] + artifactPath = 'libs/vertx-3.4-1.0.0-SNAPSHOT-fat.jar' + sysProperty = 'datadog.smoketest.vertx.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) +} + dependencies { testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) testImplementation project(':dd-smoke-tests:appsec') } -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' -// define the task that builds the quarkus project -tasks.register('vertxBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(8) - ] - commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) -} - -tasks.named("vertxBuild", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") -} - tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'vertxBuild' outputs.upToDateWhen { - !vertxBuild.didWork + !tasks.named('vertxBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.vertx.uberJar.path=$appBuildDir/libs/vertx-3.4-1.0.0-SNAPSHOT-fat.jar" -} - spotless { java { target "**/*.java" @@ -64,6 +43,6 @@ spotless { idea { module { - excludeDirs += [file("$appDir")] + excludeDirs += [file("$projectDir/application")] } } diff --git a/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023e..00000000000 Binary files a/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4cf193f638..00000000000 --- a/dd-smoke-tests/vertx-3.9-resteasy/application/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,8 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew b/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew deleted file mode 100755 index 965aff38453..00000000000 --- a/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew.bat b/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/dd-smoke-tests/vertx-3.9-resteasy/application/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/dd-smoke-tests/vertx-3.9-resteasy/build.gradle b/dd-smoke-tests/vertx-3.9-resteasy/build.gradle index c7e3dd90565..4bb83945540 100644 --- a/dd-smoke-tests/vertx-3.9-resteasy/build.gradle +++ b/dd-smoke-tests/vertx-3.9-resteasy/build.gradle @@ -1,54 +1,33 @@ plugins { + id 'dd-trace-java.smoke-test-app' id 'idea' } apply from: "$rootDir/gradle/java.gradle" -dependencies { - testImplementation project(':dd-smoke-tests') -} - -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' -// define the task that builds the quarkus project -tasks.register('vertxBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(8) - ] - commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") +description = 'Vert.x 3.9 RestEasy Smoke Tests.' - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +smokeTestApp { + application { + taskName = 'vertxBuild' + nestedTasks = ['assemble'] + artifactPath = 'libs/vertx-3.9-resteasy-1.0.0-SNAPSHOT-fat.jar' + sysProperty = 'datadog.smoketest.vertx.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -tasks.named("vertxBuild", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") +dependencies { + testImplementation project(':dd-smoke-tests') } tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'vertxBuild' outputs.upToDateWhen { - !vertxBuild.didWork + !tasks.named('vertxBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.vertx.uberJar.path=$appBuildDir/libs/vertx-3.9-resteasy-1.0.0-SNAPSHOT-fat.jar" -} - spotless { java { target "**/*.java" @@ -61,6 +40,6 @@ spotless { idea { module { - excludeDirs += [file("$appDir")] + excludeDirs += [file("$projectDir/application")] } } diff --git a/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023e..00000000000 Binary files a/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4cf193f638..00000000000 --- a/dd-smoke-tests/vertx-3.9/application/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,8 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/vertx-3.9/application/gradlew b/dd-smoke-tests/vertx-3.9/application/gradlew deleted file mode 100755 index 965aff38453..00000000000 --- a/dd-smoke-tests/vertx-3.9/application/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/vertx-3.9/application/gradlew.bat b/dd-smoke-tests/vertx-3.9/application/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/dd-smoke-tests/vertx-3.9/application/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/dd-smoke-tests/vertx-3.9/build.gradle b/dd-smoke-tests/vertx-3.9/build.gradle index 2f374a5c699..59255a35080 100644 --- a/dd-smoke-tests/vertx-3.9/build.gradle +++ b/dd-smoke-tests/vertx-3.9/build.gradle @@ -1,55 +1,34 @@ plugins { + id 'dd-trace-java.smoke-test-app' id 'idea' } apply from: "$rootDir/gradle/java.gradle" -dependencies { - testImplementation project(':dd-smoke-tests') - testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) -} - -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' -// define the task that builds the vertx project -tasks.register('vertxBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(8) - ] - commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") +description = 'Vert.x 3.9 Smoke Tests.' - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) +smokeTestApp { + application { + taskName = 'vertxBuild' + nestedTasks = ['assemble'] + artifactPath = 'libs/vertx-3.9-1.0.0-SNAPSHOT-fat.jar' + sysProperty = 'datadog.smoketest.vertx.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) } -tasks.named("vertxBuild", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") +dependencies { + testImplementation project(':dd-smoke-tests') + testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'vertxBuild' outputs.upToDateWhen { - !vertxBuild.didWork + !tasks.named('vertxBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.vertx.uberJar.path=$appBuildDir/libs/vertx-3.9-1.0.0-SNAPSHOT-fat.jar" -} - spotless { java { target "**/*.java" @@ -62,6 +41,6 @@ spotless { idea { module { - excludeDirs += [file("$appDir")] + excludeDirs += [file("$projectDir/application")] } } diff --git a/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c023e..00000000000 Binary files a/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4cf193f638..00000000000 --- a/dd-smoke-tests/vertx-4.2/application/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,8 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/vertx-4.2/application/gradlew b/dd-smoke-tests/vertx-4.2/application/gradlew deleted file mode 100755 index 965aff38453..00000000000 --- a/dd-smoke-tests/vertx-4.2/application/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/vertx-4.2/application/gradlew.bat b/dd-smoke-tests/vertx-4.2/application/gradlew.bat deleted file mode 100644 index 107acd32c4e..00000000000 --- a/dd-smoke-tests/vertx-4.2/application/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/dd-smoke-tests/vertx-4.2/build.gradle b/dd-smoke-tests/vertx-4.2/build.gradle index bc36d08acb0..54465508016 100644 --- a/dd-smoke-tests/vertx-4.2/build.gradle +++ b/dd-smoke-tests/vertx-4.2/build.gradle @@ -1,56 +1,35 @@ plugins { + id 'dd-trace-java.smoke-test-app' id 'idea' } apply from: "$rootDir/gradle/java.gradle" +description = 'Vert.x 4.2 Smoke Tests.' + +smokeTestApp { + application { + taskName = 'vertxBuild' + nestedTasks = ['assemble'] + artifactPath = 'libs/vertx-4.2-1.0.0-SNAPSHOT-fat.jar' + sysProperty = 'datadog.smoketest.vertx.uberJar.path' + } + projectJar('apiJar', project(':dd-trace-api')) +} + dependencies { testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) testImplementation project(':dd-smoke-tests:appsec') } -def appDir = "$projectDir/application" -def appBuildDir = "$buildDir/application" -def isWindows = System.getProperty("os.name").toLowerCase().contains("win") -def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' -// define the task that builds the quarkus project -tasks.register('vertxBuild', Exec) { - workingDir "$appDir" - environment += [ - "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", - "JAVA_HOME": getLazyJavaHomeFor(8) - ] - commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" - - outputs.cacheIf { true } - - outputs.dir(appBuildDir) - .withPropertyName("applicationJar") - - inputs.files(fileTree(appDir) { - include '**/*' - exclude '.gradle/**' - }) - .withPropertyName("application") - .withPathSensitivity(PathSensitivity.RELATIVE) -} - -tasks.named("vertxBuild", Exec) { - dependsOn project(':dd-trace-api').tasks.named("jar") -} - tasks.named("compileTestGroovy", GroovyCompile) { dependsOn 'vertxBuild' outputs.upToDateWhen { - !vertxBuild.didWork + !tasks.named('vertxBuild').get().didWork } } -tasks.withType(Test).configureEach { - jvmArgs "-Ddatadog.smoketest.vertx.uberJar.path=$appBuildDir/libs/vertx-4.2-1.0.0-SNAPSHOT-fat.jar" -} - spotless { java { target "**/*.java" @@ -63,6 +42,6 @@ spotless { idea { module { - excludeDirs += [file("$appDir")] + excludeDirs += [file("$projectDir/application")] } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6b1916a456f..6abe7896aab 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,6 +4,7 @@ # Build develocity = "4.4.1" forbiddenapis = "3.10" +gradle-tooling-api = "8.14.5" spotbugs_annotations = "4.9.8" # DataDog libs and forks @@ -78,6 +79,7 @@ testcontainers = "1.21.4" # Build develocity = { module = "com.gradle:develocity-gradle-plugin", version.ref = "develocity" } forbiddenapis = { module = "de.thetaphi:forbiddenapis", version.ref = "forbiddenapis" } +gradle-tooling-api = { module = "org.gradle:gradle-tooling-api", version.ref = "gradle-tooling-api" } spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", version.ref = "spotbugs_annotations" } # DataDog libs and forks diff --git a/gradle/repositories.gradle b/gradle/repositories.gradle index 98085e93c50..e7d4824b4c6 100644 --- a/gradle/repositories.gradle +++ b/gradle/repositories.gradle @@ -35,4 +35,12 @@ repositories { includeGroupAndSubgroups "org.springframework" } } + // Hosts gradle-tooling-api, used by build-logic:smoke-test to run nested + // Gradle builds for smoke-test applications pinned to older Gradle versions. + maven { + url = 'https://repo.gradle.org/gradle/libs-releases' + content { + includeGroup "org.gradle" + } + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index bd5aaceffaa..e6c9469b9c6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,16 @@ pluginManagement { } gradlePluginPortal() mavenCentral() + // Hosts gradle-tooling-api, a transitive dep of the build-logic:smoke-test plugin used + // to run nested Gradle builds for smoke-test applications pinned to older Gradle versions. + maven { + url = uri("https://repo.gradle.org/gradle/libs-releases") + content { + includeGroup("org.gradle") + } + } } + includeBuild("build-logic") } plugins {