EDIT: Found out what was wrong, srcDir will add a source directory, not set it.
It works as expected with:
main {
scala.setSrcDirs(['whatever'])
}
In my opinion srcDir
is a rather terrible name for that method, it should be called addSrcDir
.
The half second saved in typing add is lost a thousand times over by this kind of subtle ambiguity.
I would certainly deprecate srcDir
OIGINAL POST:
Changes made to sourceSets are not visible:
plugins {
id 'scala'
}
sourceSets {
main {
scala.srcDir 'whatever'
}
}
task debug << {
println(sourceSets.main.scala.getSrcDirs().iterator().next().absolutePath)
}
debug.dependsOn scaladoc
//why I need that info, not actually part of the issue:
scaladoc.scalaDocOptions.additionalParameters =
["-sourcepath "+sourceSets.main.scala.getSrcDirs().iterator().next().absolutePath,
"-doc-source-url https://github.com/acdenhartog/Rakka/tree/master/scala-rakka/src/\u20AC{FILE_PATH}.scala"]
running debug will print:
C:\...\MyProject\src\main\scala
but it should print:
C:\...\MyProject\whatever
What is causing this? Is sourceSets not part of the initialization phase?
Is source sourceSets not a local variable, i.e. is srcDir ‘whatever’ not modifying sourceSets
itself but rather some other local object?
In any case, I am filing this as a bug because it does not seem like expected behavior.