setting the classes output dir for kotlin doesn’t ...
# gradle
m
setting the classes output dir for kotlin doesn’t seem to work (using
gradle-4.1
)
Copy code
sourceSets.main.output.classesDir =  new File(buildDir, “classes/main”)
sourceSets.main.kotlin.outputDir =  new File(buildDir, “classes/main”)
h
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
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
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
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.