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"/> |
---|
114 | <arg value="${commit.message}"/> |
---|
115 | <arg value="."/> |
---|
116 | </exec> |
---|
117 | </target> |
---|
118 | <!-- |
---|
119 | ** updates (svn up) the source tree for this plugin |
---|
120 | --> |
---|
121 | <target name="update-current"> |
---|
122 | <echo>Updating plugin source ...</echo> |
---|
123 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> |
---|
124 | <env key="LANG" value="C"/> |
---|
125 | <arg value="up"/> |
---|
126 | <arg value="."/> |
---|
127 | </exec> |
---|
128 | <echo>Updating ${plugin.jar} ...</echo> |
---|
129 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> |
---|
130 | <env key="LANG" value="C"/> |
---|
131 | <arg value="up"/> |
---|
132 | <arg value="../dist/${plugin.jar}"/> |
---|
133 | </exec> |
---|
134 | </target> |
---|
135 | <!-- |
---|
136 | ** commits the plugin.jar |
---|
137 | --> |
---|
138 | <target name="commit-dist"> |
---|
139 | <echo> |
---|
140 | ***** Properties of published ${plugin.jar} ***** |
---|
141 | Commit message : '${commit.message}' |
---|
142 | Plugin-Mainversion: ${plugin.main.version} |
---|
143 | JOSM build version: ${coreversion.info.entry.revision} |
---|
144 | Plugin-Version : ${version.entry.commit.revision} |
---|
145 | ***** / Properties of published ${plugin.jar} ***** |
---|
146 | |
---|
147 | Now commiting ${plugin.jar} ... |
---|
148 | </echo> |
---|
149 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> |
---|
150 | <env key="LANG" value="C"/> |
---|
151 | <arg value="-m"/> |
---|
152 | <arg value="${commit.message}"/> |
---|
153 | <arg value="commit"/> |
---|
154 | <arg value="${plugin.jar}"/> |
---|
155 | </exec> |
---|
156 | </target> |
---|
157 | <!-- ** make sure svn is present as a command line tool ** --> |
---|
158 | <target name="ensure-svn-present"> |
---|
159 | <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code"> |
---|
160 | <env key="LANG" value="C"/> |
---|
161 | <arg value="--version"/> |
---|
162 | </exec> |
---|
163 | <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system."> |
---|
164 | <!-- return code not set at all? Most likely svn isn't installed --> |
---|
165 | <condition> |
---|
166 | <not> |
---|
167 | <isset property="svn.exit.code"/> |
---|
168 | </not> |
---|
169 | </condition> |
---|
170 | </fail> |
---|
171 | <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system."> |
---|
172 | <!-- error code from SVN? Most likely svn is not what we are looking on this system --> |
---|
173 | <condition> |
---|
174 | <isfailure code="${svn.exit.code}"/> |
---|
175 | </condition> |
---|
176 | </fail> |
---|
177 | </target> |
---|
178 | <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist"> |
---|
179 | </target> |
---|
180 | </project> |
---|
181 | |
---|