Issue with relative paths with maven init
Hi, i was trying ./mill init with mill 0.12.10 (and also a 0.13 version) on my multi module maven project (with wsl linux). I get the following stack trace
[1/1] init
[7/7] mill.init.InitMavenModule.init
[7] converting Maven build
[7] Exception in thread "main" os.PathError$InvalidSegment: [../backend-api] is not a valid path segment. [/] is not a valid character to appear in a non-literal path segment. If you are dealing with dynamic path-strings coming from external sources, use the Path(...)/RelPath(...)/SubPath(...) constructor calls to convert them.
[7] at os.BasePath$.fail$1(Path.scala:179)
[7] at os.BasePath$.checkSegment(Path.scala:186)
[7] at os.PathChunk$StringPathChunkInternal.<init>(Path.scala:70)
[7] at os.StringPathChunkConversion.stringToPathChunk(Path.scala:19)
[7] at os.StringPathChunkConversion.stringToPathChunk$(Path.scala:18)
[7] at os.PathChunk$.stringToPathChunk(Path.scala:22)
[7] at mill.main.maven.MavenBuildGenMain$.$anonfun$run$2(MavenBuildGenMain.scala:53)
[7] at scala.collection.immutable.List.map(List.scala:247)
[7] at scala.collection.immutable.List.map(List.scala:79)
[7] at os.PathChunk$SeqPathChunk.<init>(Path.scala:101)
[7] at os.PathChunk$.SeqPathChunk(Path.scala:95)
[7] at mill.main.maven.MavenBuildGenMain$.$anonfun$run$1(MavenBuildGenMain.scala:53)
[7] at mill.main.buildgen.Tree$.recurse$2(Tree.scala:36)
[7] at mill.main.buildgen.Tree$.$anonfun$from$1(Tree.scala:37)
[7] at scala.collection.Iterator$$anon$9.next(Iterator.scala:584)
[7] at scala.collection.immutable.List.prependedAll(List.scala:153)
[7] at scala.collection.immutable.List$.from(List.scala:685)
[7] at scala.collection.immutable.List$.from(List.scala:682)
[7] at scala.collection.SeqFactory$Delegate.from(Factory.scala:306)
[7] at scala.collection.immutable.Seq$.from(Seq.scala:42)
[7] at scala.collection.IterableOnceOps.toSeq(IterableOnce.scala:1473)
[7] at scala.collection.IterableOnceOps.toSeq$(IterableOnce.scala:1473)
[7] at scala.collection.AbstractIterator.toSeq(Iterator.scala:1306)
[7] at mill.main.buildgen.Tree$.recurse$2(Tree.scala:37)
[7] at mill.main.buildgen.Tree$.from(Tree.scala:40)
[7] at mill.main.maven.MavenBuildGenMain$.run(MavenBuildGenMain.scala:52)
[7] at mill.main.maven.MavenBuildGenMain$.main(MavenBuildGenMain.scala:44)
[7] at mill.main.maven.MavenBuildGenMain.main(MavenBuildGenMain.scala)
[1/1, 1 failed] ============================== init ============================== 10s
1 tasks failed
init java.lang.Exception: 1 tasks failed
As seen in the stack trace, it's a multi module build with modules defined like this in the parent module:
<modules>
<module>../backend-api</module>
</modules>
I hope this is an actual bug and not something that's not supposed to be supported, since I was just playing around. I haven't really looked around in the source yet since I am just learning scala.
Minimum Example: https://github.com/prog-r-amer/mill-multi-module-maven-issue
Thanks for the report @prog-r-amer! Will take a look
I think the issue here is that Mill assumes you have one top-level folder with a pom.xml that contains all sub-projects. It doesn't really support "sibling" projects which are related without a common parent. @prog-r-amer is there any "enclosing" Maven project you can use as the location of your ./imll init command?
They all inherit from the parent file anyway. So it's just a matter of moving out parent/pom.xml in the root. Gotta try it with the real project, but my little sample project works now.
Thanks :)
I also saw that pattern in the wild. You have your entry-project in a sub-dir. I think this is a tribute to Maven's inflexibility. If you have the root project in a sub-dir, you can have more than one to map different setups.
Just copying and adapting the <module entries seems to be the workaround for now. We could think of adding an option to specify the project root. But this is likely more complex, so I wouldn't bet on it. Probably depends on how many users hit this limitation and comment here.
Hi @lihaoyi
We observed the same issue during Mill migration. But our project is more complex. It has multiple sub-modules including one sub-module which is parent for some other Spring Boot sub-modules. So we have to use sibling paths in pom.xml of this parent project :
<modules>
<module>../service1</module>
<module>../service2</module>
</modules>
But we removed this configuration block and migration finished without errors.