-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.xml
More file actions
140 lines (123 loc) · 5.99 KB
/
build.xml
File metadata and controls
140 lines (123 loc) · 5.99 KB
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
<?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>
<condition property="is-release">
<equals arg1="${release}" arg2="true" />
</condition>
<target name="release.true" if="is-release">
<echo>Calculating git revision info for release</echo>
</target>
<target name="release.false" unless="is-release">
<echo>Not a release, moving on ...</echo>
</target>
<target name="check-release" depends="release.true, release.false">
</target>
<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="templates" description="process template files" if="is-release" depends="git.revision">
<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>
</target>
<target name="xar" depends="clean,check-release,git.revision, run-npm,templates" description="create xar file">
<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="plans/**"/>
<exclude name="tests/reports/**"/>
<exclude name="tests/cypress/**"/>
<exclude name="npm-shrinkwrap.json"/>
<exclude name="build.properties.local.xml"/>
<exclude name="local.node-exist.json"/>
<exclude name="wdio*"/>
<exclude name="cypress.config.cjs"/>
<exclude name=".github/**"/>
<exclude name=".releaserc"/>
<exclude name="commitlint.config.cjs"/>
</zip>
<echo>Version: ${app.version}</echo>
</target>
<target name="git.revision" description="Store git revision in ${repository.version}"
if="is-release" depends="check-release">
<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>