Skip to content

Commit

Permalink
complete migration to version catalogue
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Jan 3, 2024
1 parent 6c26ac5 commit 2f205a5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
49 changes: 20 additions & 29 deletions kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ buildscript {
dependencies {
classpath(libs.postgresql)
classpath(libs.kotlin.gradle.plugin)
// https://kotlinlang.org/docs/all-open-plugin.html#spring-support
classpath(libs.kotlin.all.open)
classpath(libs.kotlin.all.open) // https://kotlinlang.org/docs/all-open-plugin.html#spring-support
}
// Customize Managed Version
// use extra.apply block to customize / overwrite derived versions
// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#managing-dependencies.dependency-management-plugin.customizing
extra.apply {
// Mitigate https://jira.qos.ch/browse/LOGBACK-1591 until it's part of Spring Boot's mainline
Expand All @@ -21,13 +20,10 @@ version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17

plugins {
val kotlinVersion = libs.versions.kotlin.get()

// https://docs.gradle.org/current/userguide/platforms.html
// Using alias we can reference the plugin id and version
// defined in the version catalog.
// Notice that hyphens (-) used as separator in the identifier
// are translated into type safe accessors for each subgroup.
// Central declaration of dependencies: https://docs.gradle.org/current/userguide/platforms.html
// Using alias we can reference the plugin id and version defined in the version catalog.
// Hyphens (-) used as separator in the identifier are translated into type safe accessors for each subgroup.
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dep.mgmt)
alias(libs.plugins.flyway.plugin)
Expand All @@ -39,6 +35,7 @@ plugins {
// id("org.sonarqube") version "4.3.1.3277" // new ones may cause issues against sonarcloud.io, so test first
alias(libs.plugins.sonarqube)

val kotlinVersion = libs.versions.kotlin.get()
kotlin("jvm") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion
kotlin("plugin.jpa") version kotlinVersion
Expand Down Expand Up @@ -85,23 +82,21 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-validation")

// Kotlin - Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit5"))
val kotlinVersion = libs.versions.kotlin.get()
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation(kotlin("stdlib-jdk8",kotlinVersion))
implementation(kotlin("reflect",kotlinVersion))
testImplementation(kotlin("test",kotlinVersion))
testImplementation(kotlin("test-junit5",kotlinVersion))

// Commons, HTTP Client, RSS and other Network Communication Stuff
implementation(libs.commons.lang3)
implementation(libs.unirest)
implementation (libs.bundles.rome)
implementation(libs.bundles.rome)
implementation(libs.bucket4j)


// Persistence (Postgres, JPA, Hibernate)
// val postgresVersion: String by System.getProperties()
// val flywayVersion: String by System.getProperties()
// val hypersistenceUtilsVersion: String by System.getProperties()
implementation(libs.postgresql)
implementation(libs.bundles.flyway)
implementation(libs.hypersistence.utils.hibernate)
Expand All @@ -117,23 +112,19 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")

// Test Dependencies
val archUnitVersion: String by System.getProperties()
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
// https://stackoverflow.com/a/52980523/4292075
exclude(group = "com.vaadin.external.google", module = "android-json")
}
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.kafka:spring-kafka-test")
val mockitoInlineVersion: String by System.getProperties()
val wiremockVersion: String by System.getProperties()
val greenmailVersion: String by System.getProperties()
// Mockito Inline required to mock final classes (https://stackoverflow.com/a/14292888/4292075)
testImplementation("org.mockito:mockito-inline:$mockitoInlineVersion")
testImplementation( libs.wiremock)
testImplementation("com.tngtech.archunit:archunit-junit5-api:$archUnitVersion")
testImplementation("com.icegreen:greenmail:$greenmailVersion")
testRuntimeOnly("com.tngtech.archunit:archunit-junit5-engine:$archUnitVersion")
testImplementation(libs.mockito.inline)
testImplementation(libs.wiremock)
testImplementation(libs.archunit.api)
testImplementation(libs.greenmail)
testRuntimeOnly(libs.archunit.engine)

}

Expand Down Expand Up @@ -222,9 +213,9 @@ sonarqube {
property("sonar.projectKey", "angkor-api")
property("sonar.projectName", "Angkor API")
property("sonar.projectDescription", "API for Angular Kotlin Rest App")
property("sonar.coverage.jacoco.xmlReportPaths","build/reports/jacoco/test/jacocoTestReport.xml")
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml")
// domain objects are mostly data classes which don't support inheritance really well, so we exclude
// them from duplication detection (cf. https://docs.sonarqube.org/7.4/analysis/analysis-parameters/)
property("sonar.cpd.exclusions","src/main/kotlin/net/timafe/angkor/domain/**/*")
property("sonar.cpd.exclusions", "src/main/kotlin/net/timafe/angkor/domain/**/*")
}
}
9 changes: 3 additions & 6 deletions kotlin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Version Management, update library dependency versions centrally
# DEPRECATED, move to gradle/libs.versions.toml catalog which is also supported by dependabot
systemProp.archUnitVersion=0.23.1
#systemProp.greenmailVersion=2.1.0-alpha-1 does not work (failed test)
systemProp.greenmailVersion=2.0.0-alpha-3
systemProp.mockitoInlineVersion=4.11.0
# file: gradle.properties

