Running tests with jdk1.4

(kev.hannen) #1

I want to run test for a legacy environment that uses jdk.1.4. If I do

test {

executable = “C:\Program Files (x86)\j2sdk1.4.2_01\bin\java.exe”; }

and “gradle test” then I get

Running tests with C:\Program Files (x86)\j2sdk1.4.2_01\bin\java.exe java.lang.UnsupportedClassVersionError: org/gradle/process/internal/launcher/GradleWorkerMain (Unsupported major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(





Is there a workaround for this?


(kev.hannen) #2

Well here’s one:

task jdk14test(type: Exec) {

commandLine “C:\Program Files (x86)\j2sdk1.4.2_01\bin\java.exe”, “-cp”, test.classpath.asPath, “junit.textui.TestRunner”, “” }

If a test fails the exec return value lets gradle know that the build failed. Any better ideas?

(Luke Daley) #3

Given that Gradle requires Java 1.5, this is going to be your best bet.

You may want to look at the dsl:org.gradle.api.tasks.JavaExec task.