Created
September 23, 2012 17:30
-
-
Save BorePlusPlus/3772416 to your computer and use it in GitHub Desktop.
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")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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