forked from cloudant/sync-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
277 lines (237 loc) · 8.75 KB
/
build.gradle
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// ************ //
// COMMON STUFF
// ************ //
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply from: 'AndroidExec.gradle'
//
// General settings
//
allprojects {
group = 'com.cloudant'
version = new File(rootDir, 'VERSION').text.trim()
description = """cloudant-sync"""
//if the version says "snapshot" anywhere assume it is not a release
ext.isReleaseVersion = !version.toUpperCase(Locale.ENGLISH).contains("SNAPSHOT")
// Load signing parameters from system properties
['signing.keyId', 'signing.password', 'signing.secretKeyRingFile']
.each { propName ->
// Set a property with the given name if the system property is set
if (System.properties.(propName.toString()) != null) {
ext.(propName.toString()) = System.properties.(propName.toString())
}
}
}
dependencies {
compile project(':cloudant-sync-datastore-core')
compile project(':cloudant-sync-datastore-javase')
compile project(':cloudant-sync-datastore-android')
compile project(':cloudant-sync-datastore-android-encryption')
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
ext.clientName = 'CloudantSync'
signing {
// Only apply signing when it is a release and is being published
required {
isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives")
}
// When signing, sign the archives
sign configurations.archives
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
//
// Build plugins
//
buildscript {
repositories {
mavenCentral()
}
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
defaultTasks 'build'
repositories {
mavenLocal()
mavenCentral()
}
//
// Misc. tasks
//
task listJars << {
configurations.testCompile.each { File file -> println file.name }
}
tasks.withType(Test) {
testLogging {
// Get full exception info for test failures
exceptionFormat = 'full'
showExceptions = true
showCauses = true
showStackTraces = true
}
}
//findbugs
apply plugin: 'findbugs'
findbugs {
toolVersion = "3.0.1"
reportLevel = System.getProperty("findbugs.report.level","low")
//the code base is pretty small so use max effort
effort = "max"
// We don't want to run findbugs on the test code yet
sourceSets = [sourceSets.main]
// Exclude a couple of known bugs until we get the chance to fix them
if (file("findbugs_excludes.xml").exists()) {
excludeFilter = file("findbugs_excludes.xml")
}
}
tasks.withType(FindBugs) {
// Currently only one report type can be used toggle which with a property
boolean generateXML = Boolean.getBoolean("findbugs.xml.report")
reports {
xml.enabled = generateXML
html.enabled = !generateXML
}
}
//
// *** DOCS AND PUBLISHING ***
//
// see http://issues.gradle.org/browse/GRADLE-1876
// run javadoc over union of all projects
gradle.projectsEvaluated {
javadoc {
options.encoding = "UTF-8"
options.docEncoding = "UTF-8"
options.charSet = "UTF-8"
exclude "**/internal/**"
options.showFromPublic()
title = "sync-android ${version} API"
// For the subprojects we include all the javadoc from dependencies on other subprojects
// this produces a more standalone javadoc jar for each published artifact.
source getProjectDocSources(project).collect() { dsp ->
dsp.sourceSets.main.allJava
}
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
sourceSets.all {
into(name + "/java", { from allJava })
into(name + "/resources", { from resources })
}
}
artifacts {
archives sourcesJar, javadocJar
}
uploadArchives {
ext.ossrhUsername = System.properties.ossrhUsername
ext.ossrhPassword = System.properties.ossrhPassword
doFirst {
// If the OSSRH credentials are not available, then fail the build
if (ossrhUsername == null || ossrhPassword == null) {
throw new GradleException('OSSRH credentials properties (ossrhUsername & ' +
'ossrhPassword) are required to upload archives.')
}
}
repositories {
mavenDeployer {
//when publishing sign the pom
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
//augment the pom with additional information
pom.project {
packaging 'jar'
inceptionYear '2013'
url 'https://cloudant.com'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection 'scm:git:git://github.com/cloudant/sync-android.git'
developerConnection 'scm:git:[email protected]/cloudant/sync-android.git'
url 'https://[email protected]/cloudant/sync-android.git'
}
properties {
'project.build.sourceEncoding' 'UTF-8'
}
developers {
developer {
name 'IBM Cloudant'
email '[email protected]'
url 'https://cloudant.com'
organization 'IBM'
organizationUrl 'http://www.ibm.com'
}
}
}
}
}
}
File dexAllDir = new File(project.buildDir, "dex-all")
File dexAllInputDir = new File(dexAllDir, "in")
File dexAllOutputDir = new File(dexAllDir, "out")
File dexLog = new File(dexAllOutputDir, "dex.log")
task copyDependencies(type: Copy) {
from configurations.runtime
into dexAllInputDir
}
task copyLib(type: Copy, dependsOn: assemble) {
from jar.destinationDir
into dexAllInputDir
}
task dexAll(type: AndroidExec, dependsOn: [copyDependencies, copyLib]) {
doFirst {
dexAllOutputDir.mkdir()
dexLog.createNewFile()
def writer = new PrintWriter(new File(dexAllOutputDir, "dexInputList.txt"))
writer.println(dexAllInputDir.absolutePath)
writer.close()
standardOutput = new FileOutputStream(dexLog, false)
errorOutput = standardOutput
}
doLast{
standardOutput.close()
}
inputs.dir dexAllInputDir
outputs.dir dexAllOutputDir
workingDir dexAllOutputDir
commandLine 'dx', '--dex', '--statistics', '--num-threads=4', '--core-library',
'--output=all.dex', '--input-list=dexInputList.txt'
}
task methodCount(type: Exec, dependsOn: [dexAll]) {
// Run this task to get the Android method counts.
workingDir dexAllOutputDir
commandLine 'grep', 'method id:.*', dexLog
}
}
// Function to get project doc sources (i.e. the project and all its dependent projects)
def getProjectDocSources(project) {
// Get the compile time dependencies
def projectDependencies = project.configurations.compile.getAllDependencies().withType(ProjectDependency)
// Get the projects from the dependencies
def dependentProjects = projectDependencies*.dependencyProject
// Recurse
dependentProjects.each { dependentProjects += getProjectDocSources(it) }
// Finally add the original project
dependentProjects.add(project)
// Return without duplicates
return dependentProjects.unique()
}