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

refactor(android): support for Titanium 9.0.0 and gradle #329

Merged
merged 12 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 0 additions & 21 deletions android/.classpath

This file was deleted.

29 changes: 0 additions & 29 deletions android/.project

This file was deleted.

7 changes: 0 additions & 7 deletions android/.settings/org.eclipse.jdt.apt.core.prefs

This file was deleted.

3 changes: 0 additions & 3 deletions android/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

4 changes: 0 additions & 4 deletions android/build.properties

This file was deleted.

130 changes: 0 additions & 130 deletions android/build.xml

This file was deleted.

73 changes: 73 additions & 0 deletions android/hooks/build.gradle.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

apply plugin: 'com.android.library'

// Path to the Titanium project's "./platform/android" directory.
def tiProjectPlatformAndroidDir = '<%- tiProjectPlatformAndroidDir.replace(/\\/g, '\\\\') %>'

// Path to the Titanium SDK's "m2repository" containing the "titanium.aar" library.
// Needed by "org.appcelerator:titanium:<version>" dependency reference below.
repositories {
maven {
url '<%- tiMavenUrl %>'
}
}

// Android build settings for this library project.
android {
compileSdkVersion <%- compileSdkVersion %>
defaultConfig {
minSdkVersion <%- minSdkVersion %>
targetSdkVersion <%- targetSdkVersion %>
}
lintOptions {
checkReleaseBuilds false
}
}

// Disable linting for faster build times.
tasks.lint.enabled = false

// Default hyperloop library references.
dependencies {
// Reference the JARs/AARs in the Titanium project's "./platform/android" directory.
implementation fileTree(dir: tiProjectPlatformAndroidDir, include: ['*.aar', '*.jar'])

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

// Load optional "build.gradle" file in Titanium project's "./platform/android" directory.
// This gradle file is expected to provide additional "dependencies" for hyperloop.
def customBuildGradlePath = "${tiProjectPlatformAndroidDir}/build.gradle"
if (file(customBuildGradlePath).exists()) {
apply from: customBuildGradlePath
}

// Task used to fetch the paths to all JAR dependencies available to hyperloop.
// Writes paths to a "./build/outputs/hyperloop/jar-dependencies.txt" file, separated by '\n' characters.
// To be executed via command line: "gradlew :gradle-project:generateJarDependenciesFile"
task generateJarDependenciesFile() {
doLast {
def jarPathCollection = new HashSet<String>();

// Add the main Android framework JAR to the collection.
jarPathCollection.add(
file("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar").toString())

// Fetch JAR paths to all dependencies referenced by this gradle script and "./platform/android/build.gradle".
project.android.libraryVariants.all { variant ->
variant.getCompileClasspath(null).each {
def fileObject = it
def filePath = fileObject.toString()
if (!filePath.startsWith(buildDir.toString()) && fileObject.exists()) {
jarPathCollection.add(filePath)
}
}
}

// Write the paths to all JAR file dependencies to text file, separated by newlines.
def outputFile = file("${buildDir}/outputs/hyperloop/jar-dependencies.txt")
outputFile.getParentFile().mkdirs()
outputFile.text = jarPathCollection.join('\n')
}
}