Skip to content

Commit b0099a6

Browse files
authored
Merge pull request #6 from CodeBrig/version-69
macOS support + variable CEF native version
2 parents 97b02bc + 85315c2 commit b0099a6

17 files changed

Lines changed: 778 additions & 192 deletions

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ matrix:
44
include:
55
- os: linux
66
dist: trusty
7-
# - os: osx
8-
# osx_image: xcode9.3
7+
- os: osx
8+
osx_image: xcode9.3
99

1010
before_install:
1111
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ant ; fi
12+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install adoptopenjdk/openjdk/adoptopenjdk8 && java -version ; fi
1213

1314
before_script:
1415
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./setup_native_linux.sh ; fi
16+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./setup_native_mac.sh ; fi
1517

1618
script:
1719
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./build_native_linux.sh && ./gradlew build -x test ; fi
@@ -21,8 +23,9 @@ deploy:
2123
provider: releases
2224
api_key: $GH_TOKEN
2325
file:
24-
- /home/travis/build/CodeBrig/Journey/build/libs/journey-browser-0.1.1.jar
26+
- /home/travis/build/CodeBrig/Journey/build/libs/journey-browser-0.2.16.jar
2527
- /home/travis/build/CodeBrig/Journey/jcef/binary_distrib/jcef-distrib-linux64.zip
28+
- /Users/travis/build/CodeBrig/Journey/jcef/binary_distrib/jcef-distrib-macintosh64.zip
2629
skip_cleanup: true
2730
on:
2831
tags: true

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Issues/PRs are welcome for increasing the capability of Journey to be on par wit
1010

1111
### Features
1212
- Linux (64bit) support
13+
- macOS (64bit) support
1314
- Windows (32bit/64bit) support
1415
- Release distributions (CDN via GitHub)
1516
- Online/offline CEF native file access
@@ -25,10 +26,10 @@ repositories {
2526
}
2627
2728
dependencies {
28-
compile 'com.github.codebrig:journey:0.1.1-online'
29-
30-
//or use the offline version (includes native CEF files for all platforms)
31-
//compile 'com.github.codebrig:journey:0.1.1-offline'
29+
compile 'com.github.codebrig:journey:0.2.16-online'
30+
31+
//or use the offline version (includes native CEF files for all platforms; ~300MB)
32+
//compile 'com.github.codebrig:journey:0.2.16-offline'
3233
}
3334
```
3435

@@ -45,10 +46,10 @@ dependencies {
4546
<dependency>
4647
<groupId>com.github.codebrig</groupId>
4748
<artifactId>journey</artifactId>
48-
<version>0.1.1-online</version>
49-
50-
<!-- or use the offline version (includes native CEF files for all platforms) -->
51-
<!-- <version>0.1.1-offline</version> -->
49+
<version>0.2.16-online</version>
50+
51+
<!-- or use the offline version (includes native CEF files for all platforms; ~300MB) -->
52+
<!-- <version>0.2.16-offline</version> -->
5253
</dependency>
5354
```
5455

