Implement new rust API for bindings and release v0.3
1apply plugin: 'com.android.library'
2apply plugin: 'kotlin-android-extensions'
3apply plugin: 'kotlin-android'
4apply plugin: 'com.github.dcendents.android-maven'
5apply plugin: 'com.jfrog.bintray'
6
7android {
8 compileSdkVersion 28
9
10 defaultConfig {
11 minSdkVersion 15
12 targetSdkVersion 28
13 versionCode 1
14 versionName "1.0"
15
16 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17
18 }
19
20 buildTypes {
21 release {
22 minifyEnabled false
23 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 }
25 }
26
27 sourceSets {
28 main {
29 jni.srcDirs = []
30 jniLibs.srcDir 'src/main/libs'
31 }
32 }
33}
34
35dependencies {
36 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
37 implementation "androidx.core:core:1.0.1"
38
39 testImplementation 'junit:junit:4.12'
40 androidTestImplementation 'androidx.test:runner:1.1.1'
41 androidTestImplementation 'androidx.test:rules:1.1.1'
42 androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
43}
44
45def rustBasePath = "src/main/rust"
46def cargoOutputDir = "${rustBasePath}/target"
47def archTriplets = ['arm64-v8a': 'aarch64-linux-android',
48 'armeabi-v7a': 'armv7-linux-androideabi',
49 'x86': 'i686-linux-android']
50
51archTriplets.each { arch, target ->
52 // Build with cargo
53 tasks.create(name: "cargo-build-${arch}", type: Exec, description: "Building core for ${arch}") {
54 workingDir rustBasePath
55 commandLine 'cargo', 'build', "--target=${target}", '--release'
56 }
57
58 // Copy build libs into this app's libs directory
59 tasks.create(name: "rust-sync-${arch}", type: Copy, dependsOn: "cargo-build-${arch}", description: "Copy rust libs for (${arch}) to jniLibs") {
60 from "${cargoOutputDir}/${target}/release"
61 include "*.so"
62 into "src/main/libs/${arch}"
63 }
64
65 // Hook up tasks to execute before building java
66 tasks.withType(JavaCompile) {
67 compileTask -> compileTask.dependsOn "rust-sync-${arch}"
68 }
69 preBuild.dependsOn "rust-sync-${arch}"
70
71 // Hook up clean tasks
72 tasks.create(name: "clean-${arch}", type: Delete, description: "Deleting built libs for ${arch}") {
73 delete fileTree("${cargoOutputDir}/${target}/release") {
74 include '*.so'
75 }
76 }
77
78 clean.dependsOn "clean-${arch}"
79}
80
81ext {
82 bintrayRepo = 'maven'
83 bintrayName = 'stretch-kotlin-bindings'
84
85 publishedGroupId = 'app.visly.stretch'
86 libraryName = bintrayName
87 artifact = 'stretch'
88
89 libraryDescription = 'Kotlin bindings for stretch layout engine'
90
91 siteUrl = 'https://visly.app/stretch'
92 gitUrl = 'https://github.com/vislyhq/stretch.git'
93
94 libraryVersion = '0.3.2'
95
96 developerId = 'visly'
97 developerName = 'Visly'
98 developerEmail = 'emil@visly.app'
99
100 licenseName = 'MIT'
101 licenseUrl = 'https://github.com/vislyhq/stretch/blob/master/LICENSE'
102 allLicenses = ["MIT"]
103}
104
105group = publishedGroupId
106version = libraryVersion
107
108install {
109 repositories.mavenInstaller {
110 pom.project {
111 packaging 'aar'
112 groupId publishedGroupId
113 artifactId artifact
114 name libraryName
115 description libraryDescription
116 url siteUrl
117
118 licenses {
119 license {
120 name licenseName
121 url licenseUrl
122 }
123 }
124 developers {
125 developer {
126 id developerId
127 name developerName
128 email developerEmail
129 }
130 }
131 scm {
132 connection gitUrl
133 developerConnection gitUrl
134 url siteUrl
135 }
136 }
137 }
138}
139
140task sourcesJar(type: Jar) {
141 classifier = 'sources'
142 from android.sourceSets.main.java.srcDirs
143}
144
145task javadoc(type: Javadoc) {
146 source = android.sourceSets.main.java.srcDirs
147 classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
148}
149
150task javadocJar(type: Jar, dependsOn: javadoc) {
151 classifier = 'javadoc'
152 from javadoc.destinationDir
153}
154
155artifacts {
156 archives javadocJar
157 archives sourcesJar
158}
159
160Properties properties = new Properties()
161if (project.rootProject.file("local.properties").exists()) {
162 properties.load(project.rootProject.file('local.properties').newDataInputStream())
163}
164
165bintray {
166 user = properties.getProperty("bintray.user")
167 key = properties.getProperty("bintray.apikey")
168
169 configurations = ['archives']
170
171 pkg {
172 repo = bintrayRepo
173 name = bintrayName
174 userOrg = developerId
175 desc = libraryDescription
176 websiteUrl = siteUrl
177 vcsUrl = gitUrl
178 licenses = allLicenses
179 dryRun = false
180 publish = true
181 override = false
182 publicDownloadNumbers = true
183 version {
184 desc = libraryDescription
185 }
186 }
187}