diff --git a/build.gradle.kts b/build.gradle.kts index e913159b..58b14f90 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,15 @@ import org.springframework.boot.gradle.tasks.bundling.BootBuildImage +import kotlin.jvm.optionals.getOrNull plugins { - id("org.jetbrains.dokka") version "1.8.20" - id("org.springframework.boot") version "3.1.2" - id("io.spring.dependency-management") version "1.1.3" - kotlin("jvm") version "1.9.0" - kotlin("plugin.serialization") version "1.9.0" - kotlin("plugin.spring") version "1.9.0" - id("com.diffplug.spotless") version "6.20.0" + base + alias(libs.plugins.dokka) + alias(libs.plugins.spring.boot) + alias(libs.plugins.spring.dependency.management) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.plugin.spring) + alias(libs.plugins.kotlin.plugin.serialization) + alias(libs.plugins.spotless) } repositories { @@ -19,9 +21,6 @@ repositories { mavenLocal() } -val presentationExchangeVersion = "0.1.0-SNAPSHOT" -val nimbusSdkVersion = "10.13.2" - dependencies { implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springframework.boot:spring-boot-starter-actuator") @@ -29,16 +28,26 @@ dependencies { implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") - implementation("eu.europa.ec.eudi:eudi-lib-jvm-presentation-exchange-kt:$presentationExchangeVersion") - implementation("com.nimbusds:oauth2-oidc-sdk:$nimbusSdkVersion") + implementation(libs.presentation.exchange) + implementation(libs.nimbusds.oauth2.oidc.sdk) testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("io.projectreactor:reactor-test") } +java { + val javaVersion = getVersionFromCatalog("java") + sourceCompatibility = JavaVersion.toVersion(javaVersion) +} + kotlin { - jvmToolchain(17) + + jvmToolchain { + val javaVersion = getVersionFromCatalog("java") + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + } } + testing { suites { val test by getting(JvmTestSuite::class) { @@ -55,8 +64,9 @@ tasks.named("bootBuildImage") { imageName.set("$group/${project.name}") } -val ktlintVersion = "0.50.0" + spotless { + val ktlintVersion = getVersionFromCatalog("ktlintVersion") kotlin { ktlint(ktlintVersion) licenseHeaderFile("FileHeader.txt") @@ -65,3 +75,13 @@ spotless { ktlint(ktlintVersion) } } + + +fun getVersionFromCatalog(lookup: String): String { + val versionCatalog: VersionCatalog = extensions.getByType().named("libs") + return versionCatalog + .findVersion(lookup) + .getOrNull() + ?.requiredVersion + ?: throw GradleException("Version '$lookup' is not specified in the version catalog") +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..99e52e9d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,30 @@ +[versions] +coroutines = "1.7.3" +dokka = "1.9.0" +kotlin = "1.9.10" +foojay = "0.7.0" +springboot = "3.1.4" +springDependencyManagement = "1.1.3" +spotless = "6.20.0" +java = "17" +kotlinxSerialization = "1.6.0" +oauth2OidcSdk="10.13.2" +presentationExchange="0.1.0-SNAPSHOT" +ktlintVersion="0.50.0" + + +[libraries] +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" } +nimbusds-oauth2-oidc-sdk = {module ="com.nimbusds:oauth2-oidc-sdk", version.ref="oauth2OidcSdk"} +presentation-exchange = {module ="eu.europa.ec.eudi:eudi-lib-jvm-presentation-exchange-kt", version.ref="presentationExchange"} + +[plugins] +foojay-resolver-convention = { id = "org.gradle.toolchains.foojay-resolver-convention", version.ref = "foojay" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +spring-boot = { id = "org.springframework.boot", version.ref = "springboot" } +spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "springDependencyManagement" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } +kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +