source: osm/applications/viewer/jmapviewer/build.xml@ 36139

Last change on this file since 36139 was 36139, checked in by taylor.smock, 13 months ago

Fix #23114: Add module-info to JMapViewer

File size: 10.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<project default="all" name="jmapviewer" xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if" xmlns:unless="ant:unless">
3
4 <property name="java.lang.version" value="8" />
5 <dirname property="base.dir" file="${ant.file.jmapviewer}"/>
6 <property name="tools.dir" location="${base.dir}/tools"/>
7 <property name="jacoco.includes" value="org.openstreetmap.gui.jmapviewer.*" />
8 <property name="jacoco.inclbootstrapclasses" value="false" />
9 <property name="jacoco.inclnolocationclasses" value="false" />
10 <!-- For Java specific stuff by version -->
11 <condition property="isJava9"><matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" /></condition>
12 <condition property="isJava10"><matches string="${ant.java.version}" pattern="(1|2)[0-9]" /></condition>
13 <condition property="isJava11"><matches string="${ant.java.version}" pattern="1[1-9]|[2-9][0-9]" /></condition>
14 <condition property="isJava12"><matches string="${ant.java.version}" pattern="1[2-9]|[2-9][0-9]" /></condition>
15 <condition property="isJava13"><matches string="${ant.java.version}" pattern="1[3-9]|[2-9][0-9]" /></condition>
16 <condition property="isJava14"><matches string="${ant.java.version}" pattern="1[4-9]|[2-9][0-9]" /></condition>
17 <condition property="isJava16"><matches string="${ant.java.version}" pattern="1[6-9]|[2-9][0-9]" /></condition>
18 <condition property="isJava18"><matches string="${ant.java.version}" pattern="1[8-9]|[2-9][0-9]" /></condition>
19 <condition property="isJava19"><matches string="${ant.java.version}" pattern="19|[2-9][0-9]" /></condition>
20 <condition property="isJava20"><matches string="${ant.java.version}" pattern="[2-9][0-9]" /></condition>
21 <condition property="isJava21"><matches string="${ant.java.version}" pattern="2[1-9]|[3-9][0-9]" /></condition>
22 <!-- Disable jacoco on Java 18+, see https://github.com/jacoco/jacoco/pull/1132 -->
23 <condition property="coverageByDefault">
24 <not>
25 <isset property="isJava18"/>
26 </not>
27 </condition>
28 <path id="test.classpath">
29 <fileset dir="${tools.dir}/testlib">
30 <include name="**/*.jar"/>
31 </fileset>
32 <pathelement location="bin"/>
33 </path>
34
35 <target name="all" depends="clean,build,test,svn_info,pack,create_run_jar,spotbugs,checkstyle,javadoc,create_release_zip,create_source_release_zip" />
36
37 <target name="clean">
38 <mkdir dir="bin" />
39 <mkdir dir="bintest" />
40 <mkdir dir="javadoc" />
41 <mkdir dir="report" />
42 <delete>
43 <fileset dir="bin">
44 <include name="**" />
45 </fileset>
46 <fileset dir="bintest">
47 <include name="**" />
48 </fileset>
49 <fileset dir="javadoc">
50 <include name="**" />
51 </fileset>
52 <fileset dir="report">
53 <include name="**" />
54 </fileset>
55 <fileset dir="." includes="*.jar,*.exec"/>
56 </delete>
57 </target>
58
59 <target name="build" depends="clean">
60 <!-- compile module info - we need to compile everything to ensure that all requires are there -->
61 <javac srcdir="src" destdir="bin" release="9" debug="true" includeantruntime="false" encoding="UTF-8" if:set="isJava9">
62 <include name="module-info.java" />
63 <include name="org/openstreetmap/gui/jmapviewer/**" />
64 </javac>
65
66 <!-- Remove the files compiled with Java 9 so that the next compile stage will compile to the appropriate version -->
67 <delete>
68 <fileset dir="bin">
69 <include name="org/openstreetmap/gui/jmapviewer/**" />
70 </fileset>
71 </delete>
72
73 <javac srcdir="src" destdir="bin" release="${java.lang.version}" debug="true" includeantruntime="false" encoding="UTF-8">
74 <include name="org/openstreetmap/gui/jmapviewer/**" />
75 </javac>
76
77 <copy todir="bin">
78 <fileset dir="src">
79 <include name="**/*.png" />
80 </fileset>
81 </copy>
82 </target>
83
84 <target name="svn_info" description="Get SVN info for use in JAR/ZIP filenames.">
85 <!-- Get the svn ReleaseVersion property -->
86 <exec executable="svn" outputproperty="svnReleaseVersion">
87 <arg line="propget ReleaseVersion" />
88 <env key="LANG" value="en_US"/>
89 </exec>
90 </target>
91
92 <target name="pack" depends="build">
93 <!-- Create the JAR file containing the compiled class files -->
94 <jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
95 <fileset dir="bin" includes="module-info.class,**/jmapviewer/**" />
96 </jar>
97 <!-- Create the JAR file containing the source java files -->
98 <jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
99 <fileset dir="src" includes="module-info.java,**/jmapviewer/**" />
100 </jar>
101 </target>
102
103 <!-- if you want to build outside of svn, use "ant clean build [pack]" -->
104
105 <target name="create_run_jar" description="Create a JAR file that can be used to execute the JMapViewer demo app. Requires JMapViewer.jar to be present.">
106 <jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
107 <manifest>
108 <attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
109 <attribute name="Class-Path" value="JMapViewer.jar" />
110 </manifest>
111 </jar>
112 </target>
113
114 <target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
115 <zip basedir="." destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}.zip">
116 <include name="JMapViewer*.jar" />
117 <include name="Readme.txt" />
118 <include name="Gpl.txt" />
119 </zip>
120 <delete>
121 <fileset dir="." includes="JMapViewer*.jar"/>
122 </delete>
123 </target>
124
125 <target name="create_source_release_zip" description="Create a release zip file containing the source files">
126 <zip destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}-Source.zip">
127 <zipfileset file="Readme.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
128 <zipfileset file="build.xml" prefix="jmapviewer-${svnReleaseVersion}"/>
129 <zipfileset file="Gpl.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
130 <zipfileset dir="src" includes="**/jmapviewer/**" prefix="jmapviewer-${svnReleaseVersion}/src"/>
131 </zip>
132 </target>
133
134 <target name="checkstyle">
135 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
136 classpath="tools/checkstyle/checkstyle-all.jar"/>
137 <checkstyle config="tools/checkstyle/jmapviewer_checks.xml">
138 <!-- Exclude the module-info since checkstyle currently cannot parse it -->
139 <fileset dir="${basedir}/src" includes="**/*.java" excludes="module-info.java" />
140 <formatter type="xml" toFile="checkstyle-jmapviewer.xml"/>
141 </checkstyle>
142 </target>
143
144 <target name="spotbugs" depends="pack">
145 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
146 classpath="tools/spotbugs/spotbugs-ant.jar"/>
147 <path id="spotbugs-classpath">
148 <fileset dir="tools/spotbugs/">
149 <include name="*.jar"/>
150 </fileset>
151 </path>
152 <property name="spotbugs-classpath" refid="spotbugs-classpath"/>
153 <spotbugs output="xml"
154 outputFile="spotbugs-jmapviewer.xml"
155 classpath="${spotbugs-classpath}"
156 effort="max"
157 >
158 <sourcePath path="${basedir}/src" />
159 <class location="JMapViewer.jar" />
160 </spotbugs>
161 </target>
162
163 <target name="javadoc">
164 <javadoc destdir="javadoc"
165 sourcepath="src"
166 encoding="UTF-8"
167 packagenames="org.openstreetmap.gui.jmapviewer.*"
168 windowtitle="JMapViewer"
169 use="true"
170 private="true"
171 linksource="true"
172 author="false">
173 <link href="https://docs.oracle.com/javase/8/docs/api"/>
174 <doctitle><![CDATA[<h2>JMapViewer - Javadoc</h2>]]></doctitle>
175 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JMapViewer</a>]]></bottom>
176 <arg value="-html5" if:set="isJava9" />
177 </javadoc>
178 </target>
179
180 <target name="test" depends="clean, build">
181 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="${tools.dir}/jacocoant.jar" />
182 <javac srcdir="test" destdir="bintest"
183 target="${java.lang.version}" source="${java.lang.version}" debug="on"
184 includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
185 <compilerarg value="-Xlint:all"/>
186 <compilerarg value="-Xlint:-serial"/>
187 <classpath>
188 <path refid="test.classpath"/>
189 </classpath>
190 </javac>
191 <jacoco:coverage enabled="@{coverage}" includes="${jacoco.includes}"
192 inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
193 <junit printsummary="yes" fork="true" forkmode="once">
194 <jvmarg value="-Dfile.encoding=UTF-8"/>
195 <classpath>
196 <path refid="test.classpath"/>
197 <pathelement location="bintest"/>
198 </classpath>
199 <formatter type="plain"/>
200 <formatter type="xml"/>
201 <batchtest fork="yes" todir="report">
202 <fileset dir="bintest" includes="**/*Test.class"/>
203 </batchtest>
204 </junit>
205 </jacoco:coverage>
206 </target>
207
208</project>
Note: See TracBrowser for help on using the repository browser.