Gradle does it's Scala compilation in a directory other than the project root (each worker process in Gradle runs in $GRADLE_HOME/workers). This causes the above error to occur.
Semanticdb compiler plugin gets around this by having a -Psourceroot plugin parameter that you specify. However, it's important that this parameter can also be specified relative to the output directory (aka scalac -d), which should already be available to the plugin through scalac's settings.
Longer explanation on above point. Gradle (like Bazel) supports task caching across machines. So that for larger projects, Gradle will download the compilation results (i.e. class and other files) from a remote cache, saving each users from having to do compilation themselves. For big projects this is a huge productivity gain. But for this to work, all the compiler flags have to exactly match between machines, otherwise Gradle can't be sure that the results are equivalent. This mostly works out great, but obviously breaks if you start sticking things like absolute paths in the compiler options (which are different between machines). And unfortunately you also can't make the sourceroot relative to the worker directory, because even that could be different between different machines.
So the only fixed point of reference you have to make it relative too is the scalac output directory. This itself will also be different across machines, but since it's set internally by Gradle/Zinc/Scalac rather than through a compiler option, it works out.
Gradle does it's Scala compilation in a directory other than the project root (each worker process in Gradle runs in
$GRADLE_HOME/workers). This causes the above error to occur.Semanticdb compiler plugin gets around this by having a
-Psourcerootplugin parameter that you specify. However, it's important that this parameter can also be specified relative to the output directory (akascalac -d), which should already be available to the plugin through scalac's settings.Longer explanation on above point. Gradle (like Bazel) supports task caching across machines. So that for larger projects, Gradle will download the compilation results (i.e. class and other files) from a remote cache, saving each users from having to do compilation themselves. For big projects this is a huge productivity gain. But for this to work, all the compiler flags have to exactly match between machines, otherwise Gradle can't be sure that the results are equivalent. This mostly works out great, but obviously breaks if you start sticking things like absolute paths in the compiler options (which are different between machines). And unfortunately you also can't make the
sourcerootrelative to the worker directory, because even that could be different between different machines.So the only fixed point of reference you have to make it relative too is the scalac output directory. This itself will also be different across machines, but since it's set internally by Gradle/Zinc/Scalac rather than through a compiler option, it works out.