From 4a7dc9bf71a83694a46db7b9e016092fcbccf83a Mon Sep 17 00:00:00 2001 From: Richard Harrah Date: Sat, 23 Sep 2023 17:54:32 -0400 Subject: [PATCH] update to ktlint 1.0.0 --- build.gradle.kts | 17 ++++++++----- settings.gradle.kts | 2 +- .../gradle/conventions/DependentPlugin.kt | 4 +-- .../conventions/MythicDropsJavaPlugin.kt | 9 ++++--- .../conventions/MythicDropsKotlinJvmPlugin.kt | 2 +- .../MythicDropsMavenPublishPlugin.kt | 25 +++++++++++-------- ...MythicDropsGitHubReleaseAssetUploadTask.kt | 10 +++++--- .../release/MythicDropsNexusStagingPlugin.kt | 17 +++++++------ version.properties | 2 +- versions.properties | 4 +-- 10 files changed, 52 insertions(+), 40 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 30ce9b3..a1bf00c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -92,6 +92,10 @@ gradlePlugin { } } +ktlint { + version.set("1.0.0") +} + tasks { // get dokkaJavadoc task and make javadocJar depend on it val dokkaJavadoc by this @@ -121,16 +125,17 @@ tasks { "javadocJar", "sourcesJar", "generateMetadataFileForPluginMavenPublication", - "generatePomFileForPluginMavenPublication" + "generatePomFileForPluginMavenPublication", ) } // Make GitHub release depend on generating a changelog - val generateChangelog = getByName("generateChangelog") { - previousRevision = project.ext.get("shipkit-auto-version.previous-tag")?.toString() - githubToken = System.getenv("GITHUB_TOKEN") - repository = "MythicDrops/mythicdrops-gradle-plugin" - } + val generateChangelog = + getByName("generateChangelog") { + previousRevision = project.ext.get("shipkit-auto-version.previous-tag")?.toString() + githubToken = System.getenv("GITHUB_TOKEN") + repository = "MythicDrops/mythicdrops-gradle-plugin" + } getByName("githubRelease") { dependsOn(generateChangelog) repository = generateChangelog.repository diff --git a/settings.gradle.kts b/settings.gradle.kts index fdb729e..8612e21 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { plugins { // See https://jmfayard.github.io/refreshVersions id("de.fayard.refreshVersions") version "0.60.2" - id("com.gradle.enterprise") version "3.14.1" + id("com.gradle.enterprise") version "3.15" } gradleEnterprise { diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/DependentPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/DependentPlugin.kt index 9385d8c..b4d832d 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/DependentPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/DependentPlugin.kt @@ -12,7 +12,7 @@ import org.gradle.api.logging.LogLevel */ abstract class DependentPlugin( private val pluginDescription: String, - private val prerequisitePluginId: String + private val prerequisitePluginId: String, ) : Plugin { override fun apply(target: Project) { target.pluginManager.withPlugin(prerequisitePluginId) { @@ -20,7 +20,7 @@ abstract class DependentPlugin( LogLevel.INFO, "Applying MythicDrops {} plugin as the \"{}\" plugin is applied", pluginDescription, - prerequisitePluginId + prerequisitePluginId, ) configureProject(target) } diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt index 130383c..befcc29 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt @@ -19,10 +19,11 @@ val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_17 */ open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") { override fun configureProject(target: Project) { - val javaExtension = target.extensions.create("mythicDropsJava").apply { - // default to Java 17 - javaVersion.convention(DEFAULT_JAVA_VERSION) - } + val javaExtension = + target.extensions.create("mythicDropsJava").apply { + // default to Java 17 + javaVersion.convention(DEFAULT_JAVA_VERSION) + } target.configure { toolchain { diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt index 7879726..e6f3665 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsKotlinJvmPlugin.kt @@ -24,7 +24,7 @@ open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbr // exclude files from the build directory from being linted or formatted target.configure { - version.set("0.50.0") + version.set("1.0.0") filter { exclude { entry -> entry.file.toString().contains("generated") diff --git a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsMavenPublishPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsMavenPublishPlugin.kt index d89baf8..a380933 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsMavenPublishPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsMavenPublishPlugin.kt @@ -54,10 +54,12 @@ open class MythicDropsMavenPublishPlugin : DependentPlugin("Maven Publish", "mav // we only add compileOnly dependencies if the configuration even exists val dependencies = project.configurations.findByName("compileOnly")?.dependencies ?: return@withXml if (dependencies.size > 0) { - val deps = root.children().find { - it is groovy.util.Node && it.name().toString() - .endsWith("dependencies") - } as groovy.util.Node? ?: root.appendNode("dependencies") + val deps = + root.children().find { + it is groovy.util.Node && + it.name().toString() + .endsWith("dependencies") + } as groovy.util.Node? ?: root.appendNode("dependencies") dependencies.forEach { dependency -> deps.appendNode("dependency").apply { appendNode("groupId", dependency.group) @@ -72,7 +74,7 @@ open class MythicDropsMavenPublishPlugin : DependentPlugin("Maven Publish", "mav private data class SigningParams( val pgpKey: String, - val pgpPwd: String + val pgpPwd: String, ) /** @@ -80,15 +82,16 @@ open class MythicDropsMavenPublishPlugin : DependentPlugin("Maven Publish", "mav */ private data class SigningNullableParams( val pgpKey: String? = System.getenv("PGP_KEY"), - val pgpPwd: String? = System.getenv("PGP_PWD") + val pgpPwd: String? = System.getenv("PGP_PWD"), ) { /** * Converts to a non-nullable version of the params, returning null if any values are null. */ - fun toSigningParams(): SigningParams? = when { - pgpKey == null -> null - pgpPwd == null -> null - else -> SigningParams(pgpKey, pgpPwd) - } + fun toSigningParams(): SigningParams? = + when { + pgpKey == null -> null + pgpPwd == null -> null + else -> SigningParams(pgpKey, pgpPwd) + } } } diff --git a/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsGitHubReleaseAssetUploadTask.kt b/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsGitHubReleaseAssetUploadTask.kt index 438b697..19b69b6 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsGitHubReleaseAssetUploadTask.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsGitHubReleaseAssetUploadTask.kt @@ -39,10 +39,12 @@ abstract class MythicDropsGitHubReleaseAssetUploadTask : DefaultTask() { } val github = GitHubBuilder().withOAuthToken(githubToken.get()).build() - val githubRepository = github.getRepository(repository.get()) - ?: throw IllegalArgumentException("${repository.get()} does not exist") - val githubRelease = githubRepository.getReleaseByTagName(releaseTag.get()) - ?: throw IllegalArgumentException("Release by tag name ${releaseTag.get()} does not exist") + val githubRepository = + github.getRepository(repository.get()) + ?: throw IllegalArgumentException("${repository.get()} does not exist") + val githubRelease = + githubRepository.getReleaseByTagName(releaseTag.get()) + ?: throw IllegalArgumentException("Release by tag name ${releaseTag.get()} does not exist") assets.forEach { val contentType = Files.probeContentType(it.toPath()) diff --git a/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsNexusStagingPlugin.kt b/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsNexusStagingPlugin.kt index 304b651..f2b7d6d 100644 --- a/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsNexusStagingPlugin.kt +++ b/src/main/kotlin/dev/mythicdrops/gradle/release/MythicDropsNexusStagingPlugin.kt @@ -21,7 +21,7 @@ open class MythicDropsNexusStagingPlugin : Plugin { private fun enableSonatypePublishing( sonatypeParams: SonatypeParams?, - target: Project + target: Project, ) { if (sonatypeParams == null) { // if any environment variables are null, do not enable Sonatype publishing or signing @@ -41,7 +41,7 @@ open class MythicDropsNexusStagingPlugin : Plugin { private data class SonatypeParams( val sonatypeUser: String, - val sonatypePwd: String + val sonatypePwd: String, ) /** @@ -49,15 +49,16 @@ open class MythicDropsNexusStagingPlugin : Plugin { */ private data class SonatypeNullableParams( val sonatypeUser: String? = System.getenv("SONATYPE_USER"), - val sonatypePwd: String? = System.getenv("SONATYPE_PWD") + val sonatypePwd: String? = System.getenv("SONATYPE_PWD"), ) { /** * Converts to a non-nullable version of the params, returning null if any values are null. */ - fun toSonatypeParams(): SonatypeParams? = when { - sonatypeUser == null -> null - sonatypePwd == null -> null - else -> SonatypeParams(sonatypeUser, sonatypePwd) - } + fun toSonatypeParams(): SonatypeParams? = + when { + sonatypeUser == null -> null + sonatypePwd == null -> null + else -> SonatypeParams(sonatypeUser, sonatypePwd) + } } } diff --git a/version.properties b/version.properties index 2daab6d..9cc77e9 100644 --- a/version.properties +++ b/version.properties @@ -1 +1 @@ -version=6.0.* +version=6.1.* diff --git a/versions.properties b/versions.properties index 6b573cf..9dd5ae4 100644 --- a/versions.properties +++ b/versions.properties @@ -13,7 +13,7 @@ plugin.io.gitlab.arturbosch.detekt=1.23.1 plugin.org.jetbrains.dokka=1.9.0 -plugin.org.jlleitschuh.gradle.ktlint=11.5.1 +plugin.org.jlleitschuh.gradle.ktlint=11.6.0 plugin.org.shipkit.shipkit-auto-version=1.2.2 @@ -37,7 +37,7 @@ version.com.netflix.nebula..nebula-project-plugin=10.1.5 version.io.gitlab.arturbosch.detekt..detekt-gradle-plugin=1.23.1 -version.org.jlleitschuh.gradle..ktlint-gradle=11.5.1 +version.org.jlleitschuh.gradle..ktlint-gradle=11.6.0 version.io.github.gradle-nexus..publish-plugin=1.3.0 ## # available=2.0.0-rc-1