I have a mixed kotlin/java multi-module project that uses src/main/java for
the java code and src/main/kotlin for kotlin code.

For the java-only projects, everything is fine. sourceDirectory points to
src/main/java, testSourceDirectory points to src/test/java.

We activate a specific profile that turns on the kotlin compiler if
src/main/kotlin is present. For modules that have both kotlin and java
code, this works fine as well. We add src/main/kotlin to the source roots
and src/test/kotlin to the test roots (using the build-helper plugin).

However, for kotlin-only projects (where no src/main/java and src/test/java
exists), we get a build warning:  "Source root doesn't exist:
.../src/main/java" (e.g. from the kotlin compiler).

As we activate the compiler from a profile, we can not set the initial
sourceDirectory or testSourceDirectory (overriding those values is not
supported in a profile).

Is there a way to clear the list of source roots in the maven project? I
looked into the code and what the build helper does and tried using
project.getCompileSourceRoots().clear() which works only partially.

Is there an official way to clear / set the list of compileSourceRoots and
testSourceRoots from a plugin that can be used from a profile?

-h

Reply via email to