Nikky
04/20/2024, 6:53 PMktor-client-core
and needs the dependency to be ktor-client-core-jvm
instead.. pretty sure that is known
problem is when this is a transitive dependency, seems like using a BOM in gradle .. even in a JVM only project makes it put the ktor-client-core
dependency into the maven pom AND the version is being omitted since it gets put into the dependencyManagement
section in the pom file
leading to idea being very confused and the script execution breaking at runtime with java.lang.NoClassDefFoundError: io/ktor/client/HttpClientJvmKt
or similar fun errors
did anyone else run into this and how did you fix it ?Piotr KrzemiĆski
04/20/2024, 7:53 PM-jvm
to the artifact ID for libs that are KMPified:
âą https://github.com/typesafegithub/github-actions-typing-catalog/blob/ae261420184443651b55780eabac869eb487943d/.github/workflows/update-metadata.main.kts#L3
âą https://github.com/krzema12/kotlin-python/blob/0b7a9951fd3b019dd0ed8384710532c47d4f7199/python/experiments/generate-box-tests-reports.main.kts#L4Nikky
04/20/2024, 8:51 PM-jvm
and that it does not look up the versions from the dependencyManagement section elsewhere in the pom fileNikky
04/20/2024, 9:00 PM<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="<http://maven.apache.org/POM/4.0.0>" xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <https://maven.apache.org/xsd/maven-4.0.0.xsd>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.typesafegithub</groupId>
<artifactId>shared-internal</artifactId>
<version>1.14.1-SNAPSHOT</version>
<name>shared-internal</name>
<description>Authoring GitHub Actions workflows in Kotlin.</description>
<url><https://github.com/typesafegithub/github-workflows-kt></url>
<licenses>
<license>
<name>Apache License, version 2.0</name>
<url><https://www.apache.org/licenses/LICENSE-2.0.txt></url>
</license>
</licenses>
<developers>
<developer>
<id>typesafegithub</id>
<name>Piotr KrzemiĆski</name>
<email>git@krzeminski.it</email>
</developer>
</developers>
<scm>
<connection>scm:git:<git://github.com/typesafegithub/github-workflows-kt.git/></connection>
<developerConnection>scm:git:<ssh://github.com>:typesafegithub/github-workflows-kt.git</developerConnection>
<url><https://github.com/typesafegithub/github-workflows-kt.git></url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-bom</artifactId>
<version>2.3.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.9.23</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-core</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-cio</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-content-negotiation</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-serialization-kotlinx-json-jvm</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
the relevant dependencies are
implementation(platform("io.ktor:ktor-bom:2.3.10"))
implementation("io.ktor:ktor-client-core")
implementation("io.ktor:ktor-client-cio")
implementation("io.ktor:ktor-client-content-negotiation")
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm")
so.. we see that we CAN fix the artifactId like i do with ktor-serialization-kotlinx-json-jvm
(and it seems to be fine in gradle too.. at least on a jvm-only project)
but the thing thats still different is the absense of a version
in the dependenciesNikky
04/20/2024, 9:27 PMefemoney
04/21/2024, 10:52 AMNikky
04/21/2024, 10:55 AM-jvm
to the dependencies and still use a BOM then the version tags are still missing in the XML, .. I don't think the versionManagement field in the maven pom is a gradle specific thing?efemoney
04/21/2024, 11:00 AMNikky
04/21/2024, 11:00 AMPiotr KrzemiĆski
04/21/2024, 11:19 AMNikky
04/21/2024, 11:20 AMPiotr KrzemiĆski
04/21/2024, 11:38 AMPiotr KrzemiĆski
04/21/2024, 11:39 AMNikky
04/21/2024, 11:39 AMAdam S
05/17/2024, 4:26 PMpom.xml
https://docs.gradle.org/8.7/userguide/publishing_maven.html#publishing_maven:resolved_dependencies
I downloaded your reproducer and added
publishing {
publications {
create<MavenPublication>("mavenJava") {
// ...
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
And then published, and I could see in .m2/repository/kt_67618/kt_67618/0.1/kt_67618-0.1.pom
it specified the versions
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-core</artifactId>
<version>2.3.10</version>
<scope>runtime</scope>
</dependency>
But the script still doesn't work, because Maven doesn't know that when it sees io.ktor:ktor-client-core
it should get io.ktor:ktor-client-core-jvm