https://kotlinlang.org logo
Title
m

masc3d

09/07/2017, 4:19 PM
setting the classes output dir for kotlin doesn’t seem to work (using
gradle-4.1
)
sourceSets.main.output.classesDir =  new File(buildDir, “classes/main”)
sourceSets.main.kotlin.outputDir =  new File(buildDir, “classes/main”)
h

h0tk3y

09/07/2017, 4:46 PM
First, using a single classes directory (setting
sourceSets.main.output.classesDir
) is considered deprecated since Gradle 4.0, the builds should support separate classes directories for the JVM languages (the file collection is
sourceSets.main.output.classesDirs
). As to the destination directory that Kotlin uses, you can set it with
compileKotlin.destinationDir = ...
. Though the fact that
sourceSets.main.kotlin.outputDir = ...
doesn't work seems to be a bug, I'll check it.
m

masc3d

09/07/2017, 4:57 PM
yes, but
classesDirs
is immutable afaik, I
I would prefer to just use the defaults with IJ gradle delegation, but this is broken on windows, so I have to revert to unifying class output dirs for JVM languages + IJ as a last resort.
h

h0tk3y

09/07/2017, 5:00 PM
With the Kotlin 1.1.4-3 plugin, you can make Kotlin fall back to unified classes directories by adding
kotlin.copyClassesToJavaOutput = true
to your build script (https://youtrack.jetbrains.com/issue/KT-19774), this will make
sourceSets.main.output.classesDir =  new File(buildDir, "classes/main")
work.
m

masc3d

09/07/2017, 5:43 PM
great! you actually saved the day. many thanks
there’s new kind of breakage with
gradle-4.2
,
kotlin.copyClassesToJavaOutput
will not work when the project doesn’t contain java classes at all.