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

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

Import new "opendata" JOSM plugin

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