source: subversion/applications/editors/josm/plugins/opendata/build.xml @ 28246

Last change on this file since 28246 was 28246, checked in by donvip, 8 years ago

[josm_opendata] rely on jts plugin to reduce jar size

File size: 14.9 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3** This is the build file for the opendata plugin.
4**
5** Usage
6** =====
7** To build it run
8**
9**    > ant  dist
10**
11** To install the generated plugin locally (in you default plugin directory) run
12**
13**    > ant  install
14**
15** The generated plugin jar is not automatically available in JOSMs plugin configuration
16** dialog. You have to check it in first.
17**
18** Use the ant target 'publish' to check in the plugin and make it available to other
19** JOSM users:
20**    set the properties commit.message and plugin.main.version
21** and run
22**    > ant  publish
23**
24**
25-->
26<project name="opendata" default="dist" basedir=".">
27    <!-- enter the SVN commit message -->
28    <property name="commit.message" value="Commit message"/>
29    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
30    <property name="plugin.main.version" value="5132"/>
31    <!-- should not be necessary to change the following properties -->
32    <property name="josm" location="../../core/dist/josm-custom.jar"/>
33    <property name="jts" location="../../dist/jts.jar"/>
34    <property name="plugin.build.dir" value="build"/>
35    <property name="plugin.src.dir" value="src"/>
36    <!-- this is the directory where the plugin jar is copied to -->
37    <property name="plugin.dist.dir" value="../../dist"/>
38    <property name="ant.build.javac.source" value="1.6"/>
39    <property name="ant.build.javac.target" value="1.6"/>
40    <property name="plugin.dist.dir" value="../../dist"/>
41    <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
42    <!--<property name="xerces" location="lib/xerces-2_11_0"/>-->
43    <!--
44    **********************************************************
45    ** init - initializes the build
46    **********************************************************
47    -->
48    <target name="init">
49        <mkdir dir="${plugin.build.dir}"/>
50        <mkdir dir="${plugin.build.dir}/META-INF"/>
51    </target>
52    <!--
53    **********************************************************
54    ** compile_lang3 - compiles Apache Commons Lang 3 needed classes
55    **********************************************************
56    -->
57    <target name="compile_lang3" depends="init">
58        <echo message="compiling Apache Commons Lang 3 ... "/>
59        <javac srcdir="includes/org/apache/commons/lang3" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
60    </target>
61    <!--
62    **********************************************************
63    ** compile_poi - compiles Apache POI needed classes
64    **********************************************************
65    -->
66    <target name="compile_poi" depends="init">
67        <echo message="compiling Apache POI ... "/>
68        <javac srcdir="includes/org/apache/poi" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
69    </target>
70    <!--
71    **********************************************************
72    ** compile_collections - compiles Apache Collections needed classes
73    **********************************************************
74    -->
75    <target name="compile_collections" depends="init">
76        <echo message="compiling Apache Collections ... "/>
77        <javac srcdir="includes/org/apache/commons/collections" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
78    </target>
79    <!--
80    **********************************************************
81    ** compile_jopendoc - compiles JOpenDocument needed classes
82    **********************************************************
83    -->
84    <target name="compile_jopendoc" depends="init, compile_collections">
85        <echo message="compiling JDOM ... "/>
86        <javac srcdir="includes/org/jdom" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
87        <echo message="compiling JOpenDocument ... "/>
88        <javac srcdir="includes/org/jopendocument" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
89    </target>
90    <!--
91    **********************************************************
92    ** compile_geotools - compiles GeoTools needed classes
93    **********************************************************
94    -->
95    <target name="compile_geotools" depends="init">
96        <echo message="compiling JSR-275 ... "/>
97        <javac srcdir="includes/javax/measure" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="UTF-8" />
98        <echo message="compiling Vecmath ... "/>
99        <javac srcdir="includes/javax/vecmath" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1" />
100        <echo message="compiling GeoTools ... "/>
101        <javac debug="false" sourcepath="" srcdir="includes" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="ISO-8859-1">
102            <include name="org/geotools/**/*.java"/>
103                <include name="org/opengis/**/*.java"/>
104            <classpath>
105                <pathelement location="${jts}"/>
106            </classpath>
107        </javac>
108    </target>
109    <!--
110    **********************************************************
111    ** compile_neptune - compiles Neptune classes
112    **********************************************************
113    -->
114    <target name="compile_neptune" depends="init">
115        <echo message="compiling Neptune ... "/>
116        <javac srcdir="includes/neptune" debug="false" destdir="${plugin.build.dir}" includeAntRuntime="false" encoding="UTF-8" />
117    </target>
118    <!--
119    **********************************************************
120    ** compile - compiles the source tree
121    **********************************************************
122    -->
123    <target name="compile" depends="init, compile_lang3, compile_poi, compile_jopendoc, compile_geotools, compile_neptune">
124        <echo message="compiling sources for  ${plugin.jar} ... "/>
125        <javac srcdir="src/org/openstreetmap" debug="true" destdir="${plugin.build.dir}" includeAntRuntime="false">
126            <classpath>
127                    <pathelement path="${plugin.build.dir}"/>
128                <pathelement location="${josm}"/>
129                <pathelement location="${jts}"/>
130            </classpath>
131            <compilerarg value="-Xlint:deprecation"/>
132            <compilerarg value="-Xlint:unchecked"/>
133        </javac>
134    </target>
135    <!--
136    **********************************************************
137    ** dist - creates the plugin jar
138    **********************************************************
139    -->
140    <target name="dist" depends="compile,revision">
141        <echo message="creating ${ant.project.name}.jar ... "/>
142        <copy todir="${plugin.build.dir}">
143            <fileset dir="resources">
144                <exclude name="org/geotools/referencing/**/*_original.properties"/>
145                <exclude name="org/geotools/referencing/factory/epsg/*.sql"/>
146                <exclude name="org/geotools/referencing/factory/epsg/PrepareForHSQL.xml"/>
147                <exclude name="org/geotools/referencing/factory/epsg/UpdateEPSGDatabase.txt"/>
148            </fileset>
149        </copy>
150        <copy todir="${plugin.build.dir}/images">
151            <fileset dir="images"/>
152        </copy>
153        <copy todir="${plugin.build.dir}/data">
154            <fileset dir="data"/>
155        </copy>
156        <copy todir="${plugin.build.dir}">
157            <fileset dir=".">
158                <include name="README"/>
159            </fileset>
160            <fileset dir="licenses">
161                <include name="*.txt"/>
162            </fileset>
163        </copy>
164        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
165            <!--
166            ************************************************
167            ** configure these properties. Most of them will be copied to the plugins
168            ** manifest file. Property values will also show up in the list available
169            ** plugins: http://josm.openstreetmap.de/wiki/Plugins.
170            **
171            ************************************************
172            -->
173            <manifest>
174                <attribute name="Author" value="Don-vip"/>
175                <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.opendata.OdPlugin"/>
176                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
177                <attribute name="Plugin-Description" value="Convert data from Open Data portals to OSM layer"/>
178                <attribute name="Plugin-Early" value="false"/>
179                <attribute name="Plugin-Icon" value="images/dialogs/o24.png"/>
180                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/OpenData"/>
181                <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
182                <attribute name="Plugin-Requires" value="jts"/>
183                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
184            </manifest>
185        </jar>
186    </target>
187    <!--
188    **********************************************************
189    ** revision - extracts the current revision number for the
190    **    file build.number and stores it in the XML property
191    **    version.*
192    **********************************************************
193    -->
194    <target name="revision">
195        <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
196            <env key="LANG" value="C"/>
197            <arg value="info"/>
198            <arg value="--xml"/>
199            <arg value="."/>
200        </exec>
201        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
202        <delete file="REVISION"/>
203    </target>
204    <!--
205    **********************************************************
206    ** clean - clean up the build environment
207    **********************************************************
208    -->
209    <target name="clean">
210        <delete dir="${plugin.build.dir}"/>
211        <delete file="${plugin.jar}"/>
212    </target>
213    <!--
214    **********************************************************
215    ** install - install the plugin in your local JOSM installation
216    **********************************************************
217    -->
218    <target name="install" depends="dist">
219        <property environment="env"/>
220        <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
221            <and>
222                <os family="windows"/>
223            </and>
224        </condition>
225        <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
226    </target>
227    <!--
228    ************************** Publishing the plugin ***********************************
229    -->
230    <!--
231    ** extracts the JOSM release for the JOSM version in ../core and saves it in the
232    ** property ${coreversion.info.entry.revision}
233    -->
234    <target name="core-info">
235        <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
236            <env key="LANG" value="C"/>
237            <arg value="info"/>
238            <arg value="--xml"/>
239            <arg value="../../core"/>
240        </exec>
241        <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
242        <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
243        <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
244        <delete file="core.info.xml"/>
245    </target>
246    <!-- commits the source tree for this plugin -->
247    <target name="commit-current">
248        <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
249        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
250            <env key="LANG" value="C"/>
251            <arg value="commit"/>
252            <arg value="-m '${commit.message}'"/>
253            <arg value="."/>
254        </exec>
255    </target>
256    <!-- updates (svn up) the source tree for this plugin -->
257    <target name="update-current">
258        <echo>Updating plugin source ...</echo>
259        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
260            <env key="LANG" value="C"/>
261            <arg value="up"/>
262            <arg value="."/>
263        </exec>
264        <echo>Updating ${plugin.jar} ...</echo>
265        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
266            <env key="LANG" value="C"/>
267            <arg value="up"/>
268            <arg value="../dist/${plugin.jar}"/>
269        </exec>
270    </target>
271    <!-- commits the plugin.jar -->
272    <target name="commit-dist">
273        <echo>
274    ***** Properties of published ${plugin.jar} *****
275    Commit message    : '${commit.message}'                   
276    Plugin-Mainversion: ${plugin.main.version}
277    JOSM build version: ${coreversion.info.entry.revision}
278    Plugin-Version    : ${version.entry.commit.revision}
279    ***** / Properties of published ${plugin.jar} *****                   
280                       
281    Now commiting ${plugin.jar} ...
282    </echo>
283        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
284            <env key="LANG" value="C"/>
285            <arg value="-m '${commit.message}'"/>
286            <arg value="commit"/>
287            <arg value="${plugin.jar}"/>
288        </exec>
289    </target>
290    <!-- make sure svn is present as a command line tool -->
291    <target name="ensure-svn-present">
292        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
293            <env key="LANG" value="C"/>
294            <arg value="--version"/>
295        </exec>
296        <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
297            <!-- return code not set at all? Most likely svn isn't installed -->
298            <condition>
299                <not>
300                    <isset property="svn.exit.code"/>
301                </not>
302            </condition>
303        </fail>
304        <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
305            <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
306            <condition>
307                <isfailure code="${svn.exit.code}"/>
308            </condition>
309        </fail>
310    </target>
311    <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
312    </target>
313   
314    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
315          <classpath>
316            <fileset dir="C:\Windows\SysWOW64\jaxb-ri-20120218\lib" includes="*.jar" />
317          </classpath>
318    </taskdef>
319    <target name="xjc_neptune">
320        <xjc schema="resources/neptune/neptune.xsd" destdir="includes" package="neptune" target="2.1" />
321    </target>
322</project>
Note: See TracBrowser for help on using the repository browser.