Skip to content

Commit 6f33f9c

Browse files
rbraeunlichRonny Bräunlich
andauthored
feat: Java 8 compatibility (#19)
Closes #18 Co-authored-by: Ronny Bräunlich <ronny.braeunlich@cbc.de>
1 parent dd3d500 commit 6f33f9c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
build:
1818
strategy:
1919
matrix:
20-
java-version: [11, 17, 21]
20+
java-version: [8, 11, 17, 21]
2121
os:
2222
- macos-latest
2323
- ubuntu-latest

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies {
88
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
99
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
1010
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.4")
11+
implementation("org.apache.httpcomponents:httpclient:4.5.13")
1112
}

buildSrc/src/main/kotlin/buildsrc/conventions/lang/kotlin-multiplatform-base.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ kotlin {
4545

4646
tasks {
4747
withType<JavaCompile>().configureEach {
48-
sourceCompatibility = JavaVersion.VERSION_11.toString()
49-
targetCompatibility = JavaVersion.VERSION_11.toString()
48+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
49+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
5050
}
5151

5252
withType<KotlinJvmCompile>().configureEach {
53-
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
53+
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
5454
}
5555

5656
withType<Test>().configureEach {

buildSrc/src/main/kotlin/buildsrc/utils/Rife2TestListener.kt

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616

1717
package buildsrc.utils
1818

19+
import org.apache.http.client.methods.HttpPost
20+
import org.apache.http.impl.client.HttpClients
21+
import org.apache.http.util.EntityUtils
1922
import org.gradle.api.provider.Provider
2023
import org.gradle.api.tasks.testing.TestDescriptor
2124
import org.gradle.api.tasks.testing.TestListener
2225
import org.gradle.api.tasks.testing.TestResult
23-
import java.net.URI
24-
import java.net.http.HttpClient
25-
import java.net.http.HttpRequest
26-
import java.net.http.HttpResponse
2726

2827
class Rife2TestListener(
2928
private val testBadgeApiKey: Provider<String>
@@ -41,23 +40,23 @@ class Rife2TestListener(
4140

4241
if (apiKey != null) {
4342
println(apiKey)
44-
val response: HttpResponse<String> = HttpClient.newHttpClient()
45-
.send(
46-
HttpRequest.newBuilder()
47-
.uri(
48-
URI(
49-
"https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
50-
"apiKey=$apiKey&" +
51-
"passed=$passed&" +
52-
"failed=$failed&" +
53-
"skipped=$skipped"
54-
)
55-
)
56-
.POST(HttpRequest.BodyPublishers.noBody())
57-
.build(), HttpResponse.BodyHandlers.ofString()
58-
)
59-
println("RESPONSE: ${response.statusCode()}")
60-
println(response.body())
43+
val url = "https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
44+
"apiKey=$apiKey&" +
45+
"passed=$passed&" +
46+
"failed=$failed&" +
47+
"skipped=$skipped"
48+
49+
val client = HttpClients.createDefault()
50+
val post = HttpPost(url)
51+
52+
val response = client.execute(post)
53+
val entity = response.entity
54+
55+
val statusCode = response.statusLine.statusCode
56+
val responseBody = EntityUtils.toString(entity, "UTF-8")
57+
58+
println("RESPONSE: $statusCode")
59+
println(responseBody)
6160
}
6261
}
6362
}

0 commit comments

Comments
 (0)