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