-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
61 lines (54 loc) · 1.97 KB
/
Copy pathbuild.xml
File metadata and controls
61 lines (54 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<project name="my-plugin" default="zip" basedir=".">
<!-- properties -->
<property name="plugin.name" value="Simple Time Tracker"/>
<property name="plugin.version" value="1.4.0"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<property name="zip.file" value="${dist.dir}/${plugin.name}-${plugin.version}.zip"/>
<!-- remove old build and dist -->
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<!-- prepare build directory -->
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${dist.dir}"/>
<copy todir="${build.dir}">
<fileset dir="." excludes="lib/**,,dist/**,build.xml"/>
</copy>
</target>
<!-- load last version -->
<property file="version.properties"/>
<!-- load last version from a file that only contains the version -->
<loadfile property="version" srcFile="version.properties"/>
<!-- define Python-based bump-version -->
<scriptdef name="bump.version" language="python">
<classpath>
<pathelement location="lib/jython-standalone-2.7.4.jar"/>
</classpath>
<![CDATA[
current = project.getProperty("version")
parts = current.split(".")
major, minor, patch = map(int, parts)
patch += 1
if patch > 10:
patch = 0
minor += 1
new_version = "{}.{}.{}".format(major, minor, patch)
project.setProperty("new.version", new_version)
]]>
</scriptdef>
<!-- target to update version.properties and plugin.version -->
<target name="bump-version">
<bump.version/>
<!-- overwrite the file with just the new version string -->
<echo file="version.properties" message="${new.version}"/>
<property name="version" value="${new.version}"/>
<property name="plugin.version" value="${new.version}"/>
</target>
<!-- zip depends on bump-version -->
<target name="zip" depends="clean,init,bump-version">
<zip destfile="${dist.dir}/${plugin.name}-${plugin.version}.zip" basedir="${build.dir}"/>
</target>
</project>