-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.gradle
248 lines (207 loc) · 7.82 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
plugins {
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'jacoco'
id 'me.champeau.gradle.jmh' version '0.4.5'
id 'nebula.optional-base' version '3.2.0'
id 'com.github.hierynomus.license' version '0.15.0'
id 'com.github.spotbugs' version "4.5.0"
}
allprojects {
apply plugin: 'idea'
apply plugin: 'jacoco'
repositories {
jcenter()
}
jacoco {
toolVersion = '0.8.7'
}
}
allprojects {
group = 'com.optimizely.ab'
def travis_defined_version = System.getenv('TRAVIS_TAG')
if (travis_defined_version != null) {
version = travis_defined_version
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
}
def publishedProjects = subprojects.findAll { it.name != 'java-quickstart' }
configure(publishedProjects) {
apply plugin: 'com.github.spotbugs'
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'nebula.optional-base'
apply plugin: 'com.github.hierynomus.license'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
spotbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugs {
spotbugsJmh.enabled = false
}
test {
testLogging {
showStandardStreams = false
}
}
jmh {
duplicateClassesStrategy = 'warn'
}
sourceSets {
jmh.java.srcDirs += sourceSets.test.java.srcDirs
}
dependencies {
jmh 'org.openjdk.jmh:jmh-core:1.12'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
}
dependencies {
compile group: 'commons-codec', name: 'commons-codec', version: commonCodecVersion
testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: hamcrestVersion
testCompile group: 'com.google.guava', name: 'guava', version: guavaVersion
// logging dependencies (logback)
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
testCompile group: 'ch.qos.logback', name: 'logback-core', version: logbackVersion
testCompile group: 'com.google.code.gson', name: 'gson', version: gsonVersion
testCompile group: 'org.json', name: 'json', version: jsonVersion
testCompile group: 'com.googlecode.json-simple', name: 'json-simple', version: jsonSimpleVersion
testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
}
def docTitle = "Optimizely Java SDK"
if (name.equals('core-httpclient-impl')) {
docTitle = "Optimizely Java SDK: Httpclient"
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
customizePom(pom, docTitle)
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = isReleaseVersion ? releaseUrl : snapshotUrl
credentials {
username System.getenv('MAVEN_CENTRAL_USERNAME')
password System.getenv('MAVEN_CENTRAL_PASSWORD')
}
}
}
}
signing {
// base64 for workaround travis escape chars issue
def signingKeyBase64 = System.getenv('MAVEN_SIGNING_KEY_BASE64')
// skip signing for "local" version into MavenLocal for test-app
if (!signingKeyBase64?.trim()) return
byte[] decoded = signingKeyBase64.decodeBase64()
def signingKey = new String(decoded)
def signingPassword = System.getenv('MAVEN_SIGNING_PASSPHRASE')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.release
}
}
license {
header = rootProject.file("resources/HEADER")
skipExistingHeaders = true
include "**/*.java"
ext.author = "Optimizely"
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
task ship() {
dependsOn('publish')
}
// concurrent publishing (maven-publish) causes an issue with maven-central repository
// - a single module splits into multiple staging repos, so validation fails.
// - adding this ordering requirement forces sequential publishing processes.
project(':core-api').javadocJar.mustRunAfter = [':core-httpclient-impl:ship']
}
task ship() {
dependsOn(':core-api:ship', ':core-httpclient-impl:ship')
}
task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn publishedProjects.test, jacocoMerge
getAdditionalSourceDirs().setFrom(files(publishedProjects.sourceSets.main.allSource.srcDirs))
getSourceDirectories().setFrom(files(publishedProjects.sourceSets.main.allSource.srcDirs))
getAdditionalClassDirs().setFrom(files(publishedProjects.sourceSets.main.output))
executionData jacocoMerge.destinationFile
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
onlyIf { System.env.'CI' && !JavaVersion.current().isJava9Compatible() }
}
// standard POM format required by MavenCentral
def customizePom(pom, title) {
pom.withXml {
asNode().children().last() + {
// keep this - otherwise some properties are not made into pom properly
resolveStrategy = Closure.DELEGATE_FIRST
name title
url 'https://github.com/optimizely/java-sdk'
description 'The Java SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'optimizely'
name 'Optimizely'
email '[email protected]'
}
}
scm {
connection 'scm:git:git://github.com/optimizely/java-sdk.git'
developerConnection 'scm:git:ssh:github.com/optimizely/java-sdk.git'
url 'https://github.com/optimizely/java-sdk.git'
}
}
}
}