From 3d51fa18ee7472ea7d28ea453912641dc5e4167c Mon Sep 17 00:00:00 2001 From: Danilo Pianini Date: Fri, 8 Oct 2021 18:26:51 +0200 Subject: [PATCH] Use catalogs and multi-jvm testing --- .github/build-steps/build.sh | 26 ------- .github/build-steps/check.sh | 21 ------ .github/build-steps/compatibility_check.sh | 11 --- .github/build-steps/deploy.sh | 25 ------- .github/scripts/deploy | 7 -- .gitmodules | 3 - build.gradle.kts | 69 ++++++++++--------- buildSrc/build.gradle.kts | 29 -------- buildSrc/kotlin-qa-dependencies | 4 -- buildSrc/settings.gradle.kts | 9 --- buildSrc/src/main/kotlin/kotlin-qa.gradle.kts | 42 ----------- config/detekt | 1 - gradle/libs.versions.toml | 25 +++++++ settings.gradle.kts | 13 ++-- versions.properties | 32 --------- 15 files changed, 71 insertions(+), 246 deletions(-) delete mode 100755 .github/build-steps/build.sh delete mode 100755 .github/build-steps/check.sh delete mode 100755 .github/build-steps/compatibility_check.sh delete mode 100755 .github/build-steps/deploy.sh delete mode 100755 .github/scripts/deploy delete mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/kotlin-qa-dependencies delete mode 100644 buildSrc/settings.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/kotlin-qa.gradle.kts delete mode 160000 config/detekt create mode 100644 gradle/libs.versions.toml delete mode 100644 versions.properties diff --git a/.github/build-steps/build.sh b/.github/build-steps/build.sh deleted file mode 100755 index dc35247b..00000000 --- a/.github/build-steps/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -e -CUSTOM_BUILD_SCRIPT=${CUSTOM_BUILD_SCRIPT:-.github/scripts/build} -if [ -x $CUSTOM_BUILD_SCRIPT ]; then - echo 'Detected custom build instructions' - $CUSTOM_BUILD_SCRIPT -elif [ -x 'gradlew' ]; then - echo 'Detected gradle wrapper, checking for known tasks' - if ./gradlew tasks | grep '^assemble\s'; then - echo 'Detected assemble task' - ./gradlew assemble --parallel - elif ./gradlew tasks | grep '^build\s'; then - echo 'Detected build task' - ./gradlew build --parallel - else - echo 'No known tasks, fall back to the default tasks' - ./gradlew - fi -elif [ -f 'pom.xml' ]; then - echo 'Detected Maven pom.xml, running mvn package' - mvn package -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -else - echo 'No valid configuration detected, failing' - echo "To fix, provide an *executable* build script in $CUSTOM_BUILD_SCRIPT" - exit 1 -fi diff --git a/.github/build-steps/check.sh b/.github/build-steps/check.sh deleted file mode 100755 index 743683d1..00000000 --- a/.github/build-steps/check.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e -CUSTOM_BUILD_SCRIPT=${CUSTOM_BUILD_SCRIPT:-.github/scripts/check} -if [ -x $CUSTOM_BUILD_SCRIPT ]; then - echo 'Detected custom check instructions' - $CUSTOM_BUILD_SCRIPT -elif [ -x 'gradlew' ]; then - echo 'Detected gradle wrapper, checking for known tasks' - if ./gradlew tasks | grep '^check\s'; then - echo 'Detected check task' - ./gradlew check --parallel - if ./gradlew tasks | grep '^jacocoTestReport\s'; then - ./gradlew jacocoTestReport --parallel - fi - else - echo 'No known check tasks' - fi -else - echo 'No valid configuration detected, skipping checks' - echo "To fix, provide an *executable* build script in $CUSTOM_BUILD_SCRIPT" -fi diff --git a/.github/build-steps/compatibility_check.sh b/.github/build-steps/compatibility_check.sh deleted file mode 100755 index 8b8e85e3..00000000 --- a/.github/build-steps/compatibility_check.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -if [ -x .github/scripts/compatibility_check ]; then - .github/scripts/compatibility_check -else - COMPATIBLE=true - echo "COMPATIBLE=$COMPATIBLE" - echo "COMPATIBLE=$COMPATIBLE" >> $GITHUB_ENV - REFERENCE=$([ "$OS" = 'ubuntu' ] && [ "$JAVA_VERSION" = 8 ] && echo 'true' || echo 'false') - echo "REFERENCE=$REFERENCE" - echo "REFERENCE=$REFERENCE" >> $GITHUB_ENV -fi diff --git a/.github/build-steps/deploy.sh b/.github/build-steps/deploy.sh deleted file mode 100755 index 7782f33e..00000000 --- a/.github/build-steps/deploy.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e -CUSTOM_BUILD_SCRIPT=${CUSTOM_BUILD_SCRIPT:-.github/scripts/deploy} -if [ -x $CUSTOM_BUILD_SCRIPT ]; then - echo 'Detected custom deploy instructions' - $CUSTOM_BUILD_SCRIPT -elif [ -x 'gradlew' ]; then - echo 'Detected gradle wrapper, checking for known tasks' - if ./gradlew tasks | grep '^deploy\s'; then - echo 'Detected deploy task' - ./gradlew deploy --parallel - elif ./gradlew tasks | grep '^publish\s'; then - echo 'Detected publish task' - ./gradlew publish --parallel - else - echo 'No deploy task' - fi -elif [ -f 'pom.xml' ]; then - echo 'Detected Maven pom.xml, running mvn deploy' - mvn deploy -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -else - echo 'No valid configuration detected, failing' - echo "To fix, provide an *executable* build script in $CUSTOM_BUILD_SCRIPT" - exit 1 -fi diff --git a/.github/scripts/deploy b/.github/scripts/deploy deleted file mode 100755 index c32aeac5..00000000 --- a/.github/scripts/deploy +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e -./gradlew publishPluginMavenPublicationToMavenCentralRepository -./gradlew publishKotlinMavenPublicationToMavenCentralRepository -./gradlew publishPluginMavenPublicationToGithubRepository || true -./gradlew publishKotlinMavenPublicationToGithubRepository || true -./gradlew publishPlugins -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET || true diff --git a/.gitmodules b/.gitmodules index 015f029c..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "config/detekt"] - path = config/detekt - url = git@github.com:DanySK/detekt-configuration.git diff --git a/build.gradle.kts b/build.gradle.kts index 850e69c8..b7fe0a36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,17 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +@Suppress("DSL_SCOPE_VIOLATION") plugins { `java-gradle-plugin` - id("org.danilopianini.git-sensitive-semantic-versioning") - kotlin("jvm") - id("com.gradle.plugin-publish") - id("org.danilopianini.publish-on-central") - id("org.jetbrains.dokka") - id("kotlin-qa") + alias(libs.plugins.dokka) + alias(libs.plugins.gitSemVer) + alias(libs.plugins.gradlePluginPublish) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.qa) + alias(libs.plugins.publishOnCentral) + alias(libs.plugins.multiJvmTesting) + alias(libs.plugins.taskTree) } gitSemVer { @@ -26,12 +29,30 @@ repositories { mavenCentral() } +multiJvm { + maximumSupportedJvmVersion.set(latestJavaSupportedByGradle) +} + +/* + * By default, Gradle does not include all the plugin classpath into the testing classpath. + * This task creates a descriptor of the runtime classpath, to be injected (manually) when running tests. + */ +val createClasspathManifest = tasks.register("createClasspathManifest") { + val outputDir = file("$buildDir/$name") + inputs.files(sourceSets.main.get().runtimeClasspath) + outputs.dir(outputDir) + doLast { + outputDir.mkdirs() + file("$outputDir/plugin-classpath.txt").writeText(sourceSets.main.get().runtimeClasspath.joinToString("\n")) + } +} + dependencies { implementation(kotlin("stdlib")) implementation(gradleApi()) testImplementation(gradleTestKit()) - testImplementation("io.kotest:kotest-runner-junit5:_") - testImplementation("io.kotest:kotest-assertions-core-jvm:_") + testImplementation(libs.bundles.kotlin.testing) + testRuntimeOnly(files(createClasspathManifest)) } tasks.withType { @@ -40,33 +61,17 @@ tasks.withType { } } -tasks { - "test"(Test::class) { - useJUnitPlatform() - testLogging.showStandardStreams = true - testLogging { - showCauses = true - showStackTraces = true - showStandardStreams = true - events(*TestLogEvent.values()) - } - } - register("createClasspathManifest") { - val outputDir = file("$buildDir/$name") - inputs.files(sourceSets.main.get().runtimeClasspath) - outputs.dir(outputDir) - doLast { - outputDir.mkdirs() - file("$outputDir/plugin-classpath.txt").writeText(sourceSets.main.get().runtimeClasspath.joinToString("\n")) - } +tasks.withType { + useJUnitPlatform() + testLogging { + showStandardStreams = true + showCauses = true + showStackTraces = true + events(*org.gradle.api.tasks.testing.logging.TestLogEvent.values()) + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL } } -// Add the classpath file to the test runtime classpath -dependencies { - testRuntimeOnly(files(tasks["createClasspathManifest"])) -} - pluginBundle { website = websiteUrl vcsUrl = websiteUrl diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 29e98595..00000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -plugins { - `kotlin-dsl` - id("io.gitlab.arturbosch.detekt") - id("org.jlleitschuh.gradle.ktlint") -} - -repositories { - mavenCentral() - gradlePluginPortal() -} - -dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:_") -} - -detekt { - allRules = true - buildUponDefaultConfig = true - config = files("$rootDir/../config/detekt/detekt.yml") -} - -projectDir.listFiles() - ?.filter { it.isFile && it.name.endsWith("dependencies") } - ?.flatMap { it.readLines() } - ?.forEach { - dependencies { - implementation(it) - } - } diff --git a/buildSrc/kotlin-qa-dependencies b/buildSrc/kotlin-qa-dependencies deleted file mode 100644 index 05386527..00000000 --- a/buildSrc/kotlin-qa-dependencies +++ /dev/null @@ -1,4 +0,0 @@ -io.gitlab.arturbosch.detekt:detekt-gradle-plugin:_ -org.jetbrains.kotlin:kotlin-gradle-plugin:_ -org.jlleitschuh.gradle:ktlint-gradle:_ -org.jetbrains.kotlin:kotlin-compiler-embeddable:_ diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts deleted file mode 100644 index e20ba090..00000000 --- a/buildSrc/settings.gradle.kts +++ /dev/null @@ -1,9 +0,0 @@ -pluginManagement { - plugins { - id("de.fayard.refreshVersions") version "0.10.1" - } -} - -plugins { - id("de.fayard.refreshVersions") -} diff --git a/buildSrc/src/main/kotlin/kotlin-qa.gradle.kts b/buildSrc/src/main/kotlin/kotlin-qa.gradle.kts deleted file mode 100644 index 991f3f27..00000000 --- a/buildSrc/src/main/kotlin/kotlin-qa.gradle.kts +++ /dev/null @@ -1,42 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION - -plugins { - id("io.gitlab.arturbosch.detekt") - id("org.jlleitschuh.gradle.ktlint") -} - -repositories { - mavenCentral() - gradlePluginPortal() -} - -dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:_") -} - -detekt { - allRules = true - buildUponDefaultConfig = true - val configPath = "$rootDir/config/detekt/detekt.yml" - file(configPath) - .takeIf { it.exists() } - ?.let { config = files(it) } - ?: logger.warn("Missing Detekt configuration at $configPath") -} - -tasks.withType { - kotlinOptions { - allWarningsAsErrors = true - } -} - -// Enforce Kotlin version coherence -configurations.all { - resolutionStrategy.eachDependency { - if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin")) { - useVersion(KOTLIN_VERSION) - because("All Kotlin modules should use the same version, and compiler uses $KOTLIN_VERSION") - } - } -} diff --git a/config/detekt b/config/detekt deleted file mode 160000 index f53c6665..00000000 --- a/config/detekt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f53c66656801f79eb5124fb3bfcb5623a4e50526 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..f99cd06d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,25 @@ +[versions] +konf = "1.1.2" +kotest = "4.6.3" +kotlin = "1.5.31" +mockito = "4.0.0" + +[libraries] +classgraph = "io.github.classgraph:classgraph:4.8.125" +konf-yaml = { module = "com.uchuhimo:konf-yaml", version.ref = "konf" } +kotest-junit5-jvm = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" } +kotest-assertions-core-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" } +mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } + +[bundles] +kotlin-testing = [ "kotest-junit5-jvm", "kotest-assertions-core-jvm", "mockito-core" ] + +[plugins] +dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" } +gitSemVer = { id = "org.danilopianini.git-sensitive-semantic-versioning", version = "0.3.0" } +gradlePluginPublish = { id = "com.gradle.plugin-publish", version = "0.15.0" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-qa = { id = "org.danilopianini.gradle-kotlin-qa", version = "0.2.1" } +multiJvmTesting = { id = "org.danilopianini.multi-jvm-test-plugin", version = "0.1.0" } +publishOnCentral = { id = "org.danilopianini.publish-on-central", version = "0.6.1" } +taskTree = { id = "com.dorongold.task-tree", version = "2.1.0" } diff --git a/settings.gradle.kts b/settings.gradle.kts index cb0a1983..ce187997 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,9 +1,14 @@ plugins { - id("de.fayard.refreshVersions") version "0.10.1" + id("com.gradle.enterprise") version "3.7" } -refreshVersions { - featureFlags { - enable(de.fayard.refreshVersions.core.FeatureFlag.LIBS) + +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + publishOnFailure() } } + rootProject.name = "publish-on-central" +enableFeaturePreview("VERSION_CATALOGS") diff --git a/versions.properties b/versions.properties deleted file mode 100644 index 48e3e6b3..00000000 --- a/versions.properties +++ /dev/null @@ -1,32 +0,0 @@ -#### Dependencies and Plugin versions with their available updates. -#### Generated by `./gradlew refreshVersions` version 0.10.1 -#### -#### Don't manually edit or split the comments that start with four hashtags (####), -#### they will be overwritten by refreshVersions. -#### -#### suppress inspection "SpellCheckingInspection" for whole file -#### suppress inspection "UnusedProperty" for whole file - -plugin.io.gitlab.arturbosch.detekt=version.io.gitlab.arturbosch.detekt..detekt-formatting - -plugin.com.gradle.plugin-publish=0.15.0 - -plugin.org.danilopianini.git-sensitive-semantic-versioning=0.3.0 - -plugin.org.danilopianini.publish-on-central=0.6.0-dev07-b403ca3 - -plugin.org.jetbrains.dokka=1.5.0 - -plugin.org.jlleitschuh.gradle.ktlint=version.org.jlleitschuh.gradle..ktlint-gradle - -version.io.gitlab.arturbosch.detekt..detekt-formatting=1.16.0 - -version.io.gitlab.arturbosch.detekt..detekt-gradle-plugin=1.17.1 - -version.kotest=4.5.0 - -version.kotlin=1.5.30 - -version.org.danilopianini..git-sensitive-semantic-versioning=0.3.0 - -version.org.jlleitschuh.gradle..ktlint-gradle=10.1.0