Skip to content

Commit 86cc038

Browse files
jthurneerichaagdevetiennestuder
authored
Add support for CLIENT_JAVA_HOME (#434)
* Add support for CLIENT_JAVA_HOME Users can use CLIENT_JAVA_HOME to override which JVM is used to execute the Build Scan clients. The other JVMs used (for running Gradle and for building code) are not affected. * Update release/changes.md * Add missing backtick * Remove extra space * Fallback to using JAVA_HOME if CLIENT_JAVA_HOME is not set * Add a section to the READMEs for setting the JVM used to fetch build scan data * Add newline to separate sections Co-authored-by: Eric Haag <[email protected]> Signed-off-by: Jim Hurne <[email protected]> * Polish docs * Polish docs some more * Polish docs some more * Fix broken anchors --------- Signed-off-by: Jim Hurne <[email protected]> Co-authored-by: Eric Haag <[email protected]> Co-authored-by: Etienne Studer <[email protected]>
1 parent e4021a7 commit 86cc038

File tree

6 files changed

+56
-18
lines changed

6 files changed

+56
-18
lines changed

Gradle.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The build validation scripts are compatible with a large range of Gradle version
1818

1919
| Build Validation Scripts version | Compatible Gradle versions | Compatible Gradle Enterprise versions |
2020
|----------------------------------|----------------------------|---------------------------------------|
21-
| 2.0+ | 5.0+ | 2022.1+ |
21+
| 2.0+ | 5.0+ | 2022.1+ |
2222
| 1.0 - 1.0.2 | 5.0+ | 2021.2+ |
2323

2424
## Installation
@@ -86,7 +86,7 @@ is invoked, as shown in the example below.
8686

8787
The scripts return with an exit code that depends on the outcome of running a given experiment.
8888

89-
| Exit Code | Reason |
89+
| Exit Code | Reason |
9090
|-----------|--------------------------------------------------------------------------------------------------------|
9191
| 0 | The experiment completed successfully |
9292
| 1 | An invalid input was provided while attempting to run the experiment |
@@ -150,17 +150,35 @@ Gradle Enterprise server at ge.example.io.
150150
./02-validate-local-build-caching-same-location.sh -i -e -s https://ge.example.io
151151
```
152152

153-
## Running the experiments without publishing build scans
153+
## Running the experiments without publishing Build Scan data
154154

155-
The scripts that run all builds locally can be configured to not publish any build scans and instead extract the required data
156-
right during the build to surface the state of work avoidance by passing the `-x` or `--disable-build-scan-publishing` command
157-
line argument. Obviously, no deeper analysis via build scans is possible. The use of this configuration option requires a license
158-
file from Gradle Inc. to be present in the root directory of the scripts.
155+
The scripts that run all builds locally can be configured to not publish any Build Scan data and instead extract the required data
156+
right during the build to surface the state of work avoidance by passing the `-x` or `--disable-build-scan-publishing` command
157+
line argument.
158+
159+
The use of this option requires at least Java 17 to analyze the build data. The JVM version to analyze the build data is
160+
[configurable](#specifying-the-jvm-used-to-analyze-the-build-data). You can still run the builds of the experiments with a JVM
161+
version lower than Java 17.
162+
163+
The use of this configuration option also requires a license file from Gradle Inc. to be present in the root directory of the scripts.
159164

160165
```bash
161166
./02-validate-local-build-caching-same-location.sh -i -x
162167
```
163168

169+
## Specifying the JVM used to analyze the build data
170+
171+
The scripts use a Java-based utility to fetch and analyze the captured build data.
172+
If you need to run the utility with a different Java Virtual Machine than what is configured by default on your system and used when running your builds,
173+
then you can set the `CLIENT_JAVA_HOME` environment variable when invoking the scripts:
174+
175+
```bash
176+
CLIENT_JAVA_HOME="/opt/java/temurin-17.0.7+7" ./02-validate-local-build-caching-same-location.sh -i
177+
```
178+
179+
If `CLIENT_JAVA_HOME` is not specified, then the utility will use the JVM referenced by the `JAVA_HOME` environment variable.
180+
If `JAVA_HOME` is not defined, then the utility will use the Java executable found on the system path.
181+
164182
## Analyzing the results
165183

166184
Once a script has finished running its experiment, a summary of what was run and what the outcome was is printed on

Maven.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The build validation scripts are compatible with a large range of Maven versions
1818

1919
| Build Validation Scripts version | Compatible Maven versions | Compatible Gradle Enterprise versions |
2020
|----------------------------------|---------------------------| ------------------------------------- |
21-
| 2.0+ | 3.3.1+ | 2022.1+ |
21+
| 2.0+ | 3.3.1+ | 2022.1+ |
2222
| 1.0 - 1.0.2 | 3.3.1+ | 2021.2+ |
2323

2424
## Installation
@@ -84,7 +84,7 @@ is invoked, as shown in the example below.
8484

8585
The scripts return with an exit code that depends on the outcome of running a given experiment.
8686

87-
| Exit Code | Reason |
87+
| Exit Code | Reason |
8888
|-----------|--------------------------------------------------------------------------------------------------------|
8989
| 0 | The experiment completed successfully |
9090
| 1 | An invalid input was provided while attempting to run the experiment |
@@ -148,17 +148,35 @@ Gradle Enterprise server at ge.example.io.
148148
./01-validate-local-build-caching-same-location.sh -i -e -s https://ge.example.io
149149
```
150150

151-
## Running the experiments without publishing build scans
151+
## Running the experiments without publishing Build Scan data
152152

153-
The scripts that run all builds locally can be configured to not publish any build scans and instead extract the required data
154-
right during the build to surface the state of work avoidance by passing the `-x` or `--disable-build-scan-publishing` command
155-
line argument. Obviously, no deeper analysis via build scans is possible. The use of this configuration option requires a license
156-
file from Gradle Inc. to be present in the root directory of the scripts.
153+
The scripts that run all builds locally can be configured to not publish any Build Scan data and instead extract the required data
154+
right during the build to surface the state of work avoidance by passing the `-x` or `--disable-build-scan-publishing` command
155+
line argument.
156+
157+
The use of this option requires at least Java 17 to analyze the build data. The JVM version to analyze the build data is
158+
[configurable](#specifying-the-jvm-used-to-analyze-the-build-data). You can still run the builds of the experiments with a JVM
159+
version lower than Java 17.
160+
161+
The use of this configuration option also requires a license file from Gradle Inc. to be present in the root directory of the scripts.
157162

158163
```bash
159164
./01-validate-local-build-caching-same-location.sh -i -x
160165
```
161166

167+
## Specifying the JVM used to analyze the build data
168+
169+
The scripts use a Java-based utility to fetch and analyze the captured build data.
170+
If you need to run the utility with a different Java Virtual Machine than what is configured by default on your system and used when running your builds,
171+
then you can set the `CLIENT_JAVA_HOME` environment variable when invoking the scripts:
172+
173+
```bash
174+
CLIENT_JAVA_HOME="/opt/java/temurin-17.0.7+7" ./01-validate-local-build-caching-same-location.sh -i
175+
```
176+
177+
If `CLIENT_JAVA_HOME` is not specified, then the utility will use the JVM referenced by the `JAVA_HOME` environment variable.
178+
If `JAVA_HOME` is not defined, then the utility will use the Java executable found on the system path.
179+
162180
## Analyzing the results
163181

164182
Once a script has finished running its experiment, a summary of what was run and what the outcome was is printed on

components/fetch-build-scan-data-cmdline-tool/src/main/java/com/gradle/enterprise/cli/FetchBuildScanDataCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static class ExitCode {
5656
public Integer call() {
5757
// Use System.err for logging since we're going to write out the CSV to System.out
5858
logger = new ConsoleLogger(System.err, colorScheme, debug);
59+
logger.debug("Using JVM at " + System.getProperty("java.home"));
5960

6061
networkSettingsFile.ifPresent(settingsFile -> NetworkSettingsConfigurator.configureNetworkSettings(settingsFile, logger));
6162

components/scripts/lib/build-scan-offline.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ read_build_scan_dumps() {
4949
)
5050

5151
echo "Extracting Build Scan data for all builds"
52-
if ! build_scan_data="$(invoke_java "$READ_BUILD_SCAN_DATA_JAR" "${args[@]}")"; then
52+
if ! build_scan_data="$(JAVA_HOME="${CLIENT_JAVA_HOME:-$JAVA_HOME}" invoke_java "$READ_BUILD_SCAN_DATA_JAR" "${args[@]}")"; then
5353
exit "$UNEXPECTED_ERROR"
5454
fi
5555
echo "Finished extracting Build Scan data for all builds"

components/scripts/lib/build-scan-online.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ fetch_build_scan_data() {
101101
args+=( "${run_num},${build_scan_urls[run_num]}" )
102102
done
103103

104-
invoke_java "${FETCH_BUILD_SCAN_DATA_JAR}" "${args[@]}"
104+
JAVA_HOME="${CLIENT_JAVA_HOME:-$JAVA_HOME}" invoke_java "${FETCH_BUILD_SCAN_DATA_JAR}" "${args[@]}"
105105
}

release/changes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
- [NEW] Drops support for Gradle Enterprise versions older than 2023.1 when using `-e` command line option
1+
- [NEW] Drop support for Gradle Enterprise versions older than 2023.1 when using `-e` command line option
2+
- [NEW] Use `CLIENT_JAVA_HOME` environment variable to control the JVM used to analyze the Build Scan data
23
- [FIX] Informs the Gradle Enterprise Gradle plugin that it is being applied externally when using `-e` command line option
34
- [FIX] API requests do not allow time for build scans to become available
4-
- [FIX] Build caching configuration is not applied to child builds
5+
- [FIX] Build caching configuration is not applied to child builds

0 commit comments

Comments
 (0)