Skip to content

Commit

Permalink
Set JAVA_HOME for all Maven builds triggered from integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Dec 3, 2024
1 parent 35a3fd6 commit b49daea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ public static ProcessStarter gradlew() {
}

public static ProcessStarter maven() {
return maven(currentJdkHome());
}

public static ProcessStarter maven(Path javaHome) {
return new ProcessStarter() //
.executable(Path.of(System.getProperty("mavenDistribution")).resolve("bin").resolve(
windowsOrOtherExecutable("mvn.cmd", "mvn")).toAbsolutePath()) //
.putEnvironment("JAVA_HOME", javaHome) //
.addArguments("-Djunit.jupiter.version=" + Helper.version("junit-jupiter")) //
.addArguments("-Djunit.bom.version=" + Helper.version("junit-jupiter")) //
.addArguments("-Djunit.vintage.version=" + Helper.version("junit-vintage")) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ void java_default() throws Exception {
}

List<String> execute(Path javaHome, Map<String, String> environmentVars) throws Exception {
var result = ProcessStarters.maven() //
var result = ProcessStarters.maven(javaHome) //
.workingDir(copyToWorkspace(Projects.JAVA_VERSIONS, workspace)) //
.putEnvironment("JAVA_HOME", javaHome) //
.putEnvironment(environmentVars) //
.addArguments(localMavenRepo.toCliArgument(), "-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("--update-snapshots", "--batch-mode", "verify") //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ class MavenStarterTests {

@Test
void verifyMavenStarterProject(@TempDir Path workspace) throws Exception {
var result = ProcessStarters.maven() //
var result = ProcessStarters.maven(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.workingDir(copyToWorkspace(Projects.MAVEN_STARTER, workspace)) //
.addArguments(localMavenRepo.toCliArgument(), "-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("-Dsnapshot.repo.url=" + mavenRepoProxy.getBaseUri()) //
.addArguments("--update-snapshots", "--batch-mode", "verify") //
.putEnvironment("JAVA_HOME", Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.startAndWait();

assertEquals(0, result.exitCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ class MavenSurefireCompatibilityTests {
void testMavenSurefireCompatibilityProject(String surefireVersion, String extraArg, @TempDir Path workspace)
throws Exception {
var extraArgs = extraArg == null ? new String[0] : new String[] { extraArg };
var result = ProcessStarters.maven() //
var result = ProcessStarters.maven(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.workingDir(copyToWorkspace(Projects.MAVEN_SUREFIRE_COMPATIBILITY, workspace)) //
.addArguments(localMavenRepo.toCliArgument(), "-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("-Dsurefire.version=" + surefireVersion) //
.addArguments("--update-snapshots", "--batch-mode", "test") //
.addArguments(extraArgs) //
.putEnvironment("JAVA_HOME", Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.startAndWait();

assertEquals(0, result.exitCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ void supportedVersions(String version) throws Exception {
}

private ProcessResult run(String version) throws Exception {
return ProcessStarters.maven() //
return ProcessStarters.maven(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.workingDir(copyToWorkspace(Projects.VINTAGE, workspace)) //
.putEnvironment("JAVA_HOME", Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
.addArguments("clean", "test", "--update-snapshots", "--batch-mode") //
.addArguments(localMavenRepo.toCliArgument(), "-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("-Djunit4Version=" + version) //
Expand Down

0 comments on commit b49daea

Please sign in to comment.