diff --git a/.github/workflows/diktat.yml b/.github/workflows/diktat.yml index 1e92f65d1d..7a6560ab08 100644 --- a/.github/workflows/diktat.yml +++ b/.github/workflows/diktat.yml @@ -14,36 +14,35 @@ jobs: security-events: write steps: - - name: This action is disabled until the release 2.0.0 - run: | - echo "This action is disabled until the release 2.0.0" -# - uses: actions/checkout@v3 -# - name: Set up JDK 11 -# uses: actions/setup-java@v3 -# with: -# java-version: 11 -# distribution: temurin -# - uses: gradle/gradle-build-action@v2 -# with: -# gradle-version: wrapper -# arguments: | -# diktatCheck -# mergeDiktatReports -# -Pdiktat.githubActions=true -# -Pdetekt.multiplatform.disabled=true -# --build-cache -# --continue -# -PgprUser=${{ github.actor }} -# -PgprKey=${{ secrets.GITHUB_TOKEN }} -# - name: Upload SARIF report to Github -# uses: github/codeql-action/upload-sarif@v2 -# if: ${{ always() }} -# with: -# sarif_file: build/reports/diktat/diktat-merged.sarif -# - name: Upload SARIF artifacts -# uses: actions/upload-artifact@v3 -# if: ${{ failure() }} -# with: -# name: sarif-reports -# path: "**/build/reports/diktat" -# retention-days: 1 + - uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + + - uses: gradle/gradle-build-action@v2 + with: + gradle-version: wrapper + arguments: | + diktatCheck + mergeDiktatReports + -Pdiktat.githubActions=true + -Pdetekt.multiplatform.disabled=true + --continue + --build-cache + -PgprUser=${{ github.actor }} + -PgprKey=${{ secrets.GITHUB_TOKEN }} + - name: Upload SARIF report to Github + uses: github/codeql-action/upload-sarif@v2 + if: ${{ always() }} + with: + sarif_file: build/reports/diktat/diktat-merged.sarif + - name: Upload SARIF artifacts + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: sarif-reports + path: "**/build/reports/diktat" + retention-days: 1 diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index 426ac35eb0..0b59d67ebd 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -51,11 +51,6 @@ jobs: -x test -x diktatCheck - - name: 'Override ' - run: | - mv gradle/libs.versions.toml gradle/libs.versions.toml_current - mv build/diktat-snapshot/libs.versions.toml gradle/libs.versions.toml - # copied from .github/workflows/diktat.yml - uses: gradle/gradle-build-action@v2 with: diff --git a/build.gradle.kts b/build.gradle.kts index e84609569d..b3566af866 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,10 @@ talaiot { project.description = "diKTat kotlin formatter and fixer" +val libsFileName = "libs.versions.toml" +val libsFile = rootProject.file("gradle/$libsFileName") +val libsFileBackup = rootProject.file("gradle/${libsFileName}_backup") + tasks.create("generateLibsForDiktatSnapshot") { val dir = rootProject.layout .buildDirectory @@ -32,20 +36,12 @@ tasks.create("generateLibsForDiktatSnapshot") { .get() .asFile - val dependencies = setOf( - rootProject.project(":diktat-common"), - rootProject.project(":diktat-api"), - rootProject.project(":diktat-ktlint-engine"), - rootProject.project(":diktat-rules"), - rootProject.project(":diktat-gradle-plugin"), - ) - dependsOn(dependencies.map { "${it.path}:publishToMavenLocal" }) - - val libsFile = rootProject.file("gradle/libs.versions.toml") + val dependency = rootProject.project(":diktat-gradle-plugin") + dependsOn(dependency.let { "${it.path}:publishToMavenLocal" }) inputs.file(libsFile) - inputs.files(dependencies.map { it.pomFile() }) - inputs.files(dependencies.map { it.artifactFile() }) + inputs.files(dependency.pomFile()) + inputs.files(dependency.artifactFile()) inputs.property("project-version", version.toString()) outputs.dir(dir) @@ -62,16 +58,26 @@ tasks.create("generateLibsForDiktatSnapshot") { } } .let { - val libsFileForDiktatSnapshot = dir.resolve("libs.versions.toml") + val libsFileForDiktatSnapshot = dir.resolve(libsFileName) Files.write(libsFileForDiktatSnapshot.toPath(), it) + Files.move(libsFile.toPath(), libsFileBackup.toPath()) + Files.copy(libsFileForDiktatSnapshot.toPath(), libsFile.toPath()) } - dependencies.forEach { dependency -> - val artifactDir = dir.pathToMavenArtifact(dependency) - .also { it.createDirectory() } - Files.copy(dependency.pomFile().toPath(), artifactDir.resolve(dependency.pomFileName()).toPath()) - Files.copy(dependency.artifactFile().toPath(), artifactDir.resolve(dependency.artifactFileName()).toPath()) - } + val artifactDir = dir.pathToMavenArtifact(dependency) + .also { it.createDirectory() } + Files.copy(dependency.pomFile().toPath(), artifactDir.resolve(dependency.pomFileName()).toPath()) + Files.copy(dependency.artifactFile().toPath(), artifactDir.resolve(dependency.artifactFileName()).toPath()) + } +} + +tasks.create("rollbackLibsForDiktatSnapshot") { + inputs.file(libsFileBackup) + outputs.file(libsFile) + + doLast { + Files.deleteIfExists(libsFile.toPath()) + Files.move(libsFileBackup.toPath(), libsFile.toPath()) } } diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 95808a6ada..01e5b6de3f 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -1,7 +1,10 @@ import com.saveourtool.diktat.buildutils.configurePom + +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +@Suppress("DSL_SCOPE_VIOLATION", "RUN_IN_SCRIPT") // https://github.com/gradle/gradle/issues/22797 plugins { id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration") id("com.saveourtool.diktat.buildutils.code-quality-convention") @@ -9,6 +12,7 @@ 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 { @@ -38,6 +42,13 @@ tasks.withType { } } +tasks.named("shadowJar") { + archiveClassifier.set("") + duplicatesStrategy = DuplicatesStrategy.FAIL + // all kotlin libs + relocate("org.jetbrains", "shadow.org.jetbrains") +} + gradlePlugin { website = "https://diktat.saveourtool.com/" vcsUrl = "https://github.com/saveourtool/diktat"