https://kotlinlang.org logo
#ktor
Title
# ktor
d

Didier Villevalois

11/19/2021, 2:45 PM
Hi all, I published, to my maven local, the latest main branch in order to have 2.0.0-SNAPSHOT with Kotlin 1.6.0 (and a particular PR). In a project of mine where I declare
ktor-io
and
ktor-network
as implementation dependencies for my
common
source set, I now have an error "Could not resolve io.ktorktor io2.0.0-SNAPSHOT" that I don't understand. I found lots of similar errors in the Slack search but none hints me at what the problem is. This was working fine when I was using ktor 1.6.4-SNAPSHOT and Kotlin 1.5.31. (Gradle configuration and full error in thread.) Does anyone know what can be the problem ? Thanks in advance for you help.
The gradle.build.kts file:
Copy code
val kotlinxCoroutinesVersion: String by project
val ktorVersion: String by project

val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")

kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "1.8"
        }
        testRuns["test"].executionTask.configure {
            useJUnitPlatform()
        }
    }

    val hostOs = System.getProperty("os.name")

    val hostTarget = when {
        hostOs == "Mac OS X" -> macosX64("native")
        hostOs == "Linux" -> linuxX64("native") {
            binaries.sharedLib()
        }
        hostOs.startsWith("Windows") -> mingwX64("native")
        else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
    }

    sourceSets {
        all {
            languageSettings.optIn("kotlin.RequiresOptIn")
            languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
        }

        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
                implementation("io.ktor:ktor-io:$ktorVersion")
                implementation("io.ktor:ktor-network:$ktorVersion")
                implementation(project(":ktzmq-core"))
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }

        val jvmMain by getting

        val nativeMain by getting
    }
}
The error is too long for Slack, here it is in Gist: https://gist.github.com/ptitjes/cdc864dc28597c001f2419619fb98ca3 An extract:
Copy code
> Error while evaluating property 'filteredArgumentsMap' of task ':ktzmq-cio:compileKotlinMetadata'
   > Could not resolve all files for configuration ':ktzmq-cio:metadataCompileClasspath'.
      > Could not resolve io.ktor:ktor-io:2.0.0-SNAPSHOT.
        Required by:
            project :ktzmq-cio
         > The consumer was configured to find a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of io.ktor:ktor-io:2.0.0-SNAPSHOT:
             - iosArm32ApiElements-published
             - iosArm64ApiElements-published
             - iosSimulatorArm64ApiElements-published
             - iosX64ApiElements-published
             - jsIrApiElements-published
             - jsLegacyApiElements-published
             - jvmApiElements-published
             - jvmRuntimeElements-published
             - linuxX64ApiElements-published
             - macosArm64ApiElements-published
             - macosX64ApiElements-published
             - mingwX64ApiElements-published
             - tvosArm64ApiElements-published
             - tvosSimulatorArm64ApiElements-published
             - tvosX64ApiElements-published
             - watchosArm32ApiElements-published
             - watchosArm64ApiElements-published
             - watchosSimulatorArm64ApiElements-published
             - watchosX64ApiElements-published
             - watchosX86ApiElements-published
           All of them match the consumer attributes:
             - Variant 'iosArm32ApiElements-published' capability io.ktor:ktor-io:2.0.0-SNAPSHOT declares a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
                 - Unmatched attributes:
                     - Provides integration status but the consumer didn't ask for it
                     - Provides attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm32' but the consumer didn't ask for it
             - Variant 'iosArm64ApiElements-published' capability io.ktor:ktor-io:2.0.0-SNAPSHOT declares a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
                 - Unmatched attributes:
                     - Provides integration status but the consumer didn't ask for it
                     - Provides attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but the consumer didn't ask for it
[...+
a

Aleksei Tirman [JB]

11/19/2021, 5:12 PM
Are you able to reproduce it with an EAP build, like
2.0.0-eap-267
from https://maven.pkg.jetbrains.space/public/p/ktor/eap repository?
d

Didier Villevalois

11/21/2021, 11:22 AM
I can't know because if I try to use
2.0.0-eap-267
then my build fails with missing symbols (from the PR I am trying to test). It looks like
publishToMavenLocal
does not publish all the artifacts.
a

Aleksei Tirman [JB]

11/22/2021, 6:25 PM
It should work now (fixed by https://github.com/ktorio/ktor/pull/2698). Please remove local maven artifacts of version 2.0.0-SNAPSHOT, make a clean build and publish to the maven local.
d

Didier Villevalois

11/24/2021, 10:26 PM
Oh great! Thanks @Aleksei Tirman [JB] for the heads up. I'll try again tomorow. Cheers.
a

Aleksei Tirman [JB]

11/25/2021, 8:05 AM
And don't forget to pull the
main
branch :)
🤪 1
d

Didier Villevalois

11/25/2021, 7:09 PM
@Aleksei Tirman [JB] well, now it seems that all my references to Ktor fail in
compileKotlinMetada
. After a clean of my project (this sub-project targets JVM and Native), the build phases applied in order are: •
compileCommonMainKotlinMetadata
compileKotlinLinuxX64
compileKotlinJVM
linkDebugSharedLinuxX64
linkReleaseSharedLinuxX64
compileKotlinMetadata
I have errors like:
Copy code
e: /home/didier/Code/Didier/ktzmq/ktzmq-cio/src/commonMain/kotlin/org/zeromq/CIOInstance.kt: (3, 8): Unresolved reference: io
e: /home/didier/Code/Didier/ktzmq/ktzmq-cio/src/commonMain/kotlin/org/zeromq/CIOInstance.kt: (4, 8): Unresolved reference: io
e: /home/didier/Code/Didier/ktzmq/ktzmq-cio/src/commonMain/kotlin/org/zeromq/CIOInstance.kt: (16, 12): Unresolved reference: InternalAPI
e: /home/didier/Code/Didier/ktzmq/ktzmq-cio/src/commonMain/kotlin/org/zeromq/CIOInstance.kt: (16, 12): An annotation argument must be a compile-time constant
e: /home/didier/Code/Didier/ktzmq/ktzmq-cio/src/commonMain/kotlin/org/zeromq/CIOInstance.kt: (17, 35): Unresolved reference: SelectorManager
[...]
I can't figure out what is the problem nor can I find an related issue in YouTrack...
a

Aleksei Tirman [JB]

11/26/2021, 7:47 AM
I can only suggest cleaning Gradle caches (remove
~/.m2
and
~/.gradle
directories completely)
d

Didier Villevalois

11/26/2021, 10:03 AM
So I `./gradlew clean`ed both Ktor and my project, then removed
~/.m2
 and 
~/.gradle
, then
./gradlew publishToMavenLocal
in Ktor, and then 
./gradlew assemble
in my project. I unfortunately obtain the exact same errors.
44 Views