crnk-framework icon indicating copy to clipboard operation
crnk-framework copied to clipboard

Gradle 6.x / 7.x BOM native support: Incompatible because this component declares a library and the consumer needed an enforced platform

Open gavenkoa opened this issue 2 years ago • 1 comments

BOM have to be republished with <packaging>pom</packaging> set. Following fails:

mygradle build
apply plugin: "java"
repositories {
    mavenCentral()
}
dependencies {
    implementation platform("io.crnk:crnk-bom:3.4.20210509072026")
}

Output:

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve io.crnk:crnk-bom:3.4.20210509072026.
     Required by:
         project :
      > No matching variant of io.crnk:crnk-bom:3.4.20210509072026 was found. The consumer was configured to find an API of an enforced platform compatible with Java 11, preferably in the fo
rm of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' capability io.crnk:crnk-bom:3.4.20210509072026 declares an API of a component compatible with Java 8, packaged as a jar, and its dependencies declared exter
nally:
              - Incompatible because this component declares a library and the consumer needed an enforced platform
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'runtimeElements' capability io.crnk:crnk-bom:3.4.20210509072026 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declare
d externally:
              - Incompatible because this component declares a library and the consumer needed an enforced platform
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)

If you download POM:

mvn dependency:copy -Dartifact=io.crnk:crnk-bom:3.4.20210509072026:pom

it misses <packaging>pom</packaging>. Documentation requires this in the BOM POM:

https://docs.gradle.org/current/userguide/platforms.html

In order to qualify as a BOM, a .pom file needs to have <packaging>pom</packaging> set.

gavenkoa avatar Jun 06 '22 14:06 gavenkoa

As a workaround one can use Spring Gradle Dependency Management plugin:

plugins {
    id 'org.springframework.boot' version '2.7.0'
}

apply plugin: 'io.spring.dependency-management'

repositories {
    mavenCentral()
}

dependencyManagement {
    imports {
        mavenBom "io.crnk:crnk-bom:${crnkVersion}"
    }
}

dependency {
    implementation "io.crnk:crnk-setup-spring-boot2"
}

That plugin doesn't check for <packaging>pom</packaging>.

gavenkoa avatar Jun 06 '22 16:06 gavenkoa