Open gigitalz opened 1 year ago
In reproduce the bug.
This is a kbson bug (see https://github.com/jershell/kbson/issues/25)
Workaround:
In your build.gradle.kts:
@CacheableRule
abstract class TargetJvmVersionRule @Inject constructor(val jvmVersion: Int) : ComponentMetadataRule {
@get:Inject abstract val objects: ObjectFactory
override fun execute(context: ComponentMetadataContext) {
context.details.withVariant("apiElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API))
}
}
}
}
dependencies {
components {
withModule<TargetJvmVersionRule>("com.github.jershell:kbson") {
params(8)
}
}
...
}
HTH
I still get an error, but somewhat different?
* What went wrong:
Execution failed for task ':backend:run'.
> Could not resolve all files for configuration ':backend:runtimeClasspath'.
> Could not resolve com.github.jershell:kbson:0.5.0.
Required by:
project :backend > org.litote.kmongo:kmongo-coroutine-serialization:4.9.0 > org.litote.kmongo:kmongo-serialization-mapping:4.9.0
> No matching variant of com.github.jershell:kbson:0.5.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'apiElements' capability com.github.jershell:kbson:0.5.0 declares a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'runtimeElements' capability com.github.jershell:kbson:0.5.0 declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
@CacheableRule
abstract class TargetJvmVersionRule implements ComponentMetadataRule {
@Inject abstract ObjectFactory getObjects()
final Integer jvmVersion
@Inject TargetJvmVersionRule(Integer jvmVersion) {
this.jvmVersion = jvmVersion
}
void execute(ComponentMetadataContext context) {
context.details.withVariant("apiElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_API))
}
}
}
}
dependencies {
components {
withModule("com.github.jershell:kbson", TargetJvmVersionRule) {
params(8)
}
}
I tried issuing bot apiElements and runtimeElements, still no luck
* What went wrong:
Execution failed for task ':backend:compileKotlin'.
> Could not resolve all files for configuration ':backend:compileClasspath'.
> Could not resolve com.github.jershell:kbson:0.5.0.
Required by:
project :backend > org.litote.kmongo:kmongo-coroutine-serialization:4.9.0 > org.litote.kmongo:kmongo-serialization-mapping:4.9.0
> The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of com.github.jershell:kbson:0.5.0:
- apiElements
- runtimeElements
All of them match the consumer attributes:
- Variant 'apiElements' capability com.github.jershell:kbson:0.5.0 declares an API of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attribute:
- Provides release status but the consumer didn't ask for it
- Variant 'runtimeElements' capability com.github.jershell:kbson:0.5.0 declares an API of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attribute:
- Provides release status but the consumer didn't ask for it
code:
@CacheableRule
abstract class TargetJvmVersionRule implements ComponentMetadataRule
{
@Inject
abstract ObjectFactory getObjects()
final int jvmVersion
@Inject
TargetJvmVersionRule(int jvmVersion)
{
this.jvmVersion = jvmVersion
}
void execute(ComponentMetadataContext context)
{
context.details.withVariant("apiElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_API))
}
}
context.details.withVariant("runtimeElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_API))
}
}
}
}
dependencies {
components {
withModule("com.github.jershell:kbson", TargetJvmVersionRule) {
params(8)
}
}
Looks like it's complaining about an attribute it didn't ask for so I removed it and it went through, code:
@CacheableRule
abstract class TargetJvmVersionRule implements ComponentMetadataRule
{
@Inject
abstract ObjectFactory getObjects()
final int jvmVersion
@Inject
TargetJvmVersionRule(int jvmVersion)
{
this.jvmVersion = jvmVersion
}
void execute(ComponentMetadataContext context)
{
context.details.withVariant("apiElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
}
}
context.details.withVariant("runtimeElements") {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
}
}
}
}
What is your gradle version ? Tested on my side with gradle 8.1.1
This fixed my issue. Running with gradle 8.2.1
Looks like it's complaining about an attribute it didn't ask for so I removed it and it went through, code:
@CacheableRule abstract class TargetJvmVersionRule implements ComponentMetadataRule { @Inject abstract ObjectFactory getObjects() final int jvmVersion @Inject TargetJvmVersionRule(int jvmVersion) { this.jvmVersion = jvmVersion } void execute(ComponentMetadataContext context) { context.details.withVariant("apiElements") { attributes { attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion) } } context.details.withVariant("runtimeElements") { attributes { attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion) } } } }
I reveive this error:
Please also check #391 same issue (and yes it keeps happening). I am running on java version "1.8.0_301". I'd like to update but I can't.