-
Notifications
You must be signed in to change notification settings - Fork 484
/
build.gradle
5958 lines (5161 loc) · 248 KB
/
build.gradle
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The main build script for JavaFX.
*
* MUST FIX tasks to complete:
* - build check -- making sure the final artifact has the right bits
* - some things worth automatically sanity checking:
* - are there images in the javadocs?
* - are all of the expected dylibs etc there?
* - Perform sanity checking to make sure a JDK exists with javac, etc
* - Support building with no known JDK location, as long as javac, etc are on the path
* - Check all of the native flags. We're adding weight to some libs that don't need it, and so forth.
*
* Additional projects to work on as we go:
* - Add "developer debug". This is where the natives do not have debug symbols, but the Java code does
* - The genVSproperties.bat doesn't find the directory where RC.exe lives. So it is hard coded. Might be a problem.
* - special tasks for common needs, such as:
* - updating copyright headers
* - stripping trailing whitespace (?)
* - checkstyle
* - findbugs
* - re needs?
* - sqe testing
* - API change check
* - Pushing results to a repo?
* - ServiceWithSecurityManagerTest fails to complete when run from gradle.
* - Integrate Parfait reports for C code
* - FXML Project tests are not running
*
* Adding a new project or task:
* - Fix for JDK-8297071, introduces a restriction on assigning name for a project or task.
* - If the name of project or task contains word test/Test then it is considered as test task.
* - If the name of a task contains word shim/Shim then it is considered as shims task.
* - See TEST_ONLY flag, isTestTask() method, the tasks: shims and sdk for more clarity.
*/
defaultTasks = ["sdk"]
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.util.concurrent.CountDownLatch
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Future
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
import java.lang.Runtime.Version
/******************************************************************************
* Utility methods *
*****************************************************************************/
/**
* If the given named property is not defined, then this method will define
* it with the given defaultValue. Any properties defined by this method can
* be substituted on the command line by using -P, or by specifying a
* gradle.properties file in the user home dir
*
* @param name The name of the property to define
* @param defaultValue The default value to assign the property
*/
void defineProperty(String name, String defaultValue) {
if (!project.hasProperty(name)) {
project.ext.set(name, defaultValue);
}
}
/**
* If the given named property is not defined, then this method will attempt to
* look up the property in the props map, and use the defaultValue if it cannot be found.
*
* @param name The name of the property to look up and/or define
* @param props The properties to look for the named property in, if it has not already been defined
* @param defaultValue The default value if the property has not been defined and the
* props map does not contain the named property
*/
void defineProperty(String name, Properties props, String defaultValue) {
if (!project.hasProperty(name)) {
project.ext.set(name, props.getProperty(name, defaultValue));
}
}
/**
* Converts cygwin style paths to windows style paths, but with a forward slash.
* This method is safe to call from any platform, and will only do work if
* called on Windows (in all other cases it simply returns the supplied path.
*
* @param path the path to convert
* @return the path converted to windows style, if on windows, otherwise it
* is the supplied path.
*/
String cygpath(String path) {
if (!IS_WINDOWS) return path;
if (path == null || "".equals(path)) return path;
String ret = path.replaceAll('\\\\', '/')
logger.info("Converting path '$path' via cygpath to "+ret)
return ret
}
/**
* Converts cygwin file paths for java executables to windows style
* executable paths by changing forward slashes to back slashes and
* adding the '.exe' extension.
* This method is safe to call from any platform, and will only do work if
* called on Windows (in all other cases it simply returns the supplied path).
*
* @param path the path to convert
* @return the path converted to windows style, if on windows, otherwise it
* is the supplied path.
*/
String cygpathExe(String path) {
if (!IS_WINDOWS) return path;
if (path == null || "".equals(path)) return path;
String ret = path.replaceAll('/', '\\\\')
logger.info("Converting path '$path' via cygpath to "+ret)
return ret + ".exe"
}
void loadProperties(String sourceFileName) {
def config = new Properties()
def propFile = new File(sourceFileName)
if (propFile.canRead()) {
config.load(new FileInputStream(propFile))
for (java.util.Map.Entry property in config) {
def keySplit = property.key.split("\\.");
def key = keySplit[0];
for (int i = 1; i < keySplit.length; i++) {
key = key + keySplit[i].capitalize();
}
ext[key] = property.value;
}
}
}
/**
* Struct used to contain some information passed to the closure
* passed to compileTargets.
*/
class CompileTarget {
String name;
String upper;
String capital;
}
/**
* Iterates over each of the compile targets, passing the given closure
* a CompileTarget instance.
*
* @param c The closure to call
*/
void compileTargets(Closure c) {
if (COMPILE_TARGETS == "") {
return
}
COMPILE_TARGETS.split(",").each { target ->
CompileTarget ct = new CompileTarget();
ct.name = target;
ct.upper = target.trim().toUpperCase(Locale.ROOT)
ct.capital = target.trim().capitalize()
c(ct)
}
}
/**
* Manages the execution of some closure which is responsible for producing
* content for a properties file built at build time and stored in the
* root project's $buildDir, and then loading that properties file and
* passing it to the processor closure.
*
* This is used on windows to produce a properties file containing all the
* windows visual studio paths and environment variables, and on Linux
* for storing the results of pkg-config calls.
*
* @param name the name of the file to produce
* @param loader a closure which is invoked, given the properties file. This
* closure is invoked only if the properties file needs to be created
* and is responsible for populating the properties file.
* @param processor a closure which is invoked every time this method is
* called and which will be given a Properties object, fully populated.
* The processor is then responsible for doing whatever it is that it
* must do with those properties (such as setting up environment
* variables used in subsequent native builds, or whatnot).
*/
void setupTools(String name, Closure loader, Closure processor) {
// Check to see whether $buildDir/$name.properties file exists. If not,
// then generate it. Once generated, we need to read the properties file to
// help us define the defaults for this block of properties
File propFile = file("$buildDir/${name}.properties");
if (!propFile.exists() || propFile.length() == 0) {
// Create the properties file
propFile.getParentFile().mkdirs();
propFile.createNewFile();
loader(propFile);
}
// Try reading the properties in order to define the properties. If the property file cannot
// be located, then we will throw an exception because we cannot guess these values
InputStream propStream = null;
try {
Properties properties = new Properties();
propStream = new FileInputStream(propFile);
properties.load(propStream);
processor(properties);
} finally {
try { propStream.close() } catch (Exception e) { }
}
}
/**
* Fails the build with the specified error message
*
* @param msg the reason for the failure
*/
void fail(String msg) {
throw new GradleException("FAIL: " + msg);
}
/**
* Rewrites the ZIP or JAR archive, setting the timestamp of each entry to
* the local date and time in UTC of the instant provided.
*
* Note that using the method 'eachFile(Closure)' of the Zip Task for this
* purpose fails to modify the JAR entries for META-INF and MANIFEST.MF
* because the manifest file is generated by Gradle instead of copied.
*
* Also note that the ZIP format has no notion of time zone. The UTC date
* and time can be set in optional extra fields, but only in addition to
* the local "MS-DOS date and time." To avoid depending on the time zone
* of the build machine, this method provides the local date and time in
* UTC by calling 'setTimeLocal(LocalDateTime)'.
*
* An alternative solution is to set the default time zone of the
* JVM temporarily to UTC while providing the UTC date and time with
* 'setLastModifiedTime(FileTime)'. This solution stores the precise instant
* on the time-line, but it also increases the size of the archive by adding
* an extra Extended Timestamp field for each entry.
*
* @param archive the ZIP or JAR archive file to rewrite
* @param instant the instant for the timestamp of each entry
*/
void setFileTimestamps(Provider<RegularFile> archive, Instant instant) {
def dosTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC)
def oldFile = archive.get().getAsFile()
def zipFile = new ZipFile(oldFile)
def newName = oldFile.getName() + ".new"
def newFile = new File(oldFile.getParentFile(), newName)
def output = new ZipOutputStream(new FileOutputStream(newFile))
zipFile.entries().each { ZipEntry entry ->
def clone = new ZipEntry(entry)
def input = zipFile.getInputStream(entry)
clone.setTimeLocal(dosTime)
output.putNextEntry(clone)
input.transferTo(output)
output.closeEntry()
input.close()
}
output.close()
zipFile.close()
Files.move(newFile.toPath(), oldFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
}
/******************************************************************************
* *
* Definition of project properties *
* *
* All properties defined using ext. are immediately available throughout *
* the script as variables that can be used. These variables are attached *
* to the root project (whereas if they were defined as def variables then *
* they would only be available within the root project scope). *
* *
* All properties defined using the "defineProperty" method can be replaced *
* on the command line by using the -P flag. For example, to override the *
* location of the binary plug, you would specify -PBINARY_PLUG=some/where *
* *
*****************************************************************************/
loadProperties("$projectDir/build.properties")
// If the ../rt-closed directory exists, then we are doing a closed build.
// In this case, build and property files will be read from
// ../rt-closed/closed-build.gradle and ../rt-closed/closed-properties.gradle
// respectively
def closedDir = file("../rt-closed")
def buildClosed = closedDir.isDirectory()
ext.BUILD_CLOSED = buildClosed
ext.RUNARGSFILE = "run.args"
ext.COMPILEARGSFILE = "compile.args"
ext.TESTCOMPILEARGSFILE = "testcompile.args"
ext.TESTRUNARGSFILE = "testrun.args"
// the file containing "extra" --add-exports
ext.EXTRAADDEXPORTS = 'buildSrc/addExports'
ext.MODULESOURCEPATH = "modulesourcepath.args"
// These variables indicate what platform is running the build. Is
// this build running on a Mac, Windows, or Linux machine? 32 or 64 bit?
ext.OS_NAME = System.getProperty("os.name").toLowerCase()
ext.OS_ARCH = System.getProperty("os.arch")
ext.ARCH_NAME = "x64"
ext.IS_64 = OS_ARCH.toLowerCase().contains("64")
ext.IS_AARCH64 = OS_ARCH.toLowerCase().contains("aarch64")
ext.IS_LOONGARCH64 = OS_ARCH.toLowerCase().contains("loongarch64")
ext.IS_RISCV64 = OS_ARCH.toLowerCase().contains("riscv64")
ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin")
ext.IS_WINDOWS = OS_NAME.contains("windows")
ext.IS_LINUX = OS_NAME.contains("linux")
ext.MAVEN_GROUP_ID = "org.openjfx"
// Enable native access from modules with native code
ext.enableNativeGraphics='--enable-native-access=javafx.graphics'
ext.enableNativeAll='--enable-native-access=javafx.graphics,javafx.media,javafx.web'
// FIXME: Remove this when JDK-8334137 is fixed
ext.allowSunMiscUnsafe = '--sun-misc-unsafe-memory-access=allow'
// Verify that the architecture & OS are supported configurations. Note that
// at present building on PI is not supported, but we would only need to make
// some changes on assumptions on what should be built (like SWT / Swing) and
// such and we could probably make it work.
if (!IS_MAC && !IS_WINDOWS && !IS_LINUX) fail("Unsupported build OS ${OS_NAME}")
if (IS_WINDOWS && OS_ARCH != "x86" && OS_ARCH != "amd64" && !IS_AARCH64) {
logger.warn("Unknown and unsupported build architecture: $OS_ARCH")
} else if (IS_MAC && OS_ARCH != "x86_64" && OS_ARCH != "aarch64") {
logger.warn("Unknown and unsupported build architecture: $OS_ARCH")
} else if (IS_LINUX && OS_ARCH != "i386" && OS_ARCH != "amd64" && !IS_AARCH64 && !IS_LOONGARCH64 && !IS_RISCV64) {
logger.warn("Unknown and unsupported build architecture: $OS_ARCH")
}
if (IS_64) {
if (IS_AARCH64) {
ARCH_NAME = "aarch64"
} else if (IS_LOONGARCH64) {
ARCH_NAME = "loongarch64"
} else if (IS_RISCV64) {
ARCH_NAME = "riscv64"
} else {
ARCH_NAME = "x64"
}
} else {
ARCH_NAME = "x32"
}
// Get the JDK_HOME automatically based on the version of Java used to execute gradle. Or, if specified,
// use a user supplied JDK_HOME, STUB_RUNTIME, JAVAC, all of which may be specified
// independently (or we'll try to get the right one based on other supplied info). Sometimes the
// JRE might be the thing that is being used instead of the JRE embedded in the JDK, such as:
// c:\Program Files (x86)\Java\jdk1.8.0\jre
// c:\Program Files (x86)\Java\jre8\
// Because of this, you may sometimes get the jdk's JRE (in which case the logic we used to have here
// was correct and consistent with all other platforms), or it might be the standalone JRE (for the love!).
def envJavaHome = cygpath(System.getenv("JDK_HOME"))
if (envJavaHome == null || envJavaHome.equals("")) envJavaHome = cygpath(System.getenv("JAVA_HOME"))
def javaHome = envJavaHome == null || envJavaHome.equals("") ? System.getProperty("java.home") : envJavaHome
def javaHomeFile = file(javaHome)
defineProperty("JDK_HOME",
javaHomeFile.name == "jre" ?
javaHomeFile.getParent().toString() :
javaHomeFile.name.startsWith("jre") ?
new File(javaHomeFile.getParent(), "jdk1.${javaHomeFile.name.substring(3)}.0").toString() :
javaHome) // we have to bail and set it to something and this is as good as any!
ext.JAVA_HOME = JDK_HOME
defineProperty("JAVA", cygpathExe("$JDK_HOME/bin/java"))
defineProperty("JAVAC", cygpathExe("$JDK_HOME/bin/javac"))
defineProperty("JAVADOC", cygpathExe("$JDK_HOME/bin/javadoc"))
defineProperty("JMOD", cygpathExe("$JDK_HOME/bin/jmod"))
defineProperty("JDK_DOCS", "https://docs.oracle.com/en/java/javase/${jdkDocsVersion}/docs/api/")
defineProperty("JDK_JMODS", cygpath(System.getenv("JDK_JMODS")) ?: cygpath(System.getenv("JDK_HOME") + "/jmods"))
defineProperty("libAVRepositoryURL", "https://github.com/libav/libav/archive")
defineProperty("FFmpegRepositoryURL", "https://www.ffmpeg.org/releases/")
defineProperty("icuRepositoryURL", "https://github.com/unicode-org/icu/releases/")
def supplementalPreBuildFile = file("$closedDir/closed-pre-build.gradle");
def supplementalBuildFile = file("$closedDir/closed-build.gradle");
if (BUILD_CLOSED) {
apply from: supplementalPreBuildFile
}
// GRADLE_VERSION_CHECK specifies whether to fail the build if the
// gradle version check fails
defineProperty("GRADLE_VERSION_CHECK", "true")
ext.IS_GRADLE_VERSION_CHECK = Boolean.parseBoolean(GRADLE_VERSION_CHECK)
// JAVA_TARGET_VERSION specifies the minimum compile and runtime Java version that we will target when building the JavaFX classes
ext.JAVA_TARGET_VERSION = Integer.parseInt(jfxJdkTargetVersion)
// JFX_DEPS_URL specifies the optional location of an alternate local repository
defineProperty("JFX_DEPS_URL", "")
// JDK_DOCS_LINK specifies the optional URL for offline javadoc linking
defineProperty("JDK_DOCS_LINK", "")
// COMPILE_WEBKIT specifies whether to build all of webkit.
defineProperty("COMPILE_WEBKIT", "false")
ext.IS_COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT)
// COMPILE_MEDIA specifies whether to build all of media.
defineProperty("COMPILE_MEDIA", "false")
ext.IS_COMPILE_MEDIA = Boolean.parseBoolean(COMPILE_MEDIA)
// BUILD_LIBAV_STUBS specifies whether to download and build libav/ffmpeg libraries
defineProperty("BUILD_LIBAV_STUBS", "false")
ext.IS_BUILD_LIBAV_STUBS = IS_LINUX ? Boolean.parseBoolean(BUILD_LIBAV_STUBS) : false
// BUILD_WORKING_LIBAV specifies whether to build libav/ffmpeg libraries with
// decoder, demuxer, etc. required to run media. Valid only if BUILD_LIBAV_STUBS is true.
defineProperty("BUILD_WORKING_LIBAV", "false")
ext.IS_BUILD_WORKING_LIBAV = IS_LINUX ? Boolean.parseBoolean(BUILD_WORKING_LIBAV) : false
// COMPILE_PANGO specifies whether to build javafx_font_pango.
defineProperty("COMPILE_PANGO", "${IS_LINUX}")
ext.IS_COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO)
// COMPILE_HARFBUZZ specifies whether to use Harfbuzz.
defineProperty("COMPILE_HARFBUZZ", "false")
ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ)
// COMPILE_PARFAIT specifies whether to build parfait
defineProperty("COMPILE_PARFAIT", "false")
ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)
defineProperty("STATIC_BUILD", "false")
ext.IS_STATIC_BUILD = Boolean.parseBoolean(STATIC_BUILD)
if (IS_STATIC_BUILD && IS_COMPILE_MEDIA) {
throw new GradleException("Can not have COMPILE_MEDIA when STATIC_BUILD is enabled");
}
// By default, target architecture = host architecture, but we allow different ones.
// On Apple Silicon, default architecture must be "arm64", because clang does not accept
// aarch64 as -arch parameter.
defineProperty("TARGET_ARCH", (IS_MAC && IS_AARCH64) ? "arm64" : OS_ARCH)
// BUILD_TOOLS_DOWNLOAD_SCRIPT specifies a path of a gradle script which downloads
// required build tools.
defineProperty("BUILD_TOOLS_DOWNLOAD_SCRIPT", "")
// Define the SWT.jar that we are going to have to download during the build process based
// on what platform we are compiling from (not based on our target).
ext.SWT_FILE_NAME =
IS_MAC && IS_AARCH64 ? "org.eclipse.swt.cocoa.macosx.aarch64_${swtVersion}" :
IS_MAC && !IS_AARCH64 ? "org.eclipse.swt.cocoa.macosx.x86_64_${swtVersion}" :
IS_WINDOWS ? "org.eclipse.swt.win32.win32.x86_64_${swtVersion}" :
IS_LINUX && IS_AARCH64 ? "org.eclipse.swt.gtk.linux.aarch64_${swtVersion}" :
IS_LINUX && !IS_AARCH64 ? "org.eclipse.swt.gtk.linux.x86_64_${swtVersion}" : ""
// Specifies whether to run full tests (true) or smoke tests (false)
defineProperty("FULL_TEST", "false")
ext.IS_FULL_TEST = Boolean.parseBoolean(FULL_TEST);
defineProperty("FORCE_TESTS", "false")
ext.IS_FORCE_TESTS = Boolean.parseBoolean(FORCE_TESTS);
// Specifies whether to run robot-based visual tests (only used when FULL_TEST is also enabled)
defineProperty("USE_ROBOT", "false")
ext.IS_USE_ROBOT = Boolean.parseBoolean(USE_ROBOT);
// Specified whether to run tests in headless mode
defineProperty("HEADLESS_TEST", "false")
ext.IS_HEADLESS_TEST = Boolean.parseBoolean(HEADLESS_TEST);
// Specifies whether to run system tests that depend on AWT (only used when FULL_TEST is also enabled)
defineProperty("AWT_TEST", "true")
ext.IS_AWT_TEST = Boolean.parseBoolean(AWT_TEST);
// Specifies whether to run system tests that depend on SWT (only used when FULL_TEST is also enabled)
defineProperty("SWT_TEST", "true")
ext.IS_SWT_TEST = Boolean.parseBoolean(SWT_TEST);
// Specifies whether to run unstable tests (true) - tests that don't run well with Hudson builds
// These tests should be protected with :
// assumeTrue(Boolean.getBoolean("unstable.test"));
defineProperty("UNSTABLE_TEST", "false")
ext.IS_UNSTABLE_TEST = Boolean.parseBoolean(UNSTABLE_TEST);
// Default timeout values to use in JUnit for tests and lifecycle methods
// that don't specify one
defineProperty("JUNIT_TEST_TIMEOUT", "120s")
defineProperty("JUNIT_LIFECYCLE_TIMEOUT", "20s")
// Toggle diagnostic output from the Gradle workaround and the Sandbox test apps.
defineProperty("WORKER_DEBUG", "false")
ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG);
// Specify the build configuration (Release, Debug, or DebugNative)
defineProperty("CONF", "Debug")
ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative"
ext.IS_DEBUG_NATIVE = CONF == "DebugNative"
ext.IS_RELEASE = !ext.IS_DEBUG_JAVA
// Specifies whether to enable the Maven publishing tasks
defineProperty("MAVEN_PUBLISH", "false")
ext.IS_MAVEN_PUBLISH = Boolean.parseBoolean(MAVEN_PUBLISH)
// Define the compiler lint warnings to enable.
//
// We define a separate set of options for normal classes, test classes
// (including shims), and tool classes (including JSLC).
// A project (module) can add project-specific lint options for each
// category if desired.
// extraLintOptions
// extraToolLintOptions
// extraTestLintOptions
//
// The lint options can be overriden on the command line. If set to the
// empty string, then no lint warnings are enabled; even project-specific
// lint options are disabled. If not empty, then it is parsed as a space
// or comma separated list of names. See the javac documentation for a list
// of valid lint options.
def defaultLintOptions =
"removal" + "," +
"missing-explicit-ctor"
defineProperty("LINT", defaultLintOptions)
ext.IS_LINT = LINT != ""
def defaultToolLintOptions = ""
defineProperty("TOOL_LINT", defaultToolLintOptions)
ext.IS_TOOL_LINT = TOOL_LINT != ""
def defaultTestLintOptions =
"-options" + "," +
"removal"
defineProperty("TEST_LINT", defaultTestLintOptions)
ext.IS_TEST_LINT = TEST_LINT != ""
defineProperty("JAVAC_WERROR", "true")
ext.IS_JAVAC_WERROR = Boolean.parseBoolean(JAVAC_WERROR)
defineProperty("TOOL_JAVAC_WERROR", "false")
ext.IS_TOOL_JAVAC_WERROR = Boolean.parseBoolean(TOOL_JAVAC_WERROR)
defineProperty("TEST_JAVAC_WERROR", "true")
ext.IS_TEST_JAVAC_WERROR = Boolean.parseBoolean(TEST_JAVAC_WERROR)
// Doclint options (all enabled by default)
defineProperty("DOC_LINT", "all")
ext.IS_DOC_LINT = DOC_LINT != ""
defineProperty("DOC_WERROR", "true")
ext.IS_DOC_WERROR = Boolean.parseBoolean(DOC_WERROR)
// Specifies whether to use the "useDepend" option when compiling Java sources
defineProperty("USE_DEPEND", "true")
ext.IS_USE_DEPEND = Boolean.parseBoolean(USE_DEPEND)
// Specifies whether to use the "incremental" option when compiling Java sources
defineProperty("INCREMENTAL", "false")
ext.IS_INCREMENTAL = Boolean.parseBoolean(INCREMENTAL)
// Specifies whether to include the Null3D pipeline (for perf debugging)
defineProperty("INCLUDE_NULL3D", "false")
ext.IS_INCLUDE_NULL3D = Boolean.parseBoolean(INCLUDE_NULL3D)
// Specifies whether to include the ES2 pipeline if available
defineProperty("INCLUDE_ES2", IS_WINDOWS ? "false" : "true")
ext.IS_INCLUDE_ES2 = Boolean.parseBoolean(INCLUDE_ES2)
// Specifies whether to generate code coverage statistics when running tests
defineProperty("JCOV", "false")
ext.DO_JCOV = Boolean.parseBoolean(JCOV)
// Specifies whether to use Cygwin when building OpenJFX. This should only ever
// be set to false for development builds (that skip building media and webkit).
defineProperty("USE_CYGWIN", "true")
ext.IS_USE_CYGWIN = Boolean.parseBoolean(USE_CYGWIN)
// Define the number of threads to use when compiling (specifically for native compilation, including webkit)
defineProperty("NUM_COMPILE_THREADS", "${Runtime.runtime.availableProcessors()}")
//
// The next three sections of properties are used to generate the
// VersionInfo class, and the Windows DLL manifest.
//
// The following properties should be left alone by developers and set only from Hudson.
defineProperty("HUDSON_JOB_NAME", "not_hudson")
defineProperty("HUDSON_BUILD_NUMBER","0000")
defineProperty("PROMOTED_BUILD_NUMBER", "0")
defineProperty("MILESTONE_FCS", "false")
ext.IS_MILESTONE_FCS = Boolean.parseBoolean(MILESTONE_FCS)
// The following properties define the product name for Oracle JDK and OpenJDK
// for VersionInfo and the DLL manifest.
if (BUILD_CLOSED) {
defineProperty("PRODUCT_NAME", "Java(TM)")
defineProperty("COMPANY_NAME", "Oracle Corporation")
defineProperty("PLATFORM_NAME", "Platform SE")
} else {
defineProperty("PRODUCT_NAME", "OpenJFX")
defineProperty("COMPANY_NAME", "N/A")
defineProperty("PLATFORM_NAME", "Platform")
}
// The following properties are set based on properties defined in
// build.properties. The release version and suffix should be updated
// in that file.
def relVer = 0
if (jfxReleasePatchVersion == "0") {
if (jfxReleaseSecurityVersion == "0") {
if (jfxReleaseMinorVersion == "0") {
relVer = "${jfxReleaseMajorVersion}"
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}"
}
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}"
}
} else {
relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}"
}
defineProperty("RELEASE_VERSION", relVer)
defineProperty("RELEASE_VERSION_PADDED", "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}")
def buildInstant = Instant.now().truncatedTo(ChronoUnit.SECONDS)
def sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH")
if (sourceDateEpoch != null) {
def epochSeconds = Long.parseLong(sourceDateEpoch)
buildInstant = Instant.ofEpochSecond(epochSeconds)
}
// Creates the timestamp in UTC using the ISO 8601 extended format.
def extendedTimestamp = buildInstant.toString()
// Creates the timestamp in UTC using the historical ad hoc format, which is
// valid for the OPT field of the version string. An alternative to the ad hoc
// format is the ISO 8601 basic format with the pattern "yyyyMMdd'T'HHmmssX".
def zonedTime = ZonedDateTime.ofInstant(buildInstant, ZoneOffset.UTC)
def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmmss")
def buildTimestamp = zonedTime.format(formatter)
defineProperty("BUILD_TIMESTAMP", buildTimestamp)
def relSuffix = ""
def relOpt = ""
if (HUDSON_JOB_NAME == "not_hudson") {
relSuffix = "-internal"
relOpt = "-${buildTimestamp}"
} else {
if (IS_MILESTONE_FCS) {
if (jfxExperimentalFeatureName != "") {
fail("An experimental feature branch should not be used for FCS build")
}
relSuffix = ""
} else {
if (jfxExperimentalFeatureName != "") {
relSuffix = "-${jfxExperimentalFeatureName}"
relOpt = "-${buildTimestamp}"
} else {
relSuffix = jfxReleaseSuffix
}
}
}
defineProperty("RELEASE_SUFFIX", relSuffix)
defineProperty("RELEASE_VERSION_SHORT", "${RELEASE_VERSION}${RELEASE_SUFFIX}")
defineProperty("RELEASE_VERSION_LONG", "${RELEASE_VERSION_SHORT}+${PROMOTED_BUILD_NUMBER}${relOpt}")
defineProperty("MAVEN_VERSION", IS_MAVEN_PUBLISH ? (IS_MILESTONE_FCS ? "${RELEASE_VERSION_SHORT}" : "${RELEASE_VERSION_LONG}") : "")
// Check whether the COMPILE_TARGETS property has been specified (if so, it was done by
// the user and not by this script). If it has not been defined then default
// to building the normal desktop build for this machine
project.ext.set("defaultHostTarget", IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : "");
defineProperty("COMPILE_TARGETS", "$defaultHostTarget")
// Flag indicating whether to import cross compile tools
def importCrossTools = false
if (hasProperty("IMPORT_CROSS_TOOLS")) {
importCrossTools = Boolean.parseBoolean(IMPORT_CROSS_TOOLS);
}
ext.IS_IMPORT_CROSS_TOOLS = importCrossTools
// Location of the cross compile tools
def crossToolsDir = "../crosslibs"
if (hasProperty("CROSS_TOOLS_DIR")) {
crossToolsDir = CROSS_TOOLS_DIR
}
ext.CROSS_TOOLS_DIR = file(crossToolsDir)
// For backward compatibility, -PBUILD_SDK_FOR_TEST=false will set TEST_ONLY to true
defineProperty("BUILD_SDK_FOR_TEST", "true")
def buildSdkForTest = Boolean.parseBoolean(BUILD_SDK_FOR_TEST)
// Specifies whether to run only test tasks using the already built javafx.* modules
// and shim classes, instead of rebuilding them.
// If true, then all non test tasks, except verifyJava are disabled. see task sdk and isTestTask method.
defineProperty("TEST_ONLY", "false")
ext.IS_TEST_ONLY = Boolean.parseBoolean(TEST_ONLY) || !buildSdkForTest
ext.IS_TEST_SDK = false
if (hasProperty("TEST_SDK_PATH")) {
if (!IS_TEST_ONLY) {
fail("TEST_ONLY must be set to true when using an external TEST_SDK_PATH for running tests: include -PTEST_ONLY=true")
}
def sdkShimsPath = file("${TEST_SDK_PATH}")
def sdkPath = file("${TEST_SDK_PATH}/sdk")
def shimsPath = file("${TEST_SDK_PATH}/shims")
if (!sdkShimsPath.exists() || !sdkShimsPath.isDirectory() ||
!sdkPath.exists() || !sdkPath.isDirectory() ||
!shimsPath.exists() || !shimsPath.isDirectory()) {
fail("The provided TEST_SDK_PATH=${TEST_SDK_PATH} is invalid")
}
ext.IS_TEST_SDK = true
} else {
defineProperty("TEST_SDK_PATH", "${rootProject.buildDir}")
}
// Make sure JDK_HOME/bin/java exists
if (!file(JAVA).exists()) throw new Exception("Missing or incorrect path to 'java': '$JAVA'. Perhaps bad JDK_HOME? $JDK_HOME")
if (!file(JAVAC).exists()) throw new Exception("Missing or incorrect path to 'javac': '$JAVAC'. Perhaps bad JDK_HOME? $JDK_HOME")
if (!file(JAVADOC).exists()) throw new Exception("Missing or incorrect path to 'javadoc': '$JAVADOC'. Perhaps bad JDK_HOME? $JDK_HOME")
// Determine the verion of Java in JDK_HOME. It looks like this:
//
// $ java -version
// java version "1.7.0_45"
// Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
// Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
//
// We need to parse the second line
Version jdkVersionInfo;
try (BufferedReader inStream = new java.io.BufferedReader(new java.io.InputStreamReader(
new java.lang.ProcessBuilder(JAVA, "-fullversion").start().getErrorStream()))) {
String v = inStream.readLine().trim();
if (v != null) {
int ib = v.indexOf("full version \"");
if (ib != -1) {
String str = v.substring(ib);
String ver = str.substring(str.indexOf("\"") + 1, str.size() - 1);
jdkVersionInfo = Version.parse(ver);
// Define global properties based on the version of Java
// For example, we could define a "jdk18OrLater" property as
// follows that could then be used to implement conditional build
// logic based on whether we were running on JDK 18 or later,
// should the need arise.
// ext.jdk18OrLater = jdkVersionInfo.feature() >= 18
ext.jdk24OrLater = jdkVersionInfo.feature() >= 24
}
}
}
if (jdkVersionInfo == null) throw new Exception("Unable to determine the version of Java in JDK_HOME at $JDK_HOME");
// Use --upgrade-module-path instead of --module-path when compiling and
// running tests if we are using a JDK that includes an upgradable
// jdk.jsobject module. Currently, this is JDK 24 or later. Once
// jdk.jsobject is removed from the JDK, we can stop doing it. For example,
// if jdk.jsobject is removed from the JDK in JDK 26, the logic will then be
// changed to: "jdk24OrLater && !jdk26OrLater"
ext.USE_UPGRADE_MODULE_PATH = jdk24OrLater
// Determine whether the javafx.* modules are present in the JDK. To do this,
// we will execute "java --list-modules" and search for javafx.base.
ext.HAS_JAVAFX_MODULES = false;
def inStream2 = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA, "--list-modules").start().getInputStream()));
try {
String v;
while ((v = inStream2.readLine()) != null) {
v = v.trim();
if (v.startsWith("javafx.base")) ext.HAS_JAVAFX_MODULES = true;
}
} finally {
inStream2.close();
}
// The HAS_JAVAFX_MODULES flag will be used to determine the mode for building
// and running the applications and tests.
// If HAS_JAVAFX_MODULES is true, then we will build / test javafx modules
// for exporting to a JDK build. If HAS_JAVAFX_MODULES is false, then we will
// build / test a standalone sdk for running with a JDK that does not include
// the javafx modules.
/**
* Fetch/Check that external tools are present for the build. This method
* will conditionally download the packages from project defined ivy repositories
* and unpack them into the specified destdir
*
* @param configName A unique name to distinguish the configuration (ie "ARMSFV6")
* @param packages A list of required packages (with extensions .tgz, .zip)
* @param destdir where the packages should be unpacked
* @param doFetch if true, the named packages will be download
*/
void fetchExternalTools(String configName, List packages, File destdir, boolean doFetch) {
if (doFetch) {
// create a unique configuration for this fetch
def String fetchToolsConfig = "fetchTools$configName"
rootProject.configurations.create(fetchToolsConfig)
def List<String> fetchedPackages = []
def int fetchCount = 0
packages.each { pkgname->
def int dotdex = pkgname.lastIndexOf('.')
def int dashdex = pkgname.lastIndexOf('-')
def String basename = pkgname.substring(0,dashdex)
def String ver = pkgname.substring(dashdex+1,dotdex)
def String ext = pkgname.substring(dotdex+1)
def File pkgdir = file("$destdir/$basename-$ver")
if (!pkgdir.isDirectory()) {
rootProject.dependencies.add(fetchToolsConfig, "javafx:$basename:$ver", {
artifact {
name = basename
type = ext
}
})
println "adding $pkgname as a downloadable item did not find $pkgdir"
fetchedPackages.add(pkgname)
fetchCount++
}
}
//fetch all the missing packages
if (fetchedPackages.size() > 0) {
destdir.mkdirs()
logger.quiet "fetching missing packages $fetchedPackages"
copy {
from rootProject.configurations[fetchToolsConfig]
into destdir
}
// unpack the fetched packages
fetchedPackages.each { pkgname->
logger.quiet "expanding the package $pkgname"
def srcball = file("${destdir}/${pkgname}")
if (!srcball.exists()) {
throw new GradleException("Failed to fetch $pkgname");
}
def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
def File pkgdir = file("$destdir/$basename")
if (pkgname.endsWith(".tgz") || pkgname.endsWith("tar.gz")) {
if (IS_LINUX || IS_MAC) {
// use native tar to support symlinks
pkgdir.mkdirs()
exec {
workingDir pkgdir
commandLine "tar", "zxf", "${srcball}"
}
} else {
copy {
from tarTree(resources.gzip("${srcball}"))
into pkgdir
}
}
} else if (pkgname.endsWith(".zip")) {
copy {
from zipTree("${srcball}")
into pkgdir
}
} else {
throw new GradleException("Unhandled package type for compile package ${pkgname}")
}
srcball.delete();
}
} else {
logger.quiet "all tool packages are present $packages"
}
} else { // !doFetch - so just check they are present
// check that all the dirs are really there
def List<String> errors = []
packages.each { pkgname->
def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
def File pkgdir = file("$destdir/$basename")
if (!pkgdir.isDirectory()) {
errors.add(pkgname)
}
}
if (errors.size() > 0) {
throw new GradleException("Error: missing tool packages: $errors")
} else {
logger.quiet "all tool packages are present $packages"
}
}
}
// Make a forked ANT call.
// This needs to be forked so that ant can be used with the right JDK and updated modules
// for testing obscure things like packaging of apps
void ant(String conf, // platform configuration
String dir, // directory to run from
String target, // ant target
List<String> params // parameters (usually -Dxxx=yyy)
) {
// Try to use ANT_HOME
String antHomeEnv = System.getenv("ANT_HOME")
String antHome = antHomeEnv != null ? cygpath(antHomeEnv) : null;
String ant = (antHome != null && !antHome.equals("")) ? "$antHome/bin/ant" : "ant";
List<String> cmdArgs = new ArrayList<String>()
if (IS_WINDOWS) {
cmdArgs += !ant.matches("\\s+") ? '"' + ant + '"' : ant
}
cmdArgs += "-Dbuild.compiler=javac1.7"
if ((conf != null) && !rootProject.defaultHostTarget.equals(conf)) {
def targetProperties = rootProject.ext[conf.trim().toUpperCase()]
cmdArgs += "-Dcross.platform=$conf"
if (targetProperties.containsKey('arch')) {
cmdArgs += "-Dcross.platform.arch=${targetProperties.arch}"
}
}
if (params != null) {
params.each() { s->
cmdArgs += IS_WINDOWS && !s.matches("\\s+") ? '"' + s + '"' : s
}
}
if (IS_MILESTONE_FCS) {
cmdArgs += '-Djfx.release.suffix=""'
}
cmdArgs += target
exec {
workingDir = dir
environment("JDK_HOME", JDK_HOME)
environment("JAVA_HOME", JDK_HOME)
if (IS_WINDOWS) {
environment([
"VCINSTALLDIR" : WINDOWS_VS_VCINSTALLDIR,
"VSINSTALLDIR" : WINDOWS_VS_VSINSTALLDIR,
"DEVENVDIR" : WINDOWS_VS_DEVENVDIR,
"MSVCDIR" : WINDOWS_VS_MSVCDIR,
"INCLUDE" : WINDOWS_VS_INCLUDE,
"LIB" : WINDOWS_VS_LIB,
"LIBPATH" : WINDOWS_VS_LIBPATH,
"PATH" : WINDOWS_VS_PATH
]);
commandLine "cmd", "/s", "/c", '"' + String.join(" ", cmdArgs) + '"'
} else {
commandLine ant
args(cmdArgs)
}
}
}
List<String> computeLibraryPath(boolean working) {
List<String> lp = []
if (HAS_JAVAFX_MODULES) {
List<String> modsWithNative = [ 'javafx.graphics', 'javafx.media', 'javafx.web' ]
// the build/modular-sdk area
def platformPrefix = ""
def bundledSdkDirName = "${platformPrefix}modular-sdk"
def bundledSdkDir = "${rootProject.buildDir}/${bundledSdkDirName}"
def modulesLibsDir = "${bundledSdkDir}/modules_libs"
modsWithNative.each() { m ->
lp << cygpath("${modulesLibsDir}/${m}")
}
} else {
def platformPrefix = ""
def standaloneSdkDirName = "${platformPrefix}sdk"
def standaloneSdkDir = "${TEST_SDK_PATH}/${standaloneSdkDirName}"
def modulesLibName = IS_WINDOWS ? "bin" : "lib"
def modulesLibsDir = "${standaloneSdkDir}/${modulesLibName}"
lp << cygpath("${modulesLibsDir}")
}