Cycle detection in moduleDeps
and compileModuleDeps
#2790
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a squashed and rebased version of #2349. It depends on #2789 to properly report and exit Mill with a
MillException
.The problem: We currently don't detect cycles in transitive
moduleDeps
andcompileModuleDeps
. Cycles in these result in aStackOverflowError
.To solve this, we first need to detect cycles. This is the newly added
ModuleUtils.recursive
method. Instead ofmoduleDeps
we use themoduleDepsChecked
in some places to ensure we checked for cycles before accessing module dependencies.Unfortunately, we can't easily report the detected cycle at evaluation time, as
moduleDeps
needs to be evaluated before we can create a task graph (viaT.traverse
), hence we need an alternative way to propagate the exception. The current approach throws anBuildScriptException
which itself derives from the alsomill.api.MillException
(as part of PR #2789).In
MillMain
as well asMillClientMain
, our central entry points to Mill, we catch theMillException
and report the error to the user.Pull request: #2790