samples: Port android build to stable android gradle plugin
This commit is contained in:
@@ -54,3 +54,4 @@ backend.native/tests/teamcity-test.property
|
|||||||
|
|
||||||
# Sample output
|
# Sample output
|
||||||
samples/**/*.kt.bc-build
|
samples/**/*.kt.bc-build
|
||||||
|
samples/androidNativeActivity/Polyhedron
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle-experimental:0.9.2'
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
||||||
@@ -14,81 +8,77 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
|
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
|
||||||
|
classpath "com.android.tools.build:gradle:2.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
repositories {
|
||||||
repositories {
|
jcenter()
|
||||||
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 {
|
konanArtifacts {
|
||||||
program('Polyhedron') {
|
program('Polyhedron') {
|
||||||
baseDir 'Polyhedron'
|
|
||||||
artifactName 'libpoly'
|
artifactName 'libpoly'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: "com.android.model.application"
|
task copyLibs(type: Copy) {
|
||||||
|
dependsOn konanArtifacts.Polyhedron
|
||||||
|
destinationDir libsDir
|
||||||
|
|
||||||
model {
|
platforms.each { name, platform ->
|
||||||
android {
|
into(name) {
|
||||||
compileSdkVersion = 25
|
from konanArtifacts.Polyhedron."${platform.konanTarget}".artifact
|
||||||
buildToolsVersion = '25.0.2'
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId = 'com.android.konan_activity'
|
|
||||||
minSdkVersion.apiLevel 9
|
|
||||||
targetSdkVersion.apiLevel 25
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk {
|
|
||||||
moduleName = "polyhedron"
|
|
||||||
}
|
|
||||||
|
|
||||||
productFlavors {
|
|
||||||
create("arm") {
|
|
||||||
ndk {
|
|
||||||
abiFilters.addAll(platforms)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
android.sources {
|
|
||||||
main {
|
|
||||||
jniLibs {
|
|
||||||
dependencies {
|
|
||||||
library "libpoly"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task deleteOut(type: Delete) {
|
||||||
|
delete outDir
|
||||||
|
}
|
||||||
|
|
||||||
|
clean.dependsOn deleteOut
|
||||||
|
|
||||||
tasks.matching { it.name == 'preBuild' }.all {
|
tasks.matching { it.name == 'preBuild' }.all {
|
||||||
it.dependsOn 'compileKonan'
|
it.dependsOn copyLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
task buildApk(type: DefaultTask) {
|
android {
|
||||||
dependsOn "compileKonan"
|
compileSdkVersion 25
|
||||||
dependsOn "assembleDebug"
|
buildToolsVersion '25.0.2'
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId 'com.jetbrains.konan_activity2'
|
||||||
|
minSdkVersion 9
|
||||||
|
targetSdkVersion 25
|
||||||
|
|
||||||
|
ndk {
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
jniLibs.srcDir libsDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildApk(type: Copy) {
|
||||||
|
dependsOn "assembleDebug"
|
||||||
|
destinationDir outDir
|
||||||
|
from 'build/outputs/apk'
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user