feat: Java 8 compatibility (#19)

Closes #18

Co-authored-by: Ronny Bräunlich <ronny.braeunlich@cbc.de>
This commit is contained in:
Ronny Bräunlich 2024-10-15 21:03:54 +02:00 committed by GitHub
parent dd3d500496
commit 6f33f9c2a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 25 deletions

View file

@ -17,7 +17,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
java-version: [11, 17, 21] java-version: [8, 11, 17, 21]
os: os:
- macos-latest - macos-latest
- ubuntu-latest - ubuntu-latest

View file

@ -8,4 +8,5 @@ dependencies {
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.4") implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.4")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
} }

View file

@ -45,12 +45,12 @@ kotlin {
tasks { tasks {
withType<JavaCompile>().configureEach { withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_11.toString() sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_11.toString() targetCompatibility = JavaVersion.VERSION_1_8.toString()
} }
withType<KotlinJvmCompile>().configureEach { withType<KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11) compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
} }
withType<Test>().configureEach { withType<Test>().configureEach {

View file

@ -16,14 +16,13 @@
package buildsrc.utils package buildsrc.utils
import org.apache.http.client.methods.HttpPost
import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils
import org.gradle.api.provider.Provider import org.gradle.api.provider.Provider
import org.gradle.api.tasks.testing.TestDescriptor import org.gradle.api.tasks.testing.TestDescriptor
import org.gradle.api.tasks.testing.TestListener import org.gradle.api.tasks.testing.TestListener
import org.gradle.api.tasks.testing.TestResult import org.gradle.api.tasks.testing.TestResult
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
class Rife2TestListener( class Rife2TestListener(
private val testBadgeApiKey: Provider<String> private val testBadgeApiKey: Provider<String>
@ -41,23 +40,23 @@ class Rife2TestListener(
if (apiKey != null) { if (apiKey != null) {
println(apiKey) println(apiKey)
val response: HttpResponse<String> = HttpClient.newHttpClient() val url = "https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
.send( "apiKey=$apiKey&" +
HttpRequest.newBuilder() "passed=$passed&" +
.uri( "failed=$failed&" +
URI( "skipped=$skipped"
"https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
"apiKey=$apiKey&" + val client = HttpClients.createDefault()
"passed=$passed&" + val post = HttpPost(url)
"failed=$failed&" +
"skipped=$skipped" val response = client.execute(post)
) val entity = response.entity
)
.POST(HttpRequest.BodyPublishers.noBody()) val statusCode = response.statusLine.statusCode
.build(), HttpResponse.BodyHandlers.ofString() val responseBody = EntityUtils.toString(entity, "UTF-8")
)
println("RESPONSE: ${response.statusCode()}") println("RESPONSE: $statusCode")
println(response.body()) println(responseBody)
} }
} }
} }