I need to compile a code which uses com.sun.image.codec.jpeg
package and its friends. I know, I know, its our company legacy code and we need to compile it as is.
My problem is - Eclipse compile those files without problem, it just works.
IDEA do the same - compile and works.
The problem is Gradle - it gives me errors like
error: package com.sun.image.codec.jpeg does not exist
I know - add -XDignore.symbol.file
to compilator.
I did
compileJava.options.compilerArgs.add '-XDignore.symbol.file'
in my build.grade, I turned verbose mode and I see parameter gets passed correctly
20:28:16.148 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -d C:\workspace\blabla -g -XDignore.symbol.file -classpath C:\workspace\blabla_lots_of_jars.jar C:\workspace\tons_of_java_files.java
20:28:16.153 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
But compilation fails. On the other question I found that I should add to gradle file a line
compileJava.options.useAnt = true
which makes, you guessed, that everything compiles. The debug log is a bit different, but shows that also params are passed correctly
21:50:34.101 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:javac] Compilation arguments:
'-d'
'C:\workspace\blabla'
'-classpath'
'tons_of_jars'
'-target'
'1.7'
'-g'
'-XDignore.symbol.file'
'-source'
'1.7'
But useAnt
will be removed and its seems like a dirty hack.
I use newest Gradle (1.8) and jdk1.7.0_25 on Win8 - but I doubt it matters
How can I make Gradle properly compile my sources and respect my compilation parameters?