Reputation: 595
I am trying to provide Gradle as an alternative build system on an existing project. That project makes use of sun.misc.Unsafe
which leads to warnings like this one:
warning: Unsafe is internal proprietary API and may be removed in a future release
import sun.misc.Unsafe;
To suppress this warning -XDignore.symbol.file
is passed as an argument to javac and javadoc in the current ant script.
In order to suppress these warnings in Gradle I had to resort to what I feel are 'dirty' hacks that I am not too comfortable with.
apply plugin: 'java'
compileJava {
// I only managed to get this working when I forked
// and passed 'javac' as an executable
options.compilerArgs << '-XDignore.symbol.file'
options.fork = true
options.forkOptions.executable = 'javac'
}
javadoc {
// These get ignored
// options.addStringOption('XDignore.symbol.file', null)
// options.addStringOption('XDignore.symbol.file')
// This one fails the build - I am assuming it's trying to parse ''
// options.addStringOption('XDignore.symbol.file')
// This works, but it's an ugly hack
options.addStringOption('XDignore.symbol.file', '-quiet')
}
Surely there must be a more elegant way that I don't know to achieve this.
Here ( https://gist.github.com/3772416 ) is a more complete example with an accompanying ant script and a sample class that causes the problem.
Thanks
I am running Gradle 1.1
------------------------------------------------------------
Gradle 1.1
------------------------------------------------------------
Gradle build time: Tuesday, 31 July 2012 13:24:32 o'clock UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_07 (Oracle Corporation 23.3-b01)
OS: Linux 3.2.0-30-generic amd64
It seems that this is a reasonable worakround at the moment for suppressing these particular warnings. See - http://forums.gradle.org/gradle/topics/passing_arguments_to_compiler_and_javadoc?rfm=1
Upvotes: 7
Views: 8673
Reputation: 123910
Regarding Javadoc, the following might work:
javadoc.options.jflags "-XDignore.symbol.file"
Regarding Java compilation, it would be good to know if options.fork = true
and options.forkOptions.executable = 'javac'
are still required with recent Gradle versions (e.g. 1.2). If yes, please file a problem at http://forums.gradle.org.
Upvotes: 2