From 4eb8358b783757b39c8997ddd6a8251927a90ab9 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 09:54:18 +0100 Subject: [PATCH 1/7] Report when we could not detect the declaring parent of a target --- build.sc | 4 +++- main/eval/src/mill/eval/GroupEvaluator.scala | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.sc b/build.sc index ff931aaad79..25112473f39 100644 --- a/build.sc +++ b/build.sc @@ -31,6 +31,7 @@ object Settings { val githubRepo = "mill" val projectUrl = s"https://github.com/${githubOrg}/${githubRepo}" val changelogUrl = s"${projectUrl}#changelog" + val newIssueUrl = s"${projectUrl}/issues/new/choose" val docUrl = "https://mill-build.com" // the exact branches containing a doc root val docBranches = Seq() @@ -493,7 +494,8 @@ object main extends MillStableScalaModule with BuildInfo { def buildInfoPackageName = "mill.api" def buildInfoMembers = Seq( BuildInfo.Value("millVersion", millVersion(), "Mill version."), - BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url.") + BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url."), + BuildInfo.Value("millReportNewIssueUrl", Settings.newIssueUrl, "URL to create a new issue in Mills issue tracker.") ) def ivyDeps = Agg( diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index f2f5f10f9ad..2dad8ededed 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -101,7 +101,14 @@ private[mill] trait GroupEvaluator { if decode(m.getName) == namedTask.ctx.segment.pathSegments.head } yield m - val methodClass = methods.head.getDeclaringClass.getName + val methodClass = methods + .headOption + .getOrElse(throw new MillException( + s"Could not detect the parent class of target ${namedTask}. " + + s"Please report this at ${BuildInfo.millReportNewIssueUrl}. " + + s"As a workaround, you can run Mill with `--disable-callgraph-invalidation` option." + )) + .getDeclaringClass.getName val name = namedTask.ctx.segment.pathSegments.last val expectedName = methodClass + "#" + name + "()mill.define.Target" @@ -116,7 +123,7 @@ private[mill] trait GroupEvaluator { ctx.enclosingModule match { case null => None case m: mill.define.Module => Some((m, m.millOuterCtx)) - case unknown => sys.error(s"Unknown ctx: $unknown") + case unknown => throw new MillException(s"Unknown ctx: $unknown") } } @@ -124,7 +131,7 @@ private[mill] trait GroupEvaluator { .map(m => constructorHashSignatures.get(m.getClass.getName) match { case Some(Seq((singleMethod, hash))) => hash - case Some(multiple) => sys.error( + case Some(multiple) => throw new MillException( s"Multiple constructors found for module $m: ${multiple.mkString(",")}" ) case None => 0 From fe599626fd61cc8b6021d57061a403c3a25ed82f Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 10:15:26 +0100 Subject: [PATCH 2/7] Don't swallow failed mill runs in `dev.run` --- build.sc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sc b/build.sc index 25112473f39..420f3a78367 100644 --- a/build.sc +++ b/build.sc @@ -1419,15 +1419,17 @@ object dev extends MillPublishScalaModule { case wd0 +: rest => val wd = os.Path(wd0, T.workspace) os.makeDir.all(wd) - try Jvm.runSubprocess( + try { + Jvm.runSubprocess( Seq(launcher().path.toString) ++ rest, forkEnv(), workingDir = wd ) - catch { - case e: Throwable => () /*ignore to avoid confusing stacktrace and error messages*/ + mill.api.Result.Success(()) + } catch { + case e: Throwable => + mill.api.Result.Failure(s"dev.run failed with an exception. ${e.getMessage()}") } - mill.api.Result.Success(()) } } } From 1c9432885e94beeeffbc90f223ce30a46a1a19b3 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 10:15:47 +0100 Subject: [PATCH 3/7] scalafmt --- build.sc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.sc b/build.sc index 420f3a78367..3372a9005d5 100644 --- a/build.sc +++ b/build.sc @@ -110,7 +110,8 @@ object Deps { object Play_3_0 extends Play { val playVersion = "3.0.0" } - val play = Seq(Play_3_0, Play_2_9, Play_2_8, Play_2_7, Play_2_6).map(p => (p.playBinVersion, p)).toMap + val play = + Seq(Play_3_0, Play_2_9, Play_2_8, Play_2_7, Play_2_6).map(p => (p.playBinVersion, p)).toMap val acyclic = ivy"com.lihaoyi:::acyclic:0.3.9" val ammoniteVersion = "3.0.0-M0-53-084f7f4e" @@ -495,7 +496,11 @@ object main extends MillStableScalaModule with BuildInfo { def buildInfoMembers = Seq( BuildInfo.Value("millVersion", millVersion(), "Mill version."), BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url."), - BuildInfo.Value("millReportNewIssueUrl", Settings.newIssueUrl, "URL to create a new issue in Mills issue tracker.") + BuildInfo.Value( + "millReportNewIssueUrl", + Settings.newIssueUrl, + "URL to create a new issue in Mills issue tracker." + ) ) def ivyDeps = Agg( From 4a54680c72aef8c44e9709684235f2273925819c Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 10:19:29 +0100 Subject: [PATCH 4/7] . --- main/eval/src/mill/eval/GroupEvaluator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index 2dad8ededed..09d6b808884 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -105,7 +105,7 @@ private[mill] trait GroupEvaluator { .headOption .getOrElse(throw new MillException( s"Could not detect the parent class of target ${namedTask}. " + - s"Please report this at ${BuildInfo.millReportNewIssueUrl}. " + + s"Please report this at ${BuildInfo.millReportNewIssueUrl} " + s"As a workaround, you can run Mill with `--disable-callgraph-invalidation` option." )) .getDeclaringClass.getName From 4d22b60c1e981c1ac88476d9a1bd120cc50b36f1 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 10:20:15 +0100 Subject: [PATCH 5/7] . --- main/eval/src/mill/eval/GroupEvaluator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index 09d6b808884..3dde95e184f 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -105,7 +105,7 @@ private[mill] trait GroupEvaluator { .headOption .getOrElse(throw new MillException( s"Could not detect the parent class of target ${namedTask}. " + - s"Please report this at ${BuildInfo.millReportNewIssueUrl} " + + s"Please report this at ${BuildInfo.millReportNewIssueUrl} . " + s"As a workaround, you can run Mill with `--disable-callgraph-invalidation` option." )) .getDeclaringClass.getName From 74f8328c46be61743a41b0eb144da20e6f9596e8 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 10:27:29 +0100 Subject: [PATCH 6/7] Enhance an unrelated error message with the target name --- main/eval/src/mill/eval/GroupEvaluator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index 3dde95e184f..3cb91f0a637 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -123,7 +123,7 @@ private[mill] trait GroupEvaluator { ctx.enclosingModule match { case null => None case m: mill.define.Module => Some((m, m.millOuterCtx)) - case unknown => throw new MillException(s"Unknown ctx: $unknown") + case unknown => throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown") } } From a8a488272ae9e644961da046851a5ba18a401f21 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sun, 19 Nov 2023 11:16:09 +0100 Subject: [PATCH 7/7] scalafmt --- main/eval/src/mill/eval/GroupEvaluator.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index 3cb91f0a637..cd1641ee2e8 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -123,7 +123,8 @@ private[mill] trait GroupEvaluator { ctx.enclosingModule match { case null => None case m: mill.define.Module => Some((m, m.millOuterCtx)) - case unknown => throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown") + case unknown => + throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown") } }