forked from dropbox/dropbox-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
313 lines (264 loc) · 9.29 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
import org.gradle.internal.os.OperatingSystem
apply plugin: 'java'
apply plugin: 'osgi'
apply plugin: 'maven'
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task
description = 'Official Java client library for the Dropbox API.'
group = 'com.dropbox.core'
archivesBaseName = 'dropbox-core-sdk'
version = '0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
// needed before we define the pom
conf2ScopeMappings.addMapping(1, configurations.compileOnly, 'provided')
ext {
mavenName = 'Official Dropbox Java SDK'
generatedSources = file("$buildDir/generated-sources")
generatedResources = file("$buildDir/generated-resources")
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
basePom = pom {
name = mavenName
artifactId = archivesBaseName
project {
description = description
packaging 'jar'
url 'https://www.dropbox.com/developers/core'
scm {
connection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git'
developerConnection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git'
url 'https://github.com/dropbox/dropbox-sdk-java'
}
developers {
developer {
id 'dropbox-api-team'
name 'Dropbox API Team'
email 'api-support@dropbox.com'
organization = 'Dropbox'
}
}
licenses {
license {
name 'MIT'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
}
}
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'com.dropbox.maven:pem-converter-maven-plugin:1.0'
}
}
repositories {
mavenCentral()
}
dependencies {
// Important: Jackson 2.8+ will be free to use JDK7 features and no longer guarantees JDK6
// compatibility
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
compileOnly 'javax.servlet:servlet-api:2.5'
compileOnly 'com.squareup.okhttp:okhttp:2.7.5' // support both v2 and v3 to avoid
compileOnly 'com.squareup.okhttp3:okhttp:3.5.0' // method count bloat
compileOnly 'com.google.android:android:4.1.1.4'
compileOnly 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
testCompile 'org.testng:testng:6.9.10'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.openjdk.jmh:jmh-core:1.12'
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
testCompile 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
testCompile 'com.google.appengine:appengine-api-labs:1.9.38'
testCompile 'com.google.appengine:appengine-api-stubs:1.9.38'
testCompile 'com.google.appengine:appengine-testing:1.9.38'
testCompile 'com.squareup.okhttp:okhttp:2.7.5'
testCompile 'com.squareup.okhttp3:okhttp:3.5.0'
testCompile 'com.google.guava:guava:19.0'
}
configurations {
withoutOsgi.extendsFrom compile
}
processResources {
filesMatching('**/sdk-version.txt') {
expand project.properties
}
filesMatching('**/*.crt') { fcd ->
def inputstream = fcd.open()
def certDatas = com.dropbox.maven.pem_converter.PemLoader.load(
new InputStreamReader(inputstream, "UTF-8")
)
inputstream.close()
def out = new DataOutputStream(new FileOutputStream(new File(
getDestinationDir(), fcd.name.substring(0, fcd.name.length()-4) + ".raw"
)))
com.dropbox.maven.pem_converter.RawLoader.store(certDatas, out)
out.close()
fcd.exclude()
}
}
compileJava {
options.compilerArgs << '-Xlint:all'
options.warnings = true
options.deprecation = true
options.encoding = 'utf-8'
}
test {
useTestNG()
// TestNG specific options
options.parallel 'methods'
options.threadCount 4
// exclude integration tests
exclude '**/IT*.class'
exclude '**/*IT.class'
exclude '**/*IT$*.class'
testLogging {
events "skipped", "failed"
info {
events "passed", "skipped", "failed"
}
}
}
def getAuthInfoFile() {
if (!project.hasProperty(authInfoPropertyName)) {
throw new GradleException('' +
"These tests require the \"${authInfoPropertyName}\" " +
"project property be set to point to an authorization JSON file " +
"(e.g. ./gradlew integrationTest -P${authInfoPropertyName}=auth.json)."
)
}
def authInfoFile = file(project.property(authInfoPropertyName))
if (!authInfoFile.exists()) {
throw new GradleException('' +
"The test auth info file does not exist: \"${authInfoFile.absolutePath}\". " +
"Please ensure the \"${authInfoPropertyName}\" project property is set to point to " +
"the correct authorization JSON file."
)
}
return authInfoFile
}
task integrationTest(type: Test) {
description 'Runs integration tests against Production or Dev servers.'
useTestNG()
// TestNG specific options
options.parallel 'classes'
options.threadCount 4
options.preserveOrder true
// only select integration tests (similar to maven-failsafe-plugin rules)
include '**/IT*.class'
include '**/*IT.class'
include '**/*IT$*.class'
testLogging {
events "skipped", "failed"
info {
events "passed", "skipped", "failed"
}
}
reports {
html {
destination = file("${buildDir}/reports/integration-tests")
}
}
ext {
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
httpRequestorPropertyName = 'com.dropbox.test.httpRequestor'
}
doFirst {
systemProperty authInfoPropertyName, getAuthInfoFile().absolutePath
if (project.hasProperty(httpRequestorPropertyName)) {
systemProperty httpRequestorPropertyName, project.property(httpRequestorPropertyName)
}
}
}
javadoc {
title "${project.mavenName} ${project.version} API"
failOnError true
// JDK 8's javadoc has an on-by-default lint called "missing", which requires that everything
// be documented. Disable this lint because we intentionally don't document some things.
//
// NOTE: ugly hack to set our doclint settings due to strange handling of string options by the
// javadoc task.
if (JavaVersion.current().isJava8Compatible()) {
options.addBooleanOption "Xdoclint:all,-missing", true
}
options.addStringOption "link", "http://docs.oracle.com/javase/6/docs/api/"
}
jar {
// OsgiManifest since we import 'osgi' plugin
manifest {
name project.name
description project.description
license project.basePom.getModel().getLicenses()[0].url
def noeeProp = 'osgi.bnd.noee'
def noee = project.properties.get(noeeProp, System.properties.get(noeeProp, 'false'))
instruction '-noee', noee
}
}
task jarWithoutOsgi(type: Jar, dependsOn: classes) {
classifier 'withoutOsgi'
from sourceSets.main.output
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
withoutOsgi jarWithoutOsgi
}
install {
repositories.mavenInstaller {
pom = project.basePom
}
}
// To avoid cross-compilation surprises, add JDK6 libs to the boot classpath. This prevents issues
// where we depend on a JDK7 interface that did not exist in JDK6.
if (project.sourceCompatibility == JavaVersion.VERSION_1_6) {
if (System.env.JDK6_HOME == null) {
logger.warn("Set JDK6_HOME environment to disable boot classpath warnings.")
} else {
def jdkHome = System.env.JDK6_HOME
def sep = File.pathSeparator
logger.info("Setting JVM boot classpath to use ${jdkHome}")
project.tasks.withType(JavaCompile) {
def jdkLibs = "${jdkHome}/jre/lib"
def runtimeClasses = "rt.jar"
if (OperatingSystem.current().isMacOsX()) {
jdkLibs = "${jdkHome}/Classes"
runtimeClasses = "classes.jar"
}
options.bootClasspath = "${jdkLibs}/${runtimeClasses}"
options.bootClasspath += "${sep}${jdkLibs}/jsse.jar"
options.bootClasspath += "${sep}${jdkLibs}/jce.jar"
}
}
}
// reject dependencyUpdates candidates with alpha or beta in their names:
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
/* BEGIN PRIVATE REPO ONLY */
apply from: 'stone.gradle'
// load release configuration
if (!project.version.contains('SNAPSHOT')) {
apply from: 'release.gradle'
}
/* END PRIVATE REPO ONLY */