-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.xml
90 lines (77 loc) · 3.17 KB
/
build.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
<?xml version="1.0" ?>
<project name="CompactHeader" default="dist" basedir=".">
<dirname property="my.project.dir" file="${ant.file}"/>
<property name="src.dir" value="." />
<property name="mozdev.dir" value="${src.dir}/../../workspace/compactheader.mozdev.org"/>
<property name="dist.dir" value="${mozdev.dir}/downloads/"/>
<property name="AMOdist.dir" value="${src.dir}/AMO/"/>
<property name="www.dir" value="${mozdev.dir}/www/"/>
<property name="test.dir" value="${src.dir}/test/"/>
<!-- https://stackoverflow.com/questions/2527020/parse-json-with-ant -->
<macrodef name="json-properties">
<attribute name="jsonFile"/>
<sequential>
<local name="_jsonFile"/>
<property name="_jsonFile" value="@{jsonFile}"/>
<script language="javascript">//<![CDATA[
var json = new Packages.java.lang.String(
Packages.java.nio.file.Files.readAllBytes(
Packages.java.nio.file.Paths.get(project.getProperty("_jsonFile"))), "UTF-8");
var properties = JSON.parse(json);
for(key in properties) {
project.setProperty(key, properties[key]);
}
//]]></script>
</sequential>
</macrodef>
<target name="testmacro">
<json-properties jsonFile="${my.project.dir}/manifest.json"/>
<echo message="version ${version}"/>
<echo message="name ${name}"/>
</target>
<target name="dist" depends="spreadVersion,buildAMO,buildMozdev">
</target>
<target name="clean">
<json-properties jsonFile="${my.project.dir}/manifest.json"/>
<delete file="${dist.dir}/${name}-${version}.xpi" />
</target>
<target name="buildAMO">
<json-properties jsonFile="${my.project.dir}/manifest.json"/>
<copy file="${src.dir}/manifest.json" tofile="${AMOdist.dir}/manifest.json"/>
<zip destfile="${AMOdist.dir}/${name}-${version}.xpi">
<fileset dir="${src.dir}">
<include name="chrome.manifest" />
<include name="defaults/**" />
<include name="chrome/**" />
<exclude name="**/.*" />
<exclude name="**/CVS/**" />
</fileset>
<fileset dir="${AMOdist.dir}">
<include name="manifest.json" />
</fileset>
</zip>
</target>
<target name="buildMozdev">
<json-properties jsonFile="${my.project.dir}/manifest.json"/>
<zip destfile="${dist.dir}/${name}-${version}.xpi">
<fileset dir="${src.dir}">
<include name="chrome.manifest" />
<include name="manifest.json" />
<include name="defaults/**" />
<include name="chrome/**" />
<exclude name="**/.*" />
<exclude name="**/CVS/**" />
</fileset>
</zip>
<property name="absXPI" location="${dist.dir}/${name}-${version}.xpi"/>
<echo message="absUpdate ${absUpdate}"/>
<echo message="absUpdate ${absXPI}"/>
</target>
<target name="spreadVersion">
<json-properties jsonFile="${my.project.dir}/manifest.json"/>
<replaceregexp file="${www.dir}/installation.html"
byline="true"
match="(.*update the version.*CompactHeader-).*(.xpi">Version ).*( of Co.*)"
replace="\1${version}\2${version}\3"/>
</target>
</project>