Skip to content

Commit 869ea40

Browse files
jskovJohan Vos
authored and
Johan Vos
committed
8244212: Optionally download media and webkit libraries from latest openjfx EA build
Reviewed-by: kcr, jvos
1 parent 62f8cee commit 869ea40

File tree

2 files changed

+103
-9
lines changed

2 files changed

+103
-9
lines changed

WEBKIT-MEDIA-STUBS.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Web Testing
2+
3+
The web project needs WebKit and Media shared libraries to run tests.
4+
5+
These can be supplied in a number of ways. See sections below.
6+
7+
## Compiled from source
8+
9+
Specify these Gradle properties to enable building of WebKit and Media libraries from source:
10+
11+
-PCOMPILE_WEBKIT=true -PCOMPILE_MEDIA=true
12+
13+
Note that these require additional build tooling and take some time to build.
14+
15+
If you are not actively working on these sources, you may want to cache the output by copying it to one of the folders mentioned below.
16+
17+
18+
## Cached libraries
19+
20+
You can manually place WebKit and Media shared libraries in these folders:
21+
22+
* Unix libraries (*.so or *.dylib files)
23+
````
24+
$projectDir/../caches/sdk/lib
25+
````
26+
27+
* Windows libraries (*.dll files)
28+
````
29+
$projectDir/../caches/sdk/bin
30+
````
31+
32+
## Officially released libraries
33+
34+
Gradle has a task to automate downloading officially released libraries from MavenCentral.
35+
36+
You can enable the task by specifying this Gradle property:
37+
38+
-PSTUB_RUNTIME_OPENJFX="15-ea+4"
39+
40+
Note that these libraries may not be compatible with the source tree you are working with. Always use the [latest version](https://search.maven.org/search?q=g:org.openjfx%20AND%20a:javafx); this may improve your chances of compatibility.
41+
42+
43+
## Skip Web tests
44+
45+
You can also skip the web module tests.
46+
47+
Specify these options to Gradle
48+
49+
-x :web:test
50+
51+
Note that this is fine for local work. But a full test *is* required before submitting a PR, see [CONTRIBUTING.md](https://github.com/openjdk/jfx/blob/master/CONTRIBUTING.md).

build.gradle

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,9 +1249,15 @@ if (gradle.gradleVersion != jfxGradleVersion) {
12491249

12501250
// Look for stub runtime in bundled sdk, standalone sdk, or boot JDK
12511251

1252+
// Allows automatic provisioning of webkit+media shared libraries
1253+
// from official OpenJFX releases, downloaded from MavenCentral
1254+
defineProperty("STUB_RUNTIME_OPENJFX", "")
1255+
ext.IS_STUB_RUNTIME_OPENJFX = !STUB_RUNTIME_OPENJFX.isBlank()
1256+
12521257
def String cachedBundledRuntime = cygpath("$projectDir") + "/../caches/modular-sdk"
12531258
def String cachedStandaloneRuntime = cygpath("$projectDir") + "/../caches/sdk"
12541259
def String jdkStubRuntime = cygpath("$JDK_HOME")
1260+
def String openjfxStubRuntime = cygpath("$projectDir") + "/buildSrc/build/openjfxStub"
12551261

12561262
def defaultStubRuntime = ""
12571263
if (file(cachedBundledRuntime).exists()) {
@@ -1260,6 +1266,8 @@ if (file(cachedBundledRuntime).exists()) {
12601266
defaultStubRuntime = cachedStandaloneRuntime
12611267
} else if (BUILD_CLOSED) {
12621268
defaultStubRuntime = cachedBundledRuntime
1269+
} else if (IS_STUB_RUNTIME_OPENJFX) {
1270+
defaultStubRuntime = openjfxStubRuntime
12631271
} else {
12641272
defaultStubRuntime = jdkStubRuntime
12651273
}
@@ -3373,16 +3381,21 @@ project(":web") {
33733381

33743382
test {
33753383
doFirst {
3376-
if (!IS_COMPILE_WEBKIT) {
3377-
println "*****************************************************"
3384+
if (IS_STUB_RUNTIME_OPENJFX) {
3385+
println "********************************************************"
3386+
println "WARNING: running web tests with officially built webkit."
3387+
println "The webkit native library may not be compatible with the"
3388+
println "source tree you are using."
3389+
println "If tests fail, try compiling webkit instead."
3390+
println "See WEBKIT-MEDIA-STUBS.md"
3391+
println "********************************************************"
3392+
} else if (!IS_COMPILE_WEBKIT) {
3393+
println "******************************************************"
33783394
println "WARNING: running web tests without building webkit."
33793395
println "The webkit native library will be copied from the JDK,"
33803396
println "which might lead to failures in some web tests."
3381-
println "To avoid these failures, you should either build"
3382-
println "webkit locally, copy the native webkit library from a"
3383-
println "recent build, or skip execution of web test cases with"
3384-
println "'-x :web:test'"
3385-
println "*****************************************************"
3397+
println "See WEBKIT-MEDIA-STUBS.md"
3398+
println "******************************************************"
33863399
}
33873400
}
33883401
// Run web tests in headless mode
@@ -4321,6 +4334,36 @@ compileTargets { t ->
43214334
}
43224335

43234336

4337+
/******************************************************************************
4338+
* *
4339+
* OpenJFX Stubs *
4340+
* *
4341+
*****************************************************************************/
4342+
4343+
configurations {
4344+
openjfxStubs
4345+
}
4346+
4347+
if (IS_STUB_RUNTIME_OPENJFX) {
4348+
def String platform = IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : ""
4349+
dependencies {
4350+
openjfxStubs "org.openjfx:javafx-media:$STUB_RUNTIME_OPENJFX:$platform@jar"
4351+
openjfxStubs "org.openjfx:javafx-web:$STUB_RUNTIME_OPENJFX:$platform@jar"
4352+
}
4353+
}
4354+
4355+
// Extract binary libraries from OpenJFX artifacts for use as stubs
4356+
task prepOpenJfxStubs(type: Copy) {
4357+
enabled = IS_STUB_RUNTIME_OPENJFX
4358+
4359+
from configurations.openjfxStubs.files.collect { zipTree(it) }
4360+
include("*.dll")
4361+
include("*.dylib")
4362+
include("*.so")
4363+
into IS_WINDOWS ? file("$openjfxStubRuntime/bin") : file("$openjfxStubRuntime/lib")
4364+
}
4365+
4366+
43244367
/******************************************************************************
43254368
* *
43264369
* Modules *
@@ -4915,7 +4958,7 @@ compileTargets { t ->
49154958
}
49164959
}
49174960

4918-
def buildModuleMediaTask = task("buildModuleMedia$t.capital", type: Copy, dependsOn: mediaProject.assemble) {
4961+
def buildModuleMediaTask = task("buildModuleMedia$t.capital", type: Copy, dependsOn: [mediaProject.assemble, prepOpenJfxStubs]) {
49194962
group = "Basic"
49204963
description = "copies javafx.media native libraries"
49214964

@@ -4952,7 +4995,7 @@ compileTargets { t ->
49524995
}
49534996
}
49544997

4955-
def buildModuleWeb = task("buildModuleWeb$t.capital", type: Copy, dependsOn: webProject.assemble) {
4998+
def buildModuleWeb = task("buildModuleWeb$t.capital", type: Copy, dependsOn: [webProject.assemble, prepOpenJfxStubs]) {
49564999
group = "Basic"
49575000
description = "copies javafx.web native libraries"
49585001

0 commit comments

Comments
 (0)