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

Conversation

Tapchicoma
Copy link
Collaborator

To see warning message run:

$ ./ktlint/target/ktlint --debug --reporter=html,artifact=me.cassiano:ktlint-html-reporter:0.2.3,output=ktlint.html ktlint/src/**/*.kt

On using direct jar file, message should not be visible:

$ ./ktlint/target/ktlint --debug --reporter=html,artifact=~/.m2/repository/me/cassiano/ktlint-html-reporter/0.2.3/ktlint-html-reporter-0.2.3.jar,output=ktlint.html ktlint/src/**/*.kt

@Tapchicoma
Copy link
Collaborator Author

@jaredsburrows FYI, when I tried to build standalone ktlint via ./gradlew :ktlint:runShadow and running it with 3rd party reporter, I've got following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Predicate
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:315)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316)
        at com.pinterest.ktlint.internal.MavenDependencyResolver.resolve(MavenDependencyResolver.kt:75)
        at com.pinterest.ktlint.Main.loadJARs(Main.kt:769)
        at com.pinterest.ktlint.Main.loadReporter(Main.kt:506)
        at com.pinterest.ktlint.Main.main(Main.kt:355)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Predicate
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 13 more

@jaredsburrows
Copy link
Contributor

@Tapchicoma Thanks. We should not need to shadow anything, see #465. You should be able to do gradlew :ktlint:run. But it really only seems to work when you run gradlew build, and unzip the distributions and run ./ktlint.

@shashachu
Copy link
Contributor

@Tapchicoma I just merged #465 - can you rebase and verify it works?

@jaredsburrows
Copy link
Contributor

Running gradlew :ktlint:run should return no errors and no output. This is just like when you run ./ktlint. You have to pass an argument such as --help.

- 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 <[email protected]>
@Tapchicoma Tapchicoma force-pushed the deprecate-maven-dependency-resolver branch from 9bb8bc7 to 9ae3725 Compare June 9, 2019 16:41
@Tapchicoma
Copy link
Collaborator Author

@jaredsburrows #465 does not solve the problem:

$ ./gradlew :ktlint:run
$ ./ktlint/build/install/ktlint-shadow/bin/ktlint --debug --reporter=html,artifact=me.cassiano:ktlint-html-reporter:0.2.3,output=ktlint.html ktlint/src/**/*.kt
[DEBUG] Discovered ruleset "standard"
[DEBUG] Resolving me.cassiano:ktlint-html-reporter:0.2.3
Deprecation message!
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Predicate
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:315)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316)
        at com.pinterest.ktlint.internal.MavenDependencyResolver.resolve(MavenDependencyResolver.kt:75)
        at com.pinterest.ktlint.Main.loadJARs(Main.kt:769)
        at com.pinterest.ktlint.Main.loadReporter(Main.kt:506)
        at com.pinterest.ktlint.Main.main(Main.kt:355)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Predicate
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 13 more

Building with maven produces ktlint that runs without this exception.

@shashachu PR itself does not related to this exception, it should be the same on master branch as well, only when building :ktlint with Gradle.

@jaredsburrows
Copy link
Contributor

@Tapchicoma I think there is some confusion. #465 was just to allow it to run correctly with the correct Main class. The issue you are seeing now is a missing class. It looks like you need guava. Try adding it to both Maven and Gradle projects, see: https://github.com/google/guava#adding-guava-to-your-build.

@Tapchicoma
Copy link
Collaborator Author

Tapchicoma commented Jun 9, 2019

@jaredsburrows but when I build ktlint with maven - it runs without exception 🤔

@jaredsburrows
Copy link
Contributor

jaredsburrows commented Jun 9, 2019

If you build with both Maven and Gradle, then both project setups are missing a dependency.

If it only is showing up in the Gradle project, then I am guessing the Gradle project still needs work.

@Tapchicoma
Copy link
Collaborator Author

Pom file has Guava dependency:

<groupId>com.google.guava</groupId>

build.gradle file does not.

@jaredsburrows
Copy link
Contributor

Cool. So can you add guava to the gradle project?

@Tapchicoma
Copy link
Collaborator Author

Added in #472

@shashachu
Copy link
Contributor

@Tapchicoma just merged #472.

@@ -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`
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.

👍

@shashachu shashachu merged commit d8843c4 into pinterest:master Jun 11, 2019
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
* 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 <[email protected]>

* Mention in README that maven dependency resolver is deprecated.

Signed-off-by: Yahor Berdnikau <[email protected]>
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
* 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 <[email protected]>

* Mention in README that maven dependency resolver is deprecated.

Signed-off-by: Yahor Berdnikau <[email protected]>
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
* 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 <[email protected]>

* Mention in README that maven dependency resolver is deprecated.

Signed-off-by: Yahor Berdnikau <[email protected]>
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
* 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 <[email protected]>

* Mention in README that maven dependency resolver is deprecated.

Signed-off-by: Yahor Berdnikau <[email protected]>
@Tapchicoma Tapchicoma deleted the deprecate-maven-dependency-resolver branch March 8, 2020 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants