From aa7d6f0b9b83879dcb62b63cf416ada853040a26 Mon Sep 17 00:00:00 2001 From: Jens Pots Date: Mon, 11 Nov 2024 15:30:58 +0100 Subject: [PATCH] refactor: rely on `gradle.properties` --- build.gradle.kts | 59 ++++++++++++++++++++---------- gradle.properties | 11 ++++++ rdfc-cli/build.gradle.kts | 15 ++------ rdfc-core/build.gradle.kts | 37 ++----------------- rdfc-intermediate/build.gradle.kts | 14 ++----- rdfc-orchestrator/build.gradle.kts | 26 ++----------- rdfc-parser/build.gradle.kts | 14 ++----- rdfc-processor/build.gradle.kts | 37 ++----------------- settings.gradle.kts | 19 +++++++++- 9 files changed, 88 insertions(+), 144 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0b28aa9..101a1af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,31 +1,52 @@ plugins { - kotlin("jvm") version "2.0.21" + kotlin("jvm") + id("co.uzzu.dotenv.gradle") id("maven-publish") - id("co.uzzu.dotenv.gradle") version "4.0.0" - id("org.jetbrains.dokka") version "1.9.20" + id("org.jetbrains.dokka") } -/** Generating KDoc requires all subprojects to use Dokka as well. */ -subprojects { apply(plugin = "org.jetbrains.dokka") } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } -group = "technology.idlab" +allprojects { + /** The current version number of the RDF-Connect Orchestrator. */ + val projectVersion: String by project + version = projectVersion -version = "0.0.2" + /** The group name of the project. */ + val projectGroup: String by project + group = projectGroup -kotlin { jvmToolchain(22) } + // Make the GH Packages repository available. + repositories { + mavenCentral() -/** - * A list of all the repositories we use in the project. This includes the maven central repository - * and the GitHub package repository. - */ -repositories { - mavenCentral() + maven { + url = uri("https://maven.pkg.github.com/rdf-connect/orchestrator") + credentials { + username = env.fetchOrNull("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR") + password = env.fetchOrNull("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN") + } + } + } +} + +subprojects { + // Shared plugins. + apply(plugin = "org.jetbrains.kotlin.jvm") + apply(plugin = "maven-publish") + apply(plugin = "org.jetbrains.dokka") + + // Configure testing framework. + tasks.test { + useJUnitPlatform() + + maxParallelForks = 1 - maven { - url = uri("https://maven.pkg.github.com/rdf-connect/orchestrator") - credentials { - username = env.fetchOrNull("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR") - password = env.fetchOrNull("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN") + testLogging { + events("passed", "skipped", "failed") + showStandardStreams = true } } } diff --git a/gradle.properties b/gradle.properties index efeefca..65ad8e0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,13 @@ kotlin.code.style=official + +# Project information. +projectVersion=0.0.2 +projectGroup = "technology.idlab + +# Dependency versions. kotlinVersion=2.0.21 +jdkVersion=22 +dotEnvVersion=4.0.0 +dokkaVersion=1.9.20 +shadowVersion=8.3.3 +protobufVersion=0.9.4 diff --git a/rdfc-cli/build.gradle.kts b/rdfc-cli/build.gradle.kts index 8e6f34e..bc72869 100644 --- a/rdfc-cli/build.gradle.kts +++ b/rdfc-cli/build.gradle.kts @@ -1,19 +1,14 @@ plugins { application - kotlin("jvm") version "2.0.21" - id("com.gradleup.shadow") version "8.3.3" + id("com.gradleup.shadow") } -group = "technology.idlab" - -version = "0.0.2" - /** Specify the entrypoint for the application. */ application { mainClass.set("technology.idlab.rdfc.cli.MainKt") } -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // Local dependencies @@ -29,8 +24,6 @@ dependencies { testImplementation(kotlin("test")) } -tasks.test { useJUnitPlatform() } - tasks.named("shadowJar") { // Name of the resulting archive. archiveFileName.set("rdfc.jar") diff --git a/rdfc-core/build.gradle.kts b/rdfc-core/build.gradle.kts index 7646745..f0e6143 100644 --- a/rdfc-core/build.gradle.kts +++ b/rdfc-core/build.gradle.kts @@ -1,15 +1,6 @@ -plugins { - kotlin("jvm") version "2.0.21" - id("maven-publish") -} - -group = "technology.idlab" - -version = "0.0.2" - -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // HTTP dependency @@ -27,29 +18,7 @@ dependencies { testImplementation(kotlin("test")) } -tasks.test { - useJUnitPlatform() - - maxParallelForks = 1 - - testLogging { - events("passed", "skipped", "failed") - showStandardStreams = true - } -} - publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/rdf-connect/orchestrator") - credentials { - username = env.fetchOrNull("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR") - password = env.fetchOrNull("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN") - } - } - } - publications { create("gpr") { from(components["java"]) diff --git a/rdfc-intermediate/build.gradle.kts b/rdfc-intermediate/build.gradle.kts index c4bcbe4..abd4b6b 100644 --- a/rdfc-intermediate/build.gradle.kts +++ b/rdfc-intermediate/build.gradle.kts @@ -1,12 +1,6 @@ -plugins { kotlin("jvm") version "2.0.21" } - -group = "technology.idlab" - -version = "0.0.2" - -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // Local dependencies @@ -18,5 +12,3 @@ dependencies { // KTest testImplementation(kotlin("test")) } - -tasks.test { useJUnitPlatform() } diff --git a/rdfc-orchestrator/build.gradle.kts b/rdfc-orchestrator/build.gradle.kts index 2e7dd73..14dbbfd 100644 --- a/rdfc-orchestrator/build.gradle.kts +++ b/rdfc-orchestrator/build.gradle.kts @@ -1,15 +1,8 @@ -plugins { - kotlin("jvm") version "2.0.21" - id("com.google.protobuf") version "0.9.4" -} - -group = "technology.idlab" - -version = "0.0.2" +plugins { id("com.google.protobuf") } -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // Kotlin extensions. @@ -50,17 +43,6 @@ dependencies { testImplementation("org.jetbrains.kotlin:kotlin-test") } -tasks.test { - useJUnitPlatform() - - maxParallelForks = 1 - - testLogging { - events("passed", "skipped", "failed") - showStandardStreams = true - } -} - /** We define these explicitly due to the reliance on Protobuf and gRPC. */ sourceSets { main { proto { srcDir("../proto") } } } diff --git a/rdfc-parser/build.gradle.kts b/rdfc-parser/build.gradle.kts index 0e8d25b..738c166 100644 --- a/rdfc-parser/build.gradle.kts +++ b/rdfc-parser/build.gradle.kts @@ -1,12 +1,6 @@ -plugins { kotlin("jvm") version "2.0.21" } - -group = "technology.idlab" - -version = "0.0.2" - -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // Local dependencies @@ -24,5 +18,3 @@ dependencies { // KTest testImplementation(kotlin("test")) } - -tasks.test { useJUnitPlatform() } diff --git a/rdfc-processor/build.gradle.kts b/rdfc-processor/build.gradle.kts index a938af0..3e2edfa 100644 --- a/rdfc-processor/build.gradle.kts +++ b/rdfc-processor/build.gradle.kts @@ -1,15 +1,6 @@ -plugins { - kotlin("jvm") version "2.0.21" - id("maven-publish") -} - -group = "technology.idlab" - -version = "0.0.2" - -kotlin { jvmToolchain(22) } - -repositories { mavenCentral() } +/** The target JDK. */ +val jdkVersion: String by project +kotlin { jvmToolchain(jdkVersion.toInt()) } dependencies { // Local dependencies @@ -22,29 +13,7 @@ dependencies { testImplementation(kotlin("test")) } -tasks.test { - useJUnitPlatform() - - maxParallelForks = 1 - - testLogging { - events("passed", "skipped", "failed") - showStandardStreams = true - } -} - publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/rdf-connect/orchestrator") - credentials { - username = env.fetchOrNull("GITHUB_ACTOR") ?: System.getenv("GITHUB_ACTOR") - password = env.fetchOrNull("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN") - } - } - } - publications { create("gpr") { from(components["java"]) diff --git a/settings.gradle.kts b/settings.gradle.kts index c5f7dfb..5a9ac6a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,3 @@ -plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" } - rootProject.name = "technology.idlab.rdfc" include("rdfc-core") @@ -13,3 +11,20 @@ include("rdfc-cli") include("rdfc-parser") include("rdfc-intermediate") + +pluginManagement { + val kotlinVersion: String by settings + val dotEnvVersion: String by settings + val dokkaVersion: String by settings + val shadowVersion: String by settings + val protobufVersion: String by settings + + plugins { + kotlin("jvm") version kotlinVersion + id("co.uzzu.dotenv.gradle") version dotEnvVersion + id("org.jetbrains.dokka") version dokkaVersion + id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" + id("com.gradleup.shadow") version shadowVersion + id("com.google.protobuf") version protobufVersion + } +}