1
1
buildscript {
2
2
repositories {
3
- jcenter()
4
- }
5
- dependencies {
6
- classpath ' com.android.tools.build:gradle-experimental:0.9.2'
7
- }
8
-
9
- repositories {
3
+ jcenter()
10
4
mavenCentral()
11
5
maven {
12
6
url " https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
13
7
}
14
8
}
15
9
dependencies {
16
10
classpath " org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
11
+ classpath " com.android.tools.build:gradle:2.3.3"
17
12
}
18
13
}
19
14
20
- allprojects {
21
- repositories {
22
- jcenter()
23
- }
15
+ repositories {
16
+ jcenter()
24
17
}
25
18
26
- apply plugin : " konan"
19
+ apply plugin : ' konan'
20
+ apply plugin : ' com.android.application'
27
21
28
- def platforms = [" armeabi-v7a" , " arm64-v8a" ]
29
- konan. targets = [" android_arm32" , " android_arm64" ]
22
+ konan. targets = [' android_arm32' , ' android_arm64' ]
23
+
24
+ def outDir = file(' Polyhedron' )
25
+ def libsDir = file(" $outDir /libs" )
26
+ def platforms = [
27
+ " armeabi-v7a" : [konanTarget : " android_arm32" ],
28
+ " arm64-v8a" : [konanTarget : " android_arm64" ]
29
+ ]
30
30
31
31
konanArtifacts {
32
32
program(' Polyhedron' ) {
33
- baseDir ' Polyhedron'
34
33
artifactName ' libpoly'
35
34
}
36
35
}
37
36
38
- apply plugin : " com.android.model.application"
39
-
40
- model {
41
- android {
42
- compileSdkVersion = 25
43
- buildToolsVersion = ' 25.0.2'
37
+ task copyLibs (type : Copy ) {
38
+ dependsOn konanArtifacts.Polyhedron
39
+ destinationDir libsDir
44
40
45
- defaultConfig {
46
- applicationId = ' com.android.konan_activity'
47
- minSdkVersion. apiLevel 9
48
- targetSdkVersion. apiLevel 25
41
+ platforms. each { name , platform ->
42
+ into(name) {
43
+ from konanArtifacts.Polyhedron . " ${ platform.konanTarget} " . artifact
49
44
}
45
+ }
46
+ }
50
47
51
- ndk {
52
- moduleName = " polyhedron "
53
- }
48
+ task deleteOut ( type : Delete ) {
49
+ delete outDir
50
+ }
54
51
55
- productFlavors {
56
- create(" arm" ) {
57
- ndk {
58
- abiFilters. addAll(platforms)
59
- }
60
- }
61
- }
62
- }
52
+ clean. dependsOn deleteOut
63
53
64
- repositories {
65
- libs(PrebuiltLibraries ) {
66
- libpoly {
67
- binaries. withType(SharedLibraryBinary ) {
68
- def name = targetPlatform. getName()
69
- def index = platforms. indexOf(name)
70
- if (index >= 0 )
71
- sharedLibraryFile = konanArtifacts.Polyhedron . " ${ konan.targets[index]} " . artifact
72
- }
73
- }
54
+ tasks. matching { it. name == ' preBuild' }. all {
55
+ it. dependsOn copyLibs
56
+ }
57
+
58
+ android {
59
+ compileSdkVersion 25
60
+ buildToolsVersion ' 25.0.2'
61
+
62
+ defaultConfig {
63
+ applicationId ' com.jetbrains.konan_activity2'
64
+ minSdkVersion 9
65
+ targetSdkVersion 25
66
+
67
+ ndk {
68
+ abiFilters " armeabi-v7a" , " arm64-v8a"
74
69
}
75
70
}
76
- android. sources {
71
+
72
+ sourceSets {
77
73
main {
78
- jniLibs {
79
- dependencies {
80
- library " libpoly"
81
- }
82
- }
74
+ jniLibs. srcDir libsDir
83
75
}
84
76
}
85
- }
86
77
87
- tasks. matching { it. name == ' preBuild' }. all {
88
- it. dependsOn ' compileKonan'
89
78
}
90
79
91
- task buildApk (type : DefaultTask ) {
92
- dependsOn " compileKonan"
80
+ task buildApk (type : Copy ) {
93
81
dependsOn " assembleDebug"
82
+ destinationDir outDir
83
+ from ' build/outputs/apk'
94
84
}
0 commit comments