|
| 1 | +apply plugin: 'java' |
| 2 | +apply plugin: 'osgi' |
| 3 | +apply plugin: 'maven' |
| 4 | + |
| 5 | +description = 'Official Java client library for the Dropbox API.' |
| 6 | +group = 'com.dropbox.core' |
| 7 | +archivesBaseName = 'dropbox-core-sdk' |
| 8 | +version = '0-SNAPSHOT' |
| 9 | +sourceCompatibility = JavaVersion.VERSION_1_6 |
| 10 | +targetCompatibility = JavaVersion.VERSION_1_6 |
| 11 | + |
| 12 | +// needed before we define the pom |
| 13 | +conf2ScopeMappings.addMapping(1, configurations.compileOnly, 'provided') |
| 14 | + |
| 15 | +ext { |
| 16 | + generatedSources = file("$buildDir/generated-sources") |
| 17 | + generatedResources = file("$buildDir/generated-resources") |
| 18 | + basePom = pom { |
| 19 | + artifactId = archivesBaseName |
| 20 | + project { |
| 21 | + packaging 'jar' |
| 22 | + url 'https://www.dropbox.com/developers/core' |
| 23 | + |
| 24 | + scm { |
| 25 | + connection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git' |
| 26 | + developerConnection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git' |
| 27 | + url 'https://github.com/dropbox/dropbox-sdk-java' |
| 28 | + } |
| 29 | + |
| 30 | + developers { |
| 31 | + developer { |
| 32 | + id 'dropbox-api-team' |
| 33 | + name 'Dropbox API Team' |
| 34 | + email 'api-support@dropbox.com' |
| 35 | + organization 'Dropbox' |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + licenses { |
| 40 | + license { |
| 41 | + name 'MIT' |
| 42 | + url 'http://opensource.org/licenses/MIT' |
| 43 | + distribution 'repo' |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +buildscript { |
| 51 | + repositories { |
| 52 | + jcenter() |
| 53 | + mavenCentral() |
| 54 | + } |
| 55 | + dependencies { |
| 56 | + classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +repositories { |
| 61 | + mavenCentral() |
| 62 | +} |
| 63 | + |
| 64 | +dependencies { |
| 65 | + // Important: Jackson 2.8+ will be free to use JDK7 features and no longer guarantees JDK6 |
| 66 | + // compatibility |
| 67 | + compile 'com.fasterxml.jackson.core:jackson-core:2.7.4' |
| 68 | + compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.4' |
| 69 | + compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4' |
| 70 | + |
| 71 | + compileOnly 'javax.servlet:servlet-api:2.5' |
| 72 | + compileOnly 'com.squareup.okhttp:okhttp:2.7.5' |
| 73 | + compileOnly 'com.google.android:android:4.1.1.4' |
| 74 | + |
| 75 | + testCompile 'org.testng:testng:6.9.10' |
| 76 | + testCompile 'org.mockito:mockito-core:1.10.19' |
| 77 | + testCompile 'org.openjdk.jmh:jmh-core:1.12' |
| 78 | + testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.12' |
| 79 | +} |
| 80 | + |
| 81 | +processResources { |
| 82 | + filesMatching('**/sdk-version.txt') { |
| 83 | + expand project.properties |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +compileJava { |
| 88 | + options.compilerArgs << '-Xlint:all' |
| 89 | + options.warnings = true |
| 90 | + options.deprecation = true |
| 91 | + options.encoding = 'utf-8' |
| 92 | +} |
| 93 | + |
| 94 | +test { |
| 95 | + useTestNG() |
| 96 | + |
| 97 | + // TestNG specific options |
| 98 | + options.parallel 'classesAndMethods' |
| 99 | + options.preserveOrder true |
| 100 | + options.threadCount 4 |
| 101 | + |
| 102 | + // exclude integration tests |
| 103 | + exclude '**/IT*.class' |
| 104 | + exclude '**/*IT.class' |
| 105 | + exclude '**/*IT$*.class' |
| 106 | + |
| 107 | + testLogging { |
| 108 | + events "skipped", "failed" |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +task integrationTest(type: Test) { |
| 113 | + description 'Runs integration tests against Production or Dev servers.' |
| 114 | + |
| 115 | + useTestNG() |
| 116 | + |
| 117 | + // TestNG specific options |
| 118 | + options.preserveOrder true |
| 119 | + |
| 120 | + // only select integration tests (similar to maven-failsafe-plugin rules) |
| 121 | + include '**/IT*.class' |
| 122 | + include '**/*IT.class' |
| 123 | + include '**/*IT$*.class' |
| 124 | + |
| 125 | + testLogging { |
| 126 | + events "skipped", "failed" |
| 127 | + } |
| 128 | + |
| 129 | + reports { |
| 130 | + html { |
| 131 | + destination = file("${buildDir}/reports/integration-tests") |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + ext { |
| 136 | + authInfoPropertyName = 'com.dropbox.test.authInfoFile' |
| 137 | + okHttpPropertyName = 'com.dropbox.test.okHttp' |
| 138 | + } |
| 139 | + |
| 140 | + doFirst { |
| 141 | + // we need authentication information to run integration tests |
| 142 | + if (!project.hasProperty(authInfoPropertyName)) { |
| 143 | + throw new GradleException('' + |
| 144 | + "Integration tests require the \"${authInfoPropertyName}\" " + |
| 145 | + "project property be set to point to an authorization JSON file " + |
| 146 | + "(e.g. gradle integrationTest -P${authInfoPropertyName}=auth.json)." |
| 147 | + ) |
| 148 | + } |
| 149 | + |
| 150 | + def authInfoFile = file(project.property(authInfoPropertyName)) |
| 151 | + if (!authInfoFile.exists()) { |
| 152 | + throw new GradleException('' + |
| 153 | + "Integration test auth info file does not exist: \"${authInfoFile.absolutePath}\". " + |
| 154 | + "Please ensure the \"${authInfoPropertyName}\" project property is set to point to " + |
| 155 | + "the correct authorization JSON file." |
| 156 | + ) |
| 157 | + } |
| 158 | + |
| 159 | + systemProperty authInfoPropertyName, authInfoFile.absolutePath |
| 160 | + if (project.hasProperty(okHttpPropertyName)) { |
| 161 | + systemProperty okHttpPropertyName, project.property(okHttpPropertyName) |
| 162 | + } |
| 163 | + } |
| 164 | +} |
| 165 | + |
| 166 | +javadoc { |
| 167 | + title "${project.name} ${project.version} API" |
| 168 | + failOnError true |
| 169 | + |
| 170 | + // JDK 8's javadoc has an on-by-default lint called "missing", which requires that everything |
| 171 | + // be documented. Disable this lint because we intentionally don't document some things. |
| 172 | + // |
| 173 | + // NOTE: ugly hack to set our doclint settings due to strange handling of string options by the |
| 174 | + // javadoc task. |
| 175 | + options.addBooleanOption "Xdoclint:all,-missing", true |
| 176 | + options.addStringOption "link", "http://docs.oracle.com/javase/6/docs/api/" |
| 177 | +} |
| 178 | + |
| 179 | +jar { |
| 180 | + // OsgiManifest since we import 'osgi' plugin |
| 181 | + manifest { |
| 182 | + name project.name |
| 183 | + description project.description |
| 184 | + license project.basePom.getModel().getLicenses()[0].url |
| 185 | + |
| 186 | + def noeeProp = 'osgi.bnd.noee' |
| 187 | + def noee = project.properties.get(noeeProp, System.properties.get(noeeProp, 'false')) |
| 188 | + instruction '-noee', noee |
| 189 | + } |
| 190 | +} |
| 191 | + |
| 192 | +task sourcesJar(type: Jar, dependsOn: classes) { |
| 193 | + classifier = 'sources' |
| 194 | + from sourceSets.main.allSource |
| 195 | +} |
| 196 | + |
| 197 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 198 | + classifier = 'javadoc' |
| 199 | + from javadoc.destinationDir |
| 200 | +} |
| 201 | + |
| 202 | +artifacts { |
| 203 | + archives sourcesJar |
| 204 | + archives javadocJar |
| 205 | +} |
| 206 | + |
| 207 | +install { |
| 208 | + repositories.mavenInstaller { |
| 209 | + pom = project.basePom |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +// To avoid cross-compilation surprises, add JDK6 libs to the boot classpath. This prevents issues |
| 214 | +// where we depend on a JDK7 interface that did not exist in JDK6. |
| 215 | +if (project.sourceCompatibility == JavaVersion.VERSION_1_6) { |
| 216 | + if (System.env.JDK6_HOME == null) { |
| 217 | + logger.warn("Set JDK6_HOME environment to disable boot classpath warnings.") |
| 218 | + } else { |
| 219 | + def jdkHome = System.env.JDK6_HOME |
| 220 | + def sep = File.pathSeparator |
| 221 | + |
| 222 | + logger.info("Setting JVM boot classpath to use ${jdkHome}") |
| 223 | + project.tasks.withType(JavaCompile) { |
| 224 | + options.bootClasspath = "${jdkHome}/jre/lib/rt.jar" |
| 225 | + options.bootClasspath += "${sep}${jdkHome}/jre/lib/jsse.jar" |
| 226 | + options.bootClasspath += "${sep}${jdkHome}/jre/lib/jce.jar" |
| 227 | + } |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +/* BEGIN PRIVATE REPO ONLY */ |
| 232 | + |
| 233 | +apply from: 'babel.gradle' |
| 234 | + |
| 235 | +// load release configuration |
| 236 | +if (!project.version.contains('SNAPSHOT')) { |
| 237 | + apply from: 'release.gradle' |
| 238 | +} |
| 239 | + |
| 240 | +/* END PRIVATE REPO ONLY */ |
0 commit comments