From 222ee2c51543f258bbc478374be5ea7726ce43f5 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 13:22:52 +0300 Subject: [PATCH 01/15] Changed ID for for gradle plugin ### What's done: - updated gradle plugin id - fixed README.md --- README.md | 4 ++-- diktat-gradle-plugin/build.gradle.kts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a335942094..891bb13132 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Build and test](https://github.com/saveourtool/diKTat/workflows/Build%20and%20test/badge.svg?branch=master) ![deteKT static analysis](https://github.com/saveourtool/diKTat/workflows/Run%20deteKT/badge.svg) -![diKTat code style](https://github.com/saveourtool/diKTat/workflows/Run%20diKTat%20from%20release%20version/badge.svg?branch=master) +![diKTat code style](https://github.com/saveourtool/diKTat/workflows/Run%20diKTat%20%28release%29/badge.svg?branch=master) [![codecov](https://codecov.io/gh/saveourtool/diKTat/branch/master/graph/badge.svg)](https://codecov.io/gh/saveourtool/diKTat) [![Releases](https://img.shields.io/github/v/release/saveourtool/diKTat)](https://github.com/saveourtool/diKTat/releases) [![Maven Central](https://img.shields.io/maven-central/v/com.saveourtool.diktat/diktat-rules)](https://mvnrepository.com/artifact/com.saveourtool.diktat) -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsaveourtool%2FdiKTat.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsaveourtool%2FdiKTat?ref=badge_shield) +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsaveourtool%2Fdiktat.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsaveourtool%2Fdiktat?ref=badge_shield) [![Chat on Telegram](https://img.shields.io/badge/Chat%20on-Telegram-brightgreen.svg)](https://t.me/diktat_help) [![Hits-of-Code](https://hitsofcode.com/github/saveourtool/diktat)](https://hitsofcode.com/view/github/saveourtool/diktat) diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index e1db1fb38c..96208e2023 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -38,9 +38,11 @@ tasks.withType { } gradlePlugin { + website = "https://diktat.saveourtool.com/" + vcsUrl = "https://github.com/saveourtool/diktat" plugins { create("diktatPlugin") { - id = "com.saveourtool.diktat.diktat-gradle-plugin" + id = "com.saveourtool.diktat" implementationClass = "com.saveourtool.diktat.plugin.gradle.DiktatGradlePlugin" } } From 370b5733d2dc7d7cb0daced2020fcefea26bbed2 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 15:35:35 +0300 Subject: [PATCH 02/15] supported RC with snapshots --- .../saveourtool/diktat/buildutils/VersioningConfiguration.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index 04bc814484..9bb3c17829 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -7,6 +7,7 @@ package com.saveourtool.diktat.buildutils import org.ajoberstar.reckon.core.Scope import org.ajoberstar.reckon.gradle.ReckonExtension import org.ajoberstar.reckon.gradle.ReckonPlugin +import org.ajoberstar.reckon.core.Version import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.storage.file.FileRepositoryBuilder @@ -26,6 +27,9 @@ fun Project.configureVersioning() { snapshots() setScopeCalc(calcScopeFromProp()) setStageCalc(calcStageFromProp()) + setTagParser { tagName -> + Version.parse(tagName.replace("-rc.[0-9]+".toRegex(), "")) + } } val status = FileRepositoryBuilder() From a2e39b0f42ea6980c5059303f8c9ede49860e496 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 15:53:46 +0300 Subject: [PATCH 03/15] diktatFix --- .../saveourtool/diktat/buildutils/VersioningConfiguration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index 9bb3c17829..e05701ca54 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -5,9 +5,9 @@ package com.saveourtool.diktat.buildutils import org.ajoberstar.reckon.core.Scope +import org.ajoberstar.reckon.core.Version import org.ajoberstar.reckon.gradle.ReckonExtension import org.ajoberstar.reckon.gradle.ReckonPlugin -import org.ajoberstar.reckon.core.Version import org.eclipse.jgit.api.Git import org.eclipse.jgit.internal.storage.file.FileRepository import org.eclipse.jgit.storage.file.FileRepositoryBuilder From ac67788566b81a2710b068152883bf18d0c8a422 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 16:01:23 +0300 Subject: [PATCH 04/15] fixed TagParser --- .../saveourtool/diktat/buildutils/VersioningConfiguration.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index e05701ca54..9d0090c14f 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -5,7 +5,7 @@ package com.saveourtool.diktat.buildutils import org.ajoberstar.reckon.core.Scope -import org.ajoberstar.reckon.core.Version +import org.ajoberstar.reckon.core.VersionTagParser import org.ajoberstar.reckon.gradle.ReckonExtension import org.ajoberstar.reckon.gradle.ReckonPlugin import org.eclipse.jgit.api.Git @@ -28,7 +28,7 @@ fun Project.configureVersioning() { setScopeCalc(calcScopeFromProp()) setStageCalc(calcStageFromProp()) setTagParser { tagName -> - Version.parse(tagName.replace("-rc.[0-9]+".toRegex(), "")) + VersionTagParser.getDefault().parse(tagName.replace("-rc.[0-9]+".toRegex(), "")) } } From 52419bf912989ff5c48813631a0f3fa12b40634f Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 16:41:49 +0300 Subject: [PATCH 05/15] restored gradle ID --- .github/workflows/diktat_snapshot.yml | 5 ----- build.gradle.kts | 2 +- diktat-gradle-plugin/build.gradle.kts | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index e2143b0289..d38c8845bb 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -46,11 +46,6 @@ jobs: with: gradle-version: wrapper arguments: | - :diktat-api:publishToMavenLocal - :diktat-common:publishToMavenLocal - :diktat-ktlint-engine:publishToMavenLocal - :diktat-rules:publishToMavenLocal - :diktat-gradle-plugin:publishToMavenLocal :generateLibsForDiktatSnapshot -x detekt -x test diff --git a/build.gradle.kts b/build.gradle.kts index afba69b985..3dee31eeb1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,7 +39,7 @@ tasks.create("generateLibsForDiktatSnapshot") { rootProject.project(":diktat-rules"), rootProject.project(":diktat-gradle-plugin"), ) - mustRunAfter(dependencies.map { "${it.path}:publishToMavenLocal" }) + dependsOn(dependencies.map { "${it.path}:publishToMavenLocal" }) val libsFile = rootProject.file("gradle/libs.versions.toml") inputs.file(libsFile) diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 96208e2023..17d61d1210 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -42,7 +42,7 @@ gradlePlugin { vcsUrl = "https://github.com/saveourtool/diktat" plugins { create("diktatPlugin") { - id = "com.saveourtool.diktat" + id = "com.saveourtool.diktat.diktat-gradle-plugin" implementationClass = "com.saveourtool.diktat.plugin.gradle.DiktatGradlePlugin" } } From 95b1c73ae534ff2ecb9e4928294f92ac886743da Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 18:07:00 +0300 Subject: [PATCH 06/15] reverted TarParser + removed removing javadocs --- diktat-gradle-plugin/build.gradle.kts | 12 ------------ .../diktat/buildutils/VersioningConfiguration.kt | 3 --- 2 files changed, 15 deletions(-) diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 17d61d1210..5bfc1f6f89 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -105,15 +105,3 @@ tasks.jacocoTestReport { xml.required.set(true) } } - -afterEvaluate { - tasks.named("javadocJar") { - enabled = false - } - tasks.named("generateMetadataFileForPluginMavenPublication") { - dependsOn(tasks.named("dokkaJar")) - } - tasks.named("generateMetadataFileForMavenPublication") { - dependsOn(tasks.named("dokkaJar")) - } -} diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index 9d0090c14f..021ca9e6eb 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -27,9 +27,6 @@ fun Project.configureVersioning() { snapshots() setScopeCalc(calcScopeFromProp()) setStageCalc(calcStageFromProp()) - setTagParser { tagName -> - VersionTagParser.getDefault().parse(tagName.replace("-rc.[0-9]+".toRegex(), "")) - } } val status = FileRepositoryBuilder() From ae7d31604e95cb11cb4212672d5f5ca333bf957f Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 9 Nov 2023 18:08:44 +0300 Subject: [PATCH 07/15] from snapshot to rc --- .../saveourtool/diktat/buildutils/VersioningConfiguration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index 021ca9e6eb..72ddc7c113 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -24,7 +24,7 @@ fun Project.configureVersioning() { // should be provided in the gradle.properties configure { setDefaultInferredScope(Scope.MINOR.name) - snapshots() + stages("rc", "final") setScopeCalc(calcScopeFromProp()) setStageCalc(calcStageFromProp()) } From 5da926421990cf1b5dafd13e60938a8fe8433c3e Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 15:15:55 +0300 Subject: [PATCH 08/15] removed everything and use the default configurations --- diktat-cli/build.gradle.kts | 2 + diktat-gradle-plugin/build.gradle.kts | 43 ++++++++++++++++++- diktat-maven-plugin/build.gradle.kts | 2 + diktat-ruleset/build.gradle.kts | 2 + .../buildutils/PublishingConfiguration.kt | 3 +- ...ublishing-default-configuration.gradle.kts | 1 + 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/diktat-cli/build.gradle.kts b/diktat-cli/build.gradle.kts index b7db4f5702..f14c1004cd 100644 --- a/diktat-cli/build.gradle.kts +++ b/diktat-cli/build.gradle.kts @@ -1,3 +1,4 @@ +import com.saveourtool.diktat.buildutils.configurePublications import com.github.jengelman.gradle.plugins.shadow.ShadowExtension import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.jetbrains.kotlin.incremental.createDirectory @@ -92,3 +93,4 @@ publishing { } } } +configurePublications() diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 5bfc1f6f89..27f0a82387 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -1,13 +1,16 @@ +import com.saveourtool.diktat.buildutils.configurePom import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +//import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration") id("com.saveourtool.diktat.buildutils.code-quality-convention") - id("com.saveourtool.diktat.buildutils.publishing-default-configuration") + id("com.saveourtool.diktat.buildutils.publishing-configuration") id("pl.droidsonroids.jacoco.testkit") version "1.0.12" id("org.gradle.test-retry") version "1.5.6" id("com.gradle.plugin-publish") version "1.2.1" +// alias(libs.plugins.shadow) } dependencies { @@ -48,6 +51,38 @@ gradlePlugin { } } +//tasks.named("jar") { +// enabled = false +//} +//val shadowJar by tasks.existing(ShadowJar::class) { +// archiveClassifier.set("") +// duplicatesStrategy = DuplicatesStrategy.FAIL +//} +// +//val javadocJar by tasks.registering(Jar::class) { +// group = "documentation" +// archiveClassifier.set("javadoc") +// from(tasks.named("dokkaHtml")) +//} +// +//publishing { +// repositories { +// mavenLocal() +// } +// publications { +// val pluginMaven by creating(MavenPublication::class) { +// artifact(shadowJar) +// artifact(javadocJar) +// pom { +// configurePom(project) +// } +// } +// } +//} + + + + // === testing & code coverage, jacoco is run independent from maven val functionalTestTask by tasks.register("functionalTest") tasks.withType { @@ -105,3 +140,9 @@ tasks.jacocoTestReport { xml.required.set(true) } } + +//afterEvaluate { +// tasks.named("publishDiktatPluginPluginMarkerMavenPublicationToMavenLocal") { +// dependsOn(javadocJar) +// } +//} diff --git a/diktat-maven-plugin/build.gradle.kts b/diktat-maven-plugin/build.gradle.kts index 05ace85be0..3497312994 100644 --- a/diktat-maven-plugin/build.gradle.kts +++ b/diktat-maven-plugin/build.gradle.kts @@ -1,3 +1,4 @@ +import com.saveourtool.diktat.buildutils.configurePublications import de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask import de.benediktritter.maven.plugin.development.task.GenerateMavenPluginDescriptorTask @@ -47,3 +48,4 @@ publishing { } } } +configurePublications() diff --git a/diktat-ruleset/build.gradle.kts b/diktat-ruleset/build.gradle.kts index 6f066d90bd..94bc7dc4b7 100644 --- a/diktat-ruleset/build.gradle.kts +++ b/diktat-ruleset/build.gradle.kts @@ -1,4 +1,5 @@ import com.saveourtool.diktat.buildutils.configurePom +import com.saveourtool.diktat.buildutils.configurePublications import com.github.jengelman.gradle.plugins.shadow.ShadowExtension import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar @@ -73,3 +74,4 @@ publishing { } } } +configurePublications() diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt index 321a8295de..ac62e3aca1 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt @@ -39,7 +39,6 @@ import org.jetbrains.dokka.gradle.DokkaPlugin * Configures all aspects of the publishing process. */ fun Project.configurePublishing() { - configurePublications() apply() if (this == rootProject) { configureNexusPublishing() @@ -161,7 +160,7 @@ private fun Project.configureGitHubPublishing() { * Configures all publications. The publications must already exist. */ @Suppress("TOO_LONG_FUNCTION") -private fun Project.configurePublications() { +fun Project.configurePublications() { if (this == rootProject) { return } diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/publishing-default-configuration.gradle.kts b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/publishing-default-configuration.gradle.kts index 92952dc516..47c8e7773a 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/publishing-default-configuration.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/publishing-default-configuration.gradle.kts @@ -16,4 +16,5 @@ publishing { } } +configurePublications() configurePublishing() From f1d2aab7ff13dcb27534d2c8b0ab8c9f40c15c1a Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 16:19:52 +0300 Subject: [PATCH 09/15] added sourcesJar and updated pom for gradle plugin --- diktat-gradle-plugin/build.gradle.kts | 15 +++++++++++++++ .../diktat/buildutils/PublishingConfiguration.kt | 2 ++ .../saveourtool/diktat/buildutils/TaskNames.kt | 10 ++++++++++ .../kotlin-jvm-configuration.gradle.kts | 5 +++++ 4 files changed, 32 insertions(+) create mode 100644 gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/TaskNames.kt diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 27f0a82387..5d209470eb 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -51,6 +51,21 @@ gradlePlugin { } } +publishing { + publications { + named("pluginMaven") { + pom { + configurePom(project) + } + } +// @Suppress("UNUSED_VARIABLE") +// val pluginMaven = existing(MavenPublication::class) { +// pom { +// configurePom(project) +// } +// } + } +} //tasks.named("jar") { // enabled = false //} diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt index ac62e3aca1..ac818b9bee 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt @@ -164,6 +164,7 @@ fun Project.configurePublications() { if (this == rootProject) { return } + val sourcesJar = tasks.named(SOURCES_JAR) apply() @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") val dokkaJarProvider = tasks.register("dokkaJar") { @@ -176,6 +177,7 @@ fun Project.configurePublications() { mavenLocal() } publications.withType().configureEach { + artifact(sourcesJar) artifact(dokkaJarProvider) pom { configurePom(project) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/TaskNames.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/TaskNames.kt new file mode 100644 index 0000000000..1eace3d788 --- /dev/null +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/TaskNames.kt @@ -0,0 +1,10 @@ +/** + * Names for common tasks + */ + +package com.saveourtool.diktat.buildutils + +/** + * Tasks with sources + */ +const val SOURCES_JAR = "sourcesJar" diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/kotlin-jvm-configuration.gradle.kts b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/kotlin-jvm-configuration.gradle.kts index 4c9848f100..8be3c26a19 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/kotlin-jvm-configuration.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/kotlin-jvm-configuration.gradle.kts @@ -26,6 +26,11 @@ kotlin { } } +tasks.register(SOURCES_JAR) { + archiveClassifier.set("sources") + from(kotlin.sourceSets.main.map { it.kotlin }) +} + configureJacoco() tasks.withType { useJUnitPlatform() From 9fb535e3810855d2f44466c187a4419ce1c9d446 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 16:24:40 +0300 Subject: [PATCH 10/15] cleanup the code --- diktat-gradle-plugin/build.gradle.kts | 57 ++++----------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 5d209470eb..334e7b24b9 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -1,7 +1,6 @@ import com.saveourtool.diktat.buildutils.configurePom import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -//import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration") @@ -10,7 +9,6 @@ plugins { id("pl.droidsonroids.jacoco.testkit") version "1.0.12" id("org.gradle.test-retry") version "1.5.6" id("com.gradle.plugin-publish") version "1.2.1" -// alias(libs.plugins.shadow) } dependencies { @@ -51,52 +49,17 @@ gradlePlugin { } } -publishing { - publications { - named("pluginMaven") { - pom { - configurePom(project) +afterEvaluate { + publishing { + publications { + named("pluginMaven") { + pom { + configurePom(project) + } } } -// @Suppress("UNUSED_VARIABLE") -// val pluginMaven = existing(MavenPublication::class) { -// pom { -// configurePom(project) -// } -// } } } -//tasks.named("jar") { -// enabled = false -//} -//val shadowJar by tasks.existing(ShadowJar::class) { -// archiveClassifier.set("") -// duplicatesStrategy = DuplicatesStrategy.FAIL -//} -// -//val javadocJar by tasks.registering(Jar::class) { -// group = "documentation" -// archiveClassifier.set("javadoc") -// from(tasks.named("dokkaHtml")) -//} -// -//publishing { -// repositories { -// mavenLocal() -// } -// publications { -// val pluginMaven by creating(MavenPublication::class) { -// artifact(shadowJar) -// artifact(javadocJar) -// pom { -// configurePom(project) -// } -// } -// } -//} - - - // === testing & code coverage, jacoco is run independent from maven val functionalTestTask by tasks.register("functionalTest") @@ -155,9 +118,3 @@ tasks.jacocoTestReport { xml.required.set(true) } } - -//afterEvaluate { -// tasks.named("publishDiktatPluginPluginMarkerMavenPublicationToMavenLocal") { -// dependsOn(javadocJar) -// } -//} From cdc44f2a2d7475e615e59336a2b2d268af46338b Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 16:37:48 +0300 Subject: [PATCH 11/15] need to configure pom for all publication --- diktat-gradle-plugin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 334e7b24b9..dc41980832 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -52,7 +52,7 @@ gradlePlugin { afterEvaluate { publishing { publications { - named("pluginMaven") { + withType { pom { configurePom(project) } From 749cb1701d6fcc607856fc05931062646835a09d Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 17:04:47 +0300 Subject: [PATCH 12/15] supported RC when snapshot is enabled --- .../diktat/buildutils/VersioningConfiguration.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt index 72ddc7c113..b9cca001d5 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/VersioningConfiguration.kt @@ -14,6 +14,7 @@ import org.eclipse.jgit.storage.file.FileRepositoryBuilder import org.gradle.api.Project import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import java.util.Optional /** * Configures reckon plugin for [this] project, should be applied for root project only @@ -24,7 +25,19 @@ fun Project.configureVersioning() { // should be provided in the gradle.properties configure { setDefaultInferredScope(Scope.MINOR.name) - stages("rc", "final") + if (findProperty("reckon.stage")?.toString() == "snapshot") { + snapshots() + // skip -rc candidates tags + setTagParser { tagName -> + if (tagName.contains("-rc.[0-9]+".toRegex())) { + Optional.empty() + } else { + VersionTagParser.getDefault().parse(tagName) + } + } + } else { + stages("rc", "final") + } setScopeCalc(calcScopeFromProp()) setStageCalc(calcStageFromProp()) } From 5a2439e39e4a45804b1d1b274a6dc5c483f64ea9 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 17:18:14 +0300 Subject: [PATCH 13/15] supported new gradle id --- .github/workflows/diktat_snapshot.yml | 5 ++++- build.gradle.kts | 17 ++++++++++++++++- diktat-gradle-plugin/build.gradle.kts | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index d38c8845bb..dafc6b9786 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -54,7 +54,10 @@ jobs: - name: 'Override ' run: | mv gradle/libs.versions.toml gradle/libs.versions.toml_current - mv build/diktat-snapshot/libs.versions.toml_snapshot gradle/libs.versions.toml + mv build/diktat-snapshot/libs.versions.toml gradle/libs.versions.toml + + mv gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/diktat-convention-configuration.gradle.kts gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/diktat-convention-configuration.gradle.kts_current + mv build/diktat-snapshot/diktat-convention-configuration.gradle.kts gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/diktat-convention-configuration.gradle.kts # copied from .github/workflows/diktat.yml - uses: gradle/gradle-build-action@v2 diff --git a/build.gradle.kts b/build.gradle.kts index 3dee31eeb1..ba66f0b157 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,9 +40,12 @@ tasks.create("generateLibsForDiktatSnapshot") { rootProject.project(":diktat-gradle-plugin"), ) dependsOn(dependencies.map { "${it.path}:publishToMavenLocal" }) + val libsFile = rootProject.file("gradle/libs.versions.toml") + val diktatGradleFile = rootProject.file("gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/diktat-convention-configuration.gradle.kts") inputs.file(libsFile) + inputs.file(diktatGradleFile) inputs.files(dependencies.map { it.pomFile() }) inputs.files(dependencies.map { it.artifactFile() }) inputs.property("project-version", version.toString()) @@ -61,10 +64,22 @@ tasks.create("generateLibsForDiktatSnapshot") { } } .let { - val libsFileForDiktatSnapshot = dir.resolve("libs.versions.toml_snapshot") + val libsFileForDiktatSnapshot = dir.resolve("libs.versions.toml") Files.write(libsFileForDiktatSnapshot.toPath(), it) } + Files.readAllLines(diktatGradleFile.toPath()) + .map { line -> + when { + line.contains("com.saveourtool.diktat.diktat-gradle-plugin") -> line.replace("com.saveourtool.diktat.diktat-gradle-plugin", "com.saveourtool.diktat") + else -> line + } + } + .let { + val diktatGradleFileForDiktatSnapshot = dir.resolve("diktat-convention-configuration.gradle.kts") + Files.write(diktatGradleFileForDiktatSnapshot.toPath(), it) + } + dependencies.forEach { dependency -> val artifactDir = dir.pathToMavenArtifact(dependency) .also { it.createDirectory() } diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index dc41980832..1a2e77ff1a 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -43,7 +43,7 @@ gradlePlugin { vcsUrl = "https://github.com/saveourtool/diktat" plugins { create("diktatPlugin") { - id = "com.saveourtool.diktat.diktat-gradle-plugin" + id = "com.saveourtool.diktat" implementationClass = "com.saveourtool.diktat.plugin.gradle.DiktatGradlePlugin" } } From be05ebed02264c632cf12b90820dd8d7b192845d Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 17:21:37 +0300 Subject: [PATCH 14/15] diktatFix --- .../buildutils/PublishingConfiguration.kt | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt index ac818b9bee..01fa5fb7b9 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/PublishingConfiguration.kt @@ -94,6 +94,36 @@ fun MavenPom.configurePom(project: Project) { } } +/** + * Configures all publications. The publications must already exist. + */ +@Suppress("TOO_LONG_FUNCTION") +fun Project.configurePublications() { + if (this == rootProject) { + return + } + val sourcesJar = tasks.named(SOURCES_JAR) + apply() + @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") + val dokkaJarProvider = tasks.register("dokkaJar") { + group = "documentation" + archiveClassifier.set("javadoc") + from(tasks.named("dokkaHtml")) + } + configure { + repositories { + mavenLocal() + } + publications.withType().configureEach { + artifact(sourcesJar) + artifact(dokkaJarProvider) + pom { + configurePom(project) + } + } + } +} + /** * Configures Maven Central as the publish destination. */ @@ -156,36 +186,6 @@ private fun Project.configureGitHubPublishing() { } } -/** - * Configures all publications. The publications must already exist. - */ -@Suppress("TOO_LONG_FUNCTION") -fun Project.configurePublications() { - if (this == rootProject) { - return - } - val sourcesJar = tasks.named(SOURCES_JAR) - apply() - @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") - val dokkaJarProvider = tasks.register("dokkaJar") { - group = "documentation" - archiveClassifier.set("javadoc") - from(tasks.named("dokkaHtml")) - } - configure { - repositories { - mavenLocal() - } - publications.withType().configureEach { - artifact(sourcesJar) - artifact(dokkaJarProvider) - pom { - configurePom(project) - } - } - } -} - /** * Enables signing of the artifacts if the `signingKey` project property is set. * From bd018b4824176696da7dbf20dafc3971dee4e545 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Fri, 10 Nov 2023 17:24:46 +0300 Subject: [PATCH 15/15] fixed detektAll --- .../buildutils/detekt-convention-configuration.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/detekt-convention-configuration.gradle.kts b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/detekt-convention-configuration.gradle.kts index b62eedc062..5052700c2e 100644 --- a/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/detekt-convention-configuration.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com/saveourtool/diktat/buildutils/detekt-convention-configuration.gradle.kts @@ -8,7 +8,7 @@ plugins { } detekt { - config = rootProject.files("detekt-config.yml") + config.setFrom(rootProject.files("detekt-config.yml")) basePath = rootDir.canonicalPath buildUponDefaultConfig = true }