forked from andstatus/andstatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_rules.xml
117 lines (103 loc) · 4.45 KB
/
custom_rules.xml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?xml version="1.0" encoding="UTF-8"?>
<project name="AndStatus Dump" default="dump_all">
<!-- This is included into the Ant build file build.xml -->
<target name="dump_all" description="Creates a local dump (zipped archive) of all AndStatus application-related files, including those not checked into a repository.">
<!-- get the versionName from the manifest -->
<xpath output="project.app.versionName" input="${manifest.abs.file}" expression="/manifest/@android:versionName"/>
<!-- return: version name formatted for proper file name sorting
Second and third numbers are padded to 2 and 3 symbols respectively
-->
<scriptdef name="format_version_name" language="javascript">
<attribute name="out" />
<attribute name="in" />
<![CDATA[
var ver_in = attributes.get("in").toString();
// project.log("ver_in = " + ver_in);
var ver_splitted = ver_in.split("[.]");
var ver_out = "";
if ( ver_splitted.length > 0 ) {
ver_out += ver_splitted[0];
if ( ver_splitted.length > 1 ) {
ver_out += "." + pad(ver_splitted[1], 2);
}
if ( ver_splitted.length > 2 ) {
ver_out += "." + pad(ver_splitted[2], 3);
}
}
// project.log("ver_out = " + ver_out);
project.setProperty( attributes.get( "out" ), ver_out );
function pad(n, len) {
var s = n.toString();
/* For some reason comparison as in the next script doesn't work here... */
s = ('0000000000' + s).slice(-len);
return s;
}
]]>
</scriptdef>
<format_version_name in="${project.app.versionName}" out="ver" />
<!-- Directory from which other relative paths are set: -->
<property name="dumpBaseDir" location=".." />
<property name="destDumpDir" location="${dumpBaseDir}/Archives" />
<echo message="$${basedir} is '${basedir}'" />
<echo message="Dump base dir is '${dumpBaseDir}'" />
<echo message="Creating AndStatus application dump v.${project.app.versionName} in '${destDumpDir}'" />
<condition property="destDumpDirExists">
<available file="${destDumpDir}" />
</condition>
<fail unless="destDumpDirExists" message="Directory '${destDumpDir}' doesn't exist" />
<!-- Now we have to find the first unused minor version number of the zipped file.
The code is derived from the example:
http://stackoverflow.com/questions/7351384/ant-load-file-names-and-extract-data-from-the-file-names?rq=1
and search pattern is tested here: http://www.regextester.com/
-->
<!-- return: number padded to 3 symbols -->
<scriptdef name="numeric_max_plus_one" language="javascript">
<attribute name="property" />
<attribute name="resources_id" />
<![CDATA[
var iter = project.getReference(
attributes.get( "resources_id" )
).iterator( );
var max_n = -1;
while ( iter.hasNext() )
{
var n = parseFloat( iter.next() );
if ( n > max_n ) max_n = n;
}
project.setProperty( attributes.get( "property" ), pad(max_n + 1, 3) );
function pad(n, len) {
s = n.toString();
if (s.length < len) {
s = ('0000000000' + s).slice(-len);
}
return s;
}
]]>
</scriptdef>
<property name="destPattern" value="AndStatus-${ver}-(.*)-(.*).zip" />
<echo message="Existing dumps search pattern: '${destPattern}'" />
<mappedresources id="versions">
<fileset dir="${destDumpDir}" includes="*.zip" />
<regexpmapper from="${destPattern}" to="\1" />
</mappedresources>
<numeric_max_plus_one property="next.version" resources_id="versions" />
<echo message="Unused dump version: ${next.version}." />
<input message="Enter the optional name suffix or press Enter for default suffix"
addproperty="suffix" defaultvalue="dump" />
<property name="destDumpFile" value="${destDumpDir}/AndStatus-${ver}-${next.version}-${suffix}.zip"/>
<condition property="destDumpFileExists">
<available file="${destDumpFile}" />
</condition>
<fail if="destDumpFileExists" message="File '${destDumpFile}' already exists" />
<zip destfile="${destDumpFile}">
<fileset dir="${dumpBaseDir}" defaultexcludes="no" >
<include name="Repository/**" />
<include name="images/**" />
<include name="scripts/**" />
<include name="andstatus.org/**" />
<include name="WikiRepository/**" />
<exclude name="**/Old/**" />
</fileset>
</zip>
</target>
</project>