Skip to content

Commit

Permalink
Merge pull request #6 from CodeBrig/version-69
Browse files Browse the repository at this point in the history
macOS support + variable CEF native version
  • Loading branch information
BFergerson authored Jun 11, 2019
2 parents 97b02bc + 85315c2 commit b0099a6
Show file tree
Hide file tree
Showing 17 changed files with 778 additions and 192 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ matrix:
include:
- os: linux
dist: trusty
# - os: osx
# osx_image: xcode9.3
- os: osx
osx_image: xcode9.3

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

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

script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./build_native_linux.sh && ./gradlew build -x test ; fi
Expand All @@ -21,8 +23,9 @@ deploy:
provider: releases
api_key: $GH_TOKEN
file:
- /home/travis/build/CodeBrig/Journey/build/libs/journey-browser-0.1.1.jar
- /home/travis/build/CodeBrig/Journey/build/libs/journey-browser-0.2.16.jar
- /home/travis/build/CodeBrig/Journey/jcef/binary_distrib/jcef-distrib-linux64.zip
- /Users/travis/build/CodeBrig/Journey/jcef/binary_distrib/jcef-distrib-macintosh64.zip
skip_cleanup: true
on:
tags: true
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Issues/PRs are welcome for increasing the capability of Journey to be on par wit

### Features
- Linux (64bit) support
- macOS (64bit) support
- Windows (32bit/64bit) support
- Release distributions (CDN via GitHub)
- Online/offline CEF native file access
Expand All @@ -25,10 +26,10 @@ repositories {
}
dependencies {
compile 'com.github.codebrig:journey:0.1.1-online'
//or use the offline version (includes native CEF files for all platforms)
//compile 'com.github.codebrig:journey:0.1.1-offline'
compile 'com.github.codebrig:journey:0.2.16-online'
//or use the offline version (includes native CEF files for all platforms; ~300MB)
//compile 'com.github.codebrig:journey:0.2.16-offline'
}
```

Expand All @@ -45,10 +46,10 @@ dependencies {
<dependency>
<groupId>com.github.codebrig</groupId>
<artifactId>journey</artifactId>
<version>0.1.1-online</version>
<!-- or use the offline version (includes native CEF files for all platforms) -->
<!-- <version>0.1.1-offline</version> -->
<version>0.2.16-online</version>

<!-- or use the offline version (includes native CEF files for all platforms; ~300MB) -->
<!-- <version>0.2.16-offline</version> -->
</dependency>
```

Expand Down Expand Up @@ -89,6 +90,7 @@ public class JourneyBrowser {

## Version Matrix

| Build Date | Journey Version | JCEF Version | JCEF Commit |
|------------|------------------|--------------|------------------------------------------|
| 2019-05-21 | 0.1.1 | 73.1.11.215 | [d348788e3347fa4d2a421773463f7dd62da60991](https://bitbucket.org/chromiumembedded/java-cef/commits/d348788e3347fa4d2a421773463f7dd62da60991) |
| Build Date | Journey Version | JCEF Version (Linux) | JCEF Version (macOS) | JCEF Version (Windows) |
|------------|------------------|----------------------|----------------------|----------------------|
| 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) |
| 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) |
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ deploy:
draft: false
prerelease: false
on:
branch: master
APPVEYOR_REPO_TAG: true
78 changes: 64 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
apply plugin: 'java'

group 'com.codebrig'
version '0.1.1'
version '0.2.16'

sourceCompatibility = 1.8

archivesBaseName = 'journey-browser'

ext {
jcefVersion = '73.1.11.215'
jcefCommit = 'd348788e3347fa4d2a421773463f7dd62da60991'
projectUrl = 'https://github.com/CodeBrig/Journey'

jcefVersion = [
'67': '67.0.3396.62',
'69': '69.0.3497.100',
'73': '73.1.11.215'
]
jcefCommit = [
'67': '1fda5d8f948670d08ef86bc4e8637b8581995ce9',
'69': '235e3a844380b72761643324e1d9b7713cae3b63',
'73': 'd348788e3347fa4d2a421773463f7dd62da60991'
]
}

