generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.xml
433 lines (392 loc) · 20.3 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023, Oracle and/or its affiliates.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- This file has been modified for Oracle Java SE extension -->
<project basedir="." default="netbeans" name="oracle-java-vs-code-extension">
<description>Builds, tests, and runs the project org.netbeans.modules.java.lsp.server</description>
<property name="lsp.build.dir" location="vscode/nbcode" />
<property name="build.dir" location="build" />
<property name="nbplatform.default.netbeans.dest.dir" location="netbeans/nbbuild/netbeans" />
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.netbeans.dest.dir}/harness" />
<property name="nbantext.jar" location="netbeans/nbbuild/build/nbantext.jar" />
<property name="nb_all" location="netbeans" />
<loadresource property="patch-files-l10n">
<string>
patches/l10n/filter-enabled-clusters-disabled-modules-code-cleanup.diff
patches/l10n/adding-java.lsp.server-ja-and-zh_CN.diff
</string>
<filterchain>
<tokenfilter delimoutput=" ">
<replaceregex pattern="\s+" replace=""/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="patch-files">
<string>
patches/6330.diff
patches/7491.diff
patches/7610.diff
patches/7641.diff
patches/7654.diff
patches/7670.diff
patches/7699.diff
patches/7709.diff
patches/7722.diff
patches/7724.diff
patches/7733.diff
patches/7750.diff
patches/7910.diff
patches/7921.diff
patches/7923_draft.diff
patches/7926.diff
patches/mvn-sh.diff
patches/generate-dependencies.diff
patches/rename-debugger.diff
patches/remove-db.diff
patches/nbjavac-not-required.diff
patches/l10n-licence.diff
patches/no-security-manager-allow.diff
patches/dev-dependency-licenses.diff
</string>
<filterchain>
<tokenfilter delimoutput=" ">
<replaceregex pattern="\s+" replace=""/>
</tokenfilter>
</filterchain>
</loadresource>
<property name="patches" value="${patch-files}"/>
<condition property="has-patches">
<length string="${patches}" trim="true" when="greater" length="0"/>
</condition>
<property name="patches-l10n" value="${patch-files-l10n}"/>
<condition property="has-l10n-patches">
<length string="${patches-l10n}" trim="true" when="greater" length="0"/>
</condition>
<condition property="cmd.suffix" value=".cmd" else="">
<os family="windows"/>
</condition>
<target name="proxy-setup">
<!-- <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${nbantext.jar}"/>
<taskdef name="configureproxy" classname="org.netbeans.nbbuild.extlibs.ConfigureProxy" classpath="${nbantext.jar}"/>
<configureproxy connectto="https://netbeans.osuosl.org/binaries/" hostProperty="proxyHost" portProperty="proxyPort"/>
<setproxy proxyhost="${proxyHost}" proxyPort="${proxyPort}"/>-->
</target>
<target name="build-lsp-server" depends="-set-use-jdk-javac,proxy-setup" description="Prepares NetBeans bits for vscode extensions">
<ant dir="nbcode" target="build-zip" inheritall="false" inheritrefs="false">
<property name="nbplatform.default.netbeans.dest.dir" location="${nbplatform.default.netbeans.dest.dir}" />
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.harness.dir}" />
<property name="nbantext.jar" location="${nbantext.jar}" />
</ant>
<unzip src="nbcode/dist/nbcode.zip" dest="${lsp.build.dir}/../">
<globmapper from="nbcode/nb/*" to="nbcode/nbcode/*"/>
</unzip>
<mkdir dir="${lsp.build.dir}/bin" />
<copy todir="${lsp.build.dir}/bin" file="script/bin/nbcode" overwrite="true" />
<mkdir dir="${lsp.build.dir}/etc" />
<copy todir="${lsp.build.dir}/etc" file="script/etc/nbcode.conf" overwrite="true" />
<copy todir="${lsp.build.dir}/etc" file="script/etc/nbcode.clusters" overwrite="true" />
<move file="${lsp.build.dir}/java/maven/bin/mvn" tofile="${lsp.build.dir}/java/maven/bin/mvn.sh" />
<move file="${lsp.build.dir}/bin/nbcode" tofile="${lsp.build.dir}/bin/nbcode.sh" />
<move file="${lsp.build.dir}/platform/lib/nbexec" tofile="${lsp.build.dir}/platform/lib/nbexec.sh" />
<replace file="${lsp.build.dir}/bin/nbcode.sh" token="/platform*/lib/nbexec" value="/platform*/lib/nbexec.sh"/>
<replace file="${lsp.build.dir}/bin/nbcode.sh" token="basename "$PRG"" value="basename "$PRG" ".sh""/>
<replace file="${lsp.build.dir}/platform/lib/nbexec.dll" token="java.security.manager" value="no.java.secur.manager" encoding="ISO-8859-1"/>
<replace file="${lsp.build.dir}/platform/lib/nbexec64.dll" token="java.security.manager" value="no.java.secur.manager" encoding="ISO-8859-1"/>
<chmod file="${lsp.build.dir}/bin/nbcode.sh" perm="u+x" />
<chmod file="${lsp.build.dir}/platform/lib/nbexec.sh" perm="u+x"/>
<chmod file="${lsp.build.dir}/java/maven/bin/mvn.sh" perm="u+x" />
</target>
<target name="add-extra-modules" depends="build-lsp-server,build-l10n-bundles" if="extra.modules">
<ant dir="../../nbbuild" target="build-nbms" inheritall="false" inheritrefs="false">
<property name="cluster.config" value="basic"/>
</ant>
<ant dir="../../nbbuild" target="generate-uc-catalog" inheritall="false" inheritrefs="false"/>
<makeurl file="../../nbbuild/nbms/updates.xml.gz" property="update.center.url"/>
<autoupdate installdir="${lsp.build.dir}" updatecenter="${update.center.url}">
<modules includes="${extra.modules}"/>
</autoupdate>
<delete file="../../nbbuild/nbms/tasks.jar"/>
</target>
<target name="-set-use-jdk-javac">
<property name="test.use.jdk.javac" value="true" />
</target>
<target name="clean-vscode-ext" description="Cleans all VSCode related artifacts">
<delete dir="${lsp.build.dir}" />
<delete dir="vscode/node_modules" />
<delete dir="vscode/out" />
<ant dir="nbcode" target="clean" inheritall="false" inheritrefs="false">
<property name="nbplatform.default.netbeans.dest.dir" location="${nbplatform.default.netbeans.dest.dir}" />
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.harness.dir}" />
<property name="nbantext.jar" location="${nbantext.jar}" />
</ant>
</target>
<property name="netbeans.l10n.dir" location="netbeans-l10n"/>
<property name="nbcode.l10n.dir" location="nbcode/l10n"/>
<property name="vscode.nbcode.extra.dir" location="vscode/nbcode/extra"/>
<target name="build-l10n-ant-ext-jar" unless="disable.netbeans.l10n">
<ant dir="${netbeans.l10n.dir}/l10nantext" inheritall="false" inheritrefs="false">
<property name="file.reference.ant.jar" value="${ant.home}/lib/ant.jar"/>
</ant>
</target>
<target name="build-l10n">
<ant dir="${nbcode.l10n.dir}/locale_${locale}" target="build" inheritall="false" inheritrefs="false">
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.harness.dir}"/>
<property name="nbplatform.default.netbeans.dest.dir" location="${nbplatform.default.netbeans.dest.dir}"/>
<property name="netbeans.l10n.dir" location="${netbeans.l10n.dir}"/>
</ant>
<copy todir="${vscode.nbcode.extra.dir}">
<fileset dir="${nbcode.l10n.dir}/locale_${locale}/build/cluster"/>
</copy>
</target>
<target name="clean-l10n">
<delete dir="${nbcode.l10n.dir}/locale_${locale}/build" includeemptydirs="true" quiet="true"/>
<delete dir="${nbcode.l10n.dir}/locale_${locale}/release" includeemptydirs="true" quiet="true"/>
<delete includeemptydirs="true" quiet="true">
<fileset dir="${vscode.nbcode.extra.dir}">
<include name="**/*${locale}.jar"/>
<include name="**/*${locale}.xml"/>
<include name="**/*${locale}.html"/>
</fileset>
</delete>
</target>
<target name="clean-l10n-bundles" unless="disable.netbeans.l10n">
<delete dir="${netbeans.l10n.dir}/l10nantext/build"/>
<delete dir="${netbeans.l10n.dir}/l10nantext/dist"/>
<ant target="clean-l10n">
<property name="locale" value="ja"/>
</ant>
<ant target="clean-l10n">
<property name="locale" value="zh_CN"/>
</ant>
</target>
<target name="no-l10n">
<property name="disable.netbeans.l10n" value="true"/>
</target>
<target name="build-l10n-bundles" depends="clean-l10n-bundles,build-l10n-ant-ext-jar" description="builds l10n language bundles for vs code extension"
unless="disable.netbeans.l10n">
<ant target="build-l10n">
<property name="locale" value="ja" description="japanese"/>
</ant>
<ant target="build-l10n">
<property name="locale" value="zh_CN" description="simplified chinese"/>
</ant>
</target>
<target name="build-vscode-ext" depends="add-extra-modules" description="Build the Visual Studio Code extension.">
<taskdef name="gitbranchhash" classname="org.netbeans.nbbuild.GitBranchHash" classpath="${nbantext.jar}" />
<gitbranchhash file="." branchproperty="metabuild.branch" hashproperty="metabuild.hash" />
<condition property="metabuild.hash" value="main" >
<not>
<isset property="metabuild.hash" />
</not>
</condition>
<property name="vsix.version" value="0.1.0"/>
<property name="vsce.extra.args" value="" />
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="--allow-same-version"/>
<arg value="version" />
<arg value="${vsix.version}" />
</exec>
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="install" />
</exec>
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="run" />
<arg value="compile" />
</exec>
<delete dir="${build.dir}/bundles" />
<mkdir dir="${build.dir}/bundles/package" />
<copy file="vscode/package.json" todir="${build.dir}/bundles/package" />
<copy file="vscode/package-lock.json" todir="${build.dir}/bundles/package" />
<exec executable="mvn${cmd.suffix}" failonerror="true" dir="${nb_all}/nbbuild/misc/prepare-bundles">
<arg value="package" />
<arg value="exec:java" />
<arg value="-Dexec.mainClass=org.netbeans.prepare.bundles.PrepareBundles" />
<arg value="-Dexec.args=${build.dir}/bundles ${nb_all}" />
</exec>
<mkdir dir="${build.dir}/vsce" />
<exec executable="npm${cmd.suffix}" failonerror="true" dir="${build.dir}/vsce">
<arg value="install" />
<arg value="--save" />
<arg value="@vscode/vsce@2.19.0" />
</exec>
<copy file="${basedir}/LICENSE.txt" todir="${basedir}/vscode" />
<copy file="${basedir}/THIRD_PARTY_LICENSES.txt" todir="${basedir}/vscode" />
<exec executable="${build.dir}/vsce/node_modules/.bin/vsce${cmd.suffix}" failonerror="true" dir="${basedir}/vscode">
<arg value="package" />
<arg line="${vsce.extra.args}" />
<arg value="--baseContentUrl" />
<arg value="https://github.com/oracle/javavscode/blob/${metabuild.hash}/vscode" />
<arg value="--baseImagesUrl" />
<arg value="https://github.com/oracle/javavscode/raw/${metabuild.hash}/vscode" />
<arg value="--out" />
<arg value="${build.dir}/oracle-java-${vsix.version}.vsix" />
</exec>
<delete file="${basedir}/vscode/LICENSE.txt"/>
<delete file="${basedir}/vscode/THIRD_PARTY_LICENSES.txt"/>
</target>
<target name="test-lsp-server" description="Tests the LSP server behavior">
<ant dir="nbcode" target="test" inheritall="false" inheritrefs="false">
<property name="nbplatform.default.netbeans.dest.dir" location="${nbplatform.default.netbeans.dest.dir}" />
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.harness.dir}" />
<property name="nbantext.jar" location="${nbantext.jar}" />
</ant>
</target>
<target name="test-vscode-ext" depends="test-lsp-server" description="Tests the Visual Studio Code extension built by 'build-vscode-ext' target.">
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="--allow-same-version"/>
<arg value="run" />
<arg value="test" />
</exec>
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="--allow-same-version"/>
<arg value="run" />
<arg value="apisupport" />
</exec>
</target>
<target name="update-extension" depends="build-lsp-server" description="Compile the LSP Server and the VS Code extension">
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="install"/>
</exec>
<exec executable="npm${cmd.suffix}" failonerror="true" dir="vscode">
<arg value="run"/>
<arg value="compile" />
</exec>
</target>
<target name = "git-patch" if="${has-git-patches}" >
<echo>${git-patches-list}</echo>
<exec executable="git" failonerror="true">
<arg value="apply"/>
<arg value="--directory=${git-dir}"/>
<arg value="--whitespace=nowarn"/>
<arg line="${git-patches-list}"/>
</exec>
</target>
<target name="apply-patches">
<ant target="git-patch">
<property name="git-patches-list" value="${patches}"/>
<property name="has-git-patches" value="${has-patches}"/>
<property name="git-dir" value="netbeans"/>
</ant>
<condition value="true" property="should-apply">
<and>
<istrue value="${has-l10n-patches}"/>
<not>
<istrue value="${disable.netbeans.l10n}"/>
</not>
</and>
</condition>
<ant target="git-patch">
<property name="git-patches-list" value="${patches-l10n}"/>
<property name="has-git-patches" value="${should-apply}"/>
<property name="git-dir" value="netbeans-l10n"/>
</ant>
</target>
<target name = "git-un-patch" if="${has-git-patches}" >
<!--in the reverse order:-->
<echo file="${build.dir}/Reverse.java">
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class Reverse {
public static void main(String[] args) {
List<String> patches = Arrays.asList(args[0].split(" "));
Collections.reverse(patches);
System.out.print(patches.stream().collect(Collectors.joining(" ")));
}
}
</echo>
<java sourcefile="${build.dir}/Reverse.java"
outputproperty="reverse.patches"
fork="true">
<arg value="${git-patches-list}" />
</java>
<echo>${reverse.patches}</echo>
<exec executable="git" failonerror="true">
<arg value="apply"/>
<arg value="--directory=${git-dir}"/>
<arg value="--whitespace=nowarn"/>
<arg value="--reverse"/>
<arg line="${reverse.patches}"/>
</exec>
</target>
<target name="unapply-patches">
<ant target="git-un-patch">
<property name="git-patches-list" value="${patches}"/>
<property name="has-git-patches" value="${has-patches}"/>
<property name="git-dir" value="netbeans"/>
</ant>
<condition value="true" property="should-apply">
<and>
<istrue value="${has-l10n-patches}"/>
<not>
<istrue value="${disable.netbeans.l10n}"/>
</not>
</and>
</condition>
<ant target="git-un-patch">
<property name="git-patches-list" value="${patches-l10n}"/>
<property name="has-git-patches" value="${should-apply}"/>
<property name="git-dir" value="netbeans-l10n"/>
</ant>
</target>
<target name="build-netbeans">
<ant dir="netbeans" inheritAll="false" inheritRefs="false" useNativeBasedir="true"/>
</target>
<target name="clean-netbeans">
<ant dir="netbeans" target="clean" inheritAll="false" inheritRefs="false" useNativeBasedir="true"/>
</target>
<target name="generate-netbeans-license-summary" depends="-set-use-jdk-javac,proxy-setup" description="Generate license summary">
<delete dir="${build.dir}/nblic" />
<mkdir dir="${build.dir}/nblic/nbcode" />
<mkdir dir="${build.dir}/nblic/summary" />
<ant dir="nbcode" target="build-zip" inheritall="false" inheritrefs="false">
<property name="nbplatform.default.netbeans.dest.dir" location="${nbplatform.default.netbeans.dest.dir}" />
<property name="nbplatform.default.harness.dir" location="${nbplatform.default.harness.dir}" />
<property name="nbantext.jar" location="${nbantext.jar}" />
</ant>
<unzip src="nbcode/dist/nbcode.zip" dest="${build.dir}/nblic/">
</unzip>
<delete dir="${build.dir}/nblic/nbcode/nbcode" />
<taskdef name="createlicensesummary" classname="org.netbeans.nbbuild.extlibs.CreateLicenseSummary" classpath="${nbantext.jar}"/>
<property name="config.javadoc.all" value="" />
<property file="${nb_all}/nbbuild/cluster.properties" />
<taskdef name="resolvelist" classname="org.netbeans.nbbuild.ResolveList" classpath="${nbantext.jar}" />
<resolvelist name="allmodules" path="modules.fullpath" dir="${nb_all}" list="${clusters.config.full.list}"/>
<createlicensesummary licenseStub="${nb_all}/LICENSE"
noticeStub="${nb_all}/nbbuild/notice-stub.txt"
report="${build.dir}/createlicensesummary.xml"
nball="${nb_all}"
build="${build.dir}/nblic/nbcode"
license="${build.dir}/nblic/summary/LICENSE"
notice="${build.dir}/nblic/summary/NOTICE"
dependencies="${build.dir}/nblic/DEPENDENCIES"
binary="true"
excludes="${nb-extra-files}"
includeAllFiles="true"
/>
<concat destfile="${build.dir}/nblic/summary/NOTICE-ext">
<header>Content of the NOTICE file:
</header>
<filelist dir="${build.dir}/nblic/summary" files="NOTICE"/>
</concat>
<concat destfile="${build.dir}/nblic/netbeans-third-party.txt">
<filelist dir="${build.dir}/nblic/summary" files="LICENSE,NOTICE-ext"/>
</concat>
</target>
</project>