Skip to content

Commit

Permalink
feat: Java 8 compatibility (#19)
Browse files Browse the repository at this point in the history
Closes #18

Co-authored-by: Ronny Bräunlich <[email protected]>
  • Loading branch information
rbraeunlich and Ronny Bräunlich authored Oct 15, 2024
1 parent dd3d500 commit 6f33f9c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
build:
strategy:
matrix:
java-version: [11, 17, 21]
java-version: [8, 11, 17, 21]
os:
- macos-latest
- ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dependencies {
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.7.4")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ kotlin {

tasks {
withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}

withType<KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
}

withType<Test>().configureEach {
Expand Down
41 changes: 20 additions & 21 deletions buildSrc/src/main/kotlin/buildsrc/utils/Rife2TestListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

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.tasks.testing.TestDescriptor
import org.gradle.api.tasks.testing.TestListener
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(
private val testBadgeApiKey: Provider<String>
Expand All @@ -41,23 +40,23 @@ class Rife2TestListener(

if (apiKey != null) {
println(apiKey)
val response: HttpResponse<String> = HttpClient.newHttpClient()
.send(
HttpRequest.newBuilder()
.uri(
URI(
"https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
"apiKey=$apiKey&" +
"passed=$passed&" +
"failed=$failed&" +
"skipped=$skipped"
)
)
.POST(HttpRequest.BodyPublishers.noBody())
.build(), HttpResponse.BodyHandlers.ofString()
)
println("RESPONSE: ${response.statusCode()}")
println(response.body())
val url = "https://rife2.com/tests-badge/update/net.thauvin.erik/urlencoder?" +
"apiKey=$apiKey&" +
"passed=$passed&" +
"failed=$failed&" +
"skipped=$skipped"

val client = HttpClients.createDefault()
val post = HttpPost(url)

val response = client.execute(post)
val entity = response.entity

val statusCode = response.statusLine.statusCode
val responseBody = EntityUtils.toString(entity, "UTF-8")

println("RESPONSE: $statusCode")
println(responseBody)
}
}
}
Expand Down

0 comments on commit 6f33f9c

Please sign in to comment.