bjonnh
03/16/2021, 2:11 PMtapchicoma
03/16/2021, 2:39 PM1.5.0-M2
releasebjonnh
03/16/2021, 2:40 PMtapchicoma
03/16/2021, 2:41 PMbjonnh
03/16/2021, 3:01 PMbjonnh
03/16/2021, 3:02 PMtapchicoma
03/16/2021, 3:14 PMI think we (or just I) may want to document how to make modular programs with Kotlin, many of the tricks are not limited to Kotlin but I'm sure that would be helpful.Would be nice 👍 If you will found something is missing in Kotlin for better modules support - please open a new issue.
Javier
03/16/2021, 3:25 PMJavier
03/16/2021, 3:25 PMtapchicoma
03/16/2021, 3:32 PMbjonnh
03/16/2021, 3:43 PMbjonnh
03/16/2021, 3:43 PMbjonnh
03/16/2021, 3:43 PMbjonnh
03/16/2021, 3:44 PMJavier
03/16/2021, 3:45 PMJavier
03/16/2021, 3:45 PMbjonnh
03/16/2021, 3:45 PMJavier
03/16/2021, 3:45 PMbjonnh
03/16/2021, 3:46 PMbjonnh
03/16/2021, 3:46 PMbjonnh
03/16/2021, 3:48 PMVampire
03/16/2021, 4:01 PMThe other thing I need to do all the time with modular builds is to put the kotlin and java destination dirs to the same one. If not, I have to declare all the packages manually in java using empty classes…You should not do that. Tasks should not have overlapping outputs or you f*** up proper up-to-date checks and build output caching. "Just" patch your Kotlin output directory into the java compilation task using
--patch-module
Something like this should do it properly I think:
tasks.compileJava {
options.compilerArgumentProviders.add(
object : CommandLineArgumentProvider {
@get:Optional
@get:Classpath
protected val compileKotlinOutputClasses =
tasks.compileKotlin.flatMap { it.destinationDirectory }
override fun asArguments() = listOf(
"--patch-module",
"my.foo=${tasks.compileKotlin.get().destinationDir.absolutePath}"
)
}
)
}
tapchicoma
03/16/2021, 4:02 PM--patch-modules
is not exposed as compileJava task input?Vampire
03/16/2021, 4:02 PMmy.foo
is the module you are trying to buildVampire
03/16/2021, 4:03 PMtapchicoma
03/16/2021, 4:05 PMbjonnh
03/16/2021, 4:19 PMVampire
03/16/2021, 4:19 PMbjonnh
03/16/2021, 4:20 PMVampire
03/16/2021, 4:20 PMVampire
03/16/2021, 4:20 PMVampire
03/16/2021, 4:21 PMbjonnh
03/16/2021, 4:21 PMVampire
03/16/2021, 4:21 PMbjonnh
03/16/2021, 4:21 PMVampire
03/16/2021, 4:23 PMVampire
03/16/2021, 4:24 PMVampire
03/16/2021, 4:24 PMbjonnh
03/16/2021, 4:25 PMbjonnh
03/16/2021, 4:27 PMbjonnh
03/16/2021, 4:29 PM