repositories {
mavenCentral()
repositories {
maven { url 'https://jitpack.io' }
}
}

dependencies {
Expand All @@ -22,21 +34,25 @@ dependencies {
compile fileTree(dir: 'jcef/binary_distrib/linux64/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/binary_distrib/win32/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/binary_distrib/win64/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/jcef_build/native/Release', include: '*.jar')
compileOnly 'com.github.bfergerson:joor:9933e481b0'
}

task createProperties(dependsOn: processResources) {
doLast {
def mode = "online"
if ((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline")) {
mode = "offline"
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
mode = System.getenv("TRAVIS_BRANCH").split("-")[2]
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
mode = System.getenv("VERSION").split("-")[2]
}

new File("$buildDir/resources/main/journey_build.properties").withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p['jcef_version'] = project.jcefVersion.toString()
p['build_date'] = new Date().toInstant().toString()
p['mode'] = mode
p['project_url'] = project.projectUrl.toString()
p.store w, null
}
}
Expand All @@ -49,18 +65,25 @@ jar {
dependsOn "initEnvironment"

from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
(configurations.compileOnly).collect { it.isDirectory() ? it : zipTree(it) }
}
}

task initEnvironment {
def chromiumMajorVersion = "73"
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
}

if (System.getenv('JITPACK') == "true" ||
(((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))))) {
println "Downloading JCEF distribution"
def f = new File("jcef/binary_distrib", "jcef-distrib-linux64.zip")
f.getParentFile().mkdirs()
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-linux64.zip")
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
.withInputStream { i -> f.withOutputStream { it << i } }
println "Successfully downloaded JCEF distribution"

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

println "Downloading CEF natives files for offline distribution"
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-linux64.zip")
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
.withInputStream { i -> linuxBuild.withOutputStream { it << i } }
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-windows32.zip")
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-macintosh64.zip")
.withInputStream { i -> macintoshBuild.withOutputStream { it << i } }
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows32.zip")
.withInputStream { i -> windows32Build.withOutputStream { it << i } }
new URL("https://github.com/CodeBrig/Journey/releases/download/" + project.version + "-online/jcef-distrib-windows64.zip")
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows64.zip")
.withInputStream { i -> windows64Build.withOutputStream { it << i } }
println "Successfully downloaded CEF natives files for offline distribution"

println "Unpacking CEF natives files for offline distribution"
ant.unzip(src: linuxBuild.absolutePath, dest: linuxBuild.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: macintoshBuild.absolutePath, dest: macintoshBuild.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: windows32Build.absolutePath, dest: windows32Build.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: windows64Build.absolutePath, dest: windows64Build.getParentFile().absolutePath, overwrite: "true")
println "Successfully unpacked CEF natives files for offline distribution"

def resourcesDir = file('src/main/resources')
new File(linuxBuild.getParentFile(), "linux64").renameTo(new File(resourcesDir, "linux64"))
new File(macintoshBuild.getParentFile(), "macosx64").renameTo(new File(resourcesDir, "macosx64"))
new File(windows32Build.getParentFile(), "win32").renameTo(new File(resourcesDir, "win32"))
new File(windows64Build.getParentFile(), "win64").renameTo(new File(resourcesDir, "win64"))
}
Expand All @@ -101,7 +129,29 @@ task initEnvironment {
task patchJCEF {
doFirst {
//https://bitbucket.org/chromiumembedded/java-cef/issues/317
println "Patching java-cef#317"
def cefAppFile = file('jcef/java/org/cef/CefApp.java')
cefAppFile.text = cefAppFile.text.replace('System.loadLibrary("jawt");', file('patches/jcef-317.txt').text)

if (System.getenv("TRAVIS_OS_NAME") == "osx") {
//https://bitbucket.org/chromiumembedded/java-cef/issues/270
println "Patching java-cef#270"
def cefBrowserWindowMacFile = file('jcef/java/org/cef/browser/mac/CefBrowserWindowMac.java')
cefBrowserWindowMacFile.text = file('patches/jcef-270.txt').text
}
}
}
}

