From 6ba1724e5ea62ac321b0aba9aa7d7568756e8a66 Mon Sep 17 00:00:00 2001 From: "Vitaly V. Pinchuk" Date: Wed, 14 Sep 2022 16:06:39 +0300 Subject: [PATCH 1/3] Make fat-jar version of detekt-generator This will enable calls through CLI to generate configuration files for custom rules. --- detekt-generator/build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/detekt-generator/build.gradle.kts b/detekt-generator/build.gradle.kts index bdc69b687fd..747a38e48a5 100644 --- a/detekt-generator/build.gradle.kts +++ b/detekt-generator/build.gradle.kts @@ -1,7 +1,10 @@ plugins { + alias(libs.plugins.shadow) id("module") } +tasks.build { finalizedBy(tasks.shadowJar) } + dependencies { implementation(projects.detektParser) implementation(projects.detektApi) From ee5fc1aa801fa530a7e7f08f06232355c3a16c56 Mon Sep 17 00:00:00 2001 From: "Vitaly V. Pinchuk" Date: Wed, 14 Sep 2022 16:08:11 +0300 Subject: [PATCH 2/3] Update docs on detekt-generator usage --- website/docs/gettingstarted/_cli-generator-options.md | 10 ++++++++++ website/docs/gettingstarted/cli.mdx | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 website/docs/gettingstarted/_cli-generator-options.md diff --git a/website/docs/gettingstarted/_cli-generator-options.md b/website/docs/gettingstarted/_cli-generator-options.md new file mode 100644 index 00000000000..4b49776c0a9 --- /dev/null +++ b/website/docs/gettingstarted/_cli-generator-options.md @@ -0,0 +1,10 @@ +``` +Usage: java -jar detekt-generator-[detekt_version]-all.jar [options] + Options: + --generate-custom-rule-config, -gcrc + Generate custom rules configuration files. The files will be + placed under 'resources' folder of each rule respectively + (e.g. 'custom-rule/src/main/resources/config/config.yml'). + --input, -i + Input paths to rules to analyze. Multiple paths are separated by comma. +``` diff --git a/website/docs/gettingstarted/cli.mdx b/website/docs/gettingstarted/cli.mdx index ef7092c7145..981f0eedcb1 100644 --- a/website/docs/gettingstarted/cli.mdx +++ b/website/docs/gettingstarted/cli.mdx @@ -9,6 +9,7 @@ sidebar_position: 1 --- import CliOptions from "./_cli-options.md"; +import CliGeneratorOptions from "./_cli-generator-options.md"; ## Install the cli @@ -50,3 +51,11 @@ detekt will exit with one of the following exit codes: The following parameters are shown when `--help` is entered. + +## Use the cli to generate configuration for custom rules + + + +```sh +java -jar detekt-generator-[detekt_version]-all.jar -gcrc -i /path/to/rule1, /path/to/rule2 +``` From a5704f982f6d99b3bfb10a721c7745ded8e5efe7 Mon Sep 17 00:00:00 2001 From: "Vitaly V. Pinchuk" Date: Wed, 14 Sep 2022 17:26:48 +0300 Subject: [PATCH 3/3] Update releasing.gradle.kts --- build-logic/src/main/kotlin/releasing.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build-logic/src/main/kotlin/releasing.gradle.kts b/build-logic/src/main/kotlin/releasing.gradle.kts index 8721ef04588..d7549002fe4 100644 --- a/build-logic/src/main/kotlin/releasing.gradle.kts +++ b/build-logic/src/main/kotlin/releasing.gradle.kts @@ -39,6 +39,7 @@ project.afterEvaluate { cliBuildDir.resolve("libs/detekt-cli-${project.version}-all.jar"), cliBuildDir.resolve("distributions/detekt-cli-${project.version}.zip"), project(":detekt-formatting").buildDir.resolve("libs/detekt-formatting-${project.version}.jar"), + project(":detekt-generator").buildDir.resolve("libs/detekt-generator-${project.version}-all.jar"), project(":detekt-rules-ruleauthors").buildDir .resolve("libs/detekt-rules-ruleauthors-${project.version}.jar") )