forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-node.xml
243 lines (212 loc) · 7.2 KB
/
build-node.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="build-nodejs" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-common.xml" />
<macrodef name="node-execute">
<attribute name="command"/>
<attribute default="" name="commandArgs" />
<attribute default="${user.dir}" name="working.dir" />
<sequential>
<property name="node.args" value="" />
<exec dir="@{working.dir}" executable="${sdk.dir}/tools/node-v${nodejs.version}/bin/@{command}">
<arg line="@{commandArgs} ${node.args}"/>
</exec>
</sequential>
</macrodef>
<target name="download-node">
<if>
<os arch="x86_32" family="mac" />
<then>
<propertycopy from="nodejs.url[osx32]" name="nodejs.url" />
</then>
<elseif>
<os arch="x86_64" family="mac" />
<then>
<propertycopy from="nodejs.url[osx64]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd" family="unix" />
<then>
<propertycopy from="nodejs.url[linux32]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd64" family="unix" />
<then>
<propertycopy from="nodejs.url[linux64]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="x86" family="windows" />
<then>
<propertycopy from="nodejs.url[windows32]" name="nodejs.url" />
</then>
</elseif>
<elseif>
<os arch="amd64" family="windows" />
<then>
<propertycopy from="nodejs.url[windows64]" name="nodejs.url" />
</then>
</elseif>
</if>
<if>
<not>
<isset property="nodejs.url" />
</not>
<then>
<fail>
.
Unable to automatically detect the current operating system and architecture.
Please manually set the property "nodejs.url" in build.properties to the
location of NodeJS. An example value for OSX on a 64 bit architecture is
${nodejs.url[osx64]}.
</fail>
</then>
</if>
<if>
<not>
<available file="${sdk.dir}/tools/node-v${nodejs.version}" />
</not>
<then>
<antelope:stringutil string="${nodejs.url}" property="nodejs.file.beginindex">
<antelope:lastindexof string="/" />
</antelope:stringutil>
<math
datatype="int"
operand1="${nodejs.file.beginindex}"
operand2="1"
operation="+"
result="nodejs.file.beginindex"
/>
<antelope:stringutil string="${nodejs.url}" property="nodejs.file">
<antelope:substring beginindex="${nodejs.file.beginindex}" />
</antelope:stringutil>
<mirrors-get dest="${nodejs.file}" src="${nodejs.url}" />
<if>
<contains string="${nodejs.file}" substring=".tar.gz" />
<then>
<exec executable="tar">
<arg line="xfz ${nodejs.file} -C ${sdk.dir}/tools"/>
</exec>
<antelope:stringutil string="${nodejs.file}" property="nodejs.dir.endindex">
<antelope:lastindexof string=".tar.gz" />
</antelope:stringutil>
<antelope:stringutil string="${nodejs.file}" property="nodejs.dir">
<antelope:substring endindex="${nodejs.dir.endindex}" />
</antelope:stringutil>
<delete dir="${sdk.dir}/tools/node-v${nodejs.version}" />
<move file="${sdk.dir}/tools/${nodejs.dir}" tofile="${sdk.dir}/tools/node-v${nodejs.version}" />
<mkdir dir="${sdk.dir}/tools/node-v${nodejs.version}/node_modules" />
<delete file="${nodejs.file}" />
</then>
<else>
<move file="${nodejs.file}" todir="${sdk.dir}/tools/node-v${nodejs.version}" />
</else>
</if>
<if>
<os family="windows" />
<then>
<mirrors-get
dest="npm.zip"
src="${nodejs.npm.url}"
/>
<unzip
dest="${sdk.dir}/tools/node-v${nodejs.version}"
src="npm.zip"
/>
<delete file="npm.zip" />
</then>
</if>
</then>
</if>
</target>
<target name="transpile-js-files" depends="install-babel,install-config-generator,install-loader">
<property name="transpiler.force" value="false" />
<outofdate outputsourcespath="outdated-files" force="${transpiler.force}">
<sourcefiles>
<fileset dir="${transpiler.input.dir}">
<include name="**/*.js" />
</fileset>
</sourcefiles>
<mapper type="glob" dir="${transpiler.input.dir}" from="*.js" to="${transpiler.output.dir}/*.js" />
<sequential>
<if>
<istrue value="${transpiler.force}" />
<then>
<path id="outdated-files">
<fileset dir="${transpiler.input.dir}">
<include name="**/*.js" />
</fileset>
</path>
</then>
</if>
<pathconvert pathsep=" " property="outdated-files-param" setonempty="false" refid="outdated-files" >
<map from="${transpiler.input.dir}/" to="" />
</pathconvert>
<node-execute
command="node"
commandArgs="${sdk.dir}/tools/node-v${nodejs.version}/node_modules/babel/bin/babel/index.js --modules amd -d ${transpiler.output.dir} ${outdated-files-param}"
working.dir="${transpiler.input.dir}" />
</sequential>
</outofdate>
</target>
<target name="generate-modules-config" depends="install-config-generator">
<echo>
${sdk.dir}/tools/node-v${nodejs.version}/node_modules/lfr-module-config-generator/bin/index.js -l -e '${config.generator.file.extension}' -f ${config.generator.module.format} -i ${config.generator.path.ignore} -c '${config.generator.config.variable}' -o ${config.generator.output.file} -p ${config.generator.file.pattern} -m ${config.generator.module.config} -r ${config.generator.root.dir} ${config.generator.input.dir}"
</echo>
<node-execute
command="node"
commandArgs="${sdk.dir}/tools/node-v${nodejs.version}/node_modules/lfr-module-config-generator/bin/index.js -l -e '${config.generator.file.extension}' -f ${config.generator.module.format} -i ${config.generator.path.ignore} -c '${config.generator.config.variable}' -o ${config.generator.output.file} -p ${config.generator.file.pattern} -m ${config.generator.module.config} -r ${config.generator.root.dir} ${config.generator.input.dir}"
working.dir="${sdk.dir}/tools/node-v${nodejs.version}" />
</target>
<target name="install-babel" depends="download-node">
<if>
<not>
<available file="${sdk.dir}/tools/node-v${nodejs.version}/node_modules/babel" />
</not>
<then>
<antcall target="npm-execute">
<param name="node.args" value="install babel" />
</antcall>
</then>
</if>
</target>
<target name="install-config-generator" depends="download-node">
<if>
<not>
<available file="${sdk.dir}/tools/node-v${nodejs.version}/node_modules/lfr-module-config-generator" />
</not>
<then>
<antcall target="npm-execute">
<param name="node.args" value="install lfr-module-config-generator" />
</antcall>
</then>
</if>
</target>
<target name="install-loader" depends="download-node">
<if>
<not>
<available file="${sdk.dir}/tools/node-v${nodejs.version}/node_modules/lfr-amd-loader" />
</not>
<then>
<antcall target="npm-execute">
<param name="node.args" value="install lfr-amd-loader" />
</antcall>
</then>
</if>
</target>
<target name="node-execute" depends="download-node">
<property name="working.dir" value="${user.dir}" />
<node-execute
command="node"
working.dir="${working.dir}"
/>
</target>
<target name="npm-execute" depends="download-node">
<node-execute
command="npm"
working.dir="${sdk.dir}/tools/node-v${nodejs.version}"
/>
</target>
</project>