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(ClassLoader.java:537)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)

at java.net.URLClassLoader.access$100(URLClassLoader.java:55)

at java.net.URLClassLoader$1.run(URLClassLoader.java:194)

Is there a workaround for this?

Thanks


(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”, “com.xxx.yyyTest” }

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.