Code Monkey home page Code Monkey logo

Comments (6)

zigzago avatar zigzago commented on July 17, 2024

In reproduce the bug.

This is a kbson bug (see jershell/kbson#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)
        }
    }
  ...
}

(source: https://docs.gradle.org/current/userguide/component_metadata_rules.html#basics_of_writing_a_component_metadata_rule)

HTH

from kmongo.

gigitalz avatar gigitalz commented on July 17, 2024

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)
        }
    }

from kmongo.

gigitalz avatar gigitalz commented on July 17, 2024

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)
        }
    }

from kmongo.

gigitalz avatar gigitalz commented on July 17, 2024

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)
            }
        }
    }
}

from kmongo.

zigzago avatar zigzago commented on July 17, 2024

What is your gradle version ? Tested on my side with gradle 8.1.1

from kmongo.

sarhatabaot avatar sarhatabaot commented on July 17, 2024

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)
            }
        }
    }
}

from kmongo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.