File: build.xml

package info (click to toggle)
libjna-java 5.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,840 kB
  • sloc: java: 90,395; ansic: 4,994; xml: 3,722; makefile: 434; sh: 299
file content (358 lines) | stat: -rw-r--r-- 17,347 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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?xml version="1.0" encoding="UTF-8"?>
<project name="platform"
         default="default"
         basedir="."
         xmlns:if="ant:if"
         xmlns:unless="ant:unless">
    <description>Builds and tests platform-specific code.</description>

    <import file="../../common.xml" />
    <property name="build" value="build"/>
    <property name="classes" location="${build}/classes"/>
    <property name="debug" value="true"/>
    <property name="javac.release" value="8"/>
    <property name="platform.name" value="jna-platform"/>
    <property name="jar" value="${platform.name}.jar"/>
    <property name="jar-base" value="${platform.name}-base.jar"/>
    <property name="jar-jpms" value="${platform.name}-jpms.jar"/>
    <property name="src" location="src"/>
    <property name="testjar" value="${platform.name}-test.jar"/>
    <property name="test.classes" location="${build}/test-classes"/>
    <property name="test.src" location="test"/>
    <property name="tests.exclude" value=""/>
    <property name="tests.exclude-patterns" value=""/>
    <property name="dist" value="dist" />
    <path id="src.path">
        <pathelement location="${src}"/>
    </path>
    <path id="compile.path">
        <fileset dir="../../build">
            <include name="jna.jar"/>
        </fileset>
    </path>
    <path id="compile-test.path">
        <path id="test.libs">
            <fileset dir="../../lib">
                <include name="junit.jar"/>
                <include name="hamcrest-core-1.3.jar"/>
            </fileset>
            <fileset dir="../../lib/test">
                <include name="bcpkix-jdk15on-161.jar"/>
                <include name="bcprov-jdk15on-161.jar"/>
                <include name="reflections-0.9.11.jar"/>
                <include name="guava-27.1-jre.jar"/>
                <include name="javassist-3.12.1.GA.jar"/>
            </fileset>
            <fileset dir="../../build">
                <include name="jna-test.jar"/>
                <include name="jna.jar"/>
            </fileset>
            <pathelement path="../../build/test-classes"/>
            <pathelement path="${classes}"/>
        </path>
    </path>
    <path id="test.runpath">
      <pathelement path="../../build/${native.subdir}"/>
      <pathelement path="${build}/${jar}"/>
      <pathelement path="${test.classes}"/>
      <pathelement path="${test.src}"/>
      <pathelement path="../../lib/clover.jar"/>
      <path refid="test.libs"/>
    </path>

    <!-- Prepare additional ant task -->
    <path id="maven-ant-tasks.classpath">
        <pathelement location="../../lib/maven-ant-tasks-2.1.3.jar" />
    </path>

    <target name="clean">
        <delete failOnError="false" includeEmptyDirs="true">
            <fileset dir="${build}"/>
        </delete>
    </target>

    <target name="compile" description="Compile all Java source">

        <mkdir dir="${classes}" />

        <javac release="${javac.release}"
               destdir="${classes}"
               includeantruntime="false"
               deprecation="on"
               debug="${debug}"
               encoding="UTF-8"
               classpathref="compile.path">
            <src refid="src.path"/>
        </javac>
    </target>

    <target name="compile-tests" depends="compile" description="Compile all test code">

        <mkdir dir="${test.classes}" />

        <javac classpathref="compile-test.path"
               release="${javac.release}"
               destdir="${test.classes}"
               includeantruntime="false"
               excludes="${tests.exclude-patterns}"
               deprecation="on"
               debug="${debug}"
               encoding="UTF-8"
        >
            <src path="${test.src}"/>
            <exclude name="${tests.exclude}"/>
        </javac>
        <!-- Create a jar for easy movement of tests, and jar load test -->
        <jar jarfile="${build}/${testjar}" createUnicodeExtraFields="never" encoding="UTF-8">
            <fileset dir="${test.classes}">
                <include name="**/*"/>
            </fileset>
            <manifest>
                <attribute name="permissions" value="all-permissions"/>
            </manifest>
        </jar>
    </target>

    <target name="jar" depends="-pre-jar,-build-jar,-post-jar" />

    <target name="-prepare-anttools">
        <subant antfile="build-ant-tools.xml" buildpath="${basedir}/../../"></subant>
        <taskdef name="BuildArmSoftFloatDetector" classname="com.sun.jna.BuildArmSoftFloatDetector" classpath="${basedir}/../../build/ant-tools:${basedir}/../../lib/asm.jar" />
        <taskdef name="CalcAndroidVersion" classname="com.sun.jna.ant.CalcAndroidVersion" classpath="${basedir}/../../build/ant-tools:${basedir}/../../lib/asm.jar" />
        <taskdef name="ModuleGenerator" classname="com.sun.jna.ant.ModuleGenerator" classpath="${basedir}/../../build/ant-tools:${basedir}/../../lib/asm.jar" />
    </target>

    <macrodef name="build-manifest">
        <attribute name="target" />
        <attribute name="module-info" default="false" />
        <sequential>
            <manifest file="@{target}" mode="replace">
                <attribute name="Manifest-Version" value="1.0"/>
                <attribute name="Implementation-Title" value="${impl.title}"/>
                <attribute name="Implementation-Vendor" value="${vendor}"/>
                <attribute name="Implementation-Version" value="${impl.version}"/>
                <attribute name="Specification-Title" value="${spec.title}"/>
                <attribute name="Specification-Vendor" value="${spec.vendor}"/>
                <attribute name="Specification-Version" value="${spec.version}"/>
                <!--
                  OSGi Bundle attributes
                  See http://www.osgi.org/Specifications/Reference
                -->
                <attribute name="Bundle-Category" value="jni"/>
                <attribute name="Bundle-ManifestVersion" value="2"/>
                <attribute name="Bundle-Name" value="jna-platform"/>
                <attribute name="Bundle-Description" value="JNA Platform Library"/>
                <attribute name="Bundle-SymbolicName" value="com.sun.jna.platform"/>
                <attribute name="Bundle-Version" value="${osgi.version}"/>
                <attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
                <attribute name="Bundle-Vendor" value="${vendor}"/>
                <attribute name="Require-Bundle" value="com.sun.jna;bundle-version=&quot;${osgi.version}&quot;"/>
                <!--
                The full "Export-Package" statement can be generated by invoking
                create-export-package-metadata-pom.sh in the main folder. This is
                necessary if the exported packages change. Then the list in the
                shell script needs to be updated as well.
                -->
                <attribute name="Export-Package"
                           value="
