Generated sources not being marked as `true` when using Bloop contrib.
When using Mill as a build server the response to buildTarget/sources doesn't correctly mark generated sources as such. For example when using build info you'll notice that generated is false. You can see this for example in Scalatags.
{
"target": {
"uri": "file:/Users/ckipp/Documents/scala-workspace/com-lihaoyi/scalatags/scalatags/jvm/?id\u003dscalatags.jvm[3.1.3].test"
},
"sources": [
{
"uri": "file:///Users/ckipp/Documents/scala-workspace/com-lihaoyi/scalatags/scalatags/jvm/test/src/",
"kind": 2,
"generated": false
},
{
"uri": "file:///Users/ckipp/Documents/scala-workspace/com-lihaoyi/scalatags/scalatags/test/src/",
"kind": 2,
"generated": false
},
....
{
"uri": "file:///Users/ckipp/Documents/scala-workspace/com-lihaoyi/scalatags/out/scalatags/jvm/3.1.3/test/generatedBuildInfo.dest/",
"kind": 2,
"generated": false
}
]
}
In this situation the generatedBuildInfo.dest should be marked as true for generated.
Refs: https://github.com/scalameta/metals/issues/4787
I actually don't get why this is happening since this looks correct when you look at the generatedSources:
❯ mill showNamed scalatags.jvm\[3.1.3\].test.generatedSources
[1/1] showNamed
{
"scalatags.jvm[3.1.3].test.generatedSources": [
"ref:7d898225:/Users/ckipp/Documents/scala-workspace/com-lihaoyi/scalatags/out/scalatags/jvm/3.1.3/test/generatedBuildInfo.dest"
]
}
Plus this looks right as well.
https://github.com/com-lihaoyi/mill/blob/9004ff8f923f43f40a33b3998857c7dbe4147769/bsp/src/mill/bsp/MillBuildServer.scala#L361-L366
I just checked, both, the source code and the log of the BSP protocol suggests, we properly mark JavaModule.generatedSources with SourceItem.generated = true.
The generatedBuildInfo target comes from the BuildInfo contrib plugin, so this is probably specific to that plugin. Although, a first look shows, it is also extending JavaModule.generatedSources, so it should work as expected.
Ah shoot, I was still on Bloop instead of mill-bsp. Ugh, sorry. So this is actually an issue then probably with the Bloop export.
Actually looking further I don't even see how to do this with the Bloop export. I wonder if this just isn't possible? I'll check. Don't spend time on this @lefou I'll either fix it or close it.
Alright... digging even further. I think the only way we can do this with Bloop would be to utilize sourceGenerators. However looking at https://github.com/scalacenter/bloop/pull/1774 it's not super clear to me how this is meant to work with a tool like Mill. Would the command just be a mill command to regenerate? That might be hard to configure correctly.
Yeah, when I first looked into the sourceGenerators thing, I also thought, that it will not match easily with build tools, it's more suited when you use bloop as your primary tool.