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

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

See #8269: Add initial Maven support to JMapViewer

This is largely 1-1 compatible with the targets of the ant build.xml file, with
some exceptions (see "Ant targets -> Maven targets" in CONTRIBUTING.md).

Please note that maven (by default) puts most generated data into the target
directory. This has been overridden for some targets.

For this commit, the following informational files were added:

  • RELEASING.md: I got tired of looking up how to do a release for JMapViewer
  • CONTRIBUTING.md: Just in case someone else wants to contribute to JMapViewer
File size: 10.6 KB
Line 
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="tools.dir" location="${base.dir}/tools"/>
11 <property name="jacoco.includes" value="org.openstreetmap.gui.jmapviewer.*" />
12 <property name="jacoco.inclbootstrapclasses" value="false" />
13 <property name="jacoco.inclnolocationclasses" value="false" />
14 <!-- For Java specific stuff by version -->
15 <condition property="isJava9"><matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" /></condition>
16 <condition property="isJava10"><matches string="${ant.java.version}" pattern="(1|2)[0-9]" /></condition>
17 <condition property="isJava11"><matches string="${ant.java.version}" pattern="1[1-9]|[2-9][0-9]" /></condition>
18 <condition property="isJava12"><matches string="${ant.java.version}" pattern="1[2-9]|[2-9][0-9]" /></condition>
19 <condition property="isJava13"><matches string="${ant.java.version}" pattern="1[3-9]|[2-9][0-9]" /></condition>
20 <condition property="isJava14"><matches string="${ant.java.version}" pattern="1[4-9]|[2-9][0-9]" /></condition>
21 <condition property="isJava16"><matches string="${ant.java.version}" pattern="1[6-9]|[2-9][0-9]" /></condition>
22 <condition property="isJava18"><matches string="${ant.java.version}" pattern="1[8-9]|[2-9][0-9]" /></condition>
23 <condition property="isJava19"><matches string="${ant.java.version}" pattern="19|[2-9][0-9]" /></condition>
24 <condition property="isJava20"><matches string="${ant.java.version}" pattern="[2-9][0-9]" /></condition>
25 <condition property="isJava21"><matches string="${ant.java.version}" pattern="2[1-9]|[3-9][0-9]" /></condition>
26 <!-- Disable jacoco on Java 18+, see https://github.com/jacoco/jacoco/pull/1132 -->
27 <condition property="coverageByDefault">
28 <not>
29 <isset property="isJava18"/>
30 </not>
31 </condition>
32 <path id="test.classpath">
33 <pathelement location="bin"/>
34 </path>
35
36 <target name="all" depends="clean,build,test,svn_info,pack,create_run_jar,spotbugs,checkstyle,javadoc,create_release_zip,create_source_release_zip" />
37
38 <target name="clean">
39 <mkdir dir="bin" />
40 <mkdir dir="bintest" />
41 <mkdir dir="javadoc" />
42 <mkdir dir="report" />
43 <delete>
44 <fileset dir="bin">
45 <include name="**" />
46 </fileset>
47 <fileset dir="bintest">
48 <include name="**" />
49 </fileset>
50 <fileset dir="javadoc">
51 <include name="**" />
52 </fileset>
53 <fileset dir="report">
54 <include name="**" />
55 </fileset>
56 <fileset dir="." includes="*.jar,*.exec"/>
57 </delete>
58 </target>
59
60 <target name="build" depends="clean">
61 <!-- compile module info - we need to compile everything to ensure that all requires are there -->
62 <javac srcdir="src" destdir="bin" release="9" debug="true" includeantruntime="false" encoding="UTF-8" if:set="isJava9">
63 <include name="module-info.java" />
64 <include name="org/openstreetmap/gui/jmapviewer/**" />
65 </javac>
66
67 <!-- Remove the files compiled with Java 9 so that the next compile stage will compile to the appropriate version -->
68 <delete>
69 <fileset dir="bin">
70 <include name="org/openstreetmap/gui/jmapviewer/**" />
71 </fileset>
72 </delete>
73
74 <javac srcdir="src" destdir="bin" release="${java.lang.version}" debug="true" includeantruntime="false" encoding="UTF-8">
75 <include name="org/openstreetmap/gui/jmapviewer/**" />
76 </javac>
77
78 <copy todir="bin">
79 <fileset dir="src">
80 <include name="**/*.png" />
81 </fileset>
82 </copy>
83 </target>
84
85 <target name="checkdepsupdate" depends="resolve">
86 <ivy:checkdepsupdate/>
87 </target>
88
89 <target name="svn_info" description="Get SVN info for use in JAR/ZIP filenames.">
90 <!-- Get the svn ReleaseVersion property -->
91 <exec executable="svn" outputproperty="svnReleaseVersion">
92 <arg line="propget ReleaseVersion" />
93 <env key="LANG" value="en_US"/>
94 </exec>
95 </target>
96
97 <target name="pack" depends="build">
98 <!-- Create the JAR file containing the compiled class files -->
99 <jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
100 <fileset dir="bin" includes="module-info.class,**/jmapviewer/**" />
101 </jar>
102 <!-- Create the JAR file containing the source java files -->
103 <jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
104 <fileset dir="src" includes="module-info.java,**/jmapviewer/**" />
105 </jar>
106 </target>
107
108 <!-- if you want to build outside of svn, use "ant clean build [pack]" -->
109
110 <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.">
111 <jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
112 <manifest>
113 <attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
114 <attribute name="Class-Path" value="JMapViewer.jar" />
115 </manifest>
116 </jar>
117 </target>
118
119 <target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
120 <zip basedir="." destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}.zip">
121 <include name="JMapViewer*.jar" />
122 <include name="Readme.txt" />
123 <include name="Gpl.txt" />
124 </zip>
125 <delete>
126 <fileset dir="." includes="JMapViewer*.jar"/>
127 </delete>
128 </target>
129
130 <target name="create_source_release_zip" description="Create a release zip file containing the source files">
131 <zip destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}-Source.zip">
132 <zipfileset file="Readme.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
133 <zipfileset file="build.xml" prefix="jmapviewer-${svnReleaseVersion}"/>
134 <zipfileset file="Gpl.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
135 <zipfileset dir="src" includes="**/jmapviewer/**" prefix="jmapviewer-${svnReleaseVersion}/src"/>
136 </zip>
137 </target>
138
139 <target name="checkstyle" depends="resolve">
140 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
141 classpathref="checkstyle.classpath"/>
142 <checkstyle config="${basedir}/tools/checkstyle/jmapviewer_checks.xml">
143 <!-- Exclude the module-info since checkstyle currently cannot parse it -->
144 <fileset dir="${basedir}/src" includes="**/*.java" excludes="module-info.java" />
145 <formatter type="xml" toFile="checkstyle-jmapviewer.xml"/>
146 </checkstyle>
147 </target>
148
149 <target name="spotbugs" depends="pack,resolve">
150 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
151 classpathref="spotbugs.classpath"/>
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="resolve" description="Resolve Ivy dependencies">
181 <ivy:resolve/>
182 <ivy:cachepath pathid="checkstyle.classpath" conf="checkstyle"/>
183 <ivy:cachepath pathid="testlib.classpath" conf="test"/>
184 <ivy:cachepath pathid="jacoco.classpath" conf="jacocoant"/>
185 <ivy:cachepath pathid="spotbugs.classpath" conf="spotbugs"/>
186 </target>
187
188 <target name="test" depends="clean, build, resolve">
189 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="jacoco.classpath"/>
190 <javac srcdir="test" destdir="bintest"
191 target="${java.lang.version}" source="${java.lang.version}" debug="on"
192 includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
193 <compilerarg value="-Xlint:all"/>
194 <compilerarg value="-Xlint:-serial"/>
195 <classpath>
196 <path refid="testlib.classpath"/>
197 <path refid="test.classpath"/>
198 </classpath>
199 </javac>
200 <jacoco:agent enabled="@{coverage}" includes="${jacoco.includes}"
201 inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}" property="jacocoagent@{testfamily}@{testITsuffix}" if:true="@{coverage}"/>
202 <junitlauncher printsummary="yes">
203 <classpath>
204 <path refid="testlib.classpath"/>
205 <path refid="test.classpath"/>
206 <pathelement location="bintest"/>
207 </classpath>
208 <testclasses outputdir="report">
209 <fileset dir="bintest" includes="**/*Test.class"/>
210 <fork>
211 <jvmarg value="-Dfile.encoding=UTF-8"/>
212 </fork>
213 <listener type="legacy-brief" sendSysOut="true" sendSysErr="true"/>
214 <listener type="legacy-plain" />
215 <listener type="legacy-xml" />
216 </testclasses>
217 </junitlauncher>
218 </target>
219
220</project>
Note: See TracBrowser for help on using the repository browser.