# systemProp.var=X.Y.Z is DEPRECATED, use gradle/libs.versions.toml catalog which is also supported by dependabot

# enable to support incremental processing
# https://medium.com/@daniel_novak/making-incremental-kapt-work-speed-up-your-kotlin-projects-539db1a771cf
Expand Down
20 changes: 15 additions & 5 deletions kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,30 @@
[versions]
# Versions is used to declare the version numbers that will be referenced later by plugins and libraries.
# can be used as version.ref in [plugins] and [libraries] section, see flyway-core example below
archunit = "0.23.1"
flyway = "10.4.1"
jacoco = "0.8.11" # used like "toolVersion = libs.versions.jacoco.get()" in jacoco block
kotlin = "1.9.22"
mockito = "4.11.0"
postgresql = "42.7.1"
rome = "1.19.0"
spring-boot = "3.2.0"
wiremock = "3.0.1"

[plugins]
# We can use shorthand notation with the plugin id and version.
# plugins were added in Gradle 7.2, are used (obviouly) to define plugins.
# Plugins were added in Gradle 7.2, are used (obviouly) to define plugins.
# use like "alias(libs.plugins.spring.boot)" in build.gradle.kts plugins section

# We can use shorthand notation with the plugin id and version.
versions = "com.github.ben-manes.versions:0.50.0"

# We can use the longer notation option where we set the id and version for the plugin.
# Or we can use the longer notation option where we set the id and version for the plugin.
flyway-plugin = { id = "org.flywaydb.flyway", version.ref = "flyway" }
spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } # 3.1.5
spring-dep-mgmt = { id = "io.spring.dependency-management", version = "1.1.4" }
sonarqube = { id = "org.sonarqube", version = "4.4.1.3373" } # new "4.3.1.3277" -> 4.4.1.3373"

# Here we use the longer notation and version.ref to reference an entry from the [versions] section.
flyway-plugin = { id = "org.flywaydb.flyway", version.ref = "flyway" }

[libraries]
# Define the libraries that will be later accessed in our Gradle files.
Expand All @@ -64,13 +67,20 @@ rome-modules = { module = "com.rometools:rome-modules", version.ref = "rome" }

unirest = { module = "com.mashape.unirest:unirest-java", version = "1.4.9" }

# testImplementation
# testImplementation Libraries
# Use standalone b/c of issue "jetty 12 / springboot 3.2 #2395" https://github.com/wiremock/wiremock/issues/2395

# greenmail CAUTION: version =2.1.0-alpha-1 does not work (failed test)
archunit-api = { module = "com.tngtech.archunit:archunit-junit5-api", version.ref = "archunit" }
archunit-engine = { module = "com.tngtech.archunit:archunit-junit5-engine", version.ref = "archunit" }
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito" }
greenmail = { module = "com.icegreen:greenmail", version = "2.0.0-alpha-3" }
wiremock = { module = "com.github.tomakehurst:wiremock-standalone", version = "3.0.1" } # 3.0.0-beta-10

kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-all-open = { module = "org.jetbrains.kotlin:kotlin-allopen", version.ref = "kotlin" }


[bundles]
# Nice ... we can bundle libs and use like "libs.bundles.flyway"
# https://blog.jdriven.com/2022/11/gradle-goodness-grouping-version-catalog-dependencies-into-bundles/
Expand Down

0 comments on commit 2f205a5

Please sign in to comment.