Skip to content

Commit

Permalink
Merge pull request #54 from nstdio/gh-53
Browse files Browse the repository at this point in the history
feat: SPI for JSON mapping.
  • Loading branch information
nstdio authored Mar 27, 2022
2 parents 25f1e2a + 70b8e0f commit 169f485
Show file tree
Hide file tree
Showing 34 changed files with 1,234 additions and 233 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
id("net.researchgate.release")

id("io.github.nstdio.http.ext.library-conventions")
id("io.github.nstdio.http.ext.test-conventions")
id("io.github.nstdio.http.ext.quality-conventions")
id("io.github.nstdio.http.ext.publish-conventions")
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ repositories {

dependencies {
implementation("de.jjohannes.gradle:extra-java-module-info:0.11")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3")
implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
implementation("net.researchgate:gradle-release:2.8.1")
implementation("com.github.dpaukov:combinatoricslib3:3.3.3")
}

tasks.withType<KotlinCompile> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,109 +16,23 @@

@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")

import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import java.lang.Boolean as JavaBoolean

plugins {
`java-library`
jacoco
id("de.jjohannes.extra-java-module-info")
}

val isCI = System.getenv("CI").toBoolean()

group = "io.github.nstdio"

java {
withJavadocJar()
withSourcesJar()

sourceSets {
create("spiTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
}

configurations.getByName("spiTestImplementation") {
extendsFrom(configurations.testImplementation.get())
}

mapOf(
"spiTestImplementation" to "testImplementation",
"spiTestRuntimeOnly" to "testRuntimeOnly",
).forEach { (t, u) ->
configurations.getByName(t) { extendsFrom(configurations.getByName(u)) }
}

configurations.names
.filter { !setOf("compileClasspath", "runtimeClasspath").contains(it) }
.map { configurations.getByName(it) }
.forEach {
configure(listOf(it)) {
attributes {
@Suppress("UNCHECKED_CAST")
val forName = Class.forName("java.lang.Boolean") as Class<JavaBoolean>
val value: JavaBoolean = JavaBoolean.valueOf("false") as JavaBoolean

attribute(Attribute.of("javaModule", forName), value)
}
}
}

val junitVersion = "5.8.2"
val commonIoVersion = "1.3.2"
val assertJVersion = "3.22.0"
val jsonPathAssertVersion = "2.7.0"
val slf4jVersion = "1.7.36"
val jacksonVersion = "2.13.2"
val brotli4JVersion = "1.6.0"
val brotliOrgVersion = "0.1.2"

val spiDeps = listOf("org.brotli:dec:$brotliOrgVersion", "com.aayushatharva.brotli4j:brotli4j:$brotli4JVersion")
val lombokVersion = "1.18.22"

dependencies {
api("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")

compileOnly("org.projectlombok:lombok:1.18.22")
annotationProcessor("org.projectlombok:lombok:1.18.22")

spiDeps.forEach { compileOnly(it) }

/** AssertJ & Friends */
testImplementation("org.assertj:assertj-core:$assertJVersion")
testImplementation("com.jayway.jsonpath:json-path-assert:$jsonPathAssertVersion")

testImplementation("org.apache.commons:commons-io:$commonIoVersion")

/** Jupiter */
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation("org.slf4j:slf4j-simple:$slf4jVersion")
testImplementation("org.awaitility:awaitility:4.2.0")
testImplementation("org.mockito:mockito-core:4.4.0")

testImplementation("com.github.tomakehurst:wiremock-jre8:2.32.0")
testImplementation("com.tngtech.archunit:archunit-junit5:0.23.1")

val spiTestImplementation = configurations.getByName("spiTestImplementation")
spiDeps.forEach { spiTestImplementation(it) }
spiTestImplementation("com.aayushatharva.brotli4j:native-${getArch()}:$brotli4JVersion")
}

fun getArch(): String {
val operatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()

if (operatingSystem.isWindows) return "windows-x86_64"
else if (operatingSystem.isMacOsX) return "osx-x86_64"
else if (operatingSystem.isLinux)
return if (DefaultNativePlatform.getCurrentArchitecture().isArm) "linux-aarch64"
else "linux-x86_64"

return ""
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
}

tasks.withType<JavaCompile>().configureEach {
Expand All @@ -128,42 +42,3 @@ tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs = listOf("-Xlint:all", "-Xlint:-deprecation")
}

tasks.withType<Test> {
useJUnitPlatform()
reports {
html.required.set(!isCI)
}
testLogging {
events("skipped", "failed")
exceptionFormat = FULL
}
}

tasks.create<Test>("spiTest") {
description = "Run SPI tests"
group = "verification"
testClassesDirs = sourceSets.getByName("spiTest").output.classesDirs
classpath = sourceSets.getByName("spiTest").runtimeClasspath
}

tasks.check {
dependsOn("spiTest")
}

tasks.build {
dependsOn("spiTest")
}

extraJavaModuleInfo {
module("brotli4j-${brotli4JVersion}.jar", "com.aayushatharva.brotli4j", brotli4JVersion) {
exports("com.aayushatharva.brotli4j")
exports("com.aayushatharva.brotli4j.common")
exports("com.aayushatharva.brotli4j.decoder")
exports("com.aayushatharva.brotli4j.encoder")
}

module("dec-${brotliOrgVersion}.jar", "org.brotli.dec", brotliOrgVersion) {
exports("org.brotli.dec")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@

plugins {
jacoco
id("org.sonarqube")
}

sonarqube {
properties {
property("sonar.projectKey", "nstdio_http-client-ext")
property("sonar.organization", "nstdio")
property("sonar.host.url", "https://sonarcloud.io")
}
}

jacoco {
Expand Down
Loading

0 comments on commit 169f485

Please sign in to comment.