This repository was archived by the owner on Jun 22, 2021. It is now read-only.
forked from couchbaselabs/couchbase-lite-java-forestdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-android.gradle
More file actions
200 lines (173 loc) · 7.4 KB
/
build-android.gradle
File metadata and controls
200 lines (173 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.library'
apply plugin: "maven"
version = System.getenv("MAVEN_UPLOAD_VERSION")
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
repositories {
maven { url 'http://files.couchbase.com/maven2/' }
jcenter()
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
sourceSets {
main {
java.srcDirs = ['vendor/cbforest/Java/src', 'src/main/java']
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir file('libs') // This is not necessary unless you have precompiled libraries in your project.
}
}
task generateForestDBStoreJniHeaders(type: Exec, description: 'Generate ForestDBStore JNI header files') {
def classpath = "src/main/java"
def nativeIncludes = "jni/source"
commandLine "javah", "-d", "$nativeIncludes", "-classpath", "$classpath",
"com.couchbase.lite.store.ForestDBStore"
}
task generateCBForestJniHeaders(type: Exec, description: 'Generate CBForest JNI C header files') {
def classpath = "vendor/cbforest/Java/src"
def nativeIncludes = "vendor/cbforest/Java/jni"
commandLine "javah", "-d", "$nativeIncludes", "-classpath", "$classpath",
"com.couchbase.cbforest.Database",
"com.couchbase.cbforest.Document",
"com.couchbase.cbforest.DocumentIterator",
"com.couchbase.cbforest.ForestException",
"com.couchbase.cbforest.FullTextResult",
"com.couchbase.cbforest.Indexer",
"com.couchbase.cbforest.Logger",
"com.couchbase.cbforest.QueryIterator",
"com.couchbase.cbforest.View"
}
generateCBForestJniHeaders.dependsOn 'generateForestDBStoreJniHeaders'
task cleanJniHeaders(type: Delete, description: 'Clean JNI C header files') {
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_Database.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_Document.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_DocumentIterator.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_ForestException.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_FullTextResult.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_Indexer.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_Logger.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_QueryIterator.h"
delete "vendor/cbforest/Java/jni/com_couchbase_cbforest_View.h"
}
// call regular ndk-build(.cmd) script from app directory
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
def ndkBuild = "$ndkDir/ndk-build"
if(Os.isFamily(Os.FAMILY_WINDOWS))
ndkBuild = "$ndkDir\\ndk-build.cmd"
commandLine "$ndkBuild", '-C', file('jni').absolutePath
}
buildNative.dependsOn 'generateCBForestJniHeaders'
buildNative.doLast {
// Commented out JNI header clean method.
// Instead, added these generated headers in cbforest/.gitignore
// cleanJniHeaders.execute()
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
def ndkBuild = "$ndkDir/ndk-build"
if(Os.isFamily(Os.FAMILY_WINDOWS))
ndkBuild = "$ndkDir\\ndk-build.cmd"
commandLine "$ndkBuild", '-C', file('jni').absolutePath, 'clean'
}
cleanNative.dependsOn 'cleanJniHeaders'
clean.dependsOn 'cleanNative'
// Define a task for ndk-build
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile !hasProperty("buildAndroidWithArtifacts") ?
project(':libraries:couchbase-lite-java-core') :
'com.couchbase.lite:couchbase-lite-java-core:' + version
androidTestCompile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
androidTestCompile 'com.fasterxml.jackson.core:jackson-core:2.5.0'
androidTestCompile 'com.fasterxml.jackson.core:jackson-annotations:2.5.0'
}
////////////////////////////////////////////
// For Maven
////////////////////////////////////////////
task createMavenDirectory(type: Exec) {
ext {
uploadUser = System.getenv("MAVEN_UPLOAD_USERNAME") + ":" + System.getenv("MAVEN_UPLOAD_PASSWORD")
mkcolPath = System.getenv("MAVEN_UPLOAD_REPO_URL") + "com/couchbase/lite/couchbase-lite-android-forestdb/" + version + "/"
}
commandLine "curl", "--user", uploadUser, "-X", "MKCOL", mkcolPath
}
// this hack is only needed for apache mod_dav based Maven repo's like file.couchbase.com. otherwise, skip it
createMavenDirectory.onlyIf { System.getenv("MAVEN_UPLOAD_REPO_URL").contains("files") }
// first create the directory, then do the upload
task uploadArchivesWrapper(dependsOn: createMavenDirectory) << {
uploadArchives.execute()
}
// this will upload, but will not first create a directory (which is needed on some servers)
uploadArchives {
repositories {
mavenDeployer {
repository(url: System.getenv("MAVEN_UPLOAD_REPO_URL")) {
authentication(userName: System.getenv("MAVEN_UPLOAD_USERNAME"), password: System.getenv("MAVEN_UPLOAD_PASSWORD"))
}
pom.version = version
pom.groupId = 'com.couchbase.lite'
pom.artifactId = 'couchbase-lite-android-forestdb'
pom.project {
name 'com.couchbase.lite:couchbase-lite-android-forestdb'
description 'ForestDB Couchbase Lite Storage Engine for Java/Android'
url 'http://developer.couchbase.com/mobile/'
licenses {
license {
name 'Couchbase, Inc. Community Edition License Agreement'
url 'https://www.couchbase.com/binaries/content/assets/website/legal/ce-license-agreement.pdf'
distribution 'repo'
}
}
scm {
url 'http://developer.couchbase.com/mobile/'
}
developers {
developer {
name 'Couchbase Mobile'
email 'mobile@couchbase.com'
organization 'Couchbase'
organizationUrl 'http://www.couchbase.com'
}
}
}
}
}
}