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)(9_0_X): module builds should fail with aar in lib folder in 9.0.0 #11474

Merged
merged 2 commits into from
Feb 12, 2020
Merged
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
27 changes: 21 additions & 6 deletions android/templates/module/generated/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,34 @@ android {
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = 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.)
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'
}

// Trigger a build failure if an AAR library was found under the "lib" directory.
// While it will compile with the library, Google's build system won't merge the AAR into this module's AAR.
preBuild.doFirst {
def libDirectory = new File("${projectDir}/../../lib")
if (libDirectory.exists()) {
libDirectory.eachFile {
if (it.name.toLowerCase().endsWith('.aar')) {
def errorMessage =
'AAR files are no longer supported under the "lib" directory. ' +
'You must reference AAR libraries via a "build.gradle" file\'s dependencies section instead.'
throw new GradleException(errorMessage)
}
}
}
}

Expand Down Expand Up @@ -169,12 +183,13 @@ dependencies {
compileOnly files(krollAptJarPath)
kapt files(krollAptJarPath)

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

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

// Reference the core kotlin library.
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

Expand Down