Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

[WIP] allow JavaFX 9 to be used on Android #74

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ configurations.all {
}

dependencies {
compile 'org.ow2.asm:asm:7.0-beta'
compile 'net.sf.proguard:proguard-gradle:6.0.3'
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:3.0.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ class JFXMobilePlugin implements Plugin<Project> {
// configure android and ios dependencies
project.dependencies {
retrolambdaConfig "${RETROLAMBDA_COMPILE}:${project.jfxmobile.android.retrolambdaVersion}"
androidCompile("org.javafxports:jfxdvk:${project.jfxmobile.javafxportsVersion}") {
force = true
}
// androidCompile("org.javafxports:jfxdvk:${project.jfxmobile.javafxportsVersion}") {
// force = true
// }
dalvikSdk "org.javafxports:dalvik-sdk:${project.jfxmobile.javafxportsVersion}@zip"
sshAntTask 'org.apache.ant:ant-jsch:1.9.6'
}
Expand Down Expand Up @@ -324,14 +324,19 @@ class JFXMobilePlugin implements Plugin<Project> {
project.configurations.androidRuntimeNoRetrolambda)

project.dependencies {
androidRuntime project.fileTree("${project.jfxmobile.android.dalvikSdkLib}/ext") {
androidRuntime project.fileTree("${project.jfxmobile.android.dalvikSdkLib}") {
include 'jfxdvk.jar'
include 'compat-1.0.0.jar'
}
androidRuntimeNoRetrolambda project.fileTree("${project.jfxmobile.android.dalvikSdkLib}/ext") {
include 'jfxrt.jar'
}
}
// }
// androidRuntimeNoRetrolambda project.fileTree("${project.jfxmobile.android.dalvikSdkLib}") {
// include 'javafx.base.jar'
// include 'javafx.graphics.jar'
// include 'javafx.controls.jar'

}
}
project.logger.info("PROJECTDEPENDENCIES = $project.dependencies \n\n\n\n\n\n\n\n\n\n")
// configure android boot classpath
def androidBootclasspath = project.configurations.androidBootclasspath
if (!androidBootclasspath.empty) {
Expand All @@ -342,10 +347,16 @@ class JFXMobilePlugin implements Plugin<Project> {

// NOTE: from is set after all configuration for androidRuntime has completed
project.tasks.copyClassesForDesugar.from {
(project.configurations.androidRuntime - project.configurations.androidRuntimeNoRetrolambda - project.configurations.androidSdk).filter {
!it.isDirectory()
(project.configurations.androidRuntime - project.configurations.androidRuntimeNoRetrolambda - project.configurations.androidSdk)
.filter {
!it.isDirectory()}.filter{
String myname = it.getName();
if (myname.startsWith("javafx-")) return false;
project.logger.info("consider $it.name OR $myname");
true;

}.collect {
project.logger.info("Apply Desugar to $it")
project.logger.info("Apply Desugar to $it");
project.zipTree(it)
}
}
Expand Down Expand Up @@ -413,7 +424,7 @@ class JFXMobilePlugin implements Plugin<Project> {
copyClassesForDesugar.include '**/*.class'
copyClassesForDesugar.includeEmptyDirs = false
copyClassesForDesugar.exclude 'META-INF/versions/**/*.class'
copyClassesForDesugar.exclude 'module-info.class'
copyClassesForDesugar.exclude '**/module-info.class'
copyClassesForDesugar.destinationDir = project.file("${project.jfxmobile.android.temporaryDirectory}/desugar/input")
copyClassesForDesugar.dependsOn project.tasks.compileJava, project.tasks.compileAndroidJava
androidTasks.add(copyClassesForDesugar)
Expand Down Expand Up @@ -459,6 +470,7 @@ class JFXMobilePlugin implements Plugin<Project> {
mergeClassesIntoJarTask.from retrolambdaTask.retrolambdaOutput
// mergeClassesIntoJarTask.from desugarTask.get(project.jfxmobile.android.taskFactory).outputDir
mergeClassesIntoJarTask.include '**/*.class'
mergeClassesIntoJarTask.exclude '**/module-info.class'
mergeClassesIntoJarTask.dependsOn retrolambdaTask
// mergeClassesIntoJarTask.dependsOn desugarTask.get(project.jfxmobile.android.taskFactory)
androidTasks.add(mergeClassesIntoJarTask)
Expand Down Expand Up @@ -582,6 +594,8 @@ class JFXMobilePlugin implements Plugin<Project> {
"${project.jfxmobile.android.dalvikSdkLib}",
"${project.jfxmobile.android.nativeDirectory}"
).files
// project.logger.info("NATIVE LIBS FROM ${project.jfxmobile.android.dalvikSdkLib}")

}
apkTask.conventionMapping.map("outputFile") { project.file("${project.jfxmobile.android.installDirectory}/${project.name}-unaligned.apk") }
apkTask.conventionMapping.map("mainResourcesDirectory") {
Expand Down Expand Up @@ -723,9 +737,10 @@ class JFXMobilePlugin implements Plugin<Project> {
if (project.jfxmobile.android.dalvikSdk == null) {
project.jfxmobile.android.dalvikSdk = resolveSdk(project.configurations.dalvikSdk, "dalvik-sdk")
}
project.jfxmobile.android.dalvikSdkLib = project.file("${project.jfxmobile.android.dalvikSdk}/rt/lib")
project.jfxmobile.android.dalvikSdkLib = project.file("${project.jfxmobile.android.dalvikSdk}/lib")
if (!project.jfxmobile.android.dalvikSdkLib.exists()) {
throw new GradleException("Configured dalvikSdk is invalid: ${project.jfxmobile.android.dalvikSdk}")
throw new GradleException("Configured dalvikSdk is invalid (no lib directory found): ${project.jfxmobile.android.dalvikSdk}")

}
project.logger.info("Using javafxports dalvik sdk from location ${project.jfxmobile.android.dalvikSdk}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ class Apk extends DefaultTask {
}

if (getJniFolders() != null) {
project.logger.info("WE HAVE JNI FOLDERS");
getJniFolders().each {
project.logger.info("FOLDER? $it")
if (it.isDirectory()) {
project.logger.info("ADDING NATIVE LIBS")
apkBuilder.addNativeLibraries(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class Dex extends DefaultTask {

@TaskAction
void dex() {
String ap = getInputListFile().absolutePath;
project.logger.info("DEXINPUT\n\n\n\n\n\n $ap");

project.ant.java(outputproperty: "dexCmdOut",
errorProperty: "dexCmdErr",
resultProperty : "dexResult",
Expand Down Expand Up @@ -88,12 +91,12 @@ class Dex extends DefaultTask {
}
arg(value: "--no-optimize")
arg(value: "--multi-dex")
arg(value: "--min-sdk-version=26")
arg(value: "--main-dex-list=" + getMainDexListFile().absolutePath)
arg(value: "--core-library")
arg(value: "--output=" + getOutputDirectory().absolutePath)
arg(value: "--input-list=" + getInputListFile().absolutePath)
}

project.logger.debug("Dex result value = ${project.ant.project.properties.dexResult}")
if (project.ant.project.properties.dexResult != "0") {
throw new GradleException(project.ant.project.properties.dexCmdErr)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javafxports/retrobuffer/Retrobuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void visitClass(Path relativePath, byte[] bytecode) {
try {
analyzer.analyze(bytecode);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Failed to analyze class: '" + relativePath + "'.\nClasses compiled with JDK 9 or later are currently not supported on Android. Please make sure that your project does not contain JDK 9+ dependencies.", e);
throw new RuntimeException("Failed to analyze class: '" + relativePath.toAbsolutePath() + "'.\nClasses compiled with JDK 9 or later are currently not supported on Android. Please make sure that your project does not contain JDK 9+ dependencies.", e);
}
}

Expand Down