I have two gradle projects (call them A and B) in different git repos.
A uses B, i.e we have a dependency
//build.gradle.kts of Project A
...
dependencies {
implementation("com.example.B:1.0-SNAPSHOT")
}
...
Both Projects are kotlin-based. So the rest of the build.gradle is the same for both projects:
// common parts of build.gradle.kts of A and B
plugins {
kotlin("jvm") version "1.9.23"
`maven-publish`
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
//-> Only for B: implementation("com.example:B:1.0.1-SNAPSHOT")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
// Publishing configuration
publishing {
publications {
// Create a Maven publication named "mavenJava"
create<MavenPublication>("mavenJava") {
// Publish the Java component of the project
from(components["java"])
}
}
// Configure repositories for publishing
repositories {
mavenLocal() // Publish to local Maven repository
}
}
I have also added both projects to the same IntelliJ Window, meaning that i use the little plus-sign in the gradle toolbar at the right (“Link Gradle Project”).
I can start gradle tasks for both, that is fine so far.
But IntelliJ seems to miss that B is also loaded. When I start in a class from A and navigate into the sourcecode of B (using ctrl+click on the classname), I get a decompiled version of the classfile (that was loaded from mavenLocal()
). I would expect it to jump into the sources that are loaded.
As far as I understand IntelliJ Documentation, that should work. It should detect the link and resolve the library dependency with the module sourcecode from the current workspace and not with the binaries/jar from mavenLocal. That feature was known in in maven as “workspace resolution” and I wonder why it is broken for my setup (minimal example).
Does that have to do with my setup (is it broken for kotlin or gradle?) or did I miss anyting?
Currently using IntelliJ Idea 2024.1