mill
mill copied to clipboard
In Mill 0.11, importing multiple projects with same filename leads to ambiguous import
We(the Chisel guys) are using Scala for building projects from sources. However when we imports multiple file, e.g:
import $file.someproject.common
import $file.anotherproject.common
These two common becomes ambiguous:
reference to common is ambiguous;
[error] it is imported twice in the same scope by
[error] import millbuild.someproject.common
[error] and import millbuild.anotherproject.common
Thanks to #2377, I'm able to see what happens, multiple common
objects are defined as below:
package millbuild.someproject
object common extends common
class common extends _root_.mill.main.RootModule.Foreign(Some(_root_.mill.define.Segments.labels("foreign-modules", "someproject", "common")))
and
package millbuild.anotherproject
object common extends common
class common extends _root_.mill.main.RootModule.Foreign(Some(_root_.mill.define.Segments.labels("foreign-modules", "anotherproject", "common")))
These two are different object under different namespaces, but when using it from the main build script needs to workaround by using millbuild.someproject.common.SomeBuildModule
, millbuild.anotherproject.common.AnotherBuildModule
.
This is expected Scala behavior. The solution is to rename at least n-1 ambiguous imports to disambiguate them.
import $file.someproject.{common => some}
import $file.anotherproject.{common => another}
I tried this, however this seems not working.