klogging / slf4j-klogging

Simple SLF4J binding that directs log events to Klogging
Apache License 2.0
7 stars 2 forks source link

Cannot resolve io.klogging:slf4j-klogging:0.2.2 #11

Closed jmfayard closed 1 year ago

jmfayard commented 2 years ago

Hello, I added to my project

repositories {
    mavenCentral()
}
dependencies {
    implementation("io.klogging:slf4j-klogging:0.2.2")
}

It doesn't resolve

See: https://scans.gradle.com/s/xazqkjpygc6by/dependencies

Build_Scan™_for__backend-tignum-x__just_now___Gradle_Cloud_Services

I get this error if I try to compile

> Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
   > Could not resolve all files for configuration ':compileClasspath'.
      > Could not resolve io.klogging:slf4j-klogging:{require 0.2.2; reject _}.
        Required by:
            project :
         > No matching variant of io.klogging:slf4j-klogging:0.2.2 was found. 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' but:
             - Variant 'apiElements' capability io.klogging:slf4j-klogging:0.2.2 declares an API of a library, packaged as a jar, 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
                 - Other compatible attribute:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
             - Variant 'runtimeElements' capability io.klogging:slf4j-klogging:0.2.2 declares a runtime of a library, packaged as a jar, 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
                 - Other compatible attribute:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
mjstrasser commented 2 years ago

Hi @jmfayard, thanks for bringing this to my attention.

I will look into this. I may have set the dependencies wrongly.

mjstrasser commented 2 years ago

Hi @jmfayard, I have been investigating but do not have a solution yet.

I was able to recreate the error messages by creating a small application that depends on slf4j-klogging:0.2.2 and attempting to build using Java 8.

I built new versions of klogging-jvm (0.4.3) and slf4j-klogging (0.3.0-SNAPSHOT) that compile Kotlin to JVM 8 bytecode but that has not worked.

I will continue investigating and let you know.

Otherwise, if you want to use Klogging, can you use JVM 11 in your project?

jmfayard commented 2 years ago

@mjstrasser I'm already using JVM 11 as you can see here: https://scans.gradle.com/s/xazqkjpygc6by#infrastructure

AdoptOpenJDK OpenJDK 64-Bit Server VM 11.0.11+9 (mixed mode)

jmfayard commented 2 years ago

I wonder if this happens because some dependencies like ktor request jvm 8

Build_Scan™_for__backend-tignum-x__on_16_Feb_2022_at_11_14_09_CET___Gradle_Cloud_Services
mjstrasser commented 2 years ago

@jmfayard I think I have solved the issue in version 0.2.4. My sample application now builds correctly on JVM 8 and 17. Let me know if it works for you.

I added explicit Java toolchain declaration to build.gradle.kts:

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(8))
    }
}

This caused a change to outgoing variants. The output of ./gradlew outgoingVariants includes:

--------------------------------------------------
Variant apiElements
--------------------------------------------------
Description = API elements for main.

Capabilities
    - io.klogging:slf4j-klogging:0.2.4 (default capability)
Attributes
    - org.gradle.category                = library
    - org.gradle.dependency.bundling     = external
    - org.gradle.jvm.environment         = standard-jvm
    - org.gradle.jvm.version             = 8
    - org.gradle.libraryelements         = jar
    - org.gradle.usage                   = java-api
    - org.jetbrains.kotlin.platform.type = jvm

Artifacts
    - build/libs/slf4j-klogging-0.2.4.jar (artifactType = jar)

Thanks for bringing this to my attention! I had not paid attention to Gradle variants and toolchains before.