@@ -89,6 +90,7 @@ public class JourneyBrowser {
8990

9091
## Version Matrix
9192

92-
| Build Date | Journey Version | JCEF Version | JCEF Commit |
93-
|------------|------------------|--------------|------------------------------------------|
94-
| 2019-05-21 | 0.1.1 | 73.1.11.215 | [d348788e3347fa4d2a421773463f7dd62da60991](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) |
93+
| Build Date | Journey Version | JCEF Version (Linux) | JCEF Version (macOS) | JCEF Version (Windows) |
94+
|------------|------------------|----------------------|----------------------|----------------------|
95+
| 2019-06-10 | [0.2.16](https://github.com/CodeBrig/Journey/releases/tag/0.2.16-online) | [73.1.11.215](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) | [69.0.3497.100](https://bitbucket.org/chromiumembedded/java-cef/commits/235e3a844380b72761643324e1d9b7713cae3b63) | [73.1.11.215](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) |
96+
| 2019-05-21 | 0.1.1 | [73.1.11.215](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) | n/a | [73.1.11.215](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) |

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ deploy:
4949
draft: false
5050
prerelease: false
5151
on:
52-
branch: master
5352
APPVEYOR_REPO_TAG: true

build.gradle

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
apply plugin: 'java'
22

33
group 'com.codebrig'
4-
version '0.1.1'
4+
version '0.2.16'
55

66
sourceCompatibility = 1.8
7-
87
archivesBaseName = 'journey-browser'
98

109
ext {
11-
jcefVersion = '73.1.11.215'
12-
jcefCommit = 'd348788e3347fa4d2a421773463f7dd62da60991'
10+
projectUrl = 'https://github.com/CodeBrig/Journey'
11+
12+
jcefVersion = [
13+
'67': '67.0.3396.62',
14+
'69': '69.0.3497.100',
15+
'73': '73.1.11.215'
16+
]
17+
jcefCommit = [
18+
'67': '1fda5d8f948670d08ef86bc4e8637b8581995ce9',
19+
'69': '235e3a844380b72761643324e1d9b7713cae3b63',
20+
'73': 'd348788e3347fa4d2a421773463f7dd62da60991'
21+
]
1322
}
1423

1524
repositories {
1625
mavenCentral()
26+
repositories {
27+
maven { url 'https://jitpack.io' }
28+
}
1729
}
1830

1931
dependencies {
@@ -22,21 +34,25 @@ dependencies {
2234
compile fileTree(dir: 'jcef/binary_distrib/linux64/bin/', include: '*.jar')
2335
compile fileTree(dir: 'jcef/binary_distrib/win32/bin/', include: '*.jar')
2436
compile fileTree(dir: 'jcef/binary_distrib/win64/bin/', include: '*.jar')
37+
compile fileTree(dir: 'jcef/jcef_build/native/Release', include: '*.jar')
38+
compileOnly 'com.github.bfergerson:joor:9933e481b0'
2539
}
2640

2741
task createProperties(dependsOn: processResources) {
2842
doLast {
2943
def mode = "online"
30-
if ((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
31-
System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline")) {
32-
mode = "offline"
44+
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
45+
mode = System.getenv("TRAVIS_BRANCH").split("-")[2]
46+
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
47+
mode = System.getenv("VERSION").split("-")[2]
3348
}
49+
3450
new File("$buildDir/resources/main/journey_build.properties").withWriter { w ->
3551
Properties p = new Properties()
3652
p['version'] = project.version.toString()
37-
p['jcef_version'] = project.jcefVersion.toString()
3853
p['build_date'] = new Date().toInstant().toString()
3954
p['mode'] = mode
55+
p['project_url'] = project.projectUrl.toString()
4056
p.store w, null
4157
}
4258
}
@@ -49,18 +65,25 @@ jar {
4965
dependsOn "initEnvironment"
5066

5167
from {
52-
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
68+
(configurations.compileOnly).collect { it.isDirectory() ? it : zipTree(it) }
5369
}
5470
}
5571

5672
task initEnvironment {
73+
def chromiumMajorVersion = "73"
74+
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
75+
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
76+
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
77+
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
78+
}
79+
5780
if (System.getenv('JITPACK') == "true" ||
5881
(((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
5982
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))))) {
6083
println "Downloading JCEF distribution"
6184
def f = new File("jcef/binary_distrib", "jcef-distrib-linux64.zip")
6285
f.getParentFile().mkdirs()
63-
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-linux64.zip")
86+
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
6487
.withInputStream { i -> f.withOutputStream { it << i } }
6588
println "Successfully downloaded JCEF distribution"
6689

@@ -72,26 +95,31 @@ task initEnvironment {
7295
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))) {
7396
def linuxBuild = new File('natives/jcef-distrib-linux64.zip')
7497
linuxBuild.getParentFile().mkdirs()
98+
def macintoshBuild = new File('natives/jcef-distrib-macintosh64.zip')
7599
def windows32Build = new File('natives/jcef-distrib-windows32.zip')
76100
def windows64Build = new File('natives/jcef-distrib-windows64.zip')
77101

78102
println "Downloading CEF natives files for offline distribution"
79-
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-linux64.zip")
103+
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
80104
.withInputStream { i -> linuxBuild.withOutputStream { it << i } }
81-
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-windows32.zip")
105+
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-macintosh64.zip")
106+
.withInputStream { i -> macintoshBuild.withOutputStream { it << i } }
107+
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows32.zip")
82108
.withInputStream { i -> windows32Build.withOutputStream { it << i } }
83-
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-windows64.zip")
109+
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows64.zip")
84110
.withInputStream { i -> windows64Build.withOutputStream { it << i } }
85111
println "Successfully downloaded CEF natives files for offline distribution"
86112

87113
println "Unpacking CEF natives files for offline distribution"
88114
ant.unzip(src: linuxBuild.absolutePath, dest: linuxBuild.getParentFile().absolutePath, overwrite: "true")
115+
ant.unzip(src: macintoshBuild.absolutePath, dest: macintoshBuild.getParentFile().absolutePath, overwrite: "true")
89116
ant.unzip(src: windows32Build.absolutePath, dest: windows32Build.getParentFile().absolutePath, overwrite: "true")
90117
ant.unzip(src: windows64Build.absolutePath, dest: windows64Build.getParentFile().absolutePath, overwrite: "true")
91118
println "Successfully unpacked CEF natives files for offline distribution"
92119

93120
def resourcesDir = file('src/main/resources')
94121
new File(linuxBuild.getParentFile(), "linux64").renameTo(new File(resourcesDir, "linux64"))
122+
new File(macintoshBuild.getParentFile(), "macosx64").renameTo(new File(resourcesDir, "macosx64"))
95123
new File(windows32Build.getParentFile(), "win32").renameTo(new File(resourcesDir, "win32"))
96124
new File(windows64Build.getParentFile(), "win64").renameTo(new File(resourcesDir, "win64"))
97125
}
@@ -101,7 +129,29 @@ task initEnvironment {
101129
task patchJCEF {
102130
doFirst {
103131
//https://bitbucket.org/chromiumembedded/java-cef/issues/317
132+
println "Patching java-cef#317"
104133
def cefAppFile = file('jcef/java/org/cef/CefApp.java')
105134
cefAppFile.text = cefAppFile.text.replace('System.loadLibrary("jawt");', file('patches/jcef-317.txt').text)
135+
136+
if (System.getenv("TRAVIS_OS_NAME") == "osx") {
137+
//https://bitbucket.org/chromiumembedded/java-cef/issues/270
138+
println "Patching java-cef#270"
139+
def cefBrowserWindowMacFile = file('jcef/java/org/cef/browser/mac/CefBrowserWindowMac.java')
140+
cefBrowserWindowMacFile.text = file('patches/jcef-270.txt').text
141+
}
106142
}
107-
}
143+
}
144+
145+
task checkoutJCEF {
146+
doFirst {
147+
def chromiumMajorVersion = "73"
148+
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
149+
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
150+
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
151+
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
152+
}
153+
154+
def p = ("git checkout " + jcefCommit[chromiumMajorVersion]).execute(null, new File("jcef").absoluteFile)
155+
p.waitFor()
156+
}
157+
}

build_native_mac.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env bash
22

3-
git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
4-
cd jcef
5-
git checkout d348788e3347fa4d2a421773463f7dd62da60991
3+
cd jcef/jcef_build/native/Release
4+
install_name_tool -change "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "@loader_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" ./jcef_app.app/Contents/Java/libjcef.dylib
5+
install_name_tool -change "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "@executable_path/../../../Chromium Embedded Framework.framework/Chromium Embedded Framework" "./jcef_app.app/Contents/Frameworks/jcef Helper.app/Contents/MacOS/jcef Helper"
6+
cd ../../../../
67

7-
mkdir jcef_build && cd jcef_build
8-
cmake -G "Unix Makefiles" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Release ..
9-
make -j4
10-
#xcodebuild -project jcef.xcodeproj -configuration Release -target ALL_BUILD
11-
cd ../tools && ./make_distrib.sh macosx64
8+
cd jcef/tools && ./make_distrib.sh macosx64
9+
cd ../binary_distrib
10+
zip -r jcef-distrib-macintosh64.zip macosx64

patches/jcef-270.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package org.cef.browser.mac;
2+
3+
import org.cef.browser.CefBrowserWindow;
4+
5+
import java.awt.*;
6+
import java.awt.peer.ComponentPeer;
7+
import java.lang.reflect.InvocationHandler;
8+
import java.lang.reflect.InvocationTargetException;
9+
import java.lang.reflect.Method;
10+
import java.lang.reflect.Proxy;
11+
12+
@SuppressWarnings("unused")
13+
public class CefBrowserWindowMac implements CefBrowserWindow {
14+
15+
private static long[] result;
16+
17+
@Override
18+
@SuppressWarnings("unchecked")
19+
public long getWindowHandle(Component comp) {
20+
result = new long[1];
21+
22+
Class LWComponentPeer;
23+
Class CPlatformWindow;
24+
Class CFNativeAction;
25+
Method execute;
26+
Method getPlatformWindow;
27+
try {
28+
LWComponentPeer = Class.forName("sun.lwawt.LWComponentPeer");
29+
CPlatformWindow = Class.forName("sun.lwawt.macosx.CPlatformWindow");
30+
CFNativeAction = Class.forName("sun.lwawt.macosx.CFRetainedResource$CFNativeAction");
31+
execute = CPlatformWindow.getMethod("execute", CFNativeAction);
32+
getPlatformWindow = LWComponentPeer.getMethod("getPlatformWindow");
33+
} catch (ClassNotFoundException | NoSuchMethodException ex) {
34+
throw new RuntimeException(ex);
35+
}
36+
37+
while (comp != null) {
38+
if (comp.isLightweight()) {
39+
comp = comp.getParent();
40+
continue;
41+
}
42+
@SuppressWarnings("deprecation")
43+
ComponentPeer peer = comp.getPeer();
44+
45+
if (LWComponentPeer.isInstance(peer)) {
46+
Object pWindow;
47+
try {
48+
pWindow = getPlatformWindow.invoke(peer);
49+
} catch (IllegalAccessException | InvocationTargetException ex) {
50+
throw new RuntimeException(ex);
51+
}
52+
if (CPlatformWindow.isInstance(pWindow)) {
53+
try {
54+
Object nativeActionProxy = Proxy.newProxyInstance(getClass().getClassLoader(),
55+
new Class[]{CFNativeAction}, new InvocationHandler() {
56+
@Override
57+
public Object invoke(Object o, Method method, Object[] args) {
58+
if ("run".equals(method.getName())) {
59+
result[0] = (long) args[0];
60+
}
61+
return o;
62+
}
63+
});
64+
execute.invoke(pWindow, nativeActionProxy);
65+
} catch (IllegalAccessException | InvocationTargetException ex) {
66+
throw new RuntimeException(ex);
67+
}
68+
break;
69+
}
70+
}
71+
comp = comp.getParent();
72+
}
73+
return result[0];
74+
}
75+
}

setup_native_linux.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env bash
22

33
git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
4-
cd jcef
5-
git checkout d348788e3347fa4d2a421773463f7dd62da60991
4+
./gradlew checkoutJCEF
65

7-
mkdir jcef_build && cd jcef_build
6+
cd jcef && mkdir jcef_build && cd jcef_build
87
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
98
make -j4
109

setup_native_mac.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
4+
./gradlew checkoutJCEF
5+
./gradlew patchJCEF
6+
7+
cd jcef && mkdir jcef_build && cd jcef_build
8+
cmake -G "Xcode" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Release ..
9+
xcodebuild -project jcef.xcodeproj -configuration Release -target ALL_BUILD

setup_native_windows.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
SET PATH=%JAVA_HOME%;%PATH%
22

33
git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
4-
cd jcef
5-
git checkout d348788e3347fa4d2a421773463f7dd62da60991
4+
call gradlew.bat checkoutJCEF
65

76
echo "Running cmake..."
7+
cd jcef
88
mkdir jcef_build
99
cd jcef_build
1010
cmake -G "%generatorName%" ..

0 commit comments

Comments
 (0)