tindzk / seed

Build tool for Scala projects
https://tindzk.github.io/seed/
Apache License 2.0
237 stars 13 forks source link

Crash on transitively duplicate moduleDeps in 0.1.5 #47

Closed nafg closed 5 years ago

nafg commented 5 years ago
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed
    at scala.Predef$.require(Predef.scala:268)
    at seed.artefact.ArtefactResolution$.resolveScalaCompiler(ArtefactResolution.scala:246)
    at seed.generation.Bloop$.$anonfun$writeJsModule$1(Bloop.scala:197)
    at seed.generation.Bloop$.$anonfun$writeJsModule$1$adapted(Bloop.scala:148)
    at scala.Option.foreach(Option.scala:274)
    at seed.generation.Bloop$.writeJsModule(Bloop.scala:148)
    at seed.generation.Bloop$.buildModule(Bloop.scala:474)
    at seed.generation.Bloop$.$anonfun$build$2(Bloop.scala:621)
    at seed.generation.Bloop$.$anonfun$build$2$adapted(Bloop.scala:607)
    at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:234)
    at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:465)
    at seed.generation.Bloop$.build(Bloop.scala:607)
    at seed.cli.Generate$.ui(Generate.scala:56)
    at seed.Cli$.main(Cli.scala:300)
    at seed.Cli.main(Cli.scala)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at coursier.bootstrap.launcher.a.a(Unknown Source)
    at coursier.bootstrap.launcher.Launcher.main(Unknown Source)
nafg commented 5 years ago

Apparently the cause was a moduleDeps that included two modules one of which transitively depends on the other, making including that one redundant.

nafg commented 5 years ago

This can be more of an issue when there is a dependency diamond. If A depends on B and C which both depend on D, then D will be a transitive dependency twice.

tindzk commented 5 years ago

Thanks for the bug report! Could you provide a minimal build file to reproduce the issue?

I tried the following, but it does not throw the exception you have seen:

[project]
scalaVersion   = "2.13.0"
scalaJsVersion = "0.6.28"

[module.a.js]
moduleDeps = ["b", "c"]
sources    = ["a/"]

[module.b.js]
moduleDeps = ["d"]
sources    = ["b/"]

[module.c.js]
moduleDeps = ["d"]
sources    = ["c/"]

[module.d.js]
sources   = ["d/"]
scalaDeps = [
  ["org.scala-js", "scalajs-dom", "0.9.7"]
]
nafg commented 5 years ago

I haven't minimized it but here is the TOML version of my build: https://gist.github.com/nafg/bcad12fab7a9e4a858e04b8a6349961b

tindzk commented 5 years ago

Thanks. I managed to minimise it:

[project]
scalaVersion = "2.12.8"

[module.shared]
sources = ["shared/"]
targets = ["jvm"]

[module.a]
sources = ["a/"]
targets = ["jvm"]
moduleDeps = ["shared"]

[module.b]
sources = ["b/"]
targets = ["jvm"]
moduleDeps = ["shared"]

[module.root]
sources = ["root/"]
targets = ["jvm"]
moduleDeps = ["a", "b"]