Skip to content

Commit 008cd35

Browse files
authored
Rewritten Rest Client using HttpClient (#42)
1 parent ada00b2 commit 008cd35

File tree

6 files changed

+115
-294
lines changed

6 files changed

+115
-294
lines changed

build.gradle

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ group 'io.github.jopenlibs'
1010
archivesBaseName = 'vault-java-driver'
1111
version '5.4.0'
1212

13-
// This project is actually limited to Java 8 compatibility. See below.
14-
sourceCompatibility = 9
15-
targetCompatibility = 9
13+
sourceCompatibility = 11
14+
targetCompatibility = 11
1615

1716
repositories {
1817
mavenCentral()
@@ -31,46 +30,14 @@ dependencies {
3130
testRuntimeOnly('org.slf4j:slf4j-simple:2.0.3')
3231
}
3332

34-
// Beginning of Java 9 compatibility config
35-
//
36-
// Allowing a library to support Java 9+ modularity, while also maintaining backwards-compatibility for Java 8 users, is WAY more
37-
// tricky than expected! The lines below are adapted from a blog article (https://dzone.com/articles/building-java-6-8-libraries-for-jpms-in-gradle),
38-
// and cause the built classes to support a Java 8 JRE, while also including a module definition suitable for use with Java 9. There are a
39-
// few considerations that come with this:
40-
//
41-
// * You now need JDK 9 or higher to BUILD this library. You can still USE the built artifact as a dependency in a Java 8 project.
42-
// * Although "sourceCompatibility" and "targetCompatability" above are set for Java 9, the "compileJava" settings below will not
43-
// allow you to build with any code changes that are not Java 8 compatible.
44-
// * Unfortunately, IntelliJ (and perhaps other IDE's?) will show syntax highlighting, code completion tips, etc for Java 9. Sorry for
45-
// the inconvenience. In any case, you should not commit changes to source control without confirming that the project builds.
4633
compileJava {
47-
exclude 'module-info.java'
48-
49-
options.compilerArgs = ['--release', '8']
34+
options.compilerArgs = ['--release', targetCompatibility.toString()]
5035
}
5136

5237
tasks.withType(JavaCompile).configureEach {
5338
options.encoding = 'UTF-8'
5439
}
5540

56-
tasks.register('compileModuleInfoJava', JavaCompile) {
57-
classpath = files()
58-
source = 'src/main/java/module-info.java'
59-
destinationDir = compileJava.destinationDir
60-
options.encoding = compileJava.options.encoding
61-
62-
doFirst {
63-
options.compilerArgs = [
64-
'--release', '9',
65-
'--module-path', compileJava.classpath.asPath,
66-
]
67-
}
68-
}
69-
70-
compileModuleInfoJava.dependsOn compileJava
71-
classes.dependsOn compileModuleInfoJava
72-
// End of Java 9 compatibility config
73-
7441
tasks.register('javadocJar', Jar) {
7542
dependsOn tasks.named("javadoc")
7643
archiveClassifier.set('javadoc')
@@ -115,8 +82,14 @@ tasks.named('test') {
11582
events "passed", "skipped", "failed"
11683
}
11784

118-
reports.html.enabled = false
119-
reports.junitXml.enabled = true
85+
reports {
86+
html {
87+
required = false
88+
}
89+
junitXml {
90+
required = true
91+
}
92+
}
12093
}
12194

12295
def integrationTestTask = tasks.register('integrationTest', Test) {
@@ -127,8 +100,14 @@ def integrationTestTask = tasks.register('integrationTest', Test) {
127100
events "passed", "skipped", "failed"
128101
}
129102

130-
reports.html.enabled = false
131-
reports.junitXml.enabled = true
103+
reports {
104+
html {
105+
required = false
106+
}
107+
junitXml {
108+
required = true
109+
}
110+
}
132111
}
133112

134113
//

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip
6+
distributionUrl=https://services.gradle.org/distributions/gradle-8.2-all.zip

src/main/java/io/github/jopenlibs/vault/api/Auth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public AuthResponse loginByAppID(final String path, final String appId, final St
439439
.toString();
440440
final RestResponse restResponse = new Rest()//NOPMD
441441
.url(config.getAddress() + "/v1/auth/" + path)
442-
.optionalHeader("X-Vault-Namespace", this.nameSpace)
442+
.header("X-Vault-Namespace", this.nameSpace)
443443
.body(requestJson.getBytes(StandardCharsets.UTF_8))
444444
.connectTimeoutSeconds(config.getOpenTimeout())
445445
.readTimeoutSeconds(config.getReadTimeout())

0 commit comments

Comments
 (0)