From 9ae37253188bd02df1e5e5a59ee46ff2c57efb93 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Sun, 9 Jun 2019 16:55:48 +0200 Subject: [PATCH 1/2] Deprecate MavenDependencyResolver. - print warning message with link to the issue, when resolver is used - hide related command-line options - remove mentioning from project readme Signed-off-by: Yahor Berdnikau --- README.md | 7 +------ .../main/kotlin/com/pinterest/ktlint/Main.kt | 17 +++++------------ .../ktlint/internal/MavenDependencyResolver.kt | 2 ++ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 11dee9265b..bd78ebcd8a 100644 --- a/README.md +++ b/README.md @@ -315,11 +315,6 @@ Once packaged in a JAR [e.g. via `./gradlew build`](https://github.com/pint ```sh # enable additional 3rd party ruleset by pointing ktlint to its location on the file system $ ktlint -R /path/to/custom/rulseset.jar "src/test/**/*.kt" - -# you can also use :: triple in which case artifact is -# downloaded from Maven Central, JCenter or JitPack (depending on where it's located and -# whether or not it's already present in local Maven cache) -$ ktlint -R com.github.username:rulseset:master-SNAPSHOT ``` A complete sample project (with tests and build files) is included in this repo under the [ktlint-ruleset-template](ktlint-ruleset-template) directory @@ -367,7 +362,7 @@ In short, all you need to do is to implement a a custom [ReporterProvider](ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/ReporterProvider.kt) using `META-INF/services/com.pinterest.ktlint.core.ReporterProvider`. Pack all of that into a JAR and you're done. -To load a custom (3rd party) reporter use `ktlint --reporter=name,artifact=groupId:artifactId:version` / `ktlint --reporter=name,artifact=/path/to/custom-ktlint-reporter.jar` +To load a custom (3rd party) reporter use `ktlint --reporter=name,artifact=/path/to/custom-ktlint-reporter.jar` (see `ktlint --help` for more). Third-party: diff --git a/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt b/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt index 6984719b4a..07a8ea1f1f 100644 --- a/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt +++ b/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt @@ -175,21 +175,19 @@ object Main { names = ["--reporter"], description = [ "A reporter to use (built-in: plain (default), plain?group_by_file, json, checkstyle). " + - "To use a third-party reporter specify either a path to a JAR file on the filesystem or a" + - ":: triple pointing to a remote artifact " + - "(in which case ktlint will first check local cache (~/.m2/repository) and then, " + - "if not found, attempt downloading it from Maven Central/JCenter/JitPack/user-provided repository)\n" + - "e.g. \"html,artifact=com.github.username:ktlint-reporter-html:master-SNAPSHOT\"" + "To use a third-party reporter specify a path to a JAR file on the filesystem." ] ) private var reporters = ArrayList() + @Deprecated("See https://github.com/pinterest/ktlint/issues/451") @Option( names = ["--repository"], description = [ "An additional Maven repository (Maven Central/JCenter/JitPack are active by default) " + "(value format: =)" - ] + ], + hidden = true ) private var repositories = ArrayList() @@ -213,12 +211,7 @@ object Main { @Option( names = ["--ruleset", "-R"], - description = [ - "A path to a JAR file containing additional ruleset(s) or a " + - ":: triple pointing to a remote artifact " + - "(in which case ktlint will first check local cache (~/.m2/repository) and then, " + - "if not found, attempt downloading it from Maven Central/JCenter/JitPack/user-provided repository)" - ] + description = ["A path to a JAR file containing additional ruleset(s)"] ) private var rulesets = ArrayList() diff --git a/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/MavenDependencyResolver.kt b/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/MavenDependencyResolver.kt index 349428dc7b..d5a790dc73 100644 --- a/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/MavenDependencyResolver.kt +++ b/ktlint/src/main/kotlin/com/pinterest/ktlint/internal/MavenDependencyResolver.kt @@ -64,6 +64,8 @@ class MavenDependencyResolver( } fun resolve(vararg artifacts: Artifact): Collection { + System.err.println("[WARNING] Resolving third party rules/reporters from artifactory is deprecated!") + System.err.println("[WARNING] See: https://github.com/pinterest/ktlint/issues/451") val collectRequest = CollectRequest() artifacts.forEach { collectRequest.addDependency(Dependency(it, "compile")) From b583aaf482fd4fb28b4d73467c34d87f143a3e13 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Mon, 10 Jun 2019 22:08:11 +0200 Subject: [PATCH 2/2] Mention in README that maven dependency resolver is deprecated. Signed-off-by: Yahor Berdnikau --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index bd78ebcd8a..b8c7afcfd7 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,9 @@ Once packaged in a JAR [e.g. via `./gradlew build`](https://github.com/pint $ ktlint -R /path/to/custom/rulseset.jar "src/test/**/*.kt" ``` +Loading custom (3rd party) ruleset via built-in maven dependency resolver is deprecated, +see https://github.com/pinterest/ktlint/issues/451. + A complete sample project (with tests and build files) is included in this repo under the [ktlint-ruleset-template](ktlint-ruleset-template) directory (make sure to check [NoVarRuleTest](ktlint-ruleset-template/src/test/kotlin/yourpkgname/NoVarRuleTest.kt) as it contains some useful information). @@ -365,6 +368,9 @@ a custom [ReporterProvider](ktlint-core/src/main/kotlin/com/pinterest/ktlint/cor To load a custom (3rd party) reporter use `ktlint --reporter=name,artifact=/path/to/custom-ktlint-reporter.jar` (see `ktlint --help` for more). +Loading custom (3rd party) reporter via built-in maven dependency resolver is deprecated, +see https://github.com/pinterest/ktlint/issues/451. + Third-party: * [mcassiano/ktlint-html-reporter](https://github.com/mcassiano/ktlint-html-reporter)