From 5ba779817cbe9a7ec4d708db0529b454bccdd337 Mon Sep 17 00:00:00 2001 From: spvessel Date: Tue, 15 Sep 2020 17:03:15 +0300 Subject: [PATCH] Updated build script to download jcef binaries. --- cef/README.md | 10 ---------- cef/build.gradle.kts | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/cef/README.md b/cef/README.md index ecd7166f0d..e57a1c11d2 100644 --- a/cef/README.md +++ b/cef/README.md @@ -1,15 +1,5 @@ CEF integration for Desktop Jetpack Compose. -Setup: -1. Clone the java-cef repository (``git clone https://bitbucket.org/chromiumembedded/java-cef.git``) into ``/third_party`` directory. -2. Apply patch ``/third_party/java-cef-jb-compose-patch/jb_compose_support.patch`` to ``/third_party/java-cef`` -3. Download [skiko-jvm-0.1.6.jar](https://github.com/JetBrains/skiko/releases) library and copy it to ``/third_party/java-cef/third_party/jogamp/jar`` directory. -4. Follow instructions to compile java-cef ([BranchesAndBuilding](https://bitbucket.org/chromiumembedded/java-cef/wiki/BranchesAndBuilding.md)) **until you reach step 3 of the instruction**. -5. Make **jcef.jar** - execute command in terminal (from ``/third_party/java-cef/tools`` directory): - Windows: ``make_jar.bat win64`` - Linux: ``make_jar.sh linux64`` -6. Copy **jcef.jar** file from ``/third_party/java-cef/out/win64`` (or ``/third_party/java-cef/out/linux64`` for Linux) to ``/libs`` directory. - Run example: To run application execute in terminal: ``./gradlew run`` diff --git a/cef/build.gradle.kts b/cef/build.gradle.kts index 508d2a6d22..8419c2ec69 100644 --- a/cef/build.gradle.kts +++ b/cef/build.gradle.kts @@ -1,12 +1,44 @@ import org.jetbrains.compose.compose import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import de.undercouch.gradle.tasks.download.Download +import kotlin.text.capitalize plugins { kotlin("jvm") version "1.4.0" id("org.jetbrains.compose") version "0.1.0-unmerged30" + id("de.undercouch.download") version "4.1.1" application } +val libraryPath = "third_party/java-cef" +val hostOs = System.getProperty("os.name") +val target = when { + hostOs == "Mac OS X" -> "macos" + hostOs == "Linux" -> "linux" + hostOs.startsWith("Win") -> "windows" + else -> throw Error("Unknown os $hostOs") +} + +val cefDownloadZip = run { + val zipName = "jcef-runtime-$target.zip" + val zipFile = File("third_party/$zipName") + + tasks.register("downloadCef", Download::class) { + onlyIf { !zipFile.exists() } + src("https://bintray.com/jetbrains/skija/download_file?file_path=$zipName") + dest(zipFile) + onlyIfModified(true) + }.map { zipFile } +} + +val cefUnZip = run { + val targetDir = File("third_party/java-cef").apply { mkdirs() } + tasks.register("unzipCef", Copy::class) { + from(cefDownloadZip.map { zipTree(it) }) + into(targetDir) + }.map { targetDir } +} + repositories { google() jcenter() @@ -14,16 +46,15 @@ repositories { } dependencies { - implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation("org.jetbrains.jcef:jcef-skiko:0.1") implementation(compose.desktop.all) } tasks.withType().configureEach { kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" + dependsOn(cefUnZip) } -val libraryPath = "third_party/java-cef/jcef_build/native/Release" - application { applicationDefaultJvmArgs = listOf("-Djava.library.path=$libraryPath") mainClassName = "org.jetbrains.compose.desktop.AppKt"