Le sam. 2 sept. 2023 à 08:16, Henning Schmiedehausen <
henn...@schmiedehausen.org> a écrit :

> 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).
>

Why is the kotlin compiler given a pointer to a java source root ?
The java compiler has a property compileSourceRoots which defaults to the
project.compileSourceRoots but that can be overridden in such cases.
It seems the kotlin-maven-plugin has a sourceDirs property which you could
set to only the kotlin one.


>
> 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).
>

Have you tried setting those values with properties and override the
properties in the 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.
>

Why 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?
>

Not sure about that... ;-)


>
> -h
>


-- 
------------------------
Guillaume Nodet

Reply via email to