Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gradle: Passing arguments to compiler and javadoc. (Getting rid of "warning: sun.misc.Unsafe is internal proprietary API and may be removed in a future release")
apply plugin: 'java'
compileJava {
// This only works when forking and passing '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 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')
}
<?xml version="1.0" encoding="UTF-8"?>
<project name="gradleTest" basedir=".">
<property name="dir.main.src" value="src/main/java"/>
<property name="dir.main.build" value="build/classes/main"/>
<property name="dir.docs" value="build/docs/javadoc"/>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compileJava">
<mkdir dir="${dir.main.build}"/>
<javac destdir="${dir.main.build}"
includeAntRuntime="false"
nowarn="true">
<compilerarg value="-XDignore.symbol.file"/>
<src path="${dir.main.src}"/>
</javac>
</target>
<target name="javadoc">
<javadoc sourcepath="${dir.main.src}"
destdir="${dir.docs}">
<arg value="-XDignore.symbol.file"/>
</javadoc>
</target>
</project>
//Should be placed in './src/main/java/org/bore/sample' directory
package org.bore.sample;
import sun.misc.Unsafe;
public class Sample {
public int foo() {
return Unsafe.getUnsafe().pageSize();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.