forked from optimizely/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
232 lines (192 loc) · 6.38 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
buildscript {
repositories {
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
}
}
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'
}
allprojects {
group = 'com.optimizely.ab'
apply plugin: 'idea'
apply plugin: 'jacoco'
repositories {
jcenter()
}
jacoco {
toolVersion = '0.8.0'
}
}
apply from: 'gradle/publish.gradle'
allprojects {
def travis_defined_version = System.getenv('TRAVIS_TAG')
if (travis_defined_version != null) {
version = travis_defined_version
}
}
subprojects {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'nebula.optional-base'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
jcenter()
}
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
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
findbugs {
findbugsJmh.enabled = false
}
test {
useJUnit {
excludeCategories 'com.optimizely.ab.categories.ExhaustiveTest'
}
testLogging {
showStandardStreams = false
}
}
task exhaustiveTest(type: Test) {
useJUnit {
includeCategories 'com.optimizely.ab.categories.ExhaustiveTest'
}
}
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 {
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
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
url 'https://github.com/optimizely/java-sdk'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'optimizely'
name 'Optimizely'
email 'developers@optimizely.com'
}
}
}
}
}
}
}
def bintrayName = 'core-api';
if (name.equals('core-httpclient-impl')) {
bintrayName = 'httpclient'
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
pkg {
repo = 'optimizely'
name = "optimizely-sdk-${bintrayName}"
userOrg = 'optimizely'
version {
name = rootProject.version
}
publications = ['mavenJava']
}
}
build.dependsOn('generatePomFileForMavenJavaPublication')
bintrayUpload.dependsOn 'build'
task ship() {
dependsOn('bintrayUpload')
}
}
task ship() {
dependsOn(':core-api:ship', ':core-httpclient-impl:ship')
}
// Only report code coverage for projects that are distributed
def publishedProjects = subprojects.findAll { it.path != ':simulator' }
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
additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = 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() }
}