forked from rogerjohansson/html5validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
126 lines (113 loc) · 6.04 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
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
118
119
120
121
122
123
124
125
126
<?xml version="1.0"?>
<!-- build command: ant build -->
<project name="Generic" default="." basedir=".">
<description>Generic Firefox add-on build script</description>
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="dist" location="xpi"/>
<mkdir dir="${dist}"/>
<delete dir="${build}"/>
<!-- determine version number, etc, based on install.rdf -->
<target name="read-install.rdf">
<xmlproperty file="${src}/install.rdf"/>
<property name="file-base-name" value="${RDF.Description.em:id}"/>
<property name="plain-version" value="${RDF.Description.em:version}"/>
<buildnumber/>
<property name="full-version" value="${RDF.Description.em:version}.${build.number}"/>
<property name="xpi-release-name" value="${file-base-name}-${full-version}.xpi"/>
<property name="xpi-release" location="${dist}/${xpi-release-name}"/>
<property name="xpi-plain" location="${dist}/${file-base-name}-${plain-version}.xpi"/>
</target>
<target name="copy-build" depends="read-install.rdf">
<mkdir dir="${build}"/>
<copy todir="${build}">
<fileset dir=".">
<includesfile name="files-to-copy.txt"/>
</fileset>
</copy>
<replace file="${build}/install.rdf" token="${RDF.Description.em:version}" value="${full-version}"/>
</target>
<target name="clean-build" depends="copy-build" unless="nostrip">
<echo>Stripping log() invocations</echo>
<replaceregexp byline="true">
<regexp pattern="\blog\(.+\)"/>
<substitution expression=""/>
<fileset dir="${build}">
<include name="**/*.js"/>
</fileset>
</replaceregexp>
</target>
<target name="prepare-update" depends="clean-build">
<property name="update-url-base" value="${RDF.Description.em:updateURL}"/>
<property name="update-file-name" value="update-${file-base-name}.rdf"/>
<property name="update-path" value="${dist}/${update-file-name}"/>
<copy file="${src}/update.rdf" tofile="${update-path}" overwrite="true"/>
<replace file="${update-path}" token="___EXTENSION_ID___" value="${RDF.Description.em:id}"/>
<replace file="${update-path}" token="___VERSION___" value="${full-version}"/>
<replace file="${update-path}" token="___APPID___" value="${RDF.Description.em:targetApplication.Description.em:id}"/>
<replace file="${update-path}" token="___MINVERSION___" value="${RDF.Description.em:targetApplication.Description.em:minVersion}"/>
<replace file="${update-path}" token="___MAXVERSION___" value="${RDF.Description.em:targetApplication.Description.em:maxVersion}"/>
<replace file="${build}/install.rdf" token="${RDF.Description.em:updateURL}" value="${update-url-base}/${update-file-name}"/>
<loadfile property="updateKeyString" srcFile="updateKey">
<filterchain><striplinebreaks/></filterchain>
</loadfile>
<echo>updateKey: "${updateKeyString}"</echo>
<replace file="${build}/install.rdf" token="${RDF.Description.em:updateKey}" value="${updateKeyString}"/>
<xmlproperty file="${src}/update.rdf"/>
<property name="updateInfoURL" value="${r:RDF.r:Description.updates.r:Seq.r:li.r:Description.targetApplication.r:Description.updateInfoURL}"/>
<condition property="updateInfo">
<resourceexists>
<file file="${src}/${updateInfoURL}"/>
</resourceexists>
</condition>
</target>
<target name="prepare-changelog-yes" depends="prepare-update" if="updateInfo">
<property name="changelog.xml" value="${file-base-name}-${updateInfoURL}"></property>
<property name="changelog-path" value="${dist}/${changelog.xml}"></property>
<copy file="${src}/${updateInfoURL}" tofile="${changelog-path}" overwrite="true"/>
<replace file="${update-path}" token="${updateInfoURL}" value="${update-url-base}/${changelog.xml}"/>
</target>
<target name="prepare-changelog-no" depends="prepare-update" unless="updateInfo">
<property name="changelog-path" value=""></property>
</target>
<!-- archive sources into .xpi file -->
<target name="archive" depends="clean-build" description="archive the add-on">
<zip destfile="${xpi-release}" level="9">
<fileset dir="${build}"/>
</zip>
</target>
<!-- main build action -->
<target name="build" depends="archive" unless="nocleanup">
<delete dir="${build}"/>
</target>
<target name="nostrip">
<property name="nostrip" value="true"></property>
</target>
<target name="reset-build-number">
<propertyfile file="build.number">
<entry key="build.number" type="int" value="0"/>
</propertyfile>
</target>
<target name="release-update" depends="prepare-changelog-yes, prepare-changelog-no, build">
<tempfile property="hash-file"/>
<exec executable="sha256sum" output="${hash-file}">
<arg value="${xpi-release}"/>
</exec>
<replaceregexp file="${hash-file}">
<regexp pattern="\s+.*\n"/>
<substitution expression=""/>
</replaceregexp>
<loadfile property="hash" srcFile="${hash-file}"/>
<delete file="${hash-file}"/>
<property name="hash-field" value="sha256:${hash}"/>
<echo>hash: ${hash-field}</echo>
<replace file="${update-path}" token="___XPI___" value="${update-url-base}/${xpi-release-name}"/>
<replace file="${update-path}" token="___HASH___" value="${hash-field}"/>
</target>
<target name="release-upload" depends="release-update">
<copy file="upload.command-template" tofile="upload.command" overwrite="true"/>
<replace file="upload.command" token="___FILES___" value="${xpi-release} ${changelog-path} ${update-path}"/>
<echo>${line.separator}Generated upload command file: upload.command</echo>
<echo>Don't forget to sign the update manifest before uploading!</echo>
</target>
</project>