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

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

Open
gavenkoa opened this issue Jun 6, 2022 · 1 comment

Comments

@gavenkoa
Copy link

gavenkoa commented Jun 6, 2022

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
Copy link
Author

gavenkoa commented Jun 6, 2022

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>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant