so I have a Kotlin project using Gradle 6.2 with the Kotlin DSL. I want to add a second sourceset
main2 and than use the
internal
modifier to mutually hide classes inbetween
main and
main2. So this is the expected folder structure:
src/main/kotlin
src/main2/kotlin
src/test/kotlin
I've come pretty far by add this to my
build.gradle.kts
sourceSets {
val mainSourceSet: SourceSet = sourceSets["main"]
val testSourceSet: SourceSet = sourceSets["test"]
val main2SourceSet: SourceSet = create("main2") {
compileClasspath += mainSourceSet.output
runtimeClasspath += mainSourceSet.output
}
mainSourceSet.compileClasspath += main2SourceSet.output
mainSourceSet.runtimeClasspath += main2SourceSet.output
testSourceSet.compileClasspath += main2SourceSet.output
testSourceSet.runtimeClasspath += main2SourceSet.output
}
now
• code in
main can see all the public classes from
main2 but not the internal ones
• code in
main2 can see all the public classes from
main but not the internal ones
• code in
test can see all the public and internal classes from
main
• code in
test can only see the public classes from
main2
How do I make the internal classes from
main2 accessible to
test?