-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-extension.xml
141 lines (129 loc) · 5.53 KB
/
build-extension.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0" encoding="UTF-8"?>
<!--
author: [email protected]
date: 2011-08-05
ChromeExtensionPackage: https://github.com/scarrillo/ChromeExtensionPackage
-->
<project name="ChromeExtensionPackage" default="package" basedir="../">
<description>
Package a google chrome extension and exclude private files that should never be published.
</description>
<!-- Root build -->
<property name="build" value=".build/" />
<property file="${build}build.properties" />
<!-- Required properties:
ext.name = name of the final extension: name.crx
ext.id = Extension ID for chrome web store
ext.version = Current version of your extension
ext.chrome = Path to chrome's executable
-->
<!-- Extension's build directory. Files will be copied and compiled. The .crx and .zip files will be created in the parent. This directory can be used to load the unpackaged plugin in chrome from, otherwise it is deleted -->
<property name="buildDir" value="${build}${ext.name}" />
<!-- Path to the extension's files that were copied into the build path -->
<property name="extPath" value="${basedir}/${buildDir}" />
<!-- Path to the extension's certificate -->
<property name="extCert" value="${basedir}/.cert/${ext.name}.pem" />
<!-- updates.xml properties: see updates.template.xml or updates.xml -->
<!-- Used when hosting on a custom server. Not in chrome web store. -->
<property name="extCodebase" value="${ext.updateUrl}${ext.name}.crx" />
<!-- ex: http://www.example.com/path/to/${ext.name}.crx -->
<!-- Entry point target, executes the 'copy' target first -->
<target name="package" depends="copy" description="Generates a chrome extension" if="build.execute">
<exec executable="${ext.chrome}">
<arg value="--pack-extension=${extPath}" />
<arg value="--pack-extension-key=${extCert}" />
<!-- suppress the chrome package success message -->
<arg value="--no-message-box" />
</exec>
<!-- Package a non-crx for the chrome web store
Updating an extension in the webstore requires key.pem to preserve the extension id.
The webstore strips this file out on upload -->
<copy file="${extCert}" tofile="${basedir}/${buildDir}/key.pem"/>
<zip destfile="${build}/${ext.name}.zip" basedir="${basedir}/${buildDir}" />
<antcall target="updates" />
<antcall target="clean" />
</target>
<target name="copy" depends="verify" if="build.execute" description="copy required extension files to build directory. Exclude non-public src files and project files">
<tstamp />
<mkdir dir="${buildDir}" />
<copy todir="${buildDir}" preservelastmodified="true">
<fileset dir="${basedir}">
<exclude name=".cert/" />
<exclude name=".settings/" />
<exclude name=".build/" />
<exclude name="js-src/" />
<exclude name="lib/" />
<exclude name=".project" />
<exclude name=".gitignore" />
<exclude name="build.xml" />
<exclude name="publish-extension-ant-build.xml" />
<exclude name="updates.xml" />
<exclude name="README" />
</fileset>
</copy>
<antcall target="manifest" />
</target>
<target name="verify" description="Verify some configuration settings or fail with error">
<fail message="Verify property: ext.name">
<condition><or>
<not><isset property="ext.name" /></not>
<not><length string="${ext.name}" trim="true" when="greater" length="0" /></not>
<matches pattern="##EDIT##" string="${ext.name}" /></or>
</condition>
</fail>
<fail message="Verify property: ext.version">
<condition><or>
<not><isset property="ext.version" /></not>
<not><length string="${ext.version}" trim="true" when="greater" length="0" /></not>
<matches pattern="##EDIT##" string="${ext.version}" /></or>
</condition>
</fail>
<fail message="Verify property: ext.id">
<condition><or>
<not><isset property="ext.id" /></not>
<not><length string="${ext.id}" trim="true" when="greater" length="0" /></not>
<matches pattern="##EDIT##" string="${ext.id}" /></or>
</condition>
</fail>
<fail message="Verify property: ext.chrome">
<condition><or>
<not><isset property="ext.chrome" /></not>
<not><length string="${ext.chrome}" trim="true" when="greater" length="0" /></not>
<matches pattern="##EDIT##" string="${ext.chrome}" /></or>
</condition>
</fail>
<fail message="Verify the path to chrome.exe is correct">
<condition>
<not><available file="${ext.chrome}" type="file" /></not>
</condition>
</fail>
<property name="build.execute" value="true" />
</target>
<target name="manifest" description="update manfiest.json" if="build.execute">
<copy file="manifest.json" tofile="${buildDir}/manifest.json" overwrite="true" force="true">
<filterchain>
<replacetokens>
<token key="extension_name" value="${ext.name}" />
<token key="extension_version" value="${ext.version}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="updates" description="create updates.xml" if="build.execute">
<copy file="updates.xml" tofile="${build}updates.xml" overwrite="true" force="true">
<filterchain>
<replacetokens>
<token key="extension_id" value="${ext.id}" />
<token key="extension_codebase" value="${extCodebase}" />
<token key="extension_version" value="${ext.version}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="clean" description="clean up" if="build.execute">
<delete file="${buildDir}/key.pem" verbose="true" />
<!-- Useful to load this folder in chrome during development: Load unpacked extension
<delete dir="${buildDir}" verbose="false" />
-->
</target>
</project>