Skip to content

Commit

Permalink
Modernize Gradle and Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed Sep 23, 2022
1 parent 8c20f82 commit cf3e292
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 401 deletions.
43 changes: 0 additions & 43 deletions build.gradle

This file was deleted.

158 changes: 158 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.7.10"
jacoco
id("com.vanniktech.maven.publish") version "0.22.0"
}

val jacksonVersion = "2.13.1"

repositories {
mavenCentral()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
api("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
api("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

// pass -DreadmeFormat to format benchmark results to update readme
val readmeFormat = findProperty("readmeFormat") == "true"

val kotestVersion = "4.6.4"

dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
testApi("com.jayway.jsonpath:json-path:2.4.0")
testImplementation("org.json:json:20180813")
testImplementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion") // for kotest framework
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") // for kotest core jvm assertions
}

tasks.register<Test>("benchmark") {
useJUnitPlatform()

if(readmeFormat) {
jvmArgs("-DreadmeFormat=true")
}

filter {
include("com/nfeld/jsonpathkt/BenchmarkTest.class")
}

testLogging {
showStandardStreams = true
}

// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
}

tasks.register<Test>("perfTest") {
useJUnitPlatform()

filter {
include("com/nfeld/jsonpathkt/PerfTest.class")
}

testLogging {
// show test results for following events
events("PASSED", "FAILED", "SKIPPED")

// show printlines
showStandardStreams = true
}

// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
}

tasks.test {
useJUnitPlatform()

filter {
exclude(
"com/nfeld/jsonpathkt/BenchmarkTest.class",
"com/nfeld/jsonpathkt/PerfTest.class"
)
}

testLogging {
// show test results for following events
events("PASSED", "FAILED", "SKIPPED")

// show printlines
showStandardStreams = true
}

addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor?) {}
override fun afterTest(testDescriptor: TestDescriptor?, result: TestResult?) {}
override fun beforeTest(testDescriptor: TestDescriptor?) {}

override fun afterSuite(suite: TestDescriptor?, result: TestResult?) {
val parent = suite?.parent
if(parent != null && result != null) {
println("\nTest result: ${result.resultType}")
println(
"""
|Test summary: ${result.testCount} tests,
| ${result.successfulTestCount} succeeded,
| ${result.failedTestCount} failed,
| ${result.skippedTestCount} skipped
""".trimMargin().replace("\n", "")
)
}
}

})

configure<JacocoTaskExtension> {
setDestinationFile(layout.buildDirectory.file("jacoco/junitPlatformTest.exec").map { it.asFile })
isIncludeNoLocationClasses = true
excludes = listOf(
"*/LRUCache\$LRUMap*",
"*/JsonNodeKt*",
"jdk.internal.*"
)
}

// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
}

jacoco {
toolVersion = "0.8.8"
reportsDirectory.set(layout.buildDirectory.dir("reports"))
}

tasks.jacocoTestReport.configure {
reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)
}
}

tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = BigDecimal(0.90)
}
}
}
}

tasks.check.configure {
dependsOn(tasks.jacocoTestCoverageVerification)
}
25 changes: 24 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
kotlin.code.style=official
kotlin.code.style=official

SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

GROUP=com.nfeld.jsonpathkt
POM_ARTIFACT_ID=jsonpathkt
VERSION_NAME=2.0.1-SNAPSHOT

POM_NAME=JsonPathKt
POM_DESCRIPTION=A lighter and more efficient implementation of JsonPath in Kotlin
POM_URL=https://github.com/codeniko/JsonPathKt

POM_LICENSE_NAME=BSD-3-Clause
POM_LICENSE_URL=https://github.com/codeniko/JsonPathKt/blob/master/LICENSE
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/codeniko/JsonPathKt
POM_SCM_CONNECTION=scm:git:git://github.com/codeniko/JsonPathKt.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]:codeniko/JsonPathKt.git

POM_DEVELOPER_ID=codeniko
POM_DEVELOPER_NAME=Nikolay Feldman
POM_DEVELOPER_URL=https://www.nfeld.com
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Sep 22 11:57:03 EDT 2022
sdk.dir=/home/eli/Android/Sdk
121 changes: 0 additions & 121 deletions publish.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

18 changes: 18 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("com.gradle.enterprise") version "3.10.3"
}

rootProject.name = "jsonpathkt"

val publishBuildScan = providers.gradleProperty("publishBuildScan")

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"

if (publishBuildScan.getOrElse("false") == "true") {
publishAlways()
}
}
}
1 change: 0 additions & 1 deletion src/main/kotlin/com/nfeld/jsonpathkt/JsonPath.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.nfeld.jsonpathkt

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.module.kotlin.convertValue
import com.nfeld.jsonpathkt.cache.CacheProvider
import com.nfeld.jsonpathkt.util.JacksonUtil
Expand Down
Loading

0 comments on commit cf3e292

Please sign in to comment.