Skip to content

Commit

Permalink
feat(android): target Java8 and Kotlin support for native modules
Browse files Browse the repository at this point in the history
targets Java 8 and adds support for Kotlin for developing native android modules
  • Loading branch information
ypbnv authored and sgtcoolguy committed Jan 23, 2020
1 parent 66276cc commit 5ce5e72
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 9 deletions.
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
4 changes: 2 additions & 2 deletions android/templates/build/app.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ 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
9 changes: 7 additions & 2 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 @@ -120,8 +122,8 @@ 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
}
// 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.)
Expand Down Expand Up @@ -158,12 +160,15 @@ dependencies {
def krollAptJarPath = '<%- krollAptJarPath.replace(/\\/g, '\\\\') %>'
annotationProcessor files(krollAptJarPath)
compileOnly files(krollAptJarPath)
kapt files(krollAptJarPath)

// 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
4 changes: 2 additions & 2 deletions android/titanium/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ 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
}
}

Expand Down

0 comments on commit 5ce5e72

Please sign in to comment.