Filip Piechowski
02/21/2022, 3:40 PMmain
, adapter
and port
, where port
I want to take advantage of kotlin internal
access modifier to hide adapter
declarations from port
.
This is my current buildscript:
plugins {
kotlin("jvm") version "1.6.10"
}
group = "hex"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
}
kotlin {
sourceSets {
val ports by creating {
}
val adapters by creating {
dependsOn(ports)
}
main.get().apply {
dependsOn(ports)
dependsOn(adapters)
}
}
}
After importing gradle project in intellij I see that it recognizes new sourcesets but internal declarations in adapter
are accessible from port
sources so it’s not treated as a module described here https://kotlinlang.org/docs/visibility-modifiers.html#modules
It looks like source sets are created in gradle model, but they are used by kotlin as one collective source set, at least that’s what i think is happening.
So i want to achieve a gradle build with one project (just root, no subprojects), one compilation, but 3 source sets (depending on each other as shown by dependsOn
s). What am I missing to get that working as I expect?ESchouten
02/21/2022, 4:42 PMJavier
02/21/2022, 5:11 PMtapchicoma
02/21/2022, 6:43 PMdependsOn
exists for multiplatform sourcesetsFilip Piechowski
02/21/2022, 8:52 PMFilip Piechowski
02/21/2022, 8:54 PMJavier
02/21/2022, 10:05 PMFilip Piechowski
02/21/2022, 11:07 PMkotlin { sourceSets { … } }
block. Turns out that source sets created that way aren’t recognized as modules by kotlin plugin. The correct way to do it is to create sourcesets in sourceSets { … }
which I believe come from the java plugin. It would be helpful if there was documentation explaining how exactly the kotlin gradle project model is structured because right now it’s misleading when we have SourceSet
and KotlinSourceSet
types and we don’t know the difference betweeen them