Hi I have an application with some dependencies (say A). I need to use this application in another project(say B).
I tried tweaking the jar task as shown below. This is project A's gradle file.
import org.jetbrains.kotlin.com.intellij.openapi.vfs.StandardFileSystems.jar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.21"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
tasks.withType<Jar>{
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
duplicatesStrategy = DuplicatesStrategy.INCLUDE
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
dependencies {
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
This is my project B's gradle file.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.21"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(files("src/main/resources/ProjectA-1.0-SNAPSHOT.jar"))
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
But doing this way I cannot access any class available in the
ProjectA-1.0-SNAPSHOT.jar
from my project B
I also tried using "com.github.johnrengelman.shadow" plugin. There also could not access the class files inside the uber jar.
Am I missing something here?
Not sure if this is an ide issue when I tried creating an uber jar. The jar also included a kotlin library. For this reason the ide was not able to locate the classes inside the jar. This was my gradle file for creating uber jar
ide not recognizing classes even if the jar was added to class path
but when I modified the gradle file with the following
The ide was able to identify the classes inside the jar.
ide recognizing classes if I remove kotlin library