task checkoutJCEF {
doFirst {
def chromiumMajorVersion = "73"
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
}

def p = ("git checkout " + jcefCommit[chromiumMajorVersion]).execute(null, new File("jcef").absoluteFile)
p.waitFor()
}
}
15 changes: 7 additions & 8 deletions build_native_mac.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bash

git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
cd jcef
git checkout d348788e3347fa4d2a421773463f7dd62da60991
cd jcef/jcef_build/native/Release
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
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"
cd ../../../../

mkdir jcef_build && cd jcef_build
cmake -G "Unix Makefiles" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Release ..
make -j4
#xcodebuild -project jcef.xcodeproj -configuration Release -target ALL_BUILD
cd ../tools && ./make_distrib.sh macosx64
cd jcef/tools && ./make_distrib.sh macosx64
cd ../binary_distrib
zip -r jcef-distrib-macintosh64.zip macosx64
75 changes: 75 additions & 0 deletions patches/jcef-270.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.cef.browser.mac;

import org.cef.browser.CefBrowserWindow;

import java.awt.*;
import java.awt.peer.ComponentPeer;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

@SuppressWarnings("unused")
public class CefBrowserWindowMac implements CefBrowserWindow {

private static long[] result;

@Override
@SuppressWarnings("unchecked")
public long getWindowHandle(Component comp) {
result = new long[1];

Class LWComponentPeer;
Class CPlatformWindow;
Class CFNativeAction;
Method execute;
Method getPlatformWindow;
try {
LWComponentPeer = Class.forName("sun.lwawt.LWComponentPeer");
CPlatformWindow = Class.forName("sun.lwawt.macosx.CPlatformWindow");
CFNativeAction = Class.forName("sun.lwawt.macosx.CFRetainedResource$CFNativeAction");
execute = CPlatformWindow.getMethod("execute", CFNativeAction);
getPlatformWindow = LWComponentPeer.getMethod("getPlatformWindow");
} catch (ClassNotFoundException | NoSuchMethodException ex) {
throw new RuntimeException(ex);
}

while (comp != null) {
if (comp.isLightweight()) {
comp = comp.getParent();
continue;
}
@SuppressWarnings("deprecation")
ComponentPeer peer = comp.getPeer();

if (LWComponentPeer.isInstance(peer)) {
Object pWindow;
try {
pWindow = getPlatformWindow.invoke(peer);
} catch (IllegalAccessException | InvocationTargetException ex) {
throw new RuntimeException(ex);
}
if (CPlatformWindow.isInstance(pWindow)) {
try {
Object nativeActionProxy = Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{CFNativeAction}, new InvocationHandler() {
@Override
public Object invoke(Object o, Method method, Object[] args) {
if ("run".equals(method.getName())) {
result[0] = (long) args[0];
}
return o;
}
});
execute.invoke(pWindow, nativeActionProxy);
} catch (IllegalAccessException | InvocationTargetException ex) {
throw new RuntimeException(ex);
}
break;
}
}
comp = comp.getParent();
}
return result[0];
}
}
5 changes: 2 additions & 3 deletions setup_native_linux.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash

git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
cd jcef
git checkout d348788e3347fa4d2a421773463f7dd62da60991
./gradlew checkoutJCEF

mkdir jcef_build && cd jcef_build
cd jcef && mkdir jcef_build && cd jcef_build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j4

Expand Down
9 changes: 9 additions & 0 deletions setup_native_mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

git clone https://bitbucket.org/chromiumembedded/java-cef.git jcef
./gradlew checkoutJCEF
./gradlew patchJCEF

cd jcef && mkdir jcef_build && cd jcef_build
cmake -G "Xcode" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Release ..
xcodebuild -project jcef.xcodeproj -configuration Release -target ALL_BUILD
4 changes: 2 additions & 2 deletions setup_native_windows.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
SET PATH=%JAVA_HOME%;%PATH%

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

echo "Running cmake..."
cd jcef
mkdir jcef_build
cd jcef_build
cmake -G "%generatorName%" ..
Expand Down
Loading

0 comments on commit b0099a6

Please sign in to comment.