forked from JetBrains/kotlin-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: Port android build to stable android gradle plugin
- Loading branch information
Showing
2 changed files
with
49 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,84 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle-experimental:0.9.2' | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
maven { | ||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" | ||
} | ||
} | ||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+" | ||
classpath "com.android.tools.build:gradle:2.3.3" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
apply plugin: "konan" | ||
apply plugin: 'konan' | ||
apply plugin: 'com.android.application' | ||
|
||
def platforms = ["armeabi-v7a", "arm64-v8a"] | ||
konan.targets = ["android_arm32", "android_arm64"] | ||
konan.targets = ['android_arm32', 'android_arm64'] | ||
|
||
def outDir = file('Polyhedron') | ||
def libsDir = file("$outDir/libs") | ||
def platforms = [ | ||
"armeabi-v7a": [konanTarget: "android_arm32"], | ||
"arm64-v8a" : [konanTarget: "android_arm64"] | ||
] | ||
|
||
konanArtifacts { | ||
program('Polyhedron') { | ||
baseDir 'Polyhedron' | ||
artifactName 'libpoly' | ||
} | ||
} | ||
|
||
apply plugin: "com.android.model.application" | ||
|
||
model { | ||
android { | ||
compileSdkVersion = 25 | ||
buildToolsVersion = '25.0.2' | ||
task copyLibs(type: Copy) { | ||
dependsOn konanArtifacts.Polyhedron | ||
destinationDir libsDir | ||
|
||
defaultConfig { | ||
applicationId = 'com.android.konan_activity' | ||
minSdkVersion.apiLevel 9 | ||
targetSdkVersion.apiLevel 25 | ||
platforms.each { name, platform -> | ||
into(name) { | ||
from konanArtifacts.Polyhedron."${platform.konanTarget}".artifact | ||
} | ||
} | ||
} | ||
|
||
ndk { | ||
moduleName = "polyhedron" | ||
} | ||
task deleteOut(type: Delete) { | ||
delete outDir | ||
} | ||
|
||
productFlavors { | ||
create("arm") { | ||
ndk { | ||
abiFilters.addAll(platforms) | ||
} | ||
} | ||
} | ||
} | ||
clean.dependsOn deleteOut | ||
|
||
repositories { | ||
libs(PrebuiltLibraries) { | ||
libpoly { | ||
binaries.withType(SharedLibraryBinary) { | ||
def name = targetPlatform.getName() | ||
def index = platforms.indexOf(name) | ||
if (index >= 0) | ||
sharedLibraryFile = konanArtifacts.Polyhedron."${konan.targets[index]}".artifact | ||
} | ||
} | ||
tasks.matching { it.name == 'preBuild' }.all { | ||
it.dependsOn copyLibs | ||
} | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
|
||
defaultConfig { | ||
applicationId 'com.jetbrains.konan_activity2' | ||
minSdkVersion 9 | ||
targetSdkVersion 25 | ||
|
||
ndk { | ||
abiFilters "armeabi-v7a", "arm64-v8a" | ||
} | ||
} | ||
android.sources { | ||
|
||
sourceSets { | ||
main { | ||
jniLibs { | ||
dependencies { | ||
library "libpoly" | ||
} | ||
} | ||
jniLibs.srcDir libsDir | ||
} | ||
} | ||
} | ||
|
||
tasks.matching { it.name == 'preBuild' }.all { | ||
it.dependsOn 'compileKonan' | ||
} | ||
|
||
task buildApk(type: DefaultTask) { | ||
dependsOn "compileKonan" | ||
task buildApk(type: Copy) { | ||
dependsOn "assembleDebug" | ||
destinationDir outDir | ||
from 'build/outputs/apk' | ||
} |