com.sun.jna.platform;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32&quot;,
com.sun.jna.platform.dnd;version=&quot;${osgi.version}&quot;,
com.sun.jna.platform.linux;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.unix&quot;,
com.sun.jna.platform.mac;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform,com.sun.jna.platform.unix,com.sun.jna.ptr&quot;,
com.sun.jna.platform.unix;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.ptr&quot;,
com.sun.jna.platform.unix.aix;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna&quot;,
com.sun.jna.platform.unix.solaris;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.ptr&quot;,
com.sun.jna.platform.win32;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform,com.sun.jna.platform.win32.COM,com.sun.jna.ptr,com.sun.jna.win32&quot;,
com.sun.jna.platform.win32.COM;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM.util,com.sun.jna.ptr,com.sun.jna.win32&quot;,
com.sun.jna.platform.win32.COM.tlb;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna.platform.win32.COM.tlb.imp&quot;,
com.sun.jna.platform.win32.COM.tlb.imp;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM&quot;,
com.sun.jna.platform.win32.COM.util;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM,com.sun.jna.platform.win32.COM.util.annotation,com.sun.jna.ptr&quot;,
com.sun.jna.platform.win32.COM.util.annotation;version=&quot;${osgi.version}&quot;,
com.sun.jna.platform.wince;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32&quot;
"/>
            </manifest>
            <manifest file="@{target}" mode="update" if:true="@{module-info}">
                <attribute name="Multi-Release" value="true"/>
            </manifest>
            <manifest file="@{target}" mode="update" unless:true="@{module-info}">
                <attribute name="Automatic-Module-Name" value="com.sun.jna.platform"/>
            </manifest>
        </sequential>
    </macrodef>

    <target name="-pre-jar" depends="-prepare-anttools,compile">
        <delete dir="${classes}/META-INF" />
        <mkdir dir="${classes}/META-INF"/>
        <copy todir="${classes}/META-INF">
            <fileset dir="../../" includes="LICENSE,AL2.0,LGPL2.1"/>
        </copy>
    </target>

    <target name="-build-jar" depends="-pre-jar">
        <jar jarfile="${build}/${jar-base}" duplicate="preserve" createUnicodeExtraFields="never" encoding="UTF-8">
            <fileset dir="${classes}" >
                <patternset>
                    <include name="**/*"/>
                </patternset>
            </fileset>
            <fileset dir="${src}" >
                <patternset>
                    <include name="**/*"/>
                    <exclude name="**/*.java"/>
                </patternset>
            </fileset>
        </jar>
    </target>

    <target name="-post-jar" depends="-prepare-anttools">
        <delete dir="${build}/manifest"/>
        <mkdir dir="${build}/manifest"/>
        <build-manifest target="${build}/manifest/module.mf" module-info="true"/>
        <build-manifest target="${build}/manifest/automatic.mf" module-info="false"/>
        <ModuleGenerator
            targetFile="${build}/manifest/module-info.class"
            name="com.sun.jna.platform"
            version="${osgi.version}"
            open="false"
        >
            <exports package="com.sun.jna.platform" />
            <exports package="com.sun.jna.platform.dnd" />
            <exports package="com.sun.jna.platform.linux" />
            <exports package="com.sun.jna.platform.mac" />
            <exports package="com.sun.jna.platform.unix" />
            <exports package="com.sun.jna.platform.unix.aix" />
            <exports package="com.sun.jna.platform.unix.solaris" />
            <exports package="com.sun.jna.platform.win32" />
            <exports package="com.sun.jna.platform.win32.COM" />
            <exports package="com.sun.jna.platform.win32.COM.tlb" />
            <exports package="com.sun.jna.platform.win32.COM.tlb.imp" />
            <exports package="com.sun.jna.platform.win32.COM.util" />
            <exports package="com.sun.jna.platform.win32.COM.util.annotation" />
            <exports package="com.sun.jna.platform.wince" />
            <requires module="java.logging" />
            <requires module="java.desktop" transitive="true" />
            <requires module="java.datatransfer" transitive="true" />
            <requires module="com.sun.jna" transitive="true" />
        </ModuleGenerator>
        <jar jarfile="${dist}/${jar}" duplicate="preserve" createUnicodeExtraFields="never" encoding="UTF-8" manifest="${build}/manifest/automatic.mf">
            <zipfileset src="${build}/${jar-base}" excludes="META-INF/MANIFEST.mf"/>
        </jar>
        <jar jarfile="${dist}/jna-platform-jpms.jar" duplicate="preserve" createUnicodeExtraFields="never" encoding="UTF-8" manifest="${build}/manifest/module.mf">
            <zipfileset src="${build}/${jar-base}" excludes="META-INF/MANIFEST.mf"/>
            <zipfileset dir="${build}/manifest/" includes="module-info.class" prefix="META-INF/versions/9"/>
        </jar>
    </target>

    <target name="test" depends="compile,compile-tests" description="Run platform unit tests.">
      <echo>Running platform tests: ${test.src}</echo>
      <condition property="test.jdwp" value="-Xrunjdwp:transport=dt_socket,address=${test.debugport},server=y,suspend=y">
        <isset property="test.debugport" />
      </condition>
      <property name="test.fork" value="yes"/>
      <property name="reports.junit" location="${build}/reports/junit/${os.prefix}"/>
      <property name="results.junit" location="${build}/junit-results/${os.prefix}"/>
      <mkdir dir="${results.junit}"/>
      <echo>Saving test results in ${results.junit}</echo>
      <condition property="tests.platform.mac" value="**/mac/**/*Test.java">
        <and>
          <os family="mac"/>
          <not>
            <isset property="tests.include" />
          </not>
        </and>
      </condition>
      <condition property="tests.platform.windows" value="**/win32/**/*Test.java">
        <and>
          <os family="windows"/>
          <not>
            <isset property="tests.include" />
          </not>
        </and>
      </condition>
      <condition property="tests.platform.linux" value="**/linux/**/*Test.java">
        <and>
          <os name="Linux"/>
          <not>
            <isset property="tests.include" />
          </not>
        </and>
      </condition>
      <condition property="tests.platform.unix" value="**/unix/**/*Test.java">
        <and>
          <os family="unix"/>
          <not>
            <os family="mac"/>
          </not>
          <not>
            <isset property="tests.include" />
          </not>
        </and>
      </condition>
      <property name="tests.include" value="com/sun/jna/platform/*Test.java"/>
      <property name="tests.platform.mac" value=""/>
      <property name="tests.platform.windows" value=""/>
      <property name="tests.platform.linux" value=""/>
      <property name="tests.platform.unix" value=""/>
      <property name="tests.exclude" value=""/>
      <property name="tests.exclude-patterns" value=""/>
      <condition property="java.awt.headless" value="true">
        <isset property="headless"/>
      </condition>
      <condition property="vmopt.arch" value="-d64" else="-Dignore">
        <and>
          <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
          <not><os family="windows"/></not>
          <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
        </and>
      </condition>
      <propertyset id="headless">
        <propertyref prefix="java.awt.headless"/>
      </propertyset>
      <echo>tests.include=${tests.include}</echo>
      <echo>tests.platform.mac=${tests.platform.mac}</echo>
      <echo>tests.platform.windows=${tests.platform.windows}</echo>
      <echo>tests.platform.linux=${tests.platform.linux}</echo>
      <echo>tests.platform.unix=${tests.platform.unix}</echo>
      <propertyset id="native.api.windows">
        <propertyref name="w32.ascii"/>
      </propertyset>
      <junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build}">
        <!-- let JVM ignore unknown flags -->
        <jvmarg value="-XX:+IgnoreUnrecognizedVMOptions" />
        <!-- enable JNI on JDK 24+ -->
        <jvmarg value="--enable-native-access=ALL-UNNAMED" />
        <jvmarg if:set="test.jdwp" value="${test.jdwp}" />
        <!-- optionally run headless -->
        <syspropertyset refid="headless"/>
        <!-- avoid VM conflicts with JNA protected mode -->
        <env key="${ld.preload.name}" file="${libjsig}"/>
        <!-- Ignore any system install of JNA -->
        <sysproperty key="jna.builddir" file="${file.reference.jna.build}"/>
        <!-- Optionally force native API on Windows -->
        <syspropertyset refid="native.api.windows"/>
        <jvmarg value="${vmopt.arch}"/>
        <classpath><path refid="test.runpath"/></classpath>
        <formatter type="brief" usefile="false"/>
        <formatter type="xml"/>
        <batchtest todir="${results.junit}">
          <fileset dir="${test.src}" excludes="${tests.exclude-patterns}">
            <!-- Until StructureFieldOrderTest gets fixed up a little -->
            <include name="${tests.include}" />
            <include name="${tests.platform.mac}"/>
            <include name="${tests.platform.windows}"/>
            <include name="${tests.platform.linux}"/>
            <include name="${tests.platform.unix}"/>
            <exclude name="${tests.exclude}"/>
          </fileset>
        </batchtest>
      </junit>
      <junitreport todir="${results.junit}">
        <fileset dir="${results.junit}">
          <include name="TEST-*.xml"/>
        </fileset>
        <report todir="${reports.junit}"/>
      </junitreport>
      <echo message="View test report in file://${reports.junit}/index.html" />
      <fail if="testfailure">One or more tests failed</fail>
    </target>
</project>