Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate MavenDependencyResolver. #468

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,11 @@ Once packaged in a JAR <sup>[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 <groupId>:<artifactId>:<version> 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
```

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).

Expand Down Expand Up @@ -367,9 +365,12 @@ 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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a note here about the old groupId:artifactId:version being scheduled for deprecation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, see b583aaf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

(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)

Expand Down
17 changes: 5 additions & 12 deletions ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
"<groupId>:<artifactId>:<version> 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<String>()

@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: <id>=<url>)"
]
],
hidden = true
)
private var repositories = ArrayList<String>()

Expand All @@ -213,12 +211,7 @@ object Main {

@Option(
names = ["--ruleset", "-R"],
description = [
"A path to a JAR file containing additional ruleset(s) or a " +
"<groupId>:<artifactId>:<version> 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<String>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class MavenDependencyResolver(
}

fun resolve(vararg artifacts: Artifact): Collection<File> {
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"))
Expand Down