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

Break the dependency between repositoriesTask and ivyDeps #4465

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexarchambault
Copy link
Collaborator

mill-scalablytyped (but possibly other plugins or user setups too) adds a dependency on repositoriesTask from ivyDeps. Since the introduction of JavaModule#coursierProject, Mill had a dependency the other way around, repositoriesTask depends on ivyDeps.

This creates a cycle, leading to StackOverflowException-s.

In order to work around that, this PR splits both repositoriesTask and defaultResolver, adding:

  • allRepositoriesTask: basically repositoriesTask, with the Mill internal repository added
  • internalResolver: same as defaultResolver, with the Mill internal repository added (via allRepositoriesTask)

If users need to resolve purely external modules (most common case it seems), they can keep using repositoriesTask or defaultResolver.

If they need to resolve some Mill internal modules (usually brought in via JavaModule#coursierDependency), they now need to use allRepositoriesTask and internalResolver instead of repositoriesTask and defaultResolver.

That way, no cycle is introduced when users only need to resolve external modules.

Fixes #4457

mill-scalablytyped (but possibly other plugins or user setups too) adds
a dependency on `repositoriesTask` from `ivyDeps`. Since the introduction
of `JavaModule#coursierProject`, Mill had a dependency the other way around,
`repositoriesTask` depends on `ivyDeps`.

This creates a cycle, leading to StackOverflowException-s.

In order to work around that, this PR splits both `repositoriesTask` and
`defaultResolver`, adding:
- `allRepositoriesTask`: basically `repositoriesTask`, with the Mill internal
  repository added
- `internalResolver`: same as `defaultResolver`, with the Mill internal
  repository added (via `allRepositoriesTask`)

If users need to resolve purely external modules (most common case it seems),
they can keep using `repositoriesTask` or `defaultResolver`.

If they need to resolve some Mill internal modules (usually brought in
via `JavaModule#coursierDependency`), they now need to use `allRepositoriesTask`
and `internalResolver` instead of `repositoriesTask` and `defaultResolver`.

That way, no cycle is introduced when users only need to resolve external
modules.

Fixes com-lihaoyi#4457
Comment on lines 107 to 119
// bin-compat shim
def resolveDeps(
deps: Task[Agg[BoundDep]],
sources: Boolean,
artifactTypes: Option[Set[Type]]
): Task[Agg[PathRef]] =
resolveDeps(
deps,
sources,
artifactTypes,
enableMillInternalDependencies = false
)

Copy link
Member

Choose a reason for hiding this comment

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

Do you meant to open this PR against 0.12.x branch. Otherwise the bin-compat shim isn't needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you meant to open this PR against 0.12.x branch?

I wish, but I couldn't find it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the shim to make the CI happy (seems it requires it), but it might not be needed, yes

Copy link
Member

Choose a reason for hiding this comment

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

Huh, I restored the branch, but it seems to be removed again. What's going on here?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I restored it again. @lolgab removed it this time. haha.

Copy link
Member

Choose a reason for hiding this comment

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

I think the big green Merge button removes branches sometimes. I know that's what happened when I removed it on that PR, not sure whether the same thing happened to @lolgab

Copy link
Member

Choose a reason for hiding this comment

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

I enabled the pr branch delete option in the project settings long time ago, as it is tedious to remove them manually. It's unusual to open a PR from some maintenance branch, that's why it got removed the first time and I restored it, once I recognized it. I think the second removal by @lolgab was in good intent to clean up after a merge. It's easy to overlook that the PR branch name is actually a maintenance branch. Fortunately, the restore feature worked. The 0.12.x branch should now be there again and ready as merge target.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I opened #4472 against the 0.12.x branch. Waiting for it to be merged before reporting its changes here.

*
* @return `CoursierModule.Resolver` instance
*/
def internalResolver: Task[CoursierModule.Resolver] = Task.Anon {
Copy link
Member

Choose a reason for hiding this comment

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

How about coursierModuleResolver. It's longish, but better tells what it is. Also, it's prefixed with the originating trait name, which make it easy to associate with.

Copy link
Member

Choose a reason for hiding this comment

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

Or internalModuleResolver, if you want to keep it close to internalRepositories.

Copy link
Collaborator Author

@alexarchambault alexarchambault Feb 4, 2025

Choose a reason for hiding this comment

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

I named it this way as it goes alongside defaultResolver. Maybe defaultResolver could be renamed. The one here is meant to be equivalent, but also handles Mill modules, hence the "internal".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure about coursierModuleResolver, as in Mill, "module" is associated with Mill modules, while the resolver resolves mainly external dependencies. coursierDependencyResolver or just dependencyResolver / depResolver might work too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed it to internalCoursierResolver here: #4472

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll report it here once the state of #4472 is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrading 0.12.5 -> 0.12.6 or 0.12.7 breaks the build with StackOverflowError
3 participants