diff --git a/build.gradle.kts b/build.gradle.kts index d63568d..fd3f0e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -68,6 +68,13 @@ gradlePlugin { implementationClass = "dev.mythicdrops.gradle.conventions.MythicDropsJavaPlatformPlugin" tags.set(listOf("kotlin", "pixeloutlaw", "convention")) } + create("mythicDropsConventionJvmTestSuite") { + id = "dev.mythicdrops.gradle.convention.jvm-test-suite" + displayName = "mythicDropsGradleConventionJvmSuite" + description = "Common conventions for all MythicDrops JVM Test Suite Gradle projects." + implementationClass = "dev.mythicdrops.gradle.conventions.MythicDropsJvmTestSuitePlugin" + tags.set(listOf("kotlin", "pixeloutlaw", "convention")) + } create("mythicDropsConventionKotlinJvm") { id = "dev.mythicdrops.gradle.convention.kotlin.jvm" displayName = "mythicDropsGradleConventionKotlinJvm" diff --git a/src/main/kotlin/dev/mythicdrops/gradle/MythicDropsPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/MythicDropsPlugin.kt index 12fc8a3..4eb1115 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/MythicDropsPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/MythicDropsPlugin.kt @@ -2,6 +2,7 @@ package dev.mythicdrops.gradle import dev.mythicdrops.gradle.conventions.MythicDropsJavaPlatformPlugin import dev.mythicdrops.gradle.conventions.MythicDropsJavaPlugin +import dev.mythicdrops.gradle.conventions.MythicDropsJvmTestSuitePlugin import dev.mythicdrops.gradle.conventions.MythicDropsKotlinJvmPlugin import dev.mythicdrops.gradle.conventions.MythicDropsMavenPublishPlugin import dev.mythicdrops.gradle.projects.MythicDropsBasePlugin @@ -28,6 +29,7 @@ open class MythicDropsPlugin : Plugin { pluginManager.apply(MythicDropsBasePlugin::class) pluginManager.apply(MythicDropsJavaPlugin::class) pluginManager.apply(MythicDropsJavaPlatformPlugin::class) + pluginManager.apply(MythicDropsJvmTestSuitePlugin::class) pluginManager.apply(MythicDropsKotlinJvmPlugin::class) pluginManager.apply(MythicDropsMavenPublishPlugin::class) } diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlatformPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlatformPlugin.kt index 24662f1..18b8a49 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlatformPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlatformPlugin.kt @@ -9,7 +9,7 @@ import org.gradle.kotlin.dsl.withType /** * Plugin that configures Maven publications for Java Platforms. */ -open class MythicDropsJavaPlatformPlugin : DependentPlugin("Java", "java-platform") { +open class MythicDropsJavaPlatformPlugin : DependentPlugin("Java Platform", "java-platform") { override fun configureProject(target: Project) { target.pluginManager.withPlugin("maven-publish") { target.extensions.getByType().publications.withType { diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt index 47adfad..130383c 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt @@ -19,8 +19,7 @@ val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_17 */ open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") { override fun configureProject(target: Project) { - val javaExtension = target.extensions.create("mythicDropsJava") - javaExtension.apply { + val javaExtension = target.extensions.create("mythicDropsJava").apply { // default to Java 17 javaVersion.convention(DEFAULT_JAVA_VERSION) } @@ -34,7 +33,7 @@ open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") { // enable and configure JaCoCo target.pluginManager.apply(JacocoPlugin::class.java) target.configure { - toolVersion = "0.8.8" + toolVersion = "0.8.10" } target.tasks.withType { reports { diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJvmTestSuitePlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJvmTestSuitePlugin.kt new file mode 100644 index 0000000..c5ba42a --- /dev/null +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJvmTestSuitePlugin.kt @@ -0,0 +1,21 @@ +package dev.mythicdrops.gradle.conventions + +import org.gradle.api.Project +import org.gradle.api.plugins.jvm.JvmTestSuite +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.withType +import org.gradle.testing.base.TestingExtension + +/** + * Plugin that configures the base JVM Test Suite to use JUnit Jupiter. + */ +open class MythicDropsJvmTestSuitePlugin : DependentPlugin("JVM Test Suite", "org.gradle.jvm-test-suite") { + @Suppress("UnstableApiUsage") + override fun configureProject(target: Project) { + target.configure { + suites.withType { + useJUnitJupiter() + } + } + } +} diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt index aa3391f..7879726 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt @@ -24,8 +24,7 @@ open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbr // exclude files from the build directory from being linted or formatted target.configure { - // ktlint version that supports kotlin 1.8.0 - version.set("0.48.2") + version.set("0.50.0") filter { exclude { entry -> entry.file.toString().contains("generated") diff --git a/src/main/kotlin/dev/mythicdrops/gradle/projects/MythicDropsBasePlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/projects/MythicDropsBasePlugin.kt index adc310e..120222e 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/projects/MythicDropsBasePlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/projects/MythicDropsBasePlugin.kt @@ -6,9 +6,7 @@ import com.adarshr.gradle.testlogger.theme.ThemeType import nebula.plugin.responsible.NebulaResponsiblePlugin import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.withType /** * Plugin that applies sensible defaults to all projects. Intended for use on root and subprojects. @@ -31,10 +29,5 @@ open class MythicDropsBasePlugin : Plugin { showSkippedStandardStreams = false showPassedStandardStreams = false } - - // make tests use JUnit Jupiter - target.tasks.withType() { - useJUnitPlatform() - } } }