forked from dropbox/dropbox-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
281 lines (234 loc) · 8.96 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
import org.gradle.internal.os.OperatingSystem
apply plugin: 'java-library'
apply plugin: 'com.github.blindpirate.osgi'
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
ext {
mavenName = 'Official Dropbox Java SDK'
generatedSources = file("$buildDir/generated-sources")
generatedResources = file("$buildDir/generated-resources")
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
}
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.42.0'
classpath files('gradle/dropbox-pem-converter-plugin')
classpath 'gradle.plugin.com.github.blindpirate:gradle-legacy-osgi-plugin:0.0.6'
classpath "com.vanniktech:gradle-maven-publish-plugin:0.21.0"
}
}
repositories {
mavenCentral()
}
dependencies {
// Important: Jackson 2.8+ will be free to use JDK7 features and no longer guarantees JDK6
// compatibility
api 'com.fasterxml.jackson.core:jackson-core:2.7.9'
// DO NOT flip this back to implementation, we should split the android code to its own module in the future
compileOnly 'com.google.android:android:4.1.1.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:4.10.0' // method count bloat
compileOnly 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
testImplementation 'org.testng:testng:6.9.10'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'org.openjdk.jmh:jmh-core:1.12'
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.35'
testImplementation 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
testImplementation 'com.google.appengine:appengine-api-labs:1.9.38'
testImplementation 'com.google.appengine:appengine-api-stubs:1.9.38'
testImplementation 'com.google.appengine:appengine-testing:1.9.38'
testImplementation 'com.squareup.okhttp:okhttp:2.7.5'
testImplementation 'com.squareup.okhttp3:okhttp:4.0.0'
testImplementation 'com.google.guava:guava:23.0'
testImplementation "com.google.truth:truth:1.1.3"
}
configurations {
withoutOsgi.extendsFrom api
}
processResources { task ->
filesMatching('**/*.crt') { fcd ->
def inputstream = fcd.open()
def certDatas = com.dropbox.maven.pem_converter.PemLoader.load(
new InputStreamReader(inputstream, "UTF-8")
)
inputstream.close()
def crtPath = fcd.getPath()
def rawPath = crtPath.substring(0, crtPath.length() - 4) + ".raw"
def rawFile = new File(task.getDestinationDir(), rawPath);
rawFile.getParentFile().mkdirs();
def out = new DataOutputStream(new FileOutputStream(rawFile))
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 {
showStandardStreams = true // System.out.println
}
}
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()
// only select integration tests (similar to maven-failsafe-plugin rules)
include '**/IT*.class'
include '**/*IT.class'
include '**/*IT$*.class'
exclude '**/*V1IT.class'
exclude '**/*V1IT$*.class'
testLogging {
showStandardStreams = true // System.out.println
}
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)
}
}
// Will ensure that integration tests are re-run every time because they are not hermetic
outputs.upToDateWhen { false }
}
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 'http://opensource.org/licenses/MIT'
instruction 'Import-Package',
'android.*;resolution:=optional',
'com.google.appengine.*;resolution:=optional',
'com.squareup.okhttp;resolution:=optional',
'okhttp3;resolution:=optional',
'okio;resolution:=optional',
'*'
def noeeProp = 'osgi.bnd.noee'
def noee = providers.gradleProperty(noeeProp).forUseAtConfigurationTime().getOrElse(
providers.systemProperty(noeeProp).forUseAtConfigurationTime().getOrElse('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
}
// 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'
apply plugin: 'com.vanniktech.maven.publish'
/* END PRIVATE REPO ONLY */
allprojects {
plugins.withId("com.vanniktech.maven.publish") {
mavenPublishing {
publishToMavenCentral("S01")
}
}
}