Skip to content

Commit ad127ed

Browse files
committed
Optionally run Gradle build + ITs using different JDK
When the environment variable `GRADLE_JAVA_HOME` is present, it will be used as the `JAVA_HOME` when building `devtools/gradle/` using Gradle via Maven, Gradle devtools integration tests respect the environment variable as well.
1 parent c60e23a commit ad127ed

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

devtools/gradle/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@
4949
<gradle.executable>..\gradlew.bat</gradle.executable>
5050
</properties>
5151
</profile>
52+
<profile>
53+
<id>gradleJavaHomeSet</id>
54+
<activation>
55+
<property>
56+
<name>env.GRADLE_JAVA_HOME</name>
57+
</property>
58+
</activation>
59+
<properties>
60+
<gradleJavaHome>${env.GRADLE_JAVA_HOME}</gradleJavaHome>
61+
</properties>
62+
</profile>
63+
<profile>
64+
<id>gradleJavaHomeNotSet</id>
65+
<activation>
66+
<property>
67+
<name>!env.GRADLE_JAVA_HOME</name>
68+
</property>
69+
</activation>
70+
<properties>
71+
<gradleJavaHome>${env.JAVA_HOME}</gradleJavaHome>
72+
</properties>
73+
</profile>
5274
<profile>
5375
<id>run-gradle</id>
5476
<activation>
@@ -79,6 +101,7 @@
79101
<environmentVariables>
80102
<MAVEN_REPO_LOCAL>${settings.localRepository}</MAVEN_REPO_LOCAL>
81103
<GRADLE_OPTS>${env.MAVEN_OPTS}</GRADLE_OPTS>
104+
<JAVA_HOME>${gradleJavaHome}</JAVA_HOME>
82105
</environmentVariables>
83106
<skip>${skip.gradle.build}</skip>
84107
</configuration>

integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusGradleWrapperTestBase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public BuildResult runGradleWrapper(boolean expectError, File projectDir, boolea
8484
.redirectOutput(logOutput)
8585
// Should prevent "fragmented" output (parts of stdout and stderr interleaved)
8686
.redirectErrorStream(true);
87-
if (System.getenv("JAVA_HOME") == null) {
87+
if (System.getenv("GRADLE_JAVA_HOME") != null) {
88+
// JAVA_HOME for Gradle explicitly configured.
89+
pb.environment().put("JAVA_HOME", System.getenv("GRADLE_JAVA_HOME"));
90+
} else if (System.getenv("JAVA_HOME") == null || System.getenv("JAVA_HOME").isEmpty()) {
8891
// This helps running the tests in IntelliJ w/o configuring an explicit JAVA_HOME env var.
8992
pb.environment().put("JAVA_HOME", System.getProperty("java.home"));
9093
}

0 commit comments

Comments
 (0)