Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/datadog.gradle-debug.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val ddGradleDebugEnabled = project.hasProperty("ddGradleDebug")
val logPath = rootProject.layout.buildDirectory.file("datadog.gradle-debug.log")

fun inferJdkFromJavaHome(javaHome: String?): String {
val effectiveJavaHome = javaHome ?: System.getenv("JAVA_HOME")
val effectiveJavaHome = javaHome ?: providers.environmentVariable("JAVA_HOME").orNull
if (effectiveJavaHome == null) {
throw IllegalStateException("JAVA_HOME is not set")
}
Comment thread
AlexeyKuznetsov-DD marked this conversation as resolved.
Outdated
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/armeria-grpc/application/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/debugger-integration-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tasks.withType(Test).configureEach {

// TODO latest-jdk-app fails too often with a jgit failure, so disable until fixed
// def isLatestJdk = project.findProperty("testJvm") == latestJdk
// def latestJavaHome = System.getenv("JAVA_${latestJdk}_HOME")
// def latestJavaHome = providers.environmentVariable("JAVA_${latestJdk}_HOME").orNull
// if (isLatestJdk && latestJavaHome) {
// dependsOn buildLatestJdkApp
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ shadowJar {

def latestJdk = 17

def latestJdkHome = System.getenv("JAVA_${latestJdk}_HOME")
def latestJdkHome = providers.environmentVariable("JAVA_${latestJdk}_HOME").orNull
if (latestJdkHome != null) {
tasks.withType(JavaCompile) {
options.fork = true
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/kafka-3/application/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
6 changes: 4 additions & 2 deletions dd-smoke-tests/log-injection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,10 @@ tasks.withType(Test).configureEach {

// Runtime.getRuntime().availableProcessors() is used to scale the parallelism by default,
// but it returns weird values in Gitlab/kubernetes, so fix to a specific value when available
def override = System.getenv("RUNTIME_AVAILABLE_PROCESSORS_OVERRIDE")
maxParallelForks = override?.toInteger() ?: Math.max(1, (Runtime.runtime.availableProcessors() / 2).toInteger())
maxParallelForks = providers.environmentVariable("RUNTIME_AVAILABLE_PROCESSORS_OVERRIDE")
.map { it.toInteger() }
.orElse(Math.max(1, (Runtime.runtime.availableProcessors() / 2).toInteger()))
.get()
}


Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
4 changes: 2 additions & 2 deletions dd-smoke-tests/quarkus-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ dependencies {
}
def testJvm = gradle.startParameter.projectProperties.getOrDefault('testJvm', '')
// In order to support GraalVM 21 we need at least Java 17 for Gradle
def java17Home = System.getenv('JAVA_17_HOME')
def java17Home = providers.environmentVariable('JAVA_17_HOME').orNull
// Check 'testJvm' gradle command parameter to be at least GraalVM 17
def matcher = testJvm?.toLowerCase(Locale.ROOT) =~ /graalvm([0-9]+)/
def version = matcher?.size() == 1 ? Integer.parseInt(matcher[0][1]) : -1
if (version >= 17) {
// Retrieve GRAALVM_HOME from JVM environment variables
def testJvmEnv = "JAVA_${testJvm}_HOME"
def testJvmHome = System.getenv(testJvmEnv)
def testJvmHome = providers.environmentVariable(testJvmEnv).orNull
if (!testJvmHome) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. Have you set '$testJvmEnv'?")
}
Comment thread
AlexeyKuznetsov-DD marked this conversation as resolved.
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/quarkus/application/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/rum/wildfly-15/rum-ear/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
4 changes: 2 additions & 2 deletions dd-smoke-tests/spring-boot-3.0-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ dependencies {

def testJvm = gradle.startParameter.projectProperties.getOrDefault('testJvm', '')
// In order to support GraalVM 21 we need at least Java 17 for Gradle
def java17Home = System.getenv('JAVA_17_HOME')
def java17Home = providers.environmentVariable('JAVA_17_HOME').orNull
// Check 'testJvm' gradle command parameter to be at least GraalVM 17
def matcher = testJvm?.toLowerCase(Locale.ROOT) =~ /graalvm([0-9]+)/
def version = matcher?.size() == 1 ? Integer.parseInt(matcher[0][1]) : -1
if (version >= 17) {
// Retrieve GRAALVM_HOME from JVM environment variables
def testJvmEnv = "JAVA_${testJvm}_HOME"
def testJvmHome = System.getenv(testJvmEnv)
def testJvmHome = providers.environmentVariable(testJvmEnv).orNull
if (!testJvmHome) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. Have you set '$testJvmEnv'?")
}
Comment thread
AlexeyKuznetsov-DD marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
2 changes: 1 addition & 1 deletion dd-smoke-tests/wildfly/spring-ear/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}
}

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()

// Don't pollute the dependency cache with the build cache
if (isCI) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/configure_tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ tasks.withType(Test) {
// https://docs.gradle.com/develocity/flaky-test-detection/
// https://docs.gradle.com/develocity/gradle-plugin/current/#test_retry
develocity.testRetry {
if (System.getenv().containsKey("CI")) {
if (providers.environmentVariable("CI").isPresent()) {
maxRetries = 3
}
}
Expand Down
14 changes: 9 additions & 5 deletions gradle/java_no_deps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext.testcontainersLimit = gradle.sharedServices.registerIfAbsent("testcontainers
}

// Task for tests that want to run forked in their own separate JVM
if (tasks.matching({it.name == 'forkedTest'}).empty) {
if (tasks.matching({ it.name == 'forkedTest' }).empty) {
tasks.register('forkedTest', Test).configure {
useJUnitPlatform()
}
Expand Down Expand Up @@ -154,18 +154,22 @@ def currentJavaHomePath = getJavaHomePath(System.getProperty("java.home"))
project.afterEvaluate {
def testJvm = gradle.startParameter.projectProperties["testJvm"]
def javaTestLauncher = null as Provider<JavaLauncher>

// "stable" is calculated as the largest X found in JAVA_X_HOME
if (testJvm == "stable") {
def javaVersions = System.getenv()
.findAll { it.key =~ /^JAVA_[0-9]+_HOME$/ }
.collect { (it.key =~ /^JAVA_(\d+)_HOME$/)[0][1] as Integer }
def javaVersions = providers.environmentVariablesPrefixedBy("JAVA_").map { javaHomes ->
javaHomes
.findAll { it.key =~ /^JAVA_[0-9]+_HOME$/ }
.collect { (it.key =~ /^JAVA_(\d+)_HOME$/)[0][1] as Integer }
}.get()

if (javaVersions.isEmpty()) {
throw new GradleException("No valid JAVA_X_HOME environment variables found.")
}

testJvm = javaVersions.max().toString()
}

if (testJvm) {
def testJvmHomePath
if (Files.exists(Paths.get(testJvm))) {
Expand All @@ -177,7 +181,7 @@ project.afterEvaluate {
}
def testJvmLanguageVersion = matcher.group(2) as Integer
def testJvmEnv = "JAVA_${testJvm}_HOME"
def testJvmHome = System.getenv(testJvmEnv)
def testJvmHome = providers.environmentVariable(testJvmEnv).orNull
if (!testJvmHome) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. Have you set '$testJvmEnv'?")
}
Expand Down
3 changes: 0 additions & 3 deletions gradle/maven-pom.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.tasks.GenerateMavenPom

/** Applies the common elements to our generated POM files */
tasks.withType(GenerateMavenPom).configureEach {
doFirst {
Expand Down
14 changes: 7 additions & 7 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apply plugin: 'signing'
apply from: "$rootDir/gradle/version.gradle"
apply from: "$rootDir/gradle/maven-pom.gradle"

def isGitlabCI = System.getenv("GITLAB_CI") != null
def isGitlabCI = providers.environmentVariable("GITLAB_CI").isPresent()

// define in ~/.gradle/gradle.properties to override for testing
def forceLocal = project.hasProperty('forceLocal') && forceLocal
Expand Down Expand Up @@ -64,13 +64,13 @@ if (project.plugins.hasPlugin('com.gradleup.shadow')) {
}

signing {
useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD"))
useInMemoryPgpKeys(providers.environmentVariable("GPG_PRIVATE_KEY").orNull, providers.environmentVariable("GPG_PASSWORD").orNull)
sign publishing.publications.maven
}

tasks.withType(Sign).configureEach {
// Only sign in Gitlab CI
onlyIf { isGitlabCI || (System.getenv("GPG_PRIVATE_KEY") != null && System.getenv("GPG_PASSWORD") != null) }
onlyIf { isGitlabCI || (providers.environmentVariable("GPG_PRIVATE_KEY").isPresent() && providers.environmentVariable("GPG_PASSWORD").isPresent()) }
}

/**
Expand All @@ -81,11 +81,11 @@ gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
if (taskGraph.hasTask(publish) || taskGraph.hasTask("publishToSonatype")) {
assert project.findProperty("removeJarVersionNumbers") != true
if (taskGraph.hasTask("publishToSonatype")) {
assert System.getenv("MAVEN_CENTRAL_USERNAME") != null
assert System.getenv("MAVEN_CENTRAL_PASSWORD") != null
assert providers.environmentVariable("MAVEN_CENTRAL_USERNAME").isPresent()
assert providers.environmentVariable("MAVEN_CENTRAL_PASSWORD").isPresent()
if (isCI) {
assert System.getenv("GPG_PRIVATE_KEY") != null
assert System.getenv("GPG_PASSWORD") != null
assert providers.environmentVariable("GPG_PRIVATE_KEY").isPresent()
assert providers.environmentVariable("GPG_PASSWORD").isPresent()
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal-api/internal-api-9/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import groovy.lang.Closure
import java.nio.file.Paths

plugins {
`java-library`
Expand Down Expand Up @@ -56,5 +57,5 @@ idea {
jmh {
jmhVersion = libs.versions.jmh.get()
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
jvm = System.getenv("JAVA_11_HOME") + "/bin/java"
jvm = providers.environmentVariable("JAVA_11_HOME").map { Paths.get(it, "bin", "java").toString() }
}
2 changes: 1 addition & 1 deletion test-published-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
def sharedConfigDirectory = "$rootDir/../gradle"
rootProject.ext.sharedConfigDirectory = sharedConfigDirectory

def isCI = System.getenv("CI") != null
def isCI = providers.environmentVariable("CI").isPresent()
def versionFromFile = file("$rootDir/${isCI ? '../workspace' : '..'}/build/main.version").readLines().head()

allprojects {
Expand Down