-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code analysis configuration to
gradle/plugins
, convert to scri…
…pt plugins (#1622) * Move configuration of diktat, detekt and spotless into `gradle/plugins` Continuation of #948
- Loading branch information
Showing
25 changed files
with
135 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/DetektConfiguration.kt
This file was deleted.
Oops, something went wrong.
75 changes: 0 additions & 75 deletions
75
buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/DiktatConfiguration.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...lugins/src/main/kotlin/com/saveourtool/save/buildutils/code-quality-convention.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.saveourtool.save.buildutils | ||
|
||
plugins { | ||
id("com.saveourtool.save.buildutils.detekt-convention-configuration") | ||
id("com.saveourtool.save.buildutils.diktat-convention-configuration") | ||
id("com.saveourtool.save.buildutils.spotless-convention-configuration") | ||
} |
39 changes: 39 additions & 0 deletions
39
...rc/main/kotlin/com/saveourtool/save/buildutils/detekt-convention-configuration.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.saveourtool.save.buildutils | ||
|
||
import io.gitlab.arturbosch.detekt.Detekt | ||
import io.gitlab.arturbosch.detekt.report.ReportMergeTask | ||
|
||
plugins { | ||
id("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
detekt { | ||
config = rootProject.files("detekt.yml") | ||
basePath = rootDir.canonicalPath | ||
buildUponDefaultConfig = true | ||
} | ||
|
||
@Suppress("RUN_IN_SCRIPT") | ||
if (path == rootProject.path) { | ||
tasks.register("detektAll") { | ||
allprojects { | ||
this@register.dependsOn(tasks.withType<Detekt>()) | ||
} | ||
} | ||
|
||
tasks.register("mergeDetektReports", ReportMergeTask::class) { | ||
output.set(buildDir.resolve("detekt-sarif-reports/detekt-merged.sarif")) | ||
} | ||
} | ||
|
||
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") | ||
val reportMerge: TaskProvider<ReportMergeTask> = rootProject.tasks.named<ReportMergeTask>("mergeDetektReports") { | ||
input.from( | ||
tasks.withType<Detekt>().map { it.sarifReportFile } | ||
) | ||
shouldRunAfter(tasks.withType<Detekt>()) | ||
} | ||
tasks.withType<Detekt>().configureEach { | ||
reports.sarif.required.set(true) | ||
finalizedBy(reportMerge) | ||
} |
29 changes: 29 additions & 0 deletions
29
...rc/main/kotlin/com/saveourtool/save/buildutils/diktat-convention-configuration.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.saveourtool.save.buildutils | ||
|
||
import Versions | ||
import org.cqfn.diktat.plugin.gradle.DiktatJavaExecTaskBase | ||
|
||
plugins { | ||
id("org.cqfn.diktat.diktat-gradle-plugin") | ||
} | ||
|
||
diktat { | ||
diktatConfigFile = rootProject.file("diktat-analysis.yml") | ||
githubActions = findProperty("diktat.githubActions")?.toString()?.toBoolean() ?: false | ||
inputs { | ||
// using `Project#path` here, because it must be unique in gradle's project hierarchy | ||
if (path == rootProject.path) { | ||
include("gradle/plugins/src/**/*.kt", "*.kts", "gradle/plugins/**/*.kts") | ||
exclude("gradle/plugins/build/**") | ||
} else { | ||
include("src/**/*.kt", "**/*.kts") | ||
exclude("src/test/**/*.kt", "src/*Test/**/*.kt") | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<DiktatJavaExecTaskBase>().configureEach { | ||
javaLauncher.set(project.extensions.getByType<JavaToolchainService>().launcherFor { | ||
languageVersion.set(JavaLanguageVersion.of(Versions.jdk)) | ||
}) | ||
} |
36 changes: 36 additions & 0 deletions
36
.../main/kotlin/com/saveourtool/save/buildutils/spotless-convention-configuration.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.saveourtool.save.buildutils | ||
|
||
import org.gradle.accessors.dm.LibrariesForLibs | ||
|
||
plugins { | ||
id("com.diffplug.spotless") | ||
} | ||
|
||
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") | ||
val libs = the<LibrariesForLibs>() | ||
val diktatVersion: String = libs.versions.diktat.get() | ||
spotless { | ||
kotlin { | ||
diktat(diktatVersion).configFile(rootProject.file("diktat-analysis.yml")) | ||
target("src/**/*.kt") | ||
targetExclude("src/test/**/*.kt", "src/*Test/**/*.kt") | ||
if (path == rootProject.path) { | ||
target("gradle/plugins/src/**/*.kt") | ||
} | ||
} | ||
kotlinGradle { | ||
diktat(diktatVersion).configFile(rootProject.file("diktat-analysis.yml")) | ||
|
||
// using `Project#path` here, because it must be unique in gradle's project hierarchy | ||
if (path == rootProject.path) { | ||
target("$rootDir/*.kts", "$rootDir/gradle/plugins/**/*.kts") | ||
targetExclude( | ||
"$rootDir/build/**/*.kts", | ||
"$rootDir/gradle/plugins/build/**/*.kts", | ||
) | ||
} else { | ||
target("**/*.kts") | ||
targetExclude("build/**/*.kts") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.