From 9bb8bc70f28b46f2678f50ae5568aff172e3d92f Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Sun, 9 Jun 2019 16:55:48 +0200 Subject: [PATCH] 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 b24d2cf198..783e5bd58f 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"))