source: subversion/applications/editors/josm/plugins/build-common.xml @ 27983

Last change on this file since 27983 was 27983, checked in by jttt, 7 years ago

Save output of svn info to property instead of file

File size: 7.2 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3** Template for the build targets common to all plugins
4** ====================================================
5**
6** To override a property, add it to the plugin build.xml _before_
7** this template has been imported.
8** To override a target, add it _after_ this template has been imported.
9**
10** Paths are relative to the build.xml that imports this template.
11**
12-->
13<project name="plugin_common" basedir=".">
14
15    <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
16    <property name="plugin.build.dir"       value="build"/>
17    <property name="plugin.src.dir"         value="src"/>
18    <property name="plugin.lib.dir"         value="lib"/>
19    <!-- this is the directory where the plugin jar is copied to -->
20    <property name="plugin.dist.dir"        value="../../dist"/>
21    <property name="ant.build.javac.target" value="1.5"/>
22    <property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
23
24    <!--
25    **********************************************************
26    ** init - initializes the build
27    **********************************************************
28    -->
29    <target name="init">
30        <mkdir dir="${plugin.build.dir}"/>
31    </target>
32    <!--
33    **********************************************************
34    ** compile - complies the source tree
35    **********************************************************
36    -->
37    <target name="compile" depends="init">
38        <echo message="compiling sources for  ${plugin.jar} ... "/>
39        <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
40            <compilerarg value="-Xlint:deprecation"/>
41            <compilerarg value="-Xlint:unchecked"/>
42        </javac>
43    </target>
44    <!--
45    **********************************************************
46    ** revision - extracts the current revision number for the
47    **    file build.number and stores it in the XML property
48    **    version.*
49    **********************************************************
50    -->
51    <target name="revision">
52        <exec append="false" outputproperty="svn.revision.output" executable="svn" failifexecutionfails="false">
53            <env key="LANG" value="C"/>
54            <arg value="info"/>
55            <arg value="--xml"/>
56            <arg value="."/>
57        </exec>
58        <xmlproperty prefix="version" keepRoot="false" collapseAttributes="true">
59          <propertyresource name="svn.revision.output"/>
60        </xmlproperty>
61    </target>
62    <!--
63    **********************************************************
64    ** clean - clean up the build environment
65    **********************************************************
66    -->
67    <target name="clean">
68        <delete dir="${plugin.build.dir}"/>
69        <delete file="${plugin.jar}"/>
70    </target>
71    <!--
72    **********************************************************
73    ** install - install the plugin in your local JOSM installation
74    **********************************************************
75    -->
76    <target name="install" depends="dist">
77        <property environment="env"/>
78        <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
79            <and>
80                <os family="windows"/>
81            </and>
82        </condition>
83        <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
84    </target>
85    <!--
86    ************************** Publishing the plugin ***********************************
87    -->
88    <!--
89    ** extracts the JOSM release for the JOSM version in ../core and saves it in the
90    ** property ${coreversion.info.entry.revision}
91    **
92    -->
93    <target name="core-info">
94        <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
95            <env key="LANG" value="C"/>
96            <arg value="info"/>
97            <arg value="--xml"/>
98            <arg value="../../core"/>
99        </exec>
100        <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
101        <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
102        <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
103        <delete file="core.info.xml"/>
104    </target>
105    <!--
106    ** commits the source tree for this plugin
107    -->
108    <target name="commit-current">
109        <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
110        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
111            <env key="LANG" value="C"/>
112            <arg value="commit"/>
113            <arg value="-m '${commit.message}'"/>
114            <arg value="."/>
115        </exec>
116    </target>
117    <!--
118    ** updates (svn up) the source tree for this plugin
119    -->
120    <target name="update-current">
121        <echo>Updating plugin source ...</echo>
122        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
123            <env key="LANG" value="C"/>
124            <arg value="up"/>
125            <arg value="."/>
126        </exec>
127        <echo>Updating ${plugin.jar} ...</echo>
128        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
129            <env key="LANG" value="C"/>
130            <arg value="up"/>
131            <arg value="../dist/${plugin.jar}"/>
132        </exec>
133    </target>
134    <!--
135    ** commits the plugin.jar
136    -->
137    <target name="commit-dist">
138        <echo>
139    ***** Properties of published ${plugin.jar} *****
140    Commit message    : '${commit.message}'
141    Plugin-Mainversion: ${plugin.main.version}
142    JOSM build version: ${coreversion.info.entry.revision}
143    Plugin-Version    : ${version.entry.commit.revision}
144    ***** / Properties of published ${plugin.jar} *****
145
146    Now commiting ${plugin.jar} ...
147    </echo>
148        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
149            <env key="LANG" value="C"/>
150            <arg value="-m '${commit.message}'"/>
151            <arg value="commit"/>
152            <arg value="${plugin.jar}"/>
153        </exec>
154    </target>
155    <!-- ** make sure svn is present as a command line tool ** -->
156    <target name="ensure-svn-present">
157        <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
158            <env key="LANG" value="C"/>
159            <arg value="--version"/>
160        </exec>
161        <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
162            <!-- return code not set at all? Most likely svn isn't installed -->
163            <condition>
164                <not>
165                    <isset property="svn.exit.code"/>
166                </not>
167            </condition>
168        </fail>
169        <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
170            <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
171            <condition>
172                <isfailure code="${svn.exit.code}"/>
173            </condition>
174        </fail>
175    </target>
176    <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
177    </target>
178</project>
179
Note: See TracBrowser for help on using the repository browser.