-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mill cannot handle forward slash in crossValue #2835
Comments
I don't think allowing a cross-value to open up multiple sub-paths is the right solution. We already map Here is my counter example, in which both cross module instances whould use the same import mill._
object foo extends Cross[Foo](("a", "b/c"), ("a/b", "c"))
trait Foo extends Cross.Module2[String, String] {
...
} Instead, we could encode the special |
Fair point, and thanks for the counter example.
I think this also highlights that maybe there are two asks here:
EDIT: my above proposal for implicit object RelPathToPathSegment extends mill.define.Cross.ToSegments[os.RelPath](
p => p.segments.init.map(_ + "$") ++: List(p.segments.last)
)
object fizz extends Cross[Fizz]((os.RelPath("a/b"), os.RelPath("c/d/e")), (os.RelPath("a/b/c"), os.RelPath("d/e")))
trait Fizz extends Cross.Module2[os.RelPath, os.RelPath] $ mill resolve fizz._
fizz[a$,b$,c,d$,e]
fizz[a$,b,c$,d$,e] |
FWIW, I'm able to deal with this in my own code with: implicit object RelPathToPathSegment extends mill.define.Cross.ToSegments[os.RelPath](_.segments.toList) |
I strongly suggest to use |
I didn't realize |
I think it should be ok to add a Since we can't give strong guarantees here anyway, might as well make it a bit more convenient in some common use cases |
Aside the strong guarantees, we at least assume uniqueness, right? Otherwise, we should implement collision detection when calculating metadata destination paths. |
I think collision detection is necessary anyway. You can construct a collision already with object buzz extends Cross[Buzz](Seq((Seq("a", "b"), Seq("c")), (Seq("a"), Seq("b", "c"))))
trait Buzz extends Cross.Module2[Seq[String], Seq[String]] {
def func = T { T.dest }
} $ mill resolve buzz._
buzz[a,b,c] |
What is this? Since when does this work? I'm surprised and think, this wasn't even possible in Mill 0.10 / 0.9. |
I'm using mill 0.11.5, you can also show the same thing with object buzz extends Cross[Buzz](Seq(Seq(Seq("a", "b"), Seq("c")), Seq(Seq("a"), Seq("b", "c"))))
trait Buzz extends Cross.Module[Seq[Seq[String]]] {
def func = T { T.dest }
} |
I guess, this is due to the |
Before 0.11.0, we basically only allowed One option we could go with is to allow primitives and As a compromise, we could add a TBH I think just doing runtime enforcement is good enough. "runtime" here is before tasks actually run, so it should give pretty quick feedback anyway, and we can make sure the error is good. No need to be too stuck to compile-time validation when in this case we will always need runtime checks anyway: having the keys defined at runtime is virtually the raison detre of cross modules in the first place! |
@lihaoyi Yeah, I also think runtime-checks are good enough. We known all effective cross instances and their segments, so it's pretty easy and fast to check for collisions. @jackkoenig wrote:
Disregarding how many ways exists to configure the build to end up with the same resolved target name, we only need to make sure they don't collide. We only need a collision free mapping from a parseable string-representation (given at the CLI) to a cross instance, however it is constructed in the code. It's not relevant, if we could refactor the code but end up with the same target name. It might even a feature, as it allows to grow a build over time without adapting the surrounding knowlegde and tooling, as long as it fits. Adding a |
With PR #2984, we closed this issue, as discussed. Please be aware, that the initial use case (a cross value as string containing a forward slash) is still not supported. |
I opened #2986 to make slashes in |
Thanks for solving this @lefou! |
I am using mill version
0.11.5
.My main goal is handling a nested hierarchy of files with Dynamic Cross Modules, but I am running into issues where attempting to use relative paths as cross values causes mill to error out.
Consider the following:
Mill will happily build these cross modules:
But when you try to do Tasks that cache to disk, I think Mill is hitting an internal error due to the
/
:If I had to guess, I would guess that
mill/main/eval/src/mill/eval/EvaluatorPaths.scala
Line 31 in 1cd494b
Seq[String]
to aos.RelPath
.The text was updated successfully, but these errors were encountered: