spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Gradle plugin 6.6.1 introduces conflicting variant "spotless123"

Open snazy opened this issue 3 years ago • 4 comments

(See also https://github.com/projectnessie/cel-java/issues/185 )

Steps to reproduce:

  • Clone https://github.com/projectnessie/cel-java
  • Run ./gradlew check -> failure
  • Interestingly: ./gradlew assemble check works (may want to add -x jmh to skip running the microbenchmarks)

Downgrading the spotless plugin (in settings.gradle.kts) to 6.6.0 "fixes" the problem.

CEL-Java uses the Gradle rootProject for dependency management, as that's the easiest way that also works with dependabot. So submodules use platform(rootProject) for pull in dependency versions. This started to fail with the Spotless Gradle plugin 6.6.1.

It seems that the temporary configurations ("spotless123...") leak variants that are too similar to "regular" variants and cause the conflict. Probably due to some daemon-leak fix in 6.6.1 that causes (too?) eager configuration/variant creation.

$ ./gradlew check -x jmh 
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':conformance:test'.
> Could not resolve all task dependencies for configuration ':conformance:testRuntimeClasspath'.
   > Could not resolve project :.
     Required by:
         project :conformance
         project :conformance > project :core
         project :conformance > project :generated-pb
      > The consumer was configured to find a runtime of a platform compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally. However we cannot choose between the following variants of project ::
          - runtimeElements
          - spotless1316845950
        All of them match the consumer attributes:
          - Variant 'runtimeElements' capability org.projectnessie.cel:cel-java:0.3.4-SNAPSHOT declares a runtime of a platform:
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'spotless1316845950' capability org.projectnessie.cel:cel-java:0.3.4-SNAPSHOT declares a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a platform)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'apiElements' capability org.projectnessie.cel:cel-java:0.3.4-SNAPSHOT declares a platform:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'enforcedApiElements' capability org.projectnessie.cel:cel-java-derived-enforced-platform:0.3.4-SNAPSHOT:
              - Incompatible because this component declares an API of an enforced platform and the consumer needed a runtime of a platform
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'enforcedRuntimeElements' capability org.projectnessie.cel:cel-java-derived-enforced-platform:0.3.4-SNAPSHOT declares a runtime of a component:
              - Incompatible because this component declares an enforced platform and the consumer needed a platform
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
   > Could not find com.google.protobuf:protobuf-java:.
     Required by:
         project :conformance
         project :conformance > project :generated-pb
   > Could not find io.grpc:grpc-protobuf:.
     Required by:
         project :conformance
   > Could not find io.grpc:grpc-stub:.
     Required by:
         project :conformance
   > Could not find io.grpc:grpc-netty-shaded:.
     Required by:
         project :conformance
   > Could not find org.assertj:assertj-core:.
     Required by:
         project :conformance
   > Could not find org.junit.jupiter:junit-jupiter-api:.
     Required by:
         project :conformance
   > Could not find org.junit.jupiter:junit-jupiter-params:.
     Required by:
         project :conformance
   > Could not find org.junit.jupiter:junit-jupiter-engine:.
     Required by:
         project :conformance
   > Could not find org.agrona:agrona:.
     Required by:
         project :conformance > project :core

snazy avatar May 18 '22 18:05 snazy

Thanks for reporting this bug. I think you can workaround it with a spotlessPredeclare block.

nedtwigg avatar May 20 '22 18:05 nedtwigg

I tried the spotlessPredeclare approach here, but it sadly didn't change the outcome. In fact, the spotlessPredeclare adds another variant, so there are now 2 spotless variants.

snazy avatar May 21 '22 10:05 snazy

Ran into the same issue w/ latest spotless plugin version 6.8.0 in another way (https://github.com/projectnessie/nessie/issues/4655). The change that caused the issue to happen was an unrelated dependency version bump.

snazy avatar Jul 07 '22 08:07 snazy

Run into the same issue, and for some reason, the spotlessPredeclare extension is not available to check if it works on my issue.

My root project has a custom name, maybe that is the reason Spotless is not generating the extension.

JavierSegoviaCordoba avatar Jul 12 '22 01:07 JavierSegoviaCordoba

Fix published in plugin-gradle 6.13.0, thanks @JakeWharton for the PR.

nedtwigg avatar Jan 14 '23 23:01 nedtwigg