Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/full-path-r…
Browse files Browse the repository at this point in the history
…eporter#1795
  • Loading branch information
nulls committed Nov 15, 2023
2 parents a6d2499 + 303f006 commit 69e30d9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 57 deletions.
65 changes: 32 additions & 33 deletions .github/workflows/diktat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions .github/workflows/diktat_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ jobs:
-x test
-x diktatCheck
- name: 'Override <gradle/libs.versions.toml>'
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:
Expand Down
44 changes: 25 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,23 @@ 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
.dir("diktat-snapshot")
.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)

Expand All @@ -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())
}
}

Expand Down
11 changes: 11 additions & 0 deletions diktat-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
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")
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 {
Expand Down Expand Up @@ -38,6 +42,13 @@ tasks.withType<KotlinCompile> {
}
}

tasks.named<ShadowJar>("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"
Expand Down

0 comments on commit 69e30d9

Please sign in to comment.