Skip to content
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

Make Target type abstract to allow overriding by different concrete implementations #2402

Merged
merged 18 commits into from
Apr 3, 2023
2 changes: 1 addition & 1 deletion example/web/4-webapp-scalajs/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object app extends RootModule with ScalaModule{
ivy"com.lihaoyi::scalatags:0.12.0"
)

def resources = T.sources{
def resources = T{
os.makeDir(T.dest / "webapp")
val jsPath = client.fastLinkJS().dest.path
// Move the main.js[.map] files into the proper filesystem position
Expand Down
2 changes: 1 addition & 1 deletion example/web/5-webapp-scalajs-shared/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object app extends RootModule with AppScalaModule{

def ivyDeps = Agg(ivy"com.lihaoyi::cask:0.9.0")

def resources = T.sources{
def resources = T{
os.makeDir(T.dest / "webapp")
val jsPath = client.fastLinkJS().dest.path
os.copy(jsPath / "main.js", T.dest / "webapp" / "main.js")
Expand Down
18 changes: 6 additions & 12 deletions main/core/src/mill/define/Discover.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,14 @@ object Discover {
cases: (Type, Int, String)*
): Unit = {
for (m <- methods.toList) {
for ((tt, n, label) <- cases) {
if (
m.returnType <:< tt &&
m.paramLists.length != n
) {
c.abort(
cases
.find{case (tt, n, label) => m.returnType <:< tt}
.foreach{case (tt, n, label) =>
if (m.paramLists.length != n) c.abort(
m.pos,
s"$label definitions must have $n parameter list" + (if (n == 1) "" else "s")
)
}
}
}
}
val mapping = for {
Expand All @@ -84,11 +81,8 @@ object Discover {
overridesRoutes = {
assertParamListCounts(
methods,
(weakTypeOf[mill.define.Sources], 0, "`T.sources`"),
(weakTypeOf[mill.define.Input[_]], 0, "`T.input`"),
(weakTypeOf[mill.define.Persistent[_]], 0, "`T.persistent`"),
(weakTypeOf[mill.define.Target[_]], 0, "`T{...}`"),
(weakTypeOf[mill.define.Command[_]], 1, "`T.command`")
(weakTypeOf[mill.define.Command[_]], 1, "`T.command`"),
(weakTypeOf[mill.define.Target[_]], 0, "Target"),
)

for {
Expand Down
Loading