Skip to content

Commit

Permalink
Manage library versions in libs.versions.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Oct 13, 2024
1 parent ff9b37e commit b7d65df
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 39 deletions.
46 changes: 25 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ plugins {
`java-library`
`maven-publish`
signing
id("com.diffplug.spotless")
id("io.github.gradle-nexus.publish-plugin")
id("net.researchgate.release")
id("org.domaframework.doma.compile")
kotlin("jvm")
kotlin("kapt")
alias(libs.plugins.spotless)
alias(libs.plugins.publish)
alias(libs.plugins.release)
alias(libs.plugins.doma.compile)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.kapt)
}

val javaLangVersion: Int = project.properties["javaLangVersion"].toString().toInt()
Expand All @@ -19,6 +19,10 @@ val integrationTestProjects: List<Project> = subprojects.filter { it.name.starts
val encoding: String by project
val isReleaseVersion = !version.toString().endsWith("SNAPSHOT")

// Retain a reference to rootProject.libs to make the version catalog accessible within allprojects and subprojects.
// See https://github.com/gradle/gradle/issues/16708
val catalog = libs

fun replaceVersionInArtifact(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"(
Expand Down Expand Up @@ -64,7 +68,7 @@ fun replaceVersionInDocs(ver: String) {

allprojects {
apply(plugin = "base")
apply(plugin = "com.diffplug.spotless")
apply(plugin = catalog.plugins.spotless.get().pluginId)

repositories {
mavenCentral()
Expand All @@ -85,16 +89,16 @@ subprojects {
apply(plugin = "java")

dependencies {
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.11.2")
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.11.2")
testImplementation(catalog.junit.jupiter.api)
testRuntimeOnly(catalog.junit.jupiter.engine)
}

spotless {
java {
googleJavaFormat("1.23.0")
googleJavaFormat(catalog.google.java.format.get().version)
}
kotlin {
ktlint("0.48.2")
ktlint(catalog.ktlint.get().version)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down Expand Up @@ -208,16 +212,16 @@ configure(integrationTestProjects) {
apply(plugin = "org.domaframework.doma.compile")

dependencies {
testImplementation(platform("org.testcontainers:testcontainers-bom:1.20.2"))
testRuntimeOnly("com.h2database:h2:2.3.232")
testRuntimeOnly("mysql:mysql-connector-java:8.0.33")
testRuntimeOnly("com.oracle.database.jdbc:ojdbc11-production:23.5.0.24.07")
testRuntimeOnly("org.postgresql:postgresql:42.7.4")
testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11")
testRuntimeOnly("org.testcontainers:mysql")
testRuntimeOnly("org.testcontainers:oracle-xe")
testRuntimeOnly("org.testcontainers:postgresql")
testRuntimeOnly("org.testcontainers:mssqlserver")
testImplementation(platform(catalog.testcontainers.bom))
testRuntimeOnly(catalog.jdbc.h2)
testRuntimeOnly(catalog.jdbc.mysql)
testRuntimeOnly(catalog.jdbc.oracle)
testRuntimeOnly(catalog.jdbc.postgresql)
testRuntimeOnly(catalog.jdbc.sqlserver)
testRuntimeOnly(catalog.testcontainers.mysql)
testRuntimeOnly(catalog.testcontainers.oracle)
testRuntimeOnly(catalog.testcontainers.postgresql)
testRuntimeOnly(catalog.testcontainers.sqlserver)
}

java {
Expand Down
2 changes: 1 addition & 1 deletion doma-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") apply true
alias(libs.plugins.kotlin.jvm)
}

description = "doma-kotlin"
Expand Down
2 changes: 1 addition & 1 deletion doma-processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
alias(libs.plugins.shadow)
}

description = "doma-processor"
Expand Down
4 changes: 2 additions & 2 deletions doma-slf4j/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "doma-slf4j"

dependencies {
api("org.slf4j:slf4j-api:2.0.16")
api(libs.slf4j.api)
implementation(project(":doma-core"))
testImplementation("ch.qos.logback:logback-classic:1.5.10")
testImplementation(libs.logback.classic)
}
34 changes: 34 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[versions]
kotlin = "2.0.21"
junit = "5.11.2"

[libraries]
jdbc-h2 = { module = "com.h2database:h2", version = "2.3.232" }
jdbc-mysql = { module = "mysql:mysql-connector-java", version = "8.0.33" }
jdbc-oracle = { module = "com.oracle.database.jdbc:ojdbc11", version = "21.15.0.0" }
jdbc-postgresql = { module = "org.postgresql:postgresql", version = "42.7.4" }
jdbc-sqlserver = { module = "com.microsoft.sqlserver:mssql-jdbc", version = "12.8.1.jre11" }

slf4j-api = { module = "org.slf4j:slf4j-api", version = "2.0.16" }
logback-classic = { module = "ch.qos.logback:logback-classic", version = "1.5.10" }

junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }

testcontainers-bom = { module = "org.testcontainers:testcontainers-bom", version = "1.20.2" }
testcontainers-mysql = { module = "org.testcontainers:mysql" }
testcontainers-oracle = { module = "org.testcontainers:oracle-xe" }
testcontainers-postgresql = { module = "org.testcontainers:postgresql" }
testcontainers-sqlserver = { module = "org.testcontainers:mssqlserver" }

google-java-format = { module = "com.google.googlejavaformat:google-java-format", version = "1.23.0" }
ktlint = { module = "com.pinterest.ktlint:ktlint-cli", version = "0.48.2" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version = "6.25.0" }
publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
release = { id = "net.researchgate.release", version = "3.0.2" }
doma-compile = { id = "org.domaframework.doma.compile", version = "3.0.1" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
4 changes: 2 additions & 2 deletions integration-test-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ dependencies {
annotationProcessor(project(":doma-processor"))
implementation(project(":doma-core"))
implementation(project(":doma-slf4j"))
implementation("ch.qos.logback:logback-classic:1.5.10")
implementation("org.junit.jupiter:junit-jupiter-api:5.11.2")
implementation(libs.logback.classic)
implementation(libs.junit.jupiter.api)
}
6 changes: 2 additions & 4 deletions integration-test-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms

plugins {
kotlin("jvm")
kotlin("kapt")
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.kapt)
}

dependencies {
Expand Down
13 changes: 5 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ pluginManagement {
repositories {
gradlePluginPortal()
}
plugins {
id("com.diffplug.eclipse.apt") version "4.1.0"
id("com.diffplug.spotless") version "6.25.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("net.researchgate.release") version "3.0.2"
id("org.domaframework.doma.compile") version "3.0.1"
kotlin("jvm") version "2.0.21"
kotlin("kapt") version "2.0.21"
}

dependencyResolutionManagement {
versionCatalogs {
create("libs")
}
}

Expand Down

0 comments on commit b7d65df

Please sign in to comment.