Skip to content

Commit

Permalink
Merge pull request #36238 from snazy/jvm-toolchains
Browse files Browse the repository at this point in the history
Optionally run Gradle build + ITs using different JDK
  • Loading branch information
gsmet authored Oct 4, 2023
2 parents f283c4c + ad127ed commit 3170e5d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions devtools/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@
<gradle.executable>..\gradlew.bat</gradle.executable>
</properties>
</profile>
<profile>
<id>gradleJavaHomeSet</id>
<activation>
<property>
<name>env.GRADLE_JAVA_HOME</name>
</property>
</activation>
<properties>
<gradleJavaHome>${env.GRADLE_JAVA_HOME}</gradleJavaHome>
</properties>
</profile>
<profile>
<id>gradleJavaHomeNotSet</id>
<activation>
<property>
<name>!env.GRADLE_JAVA_HOME</name>
</property>
</activation>
<properties>
<gradleJavaHome>${env.JAVA_HOME}</gradleJavaHome>
</properties>
</profile>
<profile>
<id>run-gradle</id>
<activation>
Expand Down Expand Up @@ -79,6 +101,7 @@
<environmentVariables>
<MAVEN_REPO_LOCAL>${settings.localRepository}</MAVEN_REPO_LOCAL>
<GRADLE_OPTS>${env.MAVEN_OPTS}</GRADLE_OPTS>
<JAVA_HOME>${gradleJavaHome}</JAVA_HOME>
</environmentVariables>
<skip>${skip.gradle.build}</skip>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public BuildResult runGradleWrapper(boolean expectError, File projectDir, boolea
.redirectOutput(logOutput)
// Should prevent "fragmented" output (parts of stdout and stderr interleaved)
.redirectErrorStream(true);
if (System.getenv("JAVA_HOME") == null) {
if (System.getenv("GRADLE_JAVA_HOME") != null) {
// JAVA_HOME for Gradle explicitly configured.
pb.environment().put("JAVA_HOME", System.getenv("GRADLE_JAVA_HOME"));
} else if (System.getenv("JAVA_HOME") == null || System.getenv("JAVA_HOME").isEmpty()) {
// This helps running the tests in IntelliJ w/o configuring an explicit JAVA_HOME env var.
pb.environment().put("JAVA_HOME", System.getProperty("java.home"));
}
Expand Down

0 comments on commit 3170e5d

Please sign in to comment.