Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ develocity {
}
} else {
tag 'LOCAL'
if (providers.systemProperty('idea.active').present) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when running with configuration cache enabled, Project#providers is not available from a build scan background action. we can fall back to normal System.getProperty check instead as gradle instruments System.getProperty calls automatically to take into account for configuration caching.

if (System.getProperty('idea.active') == 'true') {
tag 'IDEA'
}
}
Expand Down
15 changes: 7 additions & 8 deletions plugins/discovery-ec2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ esplugin.bundleSpec.from('config/discovery-ec2') {
}

tasks.register("writeTestJavaPolicy") {
boolean inFips = buildParams.inFipsJvm
inputs.property("inFipsJvm", inFips)
final File javaPolicy = new File(layout.buildDirectory.asFile.get(), "tmp/java.policy")
outputs.file(javaPolicy)
doLast {
final File tmp = file("${buildDir}/tmp")
Copy link
Contributor Author

@breskeby breskeby Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Project#file utility method and the buildParams extension are not available from task execution phase (e.g. running in doLast) when configuration cache enabled.

We moved declaring the output file and the inFips boolean into the configuration phase and also declared them as proper inputs/outputs for the writeTestJavaPolicy task to mark it properly as up-to-date on unchanged reruns.

Some background on this: https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:requirements

if (tmp.exists() == false && tmp.mkdirs() == false) {
throw new GradleException("failed to create temporary directory [${tmp}]")
}
final File javaPolicy = file("${tmp}/java.policy")
if (buildParams.inFipsJvm) {
if (inFips) {
javaPolicy.write(
[
"grant {",
Expand Down Expand Up @@ -95,9 +94,9 @@ tasks.withType(Test).configureEach {
// this is needed to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
if (buildParams.inFipsJvm){
nonInputProperties.systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project#buildDir is a deprecated and will be removed at one point

nonInputProperties.systemProperty 'java.security.policy', "=file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
} else {
nonInputProperties.systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
nonInputProperties.systemProperty 'java.security.policy', "file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
}
}

Expand Down