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

Last change on this file since 36109 was 35919, checked in by Don-vip, 3 years ago

update build, readme

File size: 9.3 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="1.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 <javac srcdir="src" destdir="bin" source="${java.lang.version}" target="${java.lang.version}" debug="true" includeantruntime="false" encoding="UTF-8">
61 <include name="org/openstreetmap/gui/jmapviewer/**" />
62 </javac>
63
64 <copy todir="bin">
65 <fileset dir="src">
66 <include name="**/*.png" />
67 </fileset>
68 </copy>
69 </target>
70
71 <target name="svn_info" description="Get SVN info for use in JAR/ZIP filenames.">
72 <!-- Get the svn ReleaseVersion property -->
73 <exec executable="svn" outputproperty="svnReleaseVersion">
74 <arg line="propget ReleaseVersion" />
75 <env key="LANG" value="en_US"/>
76 </exec>
77 </target>
78
79 <target name="pack" depends="build">
80 <!-- Create the JAR file containing the compiled class files -->
81 <jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
82 <fileset dir="bin" includes="**/jmapviewer/**" />
83 </jar>
84 <!-- Create the JAR file containing the source java files -->
85 <jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
86 <fileset dir="src" includes="**/jmapviewer/**" />
87 </jar>
88 </target>
89
90 <!-- if you want to build outside of svn, use "ant clean build [pack]" -->
91
92 <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.">
93 <jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
94 <manifest>
95 <attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
96 <attribute name="Class-Path" value="JMapViewer.jar" />
97 </manifest>
98 </jar>
99 </target>
100
101 <target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
102 <zip basedir="." destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}.zip">
103 <include name="JMapViewer*.jar" />
104 <include name="Readme.txt" />
105 <include name="Gpl.txt" />
106 </zip>
107 <delete>
108 <fileset dir="." includes="JMapViewer*.jar"/>
109 </delete>
110 </target>
111
112 <target name="create_source_release_zip" description="Create a release zip file containing the source files">
113 <zip destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}-Source.zip">
114 <zipfileset file="Readme.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
115 <zipfileset file="build.xml" prefix="jmapviewer-${svnReleaseVersion}"/>
116 <zipfileset file="Gpl.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
117 <zipfileset dir="src" includes="**/jmapviewer/**" prefix="jmapviewer-${svnReleaseVersion}/src"/>
118 </zip>
119 </target>
120
121 <target name="checkstyle">
122 <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
123 classpath="tools/checkstyle/checkstyle-all.jar"/>
124 <checkstyle config="tools/checkstyle/jmapviewer_checks.xml">
125 <fileset dir="${basedir}/src" includes="**/*.java" />
126 <formatter type="xml" toFile="checkstyle-jmapviewer.xml"/>
127 </checkstyle>
128 </target>
129
130 <target name="spotbugs" depends="pack">
131 <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
132 classpath="tools/spotbugs/spotbugs-ant.jar"/>
133 <path id="spotbugs-classpath">
134 <fileset dir="tools/spotbugs/">
135 <include name="*.jar"/>
136 </fileset>
137 </path>
138 <property name="spotbugs-classpath" refid="spotbugs-classpath"/>
139 <spotbugs output="xml"
140 outputFile="spotbugs-jmapviewer.xml"
141 classpath="${spotbugs-classpath}"
142 effort="max"
143 >
144 <sourcePath path="${basedir}/src" />
145 <class location="JMapViewer.jar" />
146 </spotbugs>
147 </target>
148
149 <target name="javadoc">
150 <javadoc destdir="javadoc"
151 sourcepath="src"
152 encoding="UTF-8"
153 packagenames="org.openstreetmap.gui.jmapviewer.*"
154 windowtitle="JMapViewer"
155 use="true"
156 private="true"
157 linksource="true"
158 author="false">
159 <link href="https://docs.oracle.com/javase/8/docs/api"/>
160 <doctitle><![CDATA[<h2>JMapViewer - Javadoc</h2>]]></doctitle>
161 <bottom><![CDATA[<a href="https://josm.openstreetmap.de/">JMapViewer</a>]]></bottom>
162 <arg value="-html5" if:set="isJava9" />
163 </javadoc>
164 </target>
165
166 <target name="test" depends="clean, build">
167 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="${tools.dir}/jacocoant.jar" />
168 <javac srcdir="test" destdir="bintest"
169 target="${java.lang.version}" source="${java.lang.version}" debug="on"
170 includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
171 <compilerarg value="-Xlint:all"/>
172 <compilerarg value="-Xlint:-serial"/>
173 <classpath>
174 <path refid="test.classpath"/>
175 </classpath>
176 </javac>
177 <jacoco:coverage enabled="@{coverage}" includes="${jacoco.includes}"
178 inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
179 <junit printsummary="yes" fork="true" forkmode="once">
180 <jvmarg value="-Dfile.encoding=UTF-8"/>
181 <classpath>
182 <path refid="test.classpath"/>
183 <pathelement location="bintest"/>
184 </classpath>
185 <formatter type="plain"/>
186 <formatter type="xml"/>
187 <batchtest fork="yes" todir="report">
188 <fileset dir="bintest" includes="**/*Test.class"/>
189 </batchtest>
190 </junit>
191 </jacoco:coverage>
192 </target>
193
194</project>
Note: See TracBrowser for help on using the repository browser.