-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.gradle
More file actions
331 lines (294 loc) · 8.31 KB
/
build.gradle
File metadata and controls
331 lines (294 loc) · 8.31 KB
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'org.jsoup:jsoup:1.12.1'
// classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40'
}
}
group 'info.jdavid.ok.server'
version '3.14.4.0'
apply plugin: 'java'
//apply plugin: 'kotlin'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'idea'
repositories {
jcenter()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
println "Java version: ${System.getProperty('java.version')}"
ext {
bintrayApiKey = new File("$projectDir/local.properties").with {
it.text.splitEachLine('=', { if (it && it[0] == 'bintrayApiKey') return it[1] })
}
println(Runtime.class.getPackage().getImplementationVersion())
jdkVersion = Runtime.class.getPackage().getImplementationVersion()?.
replaceFirst('1\\.([78])\\.0_([0-9]+)(?:-[1-9a-z]+)*', '$1.$2')
println jdkVersion
}
tasks.withType(JavaCompile) {
if (jdkVersion != null) {
doFirst {
String jre6Home =
System.getProperty('java.home').replaceAll('\\\\', '/').replaceFirst(/1[.][789]/, '1.6')
if (new File(jre6Home).exists()) {
options.fork = true
options.bootClasspath = fileTree(include: ['*.jar'], dir: "${jre6Home}/lib").join(File.pathSeparator)
options.extensionDirs = "${jre6Home}/lib/ext"
}
}
}
}
tasks.withType(Test) {
if (jdkVersion != null) {
doFirst {
jvmArgs '-Xbootclasspath/p:' + configurations.alpn.files { it.group == 'info.jdavid.alpn' }
}
}
}
configurations {
// coroutinesCompile.extendsFrom compile
// coroutinesRuntime.extendsFrom runtime
samplesCompile.extendsFrom compile
samplesRuntime.extendsFrom runtime
testRuntime.extendsFrom samplesRuntime
alpn
cli
}
sourceSets {
// coroutines {
// java {
// compileClasspath += main.output
// runtimeClasspath += main.output
// }
// kotlin {
// srcDir file('src/coroutines/kotlin')
// }
// }
samples {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/samples/java')
}
resources {
srcDir file('src/samples/resources')
}
}
test {
java {
compileClasspath += samples.output
runtimeClasspath += samples.output
}
}
}
compileSamplesJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
//compileCoroutinesJava {
// sourceCompatibility = 1.8
// targetCompatibility = 1.8
//}
dependencies {
compile 'com.squareup.okio:okio:1.17.3'
compile 'com.squareup.okhttp3:okhttp:3.14.4'
compile 'org.slf4j:slf4j-api:1.7.25'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
jdkVersion?.with { alpn "info.jdavid.alpn:alpn-boot:${it}" }
// coroutinesCompile 'org.jetbrains.kotlin:kotlin-stdlib'
// coroutinesCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.16'
// coroutinesCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-nio:0.16'
samplesCompileOnly 'com.google.code.findbugs:jsr305:3.0.2'
samplesCompile 'info.jdavid.ok.json:okjson:4.3.0'
testCompile 'junit:junit:4.12'
testCompile 'info.jdavid.ok.json:okjson:4.3.0'
testCompile 'net.sourceforge.htmlunit:htmlunit:2.27'
testCompileOnly 'com.google.code.findbugs:jsr305:3.0.2'
//testCompile files('c:/progra~1/java/jdk1.8/lib/rt.jar')
testRuntime 'org.slf4j:slf4j-jdk14:1.7.25'
cli 'org.slf4j:slf4j-jdk14:1.7.25'
}
task bigJar(type: Jar) {
archiveName "${project.name}-${project.version}-all.jar"
from sourceSets.main.output.classesDirs
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}.exclude "META-INF/**"
manifest {
attributes 'Main-Class': 'info.jdavid.ok.server.RequestHandlerChain'
}
}
jar {
manifest {
attributes Sealed: true
}
finalizedBy tasks.bigJar
}
jacoco {
reportsDir = file("$buildDir/jacoco/reports")
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled true
}
}
//kotlin {
// experimental {
// coroutines 'enable'
// }
// compileKotlin {
// kotlinOptions {
// jdkVersion = '1.8'
// }
// }
//}
test {
String jreHome = System.getProperty('java.home').replaceAll('\\\\', '/')
if (jdkVersion != null) {
FileTree bootClasspath = configurations.alpn.asFileTree.plus(
fileTree(include: ['*.jar'], dir: "${jreHome}/lib")
)
setBootstrapClasspath(bootClasspath)
}
else {
jvmArgs '-XX:+IgnoreUnrecognizedVMOptions'
jvmArgs '--permit-illegal-access'
jvmArgs '--show-version'
}
testLogging {
showStandardStreams = true
}
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
systemProperty 'https.proptocols', 'TLSv1.2'
systemProperty 'started-with-gradle', 'true'
doLast {
File html = reports.html.entryPoint
def doc = org.jsoup.Jsoup.parse(html, 'UTF-8')
int total = doc.select('#tests > .counter').text() as int
int failed = doc.select('#failures > .counter').text() as int
def readme = file('README.md')
def badge = { String label, String text, String color ->
"https://img.shields.io/badge/_${label}_-_${text}-${color}.png?style=flat"
}
String label = 'Tests'
String text = "${total-failed}/${total}"
String color = failed == 0 ? 'green' : (failed < 3 ? 'yellow' : 'red')
String v = project.version
def download =
"https://bintray.com/artifact/download/programingjd/maven/info/jdavid/" +
"ok/server/okserver/$v/okserver-${v}.jar"
readme.readLines().withIndex().collect { line, i ->
switch (i) {
case 0:
return "})   })"
case 9: return "[Download](${download}) the latest jar."
case 19: return " <version>${v}</version>"
case 32: return " compile 'info.jdavid.ok.server:okserver:${v}'"
default: return line
}
}.join('\n').with { readme.text = it }
}
finalizedBy tasks.jacocoTestReport
// outputs.upToDateWhen { false }
}
task cli(type: JavaExec, dependsOn: classes) {
//debug true
main = 'info.jdavid.ok.server.RequestHandlerChain'
classpath = sourceSets.main.runtimeClasspath
classpath += files(configurations.cli.files)
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
//task coroutinesJar(type: Jar, dependsOn: coroutinesClasses) {
// classifier = 'coroutines'
// manifest {
// attributes Sealed: true
// }
// from sourceSets.main.output
// from sourceSets.coroutines.output
//}
//task javadocCoroutinesJar(type: Jar, dependsOn: javadoc) {
// classifier = 'javadoc'
// from javadoc.destinationDir
//}
//task sourcesCoroutinesJar(type: Jar, dependsOn: classes) {
// classifier = 'sources'
// from sourceSets.main.allSource
// from sourceSets.coroutines.allSource
//}
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId 'okserver'
from components.java
artifact sourcesJar
artifact javadocJar
}
// mavenJavaCoroutines(MavenPublication) {
// groupId project.group
// artifactId 'okserver-coroutines'
// from components.java
// artifact sourcesCoroutinesJar
// artifact javadocCoroutinesJar
// }
}
repositories {
maven {
url "$buildDir/repo"
}
}
}
bintray {
user = 'programingjd'
key = bintrayApiKey
dryRun = false
publish = true
publications = ['mavenJava']
pkg {
repo = 'maven'
name = 'info.jdavid.ok.server'
websiteUrl = 'https://github.com/programingjd/okserver'
issueTrackerUrl = 'https://github.com/programingjd/okserver/issues'
vcsUrl = 'https://github.com/programingjd/okserver.git'
githubRepo = 'programingjd/okserver'
githubReleaseNotesFile = 'README.md'
licenses = ['Apache-2.0']
labels = ['server','http','okio','okhttp','java']
publicDownloadNumbers = true
version {
name = project.version
mavenCentralSync {
sync = false
}
}
}
}
tasks.bintrayUpload.dependsOn tasks.check