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

Cannot choose between the following variants of com.pinterest:ktlint:0.41.0: #1114

Closed
nuhkoca opened this issue Mar 19, 2021 · 11 comments · Fixed by #1120
Closed

Cannot choose between the following variants of com.pinterest:ktlint:0.41.0: #1114

nuhkoca opened this issue Mar 19, 2021 · 11 comments · Fixed by #1120

Comments

@nuhkoca
Copy link

nuhkoca commented Mar 19, 2021

I have upgraded ktlint from 0.40.0 to 0.41.0. However, I am getting error when I execute ./gradlew ktlintCheck. How do I fix this? Thank you.

* What went wrong:
Execution failed for task ':loadKtlintReporters'.
> Could not resolve all files for configuration ':ktlint'.
   > Could not resolve com.pinterest:ktlint:0.41.0.
     Required by:
         project :
      > Cannot choose between the following variants of com.pinterest:ktlint:0.41.0:
          - runtimeElements
          - shadowRuntimeElements
        All of them match the consumer attributes:
          - Variant 'runtimeElements' capability com.pinterest:ktlint:0.41.0:
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
                  - Provides org.gradle.jvm.version '8' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
                  - Provides org.jetbrains.kotlin.localToProject 'public' but the consumer didn't ask for it
                  - Provides org.jetbrains.kotlin.platform.type 'jvm' but the consumer didn't ask for it
          - Variant 'shadowRuntimeElements' capability com.pinterest:ktlint:0.41.0:
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'shadowed' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

Steps to Reproduce

  • Update to 0.41.0
  • Execute ./gradlew ktlintCheck

Your Environment

  • Version of ktlint used: 0.41.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): ktlint-gradle plugin 10.0.0
  • Version of Gradle used (if applicable): 6.8.3
@Tapchicoma
Copy link
Collaborator

Please open a new issue in ktlint-gradle project. I think something wrong with your configuration.

@ganadist
Copy link
Contributor

ganadist commented Mar 24, 2021

Since ktlint 0.41.0, shadowRuntimeElements variant is added, and you must select variant explicitly.

 dependencies {
     val ktlintVersion: String by project.ext.properties
    add("ktlint", "com.pinterest:ktlint:$ktlintVersion") {
        attributes {
            attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
        }
    }
}

@nuhkoca
Copy link
Author

nuhkoca commented Mar 24, 2021

@ganadist thank you! How to achieve this with ktlint plugin?

@ganadist
Copy link
Contributor

If you are using ktlint with gradle plugin, it can run well without any modifications.

If you are using ktlint without gradle plugin, please follow https://github.com/pinterest/ktlint/pull/1120/files

@nuhkoca
Copy link
Author

nuhkoca commented Mar 25, 2021

@ganadist unfortunately, root project ktlintCheck fails with above error. Only ./gradlew :app:ktlintCheck works fine.

@ganadist
Copy link
Contributor

It seems that you are using allprojects notation.

And you might fix with using subprojects notation as example configuration.

I don't know the right solution for allprojects, but you might need to setup substituting a dependency with attributes

@dimsuz
Copy link

dimsuz commented Apr 26, 2021

I think this was closed too early. I have my build.gradle to be configured exactly as README.md says in with Gradle section and I'm not using ktlint-gradle plugin, but still I've got the above error after upgrading to ktlint-0.41.0

@nuhkoca
Copy link
Author

nuhkoca commented Apr 26, 2021

@dimsuz This was closed because I moved this issue to ktlint plugin repo since this issue is mainly related to the plugin itself. And it is expected to be fixed in the next release.

@dimsuz
Copy link

dimsuz commented Apr 26, 2021

But I don't use that plugin and still have this issue, that's what I've tried to say above.
Hence I think that either README should be updated to recommend only using that ktlint plugin or somehow updated to exclude this error in ktlint.

I use instructions from (without a plugin) section and they lead to the error.

@androiddevcoding
Copy link

At 0.41.0 it's the same.
0.40.0 works successfully.

@dimsuz
Copy link

dimsuz commented Aug 5, 2021

Caught this on another project.
I believe this bug was incorrectly closed.
It has nothing to do with "ktlint plugin".

As I've said above, I don't use it and I still experience this bug.

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 a pull request may close this issue.

5 participants