Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): target Java8 and Kotlin support for native modules #11434

Merged
merged 3 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ android {
]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
*/

buildscript {
ext.kotlin_version = '1.3.61'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
4 changes: 2 additions & 2 deletions android/kroll-apt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

apply plugin: 'java'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

tasks.withType(JavaCompile) {
// Suppress compiler warning "bootstrap class path not set in conjunction with source" which happens when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

import org.json.simple.JSONValue;

@SupportedSourceVersion(SourceVersion.RELEASE_7)
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SuppressWarnings("unchecked")
// clang-format off
@SupportedAnnotationTypes({
Expand Down
5 changes: 2 additions & 3 deletions android/templates/build/app.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ android {
}
<% } %>
}
// TODO: Add Java 8 support in the future.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
def tiKeystoreFilePath = <%- "'" + tiSdkAndroidDir.replace(/\\/g, '\\\\') + "/dev_keystore'" %>
Expand Down
3 changes: 3 additions & 0 deletions android/templates/build/root.build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

buildscript {
ext.kotlin_version = '1.3.61'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
18 changes: 15 additions & 3 deletions android/templates/module/generated/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

repositories {
maven {
Expand Down Expand Up @@ -118,17 +120,21 @@ android {
}
}
}
// TODO: Add Java 8 support in the future.

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
jquick-axway marked this conversation as resolved.
Show resolved Hide resolved
}
// Exclude the C++ runtime and Titanium kroll libraries for all architectures when packaging the AAR file.
// Avoids app build failure due to library file name collision. (Apps will use "titanium.aar" bundled *.so files.)
packagingOptions {
exclude '/lib/**/libc++_shared.so'
exclude '/lib/**/libkroll-v8.so'
}
// Sets the JVM target in order to allow usage of Java 8 features in Kotlin native modules.
kotlinOptions {
jvmTarget = '1.8'
}
}

tasks.withType(JavaCompile) {
Expand All @@ -153,17 +159,23 @@ tasks.withType(JavaCompile) {
}
}

// Titanium does not support incremental @Kroll annotation processing. Disable it in kotlin to avoid build warnings.
project.ext['kapt.incremental.apt'] = false

dependencies {
// This reads the code's @Kroll annotations and generates code which interops between V8 and proxy classes.
def krollAptJarPath = '<%- krollAptJarPath.replace(/\\/g, '\\\\') %>'
annotationProcessor files(krollAptJarPath)
compileOnly files(krollAptJarPath)
kapt files(krollAptJarPath)
ssekhri marked this conversation as resolved.
Show resolved Hide resolved

// Reference this module's local AAR/JAR file dependencies.
implementation fileTree(dir: "${projectDir}/../../lib", include: ['*.aar', '*.jar'])

// Reference the main Titanium library.
implementation 'org.appcelerator:titanium:<%- tiSdkVersion %>'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

// This block is used when we run "gradlew :module:publish" at the command line.
Expand Down
5 changes: 2 additions & 3 deletions android/titanium/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ android {
]
}
}
// TODO: Add Java 8 support in the future.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
jquick-axway marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down