Skip to content
Merged
Changes from all commits
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
28 changes: 18 additions & 10 deletions gradle/java_no_deps.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import org.gradle.api.internal.provider.PropertyFactory
import org.gradle.jvm.toolchain.internal.SpecificInstallationToolchainSpec

import java.nio.file.Files
import java.nio.file.Paths

apply plugin: 'java-library'

apply from: "$rootDir/gradle/codenarc.gradle"
Expand Down Expand Up @@ -164,17 +167,22 @@ project.afterEvaluate {
testJvm = javaVersions.max().toString()
}
if (testJvm) {
def matcher = testJvm =~ /([a-zA-Z]*)([0-9]+)/
if (!matcher.matches()) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. It needs to match '([a-zA-Z]*)([0-9]+)'.")
}
def testJvmLanguageVersion = matcher.group(2) as Integer
def testJvmEnv = "JAVA_${testJvm}_HOME"
def testJvmHome = System.getenv(testJvmEnv)
if (!testJvmHome) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. Have you set '$testJvmEnv'?")
def testJvmHomePath
if (Files.exists(Paths.get(testJvm))) {
testJvmHomePath = getJavaHomePath(testJvm)
} else {
def matcher = testJvm =~ /([a-zA-Z]*)([0-9]+)/
if (!matcher.matches()) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. It needs to match '([a-zA-Z]*)([0-9]+)'.")
}
def testJvmLanguageVersion = matcher.group(2) as Integer
def testJvmEnv = "JAVA_${testJvm}_HOME"
def testJvmHome = System.getenv(testJvmEnv)
if (!testJvmHome) {
throw new GradleException("Unable to find launcher for Java '$testJvm'. Have you set '$testJvmEnv'?")
}
testJvmHomePath = getJavaHomePath(testJvmHome)
}
def testJvmHomePath = getJavaHomePath(testJvmHome)
// Only change test JVM if it's not the one we are running the gradle build with
if (currentJavaHomePath != testJvmHomePath) {
def jvmSpec = new SpecificInstallationToolchainSpec(project.services.get(PropertyFactory), file(testJvmHomePath))
Expand Down