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.6"/>
|
---|
22 | <property name="ant.build.javac.source" value="1.6"/>
|
---|
23 | <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
|
---|
24 |
|
---|
25 | <!--
|
---|
26 | **********************************************************
|
---|
27 | ** init - initializes the build
|
---|
28 | **********************************************************
|
---|
29 | -->
|
---|
30 | <target name="init">
|
---|
31 | <mkdir dir="${plugin.build.dir}"/>
|
---|
32 | </target>
|
---|
33 | <!--
|
---|
34 | **********************************************************
|
---|
35 | ** compile - complies the source tree
|
---|
36 | **********************************************************
|
---|
37 | -->
|
---|
38 | <target name="compile" depends="init">
|
---|
39 | <echo message="compiling sources for ${plugin.jar} ..."/>
|
---|
40 | <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}" includeantruntime="false">
|
---|
41 | <compilerarg value="-Xlint:deprecation"/>
|
---|
42 | <compilerarg value="-Xlint:unchecked"/>
|
---|
43 | </javac>
|
---|
44 | </target>
|
---|
45 | <!--
|
---|
46 | **********************************************************
|
---|
47 | ** revision - extracts the current revision number for the
|
---|
48 | ** file build.number and stores it in the XML property
|
---|
49 | ** version.*
|
---|
50 | **********************************************************
|
---|
51 | -->
|
---|
52 | <target name="revision">
|
---|
53 | <exec append="false" outputproperty="svn.revision.output" executable="svn" failifexecutionfails="false">
|
---|
54 | <env key="LANG" value="C"/>
|
---|
55 | <arg value="info"/>
|
---|
56 | <arg value="--xml"/>
|
---|
57 | <arg value="."/>
|
---|
58 | </exec>
|
---|
59 | <xmlproperty prefix="version" keepRoot="false" collapseAttributes="true">
|
---|
60 | <propertyresource name="svn.revision.output"/>
|
---|
61 | </xmlproperty>
|
---|
62 | </target>
|
---|
63 | <!--
|
---|
64 | **********************************************************
|
---|
65 | ** clean - clean up the build environment
|
---|
66 | **********************************************************
|
---|
67 | -->
|
---|
68 | <target name="clean">
|
---|
69 | <delete dir="${plugin.build.dir}"/>
|
---|
70 | <delete file="${plugin.jar}"/>
|
---|
71 | </target>
|
---|
72 | <!--
|
---|
73 | **********************************************************
|
---|
74 | ** install - install the plugin in your local JOSM installation
|
---|
75 | **********************************************************
|
---|
76 | -->
|
---|
77 | <target name="install" depends="dist">
|
---|
78 | <property environment="env"/>
|
---|
79 | <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
|
---|
80 | <and>
|
---|
81 | <os family="windows"/>
|
---|
82 | </and>
|
---|
83 | </condition>
|
---|
84 | <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
|
---|
85 | </target>
|
---|
86 | <!--
|
---|
87 | ************************** Publishing the plugin ***********************************
|
---|
88 | -->
|
---|
89 | <!--
|
---|
90 | ** extracts the JOSM release for the JOSM version in ../core and saves it in the
|
---|
91 | ** property ${coreversion.info.entry.revision}
|
---|
92 | **
|
---|
93 | -->
|
---|
94 | <target name="core-info">
|
---|
95 | <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
|
---|
96 | <env key="LANG" value="C"/>
|
---|
97 | <arg value="info"/>
|
---|
98 | <arg value="--xml"/>
|
---|
99 | <arg value="../../core"/>
|
---|
100 | </exec>
|
---|
101 | <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
|
---|
102 | <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>
|
---|
103 | <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>
|
---|
104 | <delete file="core.info.xml"/>
|
---|
105 | </target>
|
---|
106 | <!--
|
---|
107 | ** commits the source tree for this plugin
|
---|
108 | -->
|
---|
109 | <target name="commit-current">
|
---|
110 | <echo>Commiting the plugin source with message '${commit.message}' ...</echo>
|
---|
111 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
112 | <env key="LANG" value="C"/>
|
---|
113 | <arg value="commit"/>
|
---|
114 | <arg value="-m"/>
|
---|
115 | <arg value="${commit.message}"/>
|
---|
116 | <arg value="."/>
|
---|
117 | </exec>
|
---|
118 | </target>
|
---|
119 | <!--
|
---|
120 | ** updates (svn up) the source tree for this plugin
|
---|
121 | -->
|
---|
122 | <target name="update-current">
|
---|
123 | <echo>Updating plugin source ...</echo>
|
---|
124 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
125 | <env key="LANG" value="C"/>
|
---|
126 | <arg value="up"/>
|
---|
127 | <arg value="."/>
|
---|
128 | </exec>
|
---|
129 | <echo>Updating ${plugin.jar} ...</echo>
|
---|
130 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
131 | <env key="LANG" value="C"/>
|
---|
132 | <arg value="up"/>
|
---|
133 | <arg value="../dist/${plugin.jar}"/>
|
---|
134 | </exec>
|
---|
135 | </target>
|
---|
136 | <!--
|
---|
137 | ** commits the plugin.jar
|
---|
138 | -->
|
---|
139 | <target name="commit-dist">
|
---|
140 | <echo>
|
---|
141 | ***** Properties of published ${plugin.jar} *****
|
---|
142 | Commit message : '${commit.message}'
|
---|
143 | Plugin-Mainversion: ${plugin.main.version}
|
---|
144 | JOSM build version: ${coreversion.info.entry.revision}
|
---|
145 | Plugin-Version : ${version.entry.commit.revision}
|
---|
146 | ***** / Properties of published ${plugin.jar} *****
|
---|
147 |
|
---|
148 | Now commiting ${plugin.jar} ...
|
---|
149 | </echo>
|
---|
150 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
|
---|
151 | <env key="LANG" value="C"/>
|
---|
152 | <arg value="-m"/>
|
---|
153 | <arg value="${commit.message}"/>
|
---|
154 | <arg value="commit"/>
|
---|
155 | <arg value="${plugin.jar}"/>
|
---|
156 | </exec>
|
---|
157 | </target>
|
---|
158 | <!-- ** make sure svn is present as a command line tool ** -->
|
---|
159 | <target name="ensure-svn-present">
|
---|
160 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">
|
---|
161 | <env key="LANG" value="C"/>
|
---|
162 | <arg value="--version"/>
|
---|
163 | </exec>
|
---|
164 | <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">
|
---|
165 | <!-- return code not set at all? Most likely svn isn't installed -->
|
---|
166 | <condition>
|
---|
167 | <not>
|
---|
168 | <isset property="svn.exit.code"/>
|
---|
169 | </not>
|
---|
170 | </condition>
|
---|
171 | </fail>
|
---|
172 | <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">
|
---|
173 | <!-- error code from SVN? Most likely svn is not what we are looking on this system -->
|
---|
174 | <condition>
|
---|
175 | <isfailure code="${svn.exit.code}"/>
|
---|
176 | </condition>
|
---|
177 | </fail>
|
---|
178 | </target>
|
---|
179 |
|
---|
180 | <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">
|
---|
181 | </target>
|
---|
182 |
|
---|
183 | <target name="runjosm" depends="install">
|
---|
184 | <java jar="${josm}" fork="true">
|
---|
185 | </java>
|
---|
186 | </target>
|
---|
187 |
|
---|
188 | <target name="profilejosm" depends="install">
|
---|
189 | <nbprofiledirect>
|
---|
190 | </nbprofiledirect>
|
---|
191 | <java jar="${josm}" fork="true">
|
---|
192 | <jvmarg value="${profiler.info.jvmargs.agent}"/>
|
---|
193 | </java>
|
---|
194 | </target>
|
---|
195 | </project>
|
---|
196 |
|
---|