diff --git a/build.gradle b/build.gradle index 37684452586d1..252d1ed553afa 100644 --- a/build.gradle +++ b/build.gradle @@ -426,8 +426,8 @@ gradle.projectsEvaluated { // Add Java Agent for security sandboxing if (!(project.path in [':build-tools', ":libs:agent-sm:bootstrap", ":libs:agent-sm:agent"])) { - dependsOn(project(':libs:agent-sm:agent').prepareAgent) - jvmArgs += ["-javaagent:" + project(':libs:agent-sm:agent').jar.archiveFile.get()] + dependsOn(project(':libs:agent-sm:agent').tasks.named('prepareAgent')) + jvmArgs += ["-javaagent:" + project(':libs:agent-sm:agent').tasks.named('jar').get().archiveFile.get()] } if (BuildParams.isInFipsJvm()) { def fipsSecurityFile = project.rootProject.file('distribution/src/config/fips_java.security') diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index eb090d37b4005..ab6b24c121381 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -291,6 +291,12 @@ if (project != rootProject) { suppressPomMetadataWarningsFor("testFixturesApiElements") suppressPomMetadataWarningsFor("testFixturesRuntimeElements") } + + // Gradle 9.4 changed the default to enforce stricter validation. Disabling + // the validation for now and will follow up with a fix. + tasks.validatePlugins { + enableStricterValidation = false + } } // Define this here because we need it early. It uses VersionCatalogsExtension to extract all versions diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index c2d51f9d468da..72b0c1b277fe2 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -256,6 +256,6 @@ tasks.configureEach { t -> tasks.each { if (it.name.startsWith("build")) { - it.dependsOn project(':libs:agent-sm:agent').assemble + it.dependsOn project(':libs:agent-sm:agent').tasks.named('assemble') } } diff --git a/distribution/build.gradle b/distribution/build.gradle index 65cb518d92cec..8e9f4d4f48fd4 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -44,6 +44,8 @@ import java.nio.file.Path plugins { id 'base' } + + /***************************************************************************** * Third party dependencies report * *****************************************************************************/ @@ -320,6 +322,13 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { } } } + create('agent') { + canBeConsumed = false + canBeResolved = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, 'agent-dist')) + } + } } dependencies { @@ -333,6 +342,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { libsFipsInstallerCli project(path: ':distribution:tools:fips-demo-installer-cli') bcFips libs.bundles.bouncycastle + + agent project(path: ':libs:agent-sm:agent', configuration: 'agentDist') } project.ext { @@ -362,7 +373,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { agentFiles = { copySpec { - from(project(':libs:agent-sm:agent').prepareAgent) { + from(configurations.agent) { include '**/*.jar' exclude '**/*-javadoc.jar' exclude '**/*-sources.jar' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1b33c55baabb5..f8e1ee3125fe0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b267fcc69f8b5..6506bf0c3711e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,8 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionSha256Sum=f86344275d1b194688dd330abf9f6f2344cd02872ffee035f2d1ea2fd60cf7f3 +distributionSha256Sum=b21468753cb43c167738ee04f10c706c46459cf8f8ae6ea132dc9ce589a261f2 diff --git a/libs/agent-sm/agent/build.gradle b/libs/agent-sm/agent/build.gradle index c495067d45ebb..b88e30f631e06 100644 --- a/libs/agent-sm/agent/build.gradle +++ b/libs/agent-sm/agent/build.gradle @@ -7,6 +7,20 @@ base { configurations { bootstrap.extendsFrom(implementation) + agentDist { + canBeConsumed = true + canBeResolved = false + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, 'agent-dist')) + } + } + agentJar { + canBeConsumed = true + canBeResolved = false + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, 'agent-jar')) + } + } } dependencies { @@ -53,6 +67,13 @@ task prepareAgent(type: Copy) { dependsOn jar } +artifacts { + agentJar(jar) + agentDist(file("$buildDir/distributions")) { + builtBy prepareAgent + } +} + thirdPartyAudit { ignoreMissingClasses( 'com.sun.jna.FunctionMapper', diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 0b966b40d759b..943b1652c9c3c 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -51,6 +51,13 @@ testFixtures.useFixture ":test:fixtures:krb5kdc-fixture", "hdfs" configurations { hdfsFixture + agent { + canBeConsumed = false + canBeResolved = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, 'agent-jar')) + } + } } dependencies { @@ -88,6 +95,8 @@ dependencies { if (isEclipse == false) { testRuntimeOnly files(project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "hdfs_hdfs.build.opensearch.org.keytab").parent) } + + agent project(path: ':libs:agent-sm:agent', configuration: 'agentJar') } restResources { @@ -130,7 +139,7 @@ project(':test:fixtures:krb5kdc-fixture').tasks.preProcessFixture { // Create HDFS File System Testing Fixtures for HA/Secure combinations for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', 'secureHaHdfsFixture']) { def tsk = tasks.register(fixtureName, org.opensearch.gradle.test.AntFixture) { - dependsOn configurations.hdfsFixture, project(':test:fixtures:krb5kdc-fixture').tasks.postProcessFixture, project(':libs:agent-sm:agent').prepareAgent + dependsOn configurations.hdfsFixture, project(':test:fixtures:krb5kdc-fixture').tasks.postProcessFixture, configurations.agent executable = "${BuildParams.runtimeJavaHome}/bin/java" env 'CLASSPATH', "${-> configurations.hdfsFixture.asPath}" maxWaitInSeconds = 60 @@ -140,10 +149,10 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', // it's ready, so we can just wait for the file to exist return fixture.portsFile.exists() } - final List miniHDFSArgs = [] + final List miniHDFSArgs = [] // See please https://issues.apache.org/jira/browse/HADOOP-19486 - miniHDFSArgs.add("-javaagent:" + project(':libs:agent-sm:agent').jar.archiveFile.get()) + miniHDFSArgs.add("-javaagent:${-> configurations.agent.incoming.artifactView({}).files.singleFile}") // If it's a secure fixture, then depend on Kerberos Fixture and principals + add the krb5conf to the JVM options if (fixtureName.equals('secureHdfsFixture') || fixtureName.equals('secureHaHdfsFixture')) { diff --git a/test/framework/build.gradle b/test/framework/build.gradle index 52fd8e7d670bd..5d46a169f6580 100644 --- a/test/framework/build.gradle +++ b/test/framework/build.gradle @@ -33,6 +33,16 @@ apply plugin: 'opensearch.build' apply plugin: 'opensearch.publish' apply from: "$rootDir/gradle/fips.gradle" +configurations { + agent { + canBeConsumed = false + canBeResolved = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, 'agent-jar')) + } + } +} + dependencies { api project(":client:rest") api project(":client:sniffer") @@ -60,6 +70,8 @@ dependencies { compileOnly "com.github.spotbugs:spotbugs-annotations:4.9.8" annotationProcessor "org.apache.logging.log4j:log4j-core:${versions.log4j}" + + agent project(path: ':libs:agent-sm:agent', configuration: 'agentJar') } compileJava.options.compilerArgs -= '-Xlint:cast' @@ -105,8 +117,7 @@ test { systemProperty 'tests.gradle_wire_compat_versions', BuildParams.bwcVersions.wireCompatible.join(',') systemProperty 'tests.gradle_unreleased_versions', BuildParams.bwcVersions.unreleased.join(',') - dependsOn(project(':libs:agent-sm:agent').prepareAgent) - jvmArgs += ["-javaagent:" + project(':libs:agent-sm:agent').jar.archiveFile.get()] + jvmArgs += ["-javaagent:${-> configurations.agent.incoming.artifactView({}).files.singleFile}"] } tasks.register("integTest", Test) {