forked from http-builder-ng/http-builder-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
297 lines (242 loc) · 11.1 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
plugins {
id "com.stehno.gradle.webpreview" version "0.3.0"
id 'com.github.kt3k.coveralls' version '2.8.1'
id 'java'
id 'jacoco'
id 'org.asciidoctor.convert' version '1.5.3'
id 'com.stehno.gradle.site' version '0.0.3'
id "com.github.johnrengelman.shadow" version '2.0.1'
}
group = 'io.github.http-builder-ng'
version = '1.0.4'
repositories {
jcenter()
}
configurations {
asciidoclet
}
dependencies {
asciidoclet 'org.asciidoctor:asciidoclet:1.+'
}
subprojects {
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'com.github.johnrengelman.shadow'
group = project.parent.group
version = project.parent.version
sourceCompatibility = 8
targetCompatibility = 8
repositories {
jcenter()
}
configurations {
asciidoclet
}
dependencies {
// optionals
[
'com.opencsv:opencsv:3.8',
'oauth.signpost:signpost-commonshttp4:1.2.1.1',
'oauth.signpost:signpost-core:1.2.1.1',
'org.codehaus.groovy:groovy-all:2.4.8',
'org.jsoup:jsoup:1.9.2',
'net.sourceforge.nekohtml:nekohtml:1.9.22',
'com.fasterxml.jackson.core:jackson-databind:2.8.1',
'javax.mail:javax.mail-api:1.5.6',
'com.sun.mail:javax.mail:1.5.6'
].each { opt ->
compileOnly(opt)
testCompile(opt)
}
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'com.stehno.ersatz:ersatz:1.5.0:safe@jar'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'com.stehno.vanilla:vanilla-core:0.5.1'
testCompile 'org.slf4j:jcl-over-slf4j:1.7.25'
testCompile 'ch.qos.logback:logback-classic:1.2.3'
asciidoclet 'org.asciidoctor:asciidoclet:1.+'
}
test {
systemProperty 'test.proxy.support', 'false'
reports.html.enabled = true
maxParallelForks = 4
}
jacocoTestReport {
reports {
xml.enabled = false
html.enabled = false
}
}
javadoc {
options.docletpath = configurations.asciidoclet.files.asType(List)
options.links("http://docs.oracle.com/javase/8/docs/api/", "http://docs.groovy-lang.org/latest/html/gapi/");
options.doclet = 'org.asciidoctor.Asciidoclet'
options.overview = "src/main/java/overview.adoc"
options.addStringOption "-base-dir", "${projectDir}"
options.addStringOption "-attribute", "name=${project.name},version=${project.version},title-link=https://github.com/http-builder-ng/http-builder-ng[${project.name} ${project.version}]"
}
task sourcesJar(type: Jar) {
description = 'Creates sources jar.'
classifier = 'sources'
from project.sourceSets.main.allSource
}
task javadocJar(type: Jar) {
description = 'Creates API documentation jar.'
classifier = 'javadoc'
from javadoc
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
archives shadowJar
}
publishing {
publications {
httpbPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifact shadowJar
groupId project.group
artifactId project.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', 'Groovy client for making http requests.')
root.appendNode('name', project.name)
root.appendNode('url', 'https://http-builder-ng.github.io/http-builder-ng/')
def licenseNode = root.appendNode('licenses').appendNode('license')
licenseNode.appendNode('name', 'The Apache Software License, Version 2.0')
licenseNode.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
licenseNode.appendNode('distribution', 'repo')
def developersNode = root.appendNode('developers')
def developerNode = developersNode.appendNode('developer')
developerNode.appendNode('id', 'dwclark')
developerNode.appendNode('name', 'David Clark')
developerNode = developersNode.appendNode('developer')
developerNode.appendNode('id', 'cjstehno')
developerNode.appendNode('name', 'Christopher J Stehno')
developerNode.appendNode('email', '[email protected]')
def scmNode = root.appendNode('scm')
scmNode.appendNode('connection', 'scm:git:[email protected]:http-builder-ng/http-builder-ng.git')
scmNode.appendNode('developerConnection', 'scm:git:[email protected]:http-builder-ng/http-builder-ng.git')
scmNode.appendNode('url', 'https://github.com/http-builder-ng/http-builder-ng')
}
}
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
asciidoctor {
options doctype: 'book'
backends = ['html5']
attributes 'source-highlighter': 'coderay',
'coderay-linenums-mode': 'table',
icon: 'font',
linkattrs: true,
encoding: 'utf-8'
}
tasks.site.dependsOn = [
'build', 'http-builder-ng-core:build', 'http-builder-ng-apache:build', 'http-builder-ng-okhttp:build',
'http-builder-ng-core:javadoc', 'http-builder-ng-apache:javadoc', 'http-builder-ng-okhttp:javadoc',
'http-builder-ng-core:jacocoTestReport', 'http-builder-ng-apache:jacocoTestReport', 'http-builder-ng-okhttp:jacocoTestReport',
'http-builder-ng-core:spotbugsMain', 'http-builder-ng-apache:spotbugsMain', 'http-builder-ng-okhttp:spotbugsMain',
'aggregateJavadoc', 'aggregateTestReport', 'aggregateCoverage',
'asciidoctor'
]
site {
siteUrl = 'https://http-builder-ng.github.io/http-builder-ng/'
assetDir( 'http-builder-ng-core/build/reports', into:'core', external:true )
assetDir( 'http-builder-ng-apache/build/reports', into:'apache', external:true )
assetDir( 'http-builder-ng-okhttp/build/reports', into:'okhttp', external:true )
versionedFile 'src/docs/asciidoc/index.adoc'
versionedFile 'src/docs/asciidoc/configuration.adoc'
versionedFile 'src/docs/asciidoc/examples.adoc'
testedPath '/guide/html5/index.html'
testedPath '/core/javadoc/index.html'
}
task publishSite(type: GradleBuild, group: 'Publishing', description: 'Publishes the documentation web site.', dependsOn: ['site']) {
buildFile = 'publish.gradle'
tasks = ['publishGhPages']
}
task verifyArtifacts(group: 'Verification', description: 'Verifies that the published artifacts exist in the remote repository.') {
doLast {
def base = 'https://dl.bintray.com/http-builder-ng/dclark/org/codehaus/groovy/modules'
///${project.version}/"
def artifacts = [
"$base/http-builder-ng-core/$project.version/http-builder-ng-core-$project.version-sources.jar",
"$base/http-builder-ng-core/$project.version/http-builder-ng-core-${project.version}.jar",
"$base/http-builder-ng-core/$project.version/http-builder-ng-core-${project.version}.pom",
"$base/http-builder-ng-apache/$project.version/http-builder-ng-apache-$project.version-sources.jar",
"$base/http-builder-ng-apache/$project.version/http-builder-ng-apache-${project.version}.jar",
"$base/http-builder-ng-apache/$project.version/http-builder-ng-apache-${project.version}.pom",
"$base/http-builder-ng-okhttp/$project.version/http-builder-ng-okhttp-$project.version-sources.jar",
"$base/http-builder-ng-okhttp/$project.version/http-builder-ng-okhttp-${project.version}.jar",
"$base/http-builder-ng-okhttp/$project.version/http-builder-ng-okhttp-${project.version}.pom"
]
logger.lifecycle "Verifying that artifacts exist at $base..."
boolean published = artifacts.every { art ->
boolean ok = checkUrl(art)
logger.info " - Checking: $art: ${ok ? 'ok' : 'missing'}"
ok
}
assert published, 'Some or all of the artifacts are not published. Run with --info for more details.'
}
}
task release(group: 'Development', description: 'Release a new version of the library.', dependsOn: [
'checkVersion',
'clean', 'http-builder-ng-core:clean', 'http-builder-ng-apache:clean', 'http-builder-ng-okhttp:clean',
'build', 'http-builder-ng-core:build', 'http-builder-ng-apache:build', 'http-builder-ng-okhttp:build',
'http-builder-ng-core:bintrayUpload', 'http-builder-ng-apache:bintrayUpload', 'http-builder-ng-okhttp:bintrayUpload',
'publishSite'
]) {
doLast {
logger.lifecycle 'Library has been released - confirm the Bintray publications and run "./gradlew verifyRelease"'
}
}
task verifyRelease(group: 'Verification', description: 'Verifies that the release was successful.', dependsOn: ['verifyArtifacts', 'verifySite']) {
doLast {
logger.lifecycle 'Release has been verified.'
}
}
def publishedProjects = subprojects.findAll()
task aggregateJavadoc(type: Javadoc, group: 'Documentation') {
description = 'Generates an aggregated Javadoc document.'
source publishedProjects.collect { it.sourceSets.main.allJava }
classpath = files(publishedProjects.collect { it.sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
options.docletpath = configurations.asciidoclet.files.asType(List)
options.links('http://docs.oracle.com/javase/8/docs/api/', 'http://docs.groovy-lang.org/latest/html/gapi/');
options.doclet = 'org.asciidoctor.Asciidoclet'
options.overview = 'src/docs/overview.adoc'
options.addStringOption "-base-dir", "${projectDir}"
options.addStringOption "-attribute", "name=${project.name},version=${project.version},title-link=https://github.com/http-builder-ng/http-builder-ng[${project.name} ${project.version}]"
}
task aggregateCoverage(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(publishedProjects.test)
additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(publishedProjects.sourceSets.main.output)
executionData = files(publishedProjects.jacocoTestReport.executionData)
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
task aggregateTestReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
reportOn subprojects*.test
}
coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}