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 (runtimeElements, shadowRuntimeElements) #71

Closed
vitusortner opened this issue Sep 16, 2022 · 4 comments · Fixed by #72
Closed
Assignees
Labels
bug Something isn't working

Comments

@vitusortner
Copy link

Describe the bug

Since library version 0.0.10, we're facing an error when running detekt through Gradle:

> Could not resolve all files for configuration ':detektPlugins'.
   > Could not resolve com.twitter.compose.rules:detekt:0.0.11.
     Required by:
         project :
      > Cannot choose between the following variants of com.twitter.compose.rules:detekt:0.0.11:
          - runtimeElements
          - shadowRuntimeElements
        All of them match the consumer attributes:
          - Variant 'runtimeElements' capability com.twitter.compose.rules:detekt:0.0.11:
              - 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.environment 'standard-jvm' but the consumer didn't ask for it
                  - Provides org.gradle.jvm.version '11' 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.platform.type 'jvm' but the consumer didn't ask for it
          - Variant 'shadowRuntimeElements' capability com.twitter.compose.rules:detekt:0.0.11:
              - 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

It seems like this was introduced with shadowJar. I found related issues in the ktlint (pinterest/ktlint#1114) and detekt (detekt/detekt#3743, detekt/detekt#3969, detekt/detekt#3738) repositories. I also found a temporary workaround there:

configurations.named("detektPlugins").configure { configuration ->
  configuration.attributes.attribute(
          Bundling.BUNDLING_ATTRIBUTE,
          objects.named(Bundling, Bundling.EXTERNAL)
  )
}

The detekt team solved it by not publishing the shadowRuntimeElements variant of detekt-cli anymore (detekt/detekt#3747).

To Reproduce
Steps to reproduce the behavior:

  1. use version 0.0.10/0.0.11
  2. run ./gradlew detekt
  3. see error
@mrmans0n mrmans0n self-assigned this Sep 16, 2022
@mrmans0n mrmans0n added the bug Something isn't working label Sep 16, 2022
@mrmans0n
Copy link
Contributor

mrmans0n commented Sep 16, 2022

Thanks for reporting, with reports like this our life is much easier 😄

We'll look into it and release a new version with a fix. Thanks!

mrmans0n added a commit that referenced this issue Sep 17, 2022
Publishing `shadowRuntimeElements` variant can cause problems, so we will only be doing it when passing -PuberJar param to gradle.

Fixes #71.
mrmans0n added a commit that referenced this issue Sep 17, 2022
…ublication (#72)

Publishing `shadowRuntimeElements` variant can cause problems, so we will only be doing it when passing -PuberJar param to gradle.

Fixes #71.
@mrmans0n mrmans0n reopened this Sep 17, 2022
@mrmans0n
Copy link
Contributor

mrmans0n commented Sep 17, 2022

0.0.12-SNAPSHOT should have this, but I haven't tested detekt gradle yet (ktlint cli, kotlinter and detekt cli work tho).

@mrmans0n
Copy link
Contributor

Just tested with detekt and works locally. Will publish 0.0.12 then :)

@vitusortner
Copy link
Author

Perfect! Thanks for the quick fix ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants