Sync build-compile.xml from java-common-lib
This lets error-prone run as a javac plugin on Java 9 and newer,
which prepares support for Java 10.
<property name="source.generated.dir" value=".apt-generated"/>
<property name="class.format" value="1.8"/>
<property name="class.dir" value="bin"/>
+ <property name="errorprone.options" value=""/>
<path id="errorprone">
<pathelement location="${ivy.lib.dir}/build/error_prone_ant.jar"/>
</path>
+
+ <!-- Needs to include all annotation processors and error-prone -->
<path id="processorpath">
<fileset dir="${ivy.lib.dir}" includes="build/*.jar"/>
</path>
+ <property name="errorprone" value="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
+ <condition property="java8">
+ <matches string="${ant.java.version}" pattern="8"/>
+ </condition>
+ <condition property="java.compiler" value="${errorprone}" else="modern">
+ <isset property="java8"/>
+ </condition>
+
<!-- We use error-prone as the compiler, cf. http://errorprone.info/ -->
<target name="build-project" unless="skipBuild" depends="build-dependencies">
<depend srcdir="${source.dir}" destdir="${class.dir}"/>
<mkdir dir="${source.generated.dir}"/>
+ <copy todir="${class.dir}">
+ <fileset dir="${source.dir}">
+ <exclude name="**/*.java" />
+ <exclude name="**/*.cup" />
+ <exclude name="**/*.jflex" />
+ <exclude name="**/*.nested" />
+ <exclude name="**/*.xml" />
+ <exclude name="**/*.dia" />
+ <exclude name="**/*.pdf" />
+ </fileset>
+ </copy>
<javac debug="true"
debuglevel="source,lines,vars"
destdir="${class.dir}"
source="${source.format}"
target="${class.format}"
includeAntRuntime="false"
- compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"
+ compiler="${java.compiler}"
encoding="UTF-8">
<src path="${source.dir}"/>
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
+ <compilerarg value="-Xlint:-fallthrough"/> <!-- checked by error-prone, too, and javac does not recognized $FALL-THROUGH$ -->
<compilerarg value="-Xlint:-processing"/>
+ <compilerarg value="-Xlint:-options"/> <!-- suppress warning about bootclasspath on newer JDK -->
<compilerarg value="-Werror"/>
+ <compilerarg compiler="${errorprone}" line="-XepDisableWarningsInGeneratedCode ${errorprone.options}"/>
+ <compilerarg compiler="modern" value="-XDcompilePolicy=simple"/> <!-- necessary for error-prone -->
+ <compilerarg compiler="modern" value="-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode ${errorprone.options}"/>
<compilerarg value="-s"/><compilerarg value="${source.generated.dir}"/>
<compilerarg value="-processorpath"/><compilerarg pathref="processorpath"/>
<compilerclasspath refid="errorprone"/>
