I made a mistake for a plugin ID.
build.gradle.kts
with correct ID
subprojects {
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
configure<KotlinJvmProjectExtension> {
compilerOptions {
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
}
}
}
}
But I realized that I didn’t solve the problem )
Adding compiler options change @Metadata mv property
of class Kotlin version:
import kotlin.Metadata;
@Metadata(
mv = {1, 9, 0},
k = 1,
xi = 48,
d1 = {"..."},
d2 = {"..."}
)
public class Application {
}
But dependency in pom file of published to Maven local repository artifact still contains kotlin-stdlib 2.1.0
<modelVersion>4.0.0</modelVersion>
<groupId>*****</groupId>
<artifactId>*****</artifactId>
<version>1.22.127-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>2.1.0</version>
</dependency>
In order to get rid of 2.1.0
I created buildSrc
with build.gradle.kts
:
plugins {
kotlin("jvm")
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24")
}
As a result I got pom.xml with kotlin-stdlib
with 1.9.4
<modelVersion>4.0.0</modelVersion>
<groupId>****</groupId>
<artifactId>*****</artifactId>
<version>1.22.127-SNAPSHOT</version>
<dependencyManagement>
*********
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.9.24</version>
<scope>compile</scope>
</dependency>
****
But when I try to compile an another application with this artifact I get an exception:
Unresolved reference: <class_name>
And I can navigate to this class in IDE and it has a correct (1.9.24
) kotlin version in class metadata.
What is the reason the Gradle 8.8 can’t resolve classes from this module?