How do Iuse the JDK 1.4 compiler?

I have

apply plugin: ‘java’

sourceCompatibility = 1.4 targetCompatibility = 1.4

compileJava.options.fork = true compileJava.options.forkOptions.executable = “C:\Program Files (x86)\j2sdk1.4.2_01\bin\javac.exe”

when I “gradle build” I get

[ant:javac] javac: invalid target release: 1.5 [ant:javac] Usage: javac [ant:javac] where possible options include: [ant:javac]

-g

Generate all debugging info … etc

FAILURE: Build failed with an exception.

Thanks

with --debug I find that the jvm args are:

‘-d’ ‘C:\projects\GasanBatches\Development\Q928108_JDBC_Thin_Upgrade\APXDealLoad\build\classes\main’ ‘-classpath’ ‘C:\projects…\main’ ‘-target’ ‘1.5’ ‘-g’ ‘-source’ ‘1.5’ ‘C:\projects…\xxx.java’

Now if I add:

compileJava.options.compilerArgs = ["-target", “1.4”, “-source”, “1.4”]

the jvm args are:

‘-d’ ‘C:\projects…\main’ ‘-classpath’ ‘C:\projects…\main’ ‘-target’ ‘1.5’ ‘-g’ ‘-target’ ‘1.4’ ‘-source’ ‘1.4’ ‘-source’ ‘1.5’ ‘C:\projects…\xxx.java’

Closer but not quite.

which gradle version do you use?

running this snippet locally with 1.0-milestone-8a:

sourceCompatibility = 1.4
 targetCompatibility = 1.4
  compileJava.options.fork = true
 compileJava.options.forkOptions.executable = "C:\Program Files (x86)\j2sdk1.4.2_01\bin\javac.exe"

gives me: ‘-d’

‘C:\projects…\main’

‘-classpath’

‘C:\projects…\main’

‘-target’

‘1.4’

‘-g’

‘-target’

‘1.4’

‘-source’

‘1.4’

‘-source’

‘1.4’

‘C:\projects…\xxx.java’ ---------- still duplicate source & target compatibility settings, but at least the right one.

Hello again, sorry for the misleading post. I’ve mixed up my test folders to reproduce this problem. Can you get rid of the line:

compileJava.options.compilerArgs = ["-target", "1.4", "-source", "1.4"]

and set the source and targetCompatibility only via

sourceCompatibility = 1.4
 targetCompatibility = 1.4

that should do the trick.

regards, René

And indeed it does. The problem was that I was setting sourceCompatibility and targetCompatibility for the wrong project in a parent build file. Does a parent build file configuration always override the child configuration ?

Does a parent build file configuration always override the child configuration ?

No, it doesn’t. To give a better answer, I would need more information about what you were trying to do.