mill
mill copied to clipboard
Main method is not runnable with `mill-bsp` and Scala 2 from Metals
If you have code like this:
object Main {
def main(args: Array[String]): Unit = {
println("Hello world!")
}
}
Code lenses that allow running this appear in Metals if you're using Scala 3.
But does not if you're using Scala 2.13.16:
The BSP trace shows the main classes:
[Trace - 11:54:04 AM] Received response 'buildTarget/scalaMainClasses - (8)' in 67ms
Result: {
"items": [
{
"target": {
"uri": "file:///home/arturaz/work/mill-resources-test/foo"
},
"classes": [
{
"class": "Main",
"arguments": [],
"jvmOptions": [],
"environmentVariables": [
"DOGGIES\u003dmain"
]
}
]
},
{
"target": {
"uri": "file:///home/arturaz/work/mill-resources-test/foo/test"
},
"classes": [
{
"class": "TestMain",
"arguments": [],
"jvmOptions": [],
"environmentVariables": [
"OTHER_FILES_DIR\u003d/home/arturaz/work/mill-resources-test/foo/test/other-files",
"DOGGIES\u003dtests"
]
}
]
},
{
"target": {
"uri": "file:///home/arturaz/work/mill-resources-test/mill-build"
},
"classes": []
}
]
}
Error: null
Reproduction case: https://github.com/arturaz/mill-issue-repro-5230
Tagging as upstream for now.
@arturaz Could you re-test with Mill 1.0.0-RC1 again?
Also, your repro project is on Mill 0.12.14 but the screenshot of Metals Doctor shows some 1.0.0-M1-xxx version. Is this issue present in both Mill versions?
Not sure about Scala 2, but it seems to work in Scala 3, so will close this