No matching variant with BOM platform included in both a dependency and directly

I’m trying to use a BOM across a group of projects and have run into the following issue:

In each project inside the dependencies I’m using:

dependencies {
   implementation enforcedPlatform('my-bom:1.0') 
  ...
}

This works as expected for base projects. But if I a have project that includes the platform and another project that already includes it i.e.

dependencies {
   implementation enforcedPlatform('my-bom:1.0') 

   implementation('another-project-that-depends-on-the-bom:1.0')
  ...
}

I end up with a dependency resolution issue with the variants being incompatible between the current component using the bom as a platform and the consumer needed a library.

I.e.

 Could not resolve all dependencies for configuration ':compileClasspath'.
   > Could not resolve my-bom:1..0.
     Required by:
         project : > another-project-that-depends-on-the-bom:1.0
      > No matching variant of my-bom:1.0 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' capability my-bom:1.0 declares an API of a component:
              - Incompatible because this component declares a platform and the consumer needed a library
              - 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 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)

I can workaround this by excluding the bom in the consumers i.e.

implementation('another-project-that-depends-on-the-bom:1.0') {
    exclude module: 'my-bom:1.0'
}

But that’s cumbersome. Is there a way to do this more simply?

The simple truth is, that it is almost never a good idea to use enforcedPlatform, especially in a library project.
I don’t know whether what you see is expected behavior or a bug.
But enforcedPlatform should only be the last resort usually and almost never used in a library project but platform instead.

Using platform vs. enforcedPlatform doesn’t have any effect on the behavior. In either case I’m seeing the same variant mismatch.

:frowning:
I hoped it will resolve the problem.
Can you knit an MCVE maybe then someone with more experience with platforms and variants can look into it