Hi,
Version:
Gradle: 8.5
JDK: 11
IDE - Intellij IDEA
I am facing a challenge while importing some dependencies in a gradle-based kotlin project. These dependencies are third-party libraries. Some of these are kotlin projects, while some are java based.
Issue: When i define them as dependencies in build.gradle, I’m unable to import any classes from the jars (of kotlin projects) in my src code. It fails to recognize them. But i’m able to easily import the classes from the java based project jars.
For the kotlin ones, in the IDE, under project > External Libraries > It displays the dependency as a zip file (highlighted in the screenshot). That is not the case for other dependencies like java based,
The dependencies are indeed published as zip files. Now, what additional would be needed in my project’s build.gradle to extract the jars from the zip and be able to import its underlying classes ?
This is the build.gradle.kts file for my sample-project.
plugins {
kotlin("jvm") version "1.9.0"
application
}
repositories {
mavenCentral()
mavenLocal()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
maven {
url = uri("https://aws.oss.sonatype.org/content/repositories/snapshots")
}
}
group = "org.example"
version = "1.0-SNAPSHOT"
var kotlin_version = System.getProperty("kotlin.version", "1.9.0")
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
implementation("junit:junit:4.13")
implementation("org.apache.logging.log4j:log4j-api:2.16.0")
implementation("org.apache.logging.log4j:log4j-core:2.16.0")
implementation("org.opensearch.plugin:opensearch-cross-cluster-replication:3.0.0.0-SNAPSHOT")
implementation("org.opensearch.plugin:alerting:3.0.0.0-SNAPSHOT")
implementation("org.opensearch.plugin:opensearch-index-management:3.0.0.0-SNAPSHOT")
implementation("org.opensearch:opensearch-job-scheduler-spi:3.0.0.0-SNAPSHOT")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(8)
}
application {
mainClass.set("MainKt")
}
And this is the build.gradle of one of the dependencies I’m trying to use!
Wanted to understand if something additional is needed in my project or in the dependency?