-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathbuild-compile.xml
157 lines (138 loc) · 7.62 KB
/
build-compile.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This file is part of SoSy-Lab Java-Project Template,
a collection of common files and build definitions for Java projects:
https://gitlab.com/sosy-lab/software/java-project-template
SPDX-FileCopyrightText: 2018-2020 Dirk Beyer <https://www.sosy-lab.org>
SPDX-License-Identifier: Apache-2.0
-->
<!-- vim: set tabstop=8 shiftwidth=4 expandtab filetype=ant : -->
<project name="compile" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<!-- Targets for compilation. -->
<!-- DO NOT EDIT LOCALLY!
Keep this file synchronized with
https://gitlab.com/sosy-lab/software/java-project-template
-->
<!-- These properties can be overridden from including file. -->
<property name="source.release" value="11"/>
<property name="source.dir" value="src"/>
<property name="source.generated.dir" value=".apt-generated"/>
<property name="class.dir" value="bin"/>
<!-- <property name="errorprone.disable" value=""/> --> <!-- Disable error-prone completely. -->
<property name="errorprone.options" value=""/>
<path id="processorpath">
<fileset dir="${ivy.lib.dir}" includes="build/*.jar"/>
</path>
<patternset id="source.additional">
<exclude name="**/*.java" />
</patternset>
<!-- error-prone config from https://errorprone.info/docs/installation#jdk-16 -->
<property name="errorprone.options.required" value="
-XDcompilePolicy=simple
-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
"/>
<condition property="java21">
<javaversion atleast="21"/>
</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}">
<patternset refid="source.additional" />
</fileset>
</copy>
<javac debug="true"
debuglevel="source,lines,vars"
destdir="${class.dir}"
release="${source.release}"
fork="true"
includeAntRuntime="false"
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="-Xlint:-this-escape" if:set="java21"/> <!-- false alarm for every use of configuration injection -->
<compilerarg value="-Werror" unless:set="compile.warn"/>
<compilerarg line="${errorprone.options.required}" unless:set="errorprone.disable"/>
<compilerarg value="-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode ${errorprone.options}" unless:set="errorprone.disable"/>
<compilerarg value="-s"/><compilerarg value="${source.generated.dir}"/>
<compilerarg value="-processorpath"/><compilerarg pathref="processorpath"/>
</javac>
</target>
<!-- Use error-prone as compiler and specify refaster file. -->
<target name="refaster" depends="build-dependencies">
<fail unless="refaster.rule.file" message="Specify rule file with -Drefaster.rule.file=..."/>
<property name="refaster.patch.file" value="${basedir}/error-prone.patch"/> <!-- hard-coded in error-prone -->
<delete file="${refaster.patch.file}" quiet="true"/>
<!-- We use a temp directory as destdir to make sure we compile all files. -->
<tempfile property="temp.dir" destdir="${java.io.tmpdir}" prefix="refaster-build-"/>
<mkdir dir="${temp.dir}"/>
<javac destdir="${temp.dir}"
release="${source.release}"
failonerror="false"
errorProperty="javac.failed"
createMissingPackageInfoClass="false"
fork="true"
includeAntRuntime="false"
encoding="UTF-8">
<src path="${source.dir}"/>
<classpath refid="classpath"/>
<compilerarg line="${errorprone.options.required}" unless:set="errorprone.disable"/>
<compilerarg value="-Xplugin:ErrorProne -XepPatchChecks:refaster:${refaster.rule.file} -XepPatchLocation:${basedir}" unless:set="errorprone.disable"/>
<compilerarg value="-s"/><compilerarg value="${source.generated.dir}"/>
<compilerarg value="-processorpath"/><compilerarg pathref="processorpath"/>
<compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/>
<compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"/>
</javac>
<delete dir="${temp.dir}"/>
<fail if="javac.failed" message="Compilation failed"/>
<!-- Check result and provide instructions -->
<available property="refaster.patch.file.exists" file="${refaster.patch.file}"/>
<fail if="refaster.patch.file.exists" message="Refaster suggestions are in error-prone.patch, apply with 'patch -p0 < ${refaster.patch.file}'. Make sure to format the code after applying the patch."/>
<echo message="Refaster found no suggestions." level="info"/>
</target>
<path id="ecj">
<fileset dir="${ivy.lib.dir}/build" includes="ecj.jar"/>
</path>
<target name="build-project-ecj" depends="build-dependencies" description="Build project with the Eclipse JDT compiler">
<depend srcdir="${source.dir}" destdir="${class.dir}"/>
<mkdir dir="${source.generated.dir}"/>
<copy file=".settings/org.eclipse.jdt.core.prefs" tofile="${ivy.lib.dir}/build/org.eclipse.jdt.core.prefs">
<!-- Convert all compiler warnings to errors. -->
<filterchain>
<replacetokens begintoken="=" endtoken="g">
<token key="warnin" value="=error"/>
</replacetokens>
</filterchain>
</copy>
<javac debug="true"
debuglevel="source,lines,vars"
destdir="${class.dir}"
release="${source.release}"
compiler="org.eclipse.jdt.core.JDTCompilerAdapter"
includeAntRuntime="false"
encoding="UTF-8">
<src path="${source.dir}"/>
<classpath refid="classpath"/>
<compilerarg value="-properties"/>
<compilerarg value="${ivy.lib.dir}/build/org.eclipse.jdt.core.prefs"/>
<compilerarg value="-s"/><compilerarg value="${source.generated.dir}"/>
<compilerarg value="-processorpath"/><compilerarg pathref="processorpath"/>
<compilerclasspath refid="ecj"/>
</javac>
</target>
</project>