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

Report when we could not detect the declaring parent of a target #2885

Merged
merged 7 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -109,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"
Expand Down Expand Up @@ -493,7 +495,12 @@ 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(
Expand Down Expand Up @@ -1417,15 +1424,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*/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hides any failures as dev.run will succeed.

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(())
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions main/eval/src/mill/eval/GroupEvaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -116,15 +123,16 @@ 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 of target ${namedTask}: $unknown")
}
}

val constructorHashes = allEnclosingModules
.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
Expand Down