From 79c81d839bacfdcf02172a39a6cff27939bc9457 Mon Sep 17 00:00:00 2001 From: Dai MIKURUBE Date: Wed, 17 Apr 2024 10:31:34 +0900 Subject: [PATCH] Start using Gradle's version catalog --- build.gradle | 19 ++++++++++++++++--- gradle/libs.versions.toml | 21 +++++++++++++++++++++ settings-gradle.lockfile | 4 ++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 gradle/libs.versions.toml create mode 100644 settings-gradle.lockfile diff --git a/build.gradle b/build.gradle index a849dd1..f1d43ef 100644 --- a/build.gradle +++ b/build.gradle @@ -118,10 +118,10 @@ sourceSets { } dependencies { - testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.2" - testImplementation "org.junit.jupiter:junit-jupiter-params:5.9.2" + testImplementation platform(libs.junit5.bom) + testImplementation libs.bundles.junit5.implementation - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.9.2" + testRuntimeOnly libs.bundles.junit5.runtime jruby9_1_15TestImplementation "org.jruby:jruby-complete:9.1.15.0" jruby9_1_17TestImplementation "org.jruby:jruby-complete:9.1.17.0" @@ -160,6 +160,19 @@ javadocJar { } } +// A safer and strict alternative to: "dependencies" (and "dependencies --write-locks") +// +// This task fails explicitly when the specified dependency is not available. +// In contrast, "dependencies (--write-locks)" does not fail even when a part the dependencies are unavailable. +// +// https://docs.gradle.org/8.7/userguide/dependency_locking.html#generating_and_updating_dependency_locks +task checkDependencies { + notCompatibleWithConfigurationCache("The task \"checkDependencies\" filters configurations at execution time.") + doLast { + configurations.findAll { it.canBeResolved }.each { it.resolve() } + } +} + // It should not publish a `.module` file in Maven Central. // https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication tasks.withType(GenerateModuleMetadata) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..59858a9 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,21 @@ +[versions] + +junit5 = "5.9.2" + +[libraries] + +junit5-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit5" } +junit5-api = { group = "org.junit.jupiter", name = "junit-jupiter-api" } +junit5-params = { group = "org.junit.jupiter", name = "junit-jupiter-params" } +junit5-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine" } + +[bundles] + +junit5-implementation = [ + "junit5-api", + "junit5-params", +] + +junit5-runtime = [ + "junit5-engine", +] diff --git a/settings-gradle.lockfile b/settings-gradle.lockfile new file mode 100644 index 0000000..709a43f --- /dev/null +++ b/settings-gradle.lockfile @@ -0,0 +1,4 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +empty=incomingCatalogForLibs0