Соответствующий вариант micronaut-bom не был найден, когда мое приложение зависит от библиотеки, которая зависит от другой версии micronaut

У меня есть библиотека с этим файлом build.gradle

plugins {
    id "java-library"
    id "maven"
    id "com.jfrog.artifactory" version "4.9.8"
}
...
dependencies {
    annotationProcessor platform("io.micronaut:micronaut-bom:2.0.0")
    annotationProcessor "io.micronaut:micronaut-inject-java"
    annotationProcessor "io.micronaut:micronaut-validation"
    implementation platform("io.micronaut:micronaut-bom:2.0.0")
    implementation "io.micronaut:micronaut-inject"
    implementation "io.micronaut:micronaut-runtime"
    implementation "javax.annotation:javax.annotation-api"
    implementation "io.micronaut.security:micronaut-security"
    runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
}
....

И приложение, использующее эту библиотеку:

plugins {
    id "net.ltgt.apt-idea" version "0.21"
    id "com.github.johnrengelman.shadow" version "5.0.0"
    id "application"
    id 'com.bmuschko.docker-remote-api' version '6.6.0'
}
....
dependencies {
    // Micronaut dependencies
    annotationProcessor platform("io.micronaut:micronaut-bom:${micronautVersion}")
    annotationProcessor "io.micronaut:micronaut-inject-java"
    annotationProcessor "io.micronaut:micronaut-validation"
    annotationProcessor "io.micronaut.data:micronaut-data-processor"
    implementation platform("io.micronaut:micronaut-bom:${micronautVersion}")
implementation("com.acme:my-library:0.0.1-SNAPSHOT")
    ...
}
....

Когда версия micronaut отличается между приложением и библиотекой (даже если используется только версия патча), я получаю это сообщение, когда пытаюсь собрать:

Could not determine the dependencies of task ':implementation:shadowJar'.
> Could not resolve all dependencies for configuration ':implementation:runtimeClasspath'.
   > Could not resolve io.micronaut:micronaut-bom:2.0.0.
     Required by:
         project :implementation > com.acme:my-library:0.0.1-SNAPSHOT
      > No matching variant of io.micronaut:micronaut-bom:2.0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally but:
          - Variant 'apiElements' capability io.micronaut:micronaut-bom:2.0.2:
              - Incompatible because this component declares an API of a platform and the consumer needed a runtime of 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 version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'enforcedApiElements' capability io.micronaut:micronaut-bom-derived-enforced-platform:2.0.2:
              - Incompatible because this component declares an API of an enforced platform and the consumer needed a runtime of 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 version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'enforcedRuntimeElements' capability io.micronaut:micronaut-bom-derived-enforced-platform:2.0.2 declares a runtime of a component:
              - Incompatible because this component declares an enforced 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 version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'runtimeElements' capability io.micronaut:micronaut-bom:2.0.2 declares a runtime 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 version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)

Возможно, я делаю что-то не так, потому что Gradle должен обрабатывать конфликты версий. Что мне не хватает?


person JSBach    schedule 22.09.2020    source источник


Ответы (1)


Это связано с устаревшим плагином maven, который планируется удалить в Gradle 7.0.

Вам следует удалить этот плагин и использовать вместо него maven-publish

person Graeme Rocher    schedule 15.10.2020
comment
Спасибо, это действительно ошибка. вы знаете, как исключить устаревший плагин? - person lacripta; 02.07.2021