-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.gradle
More file actions
263 lines (230 loc) · 7.82 KB
/
build.gradle
File metadata and controls
263 lines (230 loc) · 7.82 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
plugins {
id 'maven-publish'
id 'signing'
id 'java-library'
id 'tech.yanand.maven-central-publish' version '1.3.0'
}
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
jvmArgs += "--add-opens=jdk.httpserver/com.sun.net.httpserver=ALL-UNNAMED"
systemProperty("java.util.logging.config.file","logging.properties")
systemProperty("com.sun.net.httpserver.HttpServerProvider","robaho.net.httpserver.DefaultHttpServerProvider")
systemProperty("robaho.net.httpserver.http2OverSSL","true")
systemProperty("robaho.net.httpserver.http2OverNonSSL","true")
// systemProperty("robaho.net.httpserver.http2MaxConcurrentStreams","5000")
// systemProperty("robaho.net.httpserver.http2DisableFlushDelay","true")
// systemProperty("robaho.net.httpserver.http2OverSSL","true")
systemProperty("robaho.net.httpserver.http2OverNonSSL","true")
// systemProperty("javax.net.debug","ssl:handshake:verbose:keymanager:trustmanager")
}
tasks.withType(JavaExec) {
jvmArgs += "--enable-preview"
systemProperty("java.util.logging.config.file","logging.properties")
systemProperty("com.sun.net.httpserver.HttpServerProvider","robaho.net.httpserver.DefaultHttpServerProvider")
// systemProperty("robaho.net.httpserver.http2OverSSL","true")
systemProperty("robaho.net.httpserver.http2OverNonSSL","true")
systemProperty("robaho.net.httpserver.http2InitialWindowSize","1024000")
systemProperty("robaho.net.httpserver.http2ConnectionWindowSize","1024000000")
systemProperty("robaho.net.httpserver.EnableStats","true")
systemProperty("robaho.net.httpserver.EnableDebug","true")
}
dependencies {
testImplementation 'org.testng:testng:7.8.0'
}
configurations {
testMainsCompile.extendsFrom testCompile
testMainsRuntime.extendsFrom testMainsCompile
}
test {
useTestNG()
testLogging {
// events "passed", "skipped", "failed", "standard_out", "standard_error"
events "failed"
}
}
sourceSets {
main {
java {
srcDirs = [ 'src/main/java' ]
}
}
test {
java {
srcDirs = [
'src/test/extras',
'src/test/java',
'src/test/java_default/bugs',
'src/test/java_default/HttpExchange'
]
}
}
create('testMains') {
java {
srcDirs = ['src/test/test_mains']
compileClasspath = test.output + main.output + configurations.testMainsCompile
runtimeClasspath = output + compileClasspath + configurations.testMainsRuntime
}
resources {
srcDirs = [ 'src/test/resources' ]
}
}
}
// Use a lazy Provider to get the git version. This is the modern, configuration-cache-friendly approach.
def gitVersionProvider = project.providers.exec {
// 1. Describe the latest revision with a tag
commandLine = ['git', 'describe', '--tags', '--always']
ignoreExitValue = true // Don't fail the build if git fails (e.g., no tags exist)
}.standardOutput.asText.map { it.trim() }
// Apply the git version to your project
version = gitVersionProvider.get()
task showGitVersion {
doLast {
println "project version is "+version
}
}
build {
}
jar {
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Version": version)
}
}
task runSingleUnitTest(type: Test) {
outputs.upToDateWhen { false }
dependsOn testClasses
filter {
includeTestsMatching 'PipeliningStallTest'
}
useTestNG()
}
/** used for development to run a single test */
task runSingleMainTest(type: Test) {
outputs.upToDateWhen { false }
dependsOn testMainsClasses
doLast {
def testname = "B6361557"
println jvmArgs
println systemProperties
def props = systemProperties
javaexec {
classpath sourceSets.testMains.runtimeClasspath
main testname
systemProperties = props
// debug true
}
}
}
task testMainsTest(type: Test) {
dependsOn testMainsClasses
doLast {
def files = sourceSets.testMains.allJava
def is = System.in
files.each { file ->
def fileWithoutExt = file.name.take(file.name.lastIndexOf('.'))
def props = systemProperties
println " *** $fileWithoutExt ***"
javaexec {
classpath sourceSets.testMains.runtimeClasspath
main fileWithoutExt
systemProperties props
standardInput is
}
}
}
}
task runSimpleFileServer(type: JavaExec) {
doFirst {
mkdir 'fileserver'
}
dependsOn testClasses
classpath sourceSets.test.runtimeClasspath
// FIX 1: Use 'mainClass' instead of 'main'
// FIX 2: Replace "SimpleFileServer" with the FULLY QUALIFIED class name
// (e.g., if it's in a package named com.example)
mainClass = "com.example.SimpleFileServer"
args = ['fileserver','443','fileserver/logfile.txt']
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(23)
}
}
task testJar(type: Jar) {
archiveClassifier.set("test")
from sourceSets.test.output, sourceSets.testMains.output
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task runAllTests(type: Test) {
dependsOn test
dependsOn testMainsTest
}
publish {
dependsOn runAllTests
}
publishing {
publications {
maven(MavenPublication) {
groupId = 'io.github.robaho'
artifactId = 'httpserver'
from components.java
pom {
name = 'HttpServer'
description = 'A zero dependency implementation of the JDK httpserver designed for Virtual Threads. Includes websocket and Http2 support.'
signing {
sign publishing.publications.maven
sign configurations.archives
}
url = 'https://github.com/robaho/httpserver'
scm {
url = 'https://github.com/robaho/httpserver.git'
}
licenses {
license {
name = 'gnu v2.0 with classpath exception'
url = 'https://www.gnu.org/software/classpath/license.html'
}
license {
name = 'nanohttpd'
url = 'https://github.com/NanoHttpd/nanohttpd/blob/efb2ebf85a2b06f7c508aba9eaad5377e3a01e81/LICENSE.md'
}
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'robaho'
name = 'Robert Engels'
email = 'robaho@me.com'
}
}
}
}
}
}
mavenCentral {
def tokenString = "${maven_user}:${maven_password}"
def token = tokenString.bytes.encodeBase64().toString()
authToken = token
// Whether the upload should be automatically published or not. Use 'USER_MANAGED' if you wish to do this manually.
// This property is optional and defaults to 'AUTOMATIC'.
publishingType = 'AUTOMATIC'
// Max wait time for status API to get 'PUBLISHING' or 'PUBLISHED' status when the publishing type is 'AUTOMATIC',
// or additionally 'VALIDATED' when the publishing type is 'USER_MANAGED'.
// This property is optional and defaults to 60 seconds.
maxWait = 60
}