Gradle resolves platform on non transitive configurations


I am using Gradle together with IntelliJ for development. Currently, I have the issue that intellij is unable to download the sources for my published libraries. I filed an IntelliJ bug:

I understand the IntellJ part of the bug, but I don’t understand the gradle behaviour at this point.

The issue is that IntellJ generates a gradle script for downloading the sources for a library. The library is in my local maven repository. The library uses a platform/bom as enforcedPlatform in the implementation configuration.

The intellij script tries to resolve the sources of this project. For this it adds a dummy configuration with transitive = false. Gradle however still tries to resolve the transitive platform dependency which fails.

I would like to understand why gradle tries to resolve the platform dependency. As far as I understand platform dependencies are still dependencies and should not be resolved as transitive dependency if transitive = false.

I did see in the debug a line like org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver: Attempting to resolve component for <the platform>

I am looking for a workaround. Is there a way to add a enforcedPlatform in such a way that gradle does not resolve the transitive boms?

A possible solution is in my library project:

dependencies {
    compileOnly(enforcedPlatform("my platform"))
    testImplementation(enforcedPlatform("my platform"))

However is there better way?