File: build.xml

package info (click to toggle)
cofoja 1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,064 kB
  • sloc: java: 10,706; xml: 306; sh: 174; makefile: 16
file content (336 lines) | stat: -rw-r--r-- 11,403 bytes parent folder | download
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<project name="Cofoja" default="dist" basedir="."
         xmlns:if="ant:if"
         xmlns:unless="ant:unless"
         xmlns:ivy="antlib:org.apache.ivy.ant">
  <!-- Configurable properties. -->
  <condition property="platform.suffix" value=".${platform}" else="">
    <isset property="platform" />
  </condition>
  <property file="local.properties" />
  <property file="local${platform.suffix}.properties" if:set="platform" />
  <property file="default.properties" />

  <!-- Private properties. -->

  <condition property="java8">
    <or>
      <and>
        <isset property="rt.jar" />
        <available ignoresystemclasses="true"
                   classname="java.lang.invoke.LambdaMetafactory">
          <classpath location="${rt.jar}" />
        </available>
      </and>
      <and>
        <not>
          <isset property="rt.jar" />
        </not>
        <available classname="java.lang.invoke.LambdaMetafactory" />
      </and>
    </or>
  </condition>

  <property name="lib.dir" location="lib" />
  <property name="src.dir" location="src" />
  <property name="test.dir" location="test" />
  <property name="build.dir" location="build" />
  <property name="obj.dir" location="obj${platform.suffix}" />
  <property name="dist.dir" location="dist${platform.suffix}" />

  <property name="manifest.path"
            value="${src.dir}/META-INF/MANIFEST.MF" />
  <property name="apt.class"
            value="com.google.java.contract.core.apt.AnnotationProcessor" />
  <property name="test.configurator.class"
            value="com.google.java.contract.tests.Cofoja" />

  <path id="base.class.path">
    <fileset dir="${lib.dir}">
      <include name="asm-*.jar" />
    </fileset>
  </path>

  <path id="build.class.path">
    <path refid="base.class.path" />
    <pathelement path="${tools.jar}" />
  </path>

  <path id="test.class.path">
    <path refid="base.class.path" />
    <fileset dir="${lib.dir}">
      <include name="*.jar" />
    </fileset>
  </path>

  <path id="test1.class.path">
    <path refid="test.class.path" />
    <pathelement path="${obj.dir}/stage2" />
  </path>

  <path id="test2.class.path">
    <path refid="test.class.path" />
    <pathelement path="${obj.dir}/stage2" />
    <pathelement path="${obj.dir}/test" />
  </path>

  <!-- Build macros. -->

  <presetdef name="ujavac">
    <javac encoding="utf-8" debug="${debug}" includeantruntime="false">
      <bootclasspath location="${rt.jar}" if:set="rt.jar" />
    </javac>
  </presetdef>

  <macrodef name="cofojavac">
    <attribute name="srcdir" />
    <attribute name="destdir" />
    <attribute name="debug" default="false" />
    <attribute name="bootstrappath" default="" />
    <attribute name="classpathid" />
    <element name="contents" optional="true" implicit="true" />
    <sequential>
      <path id="processor.path">
        <path refid="base.class.path" />
        <pathelement location="@{bootstrappath}" />
      </path>
      <ujavac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}">
        <classpath refid="@{classpathid}" />
        <compilerarg value="-processorpath" unless:blank="@{bootstrappath}" />
        <compilerarg value="${toString:processor.path}" unless:blank="@{bootstrappath}" />
        <compilerarg value="-processor" />
        <compilerarg value="${apt.class}" />
        <compilerarg value="-Acom.google.java.contract.classpath=${toString:@{classpathid}}" />
        <compilerarg value="-Acom.google.java.contract.sourcepath=@{srcdir}" />
        <compilerarg value="-Acom.google.java.contract.classoutput=@{destdir}" />
        <contents />
      </ujavac>
    </sequential>
  </macrodef>

  <macrodef name="checkjar">
    <attribute name="label" />
    <attribute name="property" />
    <sequential>
      <condition property="@{property}.notfound"
                 value="no such file: "
                 else="">
        <not>
          <available file="${@{property}}" />
        </not>
      </condition>
      <echo message="@{label}${@{property}.notfound}${@{property}}" />
    </sequential>
  </macrodef>

  <macrodef name="requirejar">
    <attribute name="property" />
    <sequential>
      <fail message="Cannot find '${@{property}}'. Please link to the appropriate file or set the '@{property}' property to suit your environment. Consult the 'README' file for more information.">
        <condition>
          <not>
            <equals arg1="${@{property}.notfound}" arg2="" />
          </not>
        </condition>
      </fail>
    </sequential>
  </macrodef>

  <macrodef name="barejar">
    <attribute name="jarfile" />
    <attribute name="basedir" />
    <sequential>
      <jar jarfile="@{jarfile}"
           basedir="@{basedir}"
           manifest="${manifest.path}">
        <service type="javax.annotation.processing.Processor"
                 provider="${apt.class}" />
      </jar>
    </sequential>
  </macrodef>

  <macrodef name="fulljar">
    <attribute name="jarfile" />
    <attribute name="barejarfile" />
    <sequential>
      <jar jarfile="@{jarfile}"
           manifest="${manifest.path}">
        <service type="javax.annotation.processing.Processor"
                 provider="${apt.class}" />
        <zipfileset includes="**/*.class"
                    src="@{barejarfile}" />
        <zipfileset includes="**/*.class">
          <fileset dir="${lib.dir}">
            <include name="asm-*.jar" />
          </fileset>
        </zipfileset>
      </jar>
    </sequential>
  </macrodef>

  <macrodef name="bootstrapcomp">
    <attribute name="stage" />
    <attribute name="bootstrappath" />
    <sequential>
      <mkdir dir="${obj.dir}/tmp@{stage}" />
      <mkdir dir="${obj.dir}/stage@{stage}" />
      <cofojavac srcdir="${src.dir}" destdir="${obj.dir}/tmp@{stage}" debug="true"
                 bootstrappath="@{bootstrappath}" classpathid="build.class.path" />
      <cofojab srcdir="${obj.dir}/tmp@{stage}"
               destdir="${obj.dir}/stage@{stage}" />
    </sequential>
  </macrodef>

  <!-- Dependency management. -->

  <target name="resolve" description="retrieve dependencies with Ivy">
    <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]"
                  type="jar" conf="test" />
  </target>

  <target name="publish" depends="resolve,dist"
          description="publish artifacts with Ivy">
    <ivy:publish resolver="local" pubrevision="${version}"
                 artifactspattern="dist/[artifact]-${cofoja.version}.[ext]" />
  </target>

  <!-- Initialization. -->

  <target name="configure">
    <echo message="Configuration" />
    <echo message="-------------" />
    <sequential if:set="rt.jar">
      <checkjar label="JRE RT JAR:    " property="rt.jar" />
    </sequential>
    <sequential if:set="bootstrap.jar">
      <checkjar label="Bootstrap JAR: " property="bootstrap.jar" />
    </sequential>
    <echo message="Snapshot:      ${snapshot}" />
    <echo message="Debug:         ${debug}" />
  </target>

  <target name="init" depends="configure">
    <tstamp />
    <condition property="cofoja.version"
               value="${version}-${DSTAMP}"
               else="${version}">
      <equals arg1="${snapshot}" arg2="true" />
    </condition>
    <property name="cofoja.jar"
              value="${dist.dir}/cofoja+asm-${cofoja.version}.jar" />
    <property name="cofoja.bare.jar"
              value="${dist.dir}/cofoja-${cofoja.version}.jar" />
    <property name="cofoja.contracted.jar"
              value="${dist.dir}/cofoja+contracts+asm-${cofoja.version}.jar" />
    <property name="cofoja.contracted.bare.jar"
              value="${dist.dir}/cofoja+contracts-${cofoja.version}.jar" />

    <mkdir dir="${obj.dir}" />
    <mkdir dir="${dist.dir}" />
  </target>

  <!-- Simple build. -->

  <target name="build" depends="init"
          description="build class files">
    <mkdir dir="${obj.dir}/bare" />
    <ujavac srcdir="${src.dir}" destdir="${obj.dir}/bare">
      <classpath refid="build.class.path" />
    </ujavac>
  </target>

  <target name="nobootstrap" depends="build"
          description="build JAR files without self-contracts">
    <barejar jarfile="${cofoja.bare.jar}" basedir="${obj.dir}/bare" />
    <fulljar jarfile="${cofoja.jar}" barejarfile="${cofoja.bare.jar}" />
    <property name="bootstrap.jar" value="${cofoja.bare.jar}" />
  </target>

  <!-- Bootstrap. -->

  <target name="antinit" depends="init,nobootstrap">
    <mkdir dir="${obj.dir}/build" />
    <ujavac srcdir="${build.dir}" destdir="${obj.dir}/build">
      <classpath>
        <path refid="base.class.path" />
        <pathelement path="${java.class.path}" />
        <pathelement location="${bootstrap.jar}" />
      </classpath>
    </ujavac>
    <taskdef name="cofojab" classname="PreAgentAntTask">
      <classpath>
        <path refid="base.class.path" />
        <pathelement location="${obj.dir}/build" />
        <pathelement location="${bootstrap.jar}" />
      </classpath>
    </taskdef>
  </target>

  <target name="stage0" depends="antinit">
    <bootstrapcomp stage="0" bootstrappath="${bootstrap.jar}" />
  </target>

  <target name="stage1" depends="stage0">
    <bootstrapcomp stage="1" bootstrappath="${obj.dir}/stage0" />
  </target>

  <target name="stage2" depends="stage1">
    <bootstrapcomp stage="2" bootstrappath="${obj.dir}/stage1" />
  </target>

  <target name="dist" depends="stage2"
          description="build JAR files for distribution">
    <barejar jarfile="${cofoja.contracted.bare.jar}"
             basedir="${obj.dir}/stage2" />
    <fulljar jarfile="${cofoja.contracted.jar}"
             barejarfile="${cofoja.contracted.bare.jar}" />
  </target>

  <!-- Tests. -->

  <target name="buildtest1" depends="stage2">
    <mkdir dir="${obj.dir}/test" />
    <cofojavac srcdir="${test.dir}" destdir="${obj.dir}/test"
               classpathid="test1.class.path">
      <include name="**/SeparateGenericSuperclass.java" />
      <include name="**/SeparateInterface.java" />
    </cofojavac>
  </target>

  <target name="buildtest2" depends="buildtest1,stage2">
    <cofojavac srcdir="${test.dir}" destdir="${obj.dir}/test"
               classpathid="test2.class.path">
      <compilerarg value="-Acom.google.java.contract.dump=${obj.dir}/test/dump" />
      <exclude name="**/SeparateGenericSuperclass.java" />
      <exclude name="**/SeparateInterface.java" />
      <exclude name="**/Java8*.java" unless:true="${java8}" />
    </cofojavac>
  </target>

  <target name="test" depends="buildtest2,dist"
          description="run tests">
    <junit printsummary="yes" haltonfailure="yes">
      <classpath>
        <path refid="test.class.path" />
        <pathelement path="${obj.dir}/stage2" />
        <pathelement location="${obj.dir}/test" />
      </classpath>
      <jvmarg value="-javaagent:${cofoja.contracted.bare.jar}" />
      <jvmarg value="-Dcom.google.java.contract.configurator=${test.configurator.class}" />
      <formatter type="plain" />
      <batchtest fork="yes" todir="${obj.dir}/test">
        <fileset dir="${obj.dir}/test">
          <include name="**/*Test.class" />
          <exclude name="**/Java8*.class" unless:true="${java8}" />
        </fileset>
      </batchtest>
    </junit>
  </target>

  <!-- Book-keeping. -->

  <target name="clean"
          description="remove generated files">
    <delete dir="${obj.dir}" />
    <delete dir="${dist.dir}" />
  </target>
</project>