-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.xml
114 lines (103 loc) · 5.2 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
<?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="hsg-shell" basedir=".">
<xmlproperty file="build.properties.local.xml" semanticAttributes="true" keepRoot="false"/>
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="false"/>
<xmlproperty file="expath-pkg.xml"/>
<property name="build.dir" value="build"/>
<property name="git.repo.path" value="${basedir}/.git"/>
<available file="${git.repo.path}" type="dir" property="git.present"/>
<property environment="env"/>
<!-- <property name="files-to-be-excluded" value="${build.dir}/**,**/*.tmpl,node_modules/**,package.json,package-lock.json,gulpfile.js,.idea/**,.* example.local.build.properties,npm-shrinkwrap.json,tests/reports/**"/> -->
<!-- Allow HSG_ENV to be passed in either as an environment variable or as a regular variable -->
<condition property="node-env-is-set-for-production" else="false">
<or>
<equals arg1="${env.HSG_ENV}" arg2="production"/>
<equals arg1="${HSG_ENV}" arg2="production"/>
</or>
</condition>
<!-- Create a new property that sets production mode based on whether either variation of HSG_ENV is set to production -->
<condition property="HSG_ENV.production" value="production" else="development">
<istrue value="${node-env-is-set-for-production}"/>
</condition>
<target name="clean">
<echo message="Deleting xar files..."/>
<delete dir="${build.dir}"/>
</target>
<target name="run-npm">
<echo message="Calling npm start... (Production? ${node-env-is-set-for-production})"/>
<exec executable="npm" outputproperty="npm.output">
<arg line="start"/>
<env key="HSG_ENV" value="${HSG_ENV.production}"/>
</exec>
<echo message="${npm.output}"/>
</target>
<target name="xar" depends="clean,run-npm,git.revision" description="create xar file">
<echo message="Creating build folder..."/>
<mkdir dir="${build.dir}"/>
<copy todir="${basedir}" overwrite="true" verbose="true">
<fileset file="*.xml.tmpl"/>
<filterchain>
<replacetokens>
<token key="name" value="${app.name}"/>
<token key="version" value="${app.version}"/>
<token key="url" value="${app.url}"/>
<token key="title" value="${app.title}"/>
<token key="commit-id" value="${git.revision}"/>
<token key="commit-time" value="${git.time}"/>
</replacetokens>
<tokenfilter>
<!-- until we move template processing to XSLT, take care with reserved characters -->
<replacestring from="&" to="&amp;"/>
</tokenfilter>
</filterchain>
<globmapper from="*.tmpl" to="*"/>
</copy>
<echo message="------------------------------------------------------------"/>
<echo message="Creating xar file..."/>
<echo message="------------------------------------------------------------"/>
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}.xar">
<!-- <exclude name="app/**"/> -->
<exclude name="${build.dir}/**"/>
<exclude name="*.tmpl"/>
<exclude name="hsg-shell.xpr"/>
<exclude name="build.properties.local.example.xml"/>
<exclude name="build.properties.xml"/>
<exclude name="build.xml"/>
<exclude name="node_modules/**"/>
<exclude name="package.json"/>
<exclude name="package-lock.json"/>
<exclude name=".idea/**"/>
<exclude name=".vscode/**"/>
<exclude name="tests/reports/**"/>
<exclude name="npm-shrinkwrap.json"/>
<exclude name="build.properties.local.xml"/>
<exclude name="local.node-exist.json"/>
<exclude name="wdio*"/>
<exclude name=".github/**"/>
<exclude name=".releaserc"/>
<exclude name="commitlint.config.cjs"/>
</zip>
</target>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>Git repo: ${repository.version}</echo>
<exec executable="git" outputproperty="git.time" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="show"/>
<arg value="-s"/>
<arg value="--format=%ct"/>
<arg value="${git.revision}"/>
</exec>
<echo>Git time: ${git.time}</echo>
</target>
</project>