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

Deprecate resolveFilter stuff #4162

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

alexarchambault
Copy link
Collaborator

@alexarchambault alexarchambault commented Dec 18, 2024

This PR makes Mill stop relying on the resolveFilter parameter of CoursierSupport#resolveDependencies.

This parameter manually filters the artifacts provided by coursier, but not the ones originating from "local dependencies" (Mill's hack to use freshly built workers and plugins during tests), where it seems such a filtering was done in the build (by customizing testDepPaths). "Local dependencies" cannot be kept as-is in #4145 (where such dependencies aren't necessarily root dependencies anymore, making it harder to handle them in a different fashion). Hence the need to stop using resolveFilter.

Rather than filtering artifacts after dependency resolution, this PR marks unwanted dependencies of workers as compile-time only. That way, they're not pulled by dependency resolution, and we don't need to manually filter artifacts.

So that we don't need to resort to "resolveFilter" stuff to keep
only their main JAR
@alexarchambault
Copy link
Collaborator Author

The CI errors seem unrelated to these changes (I can't reproduce them locally)

@lihaoyi
Copy link
Member

lihaoyi commented Dec 18, 2024

Yes we've been seeing flakiness in ci, i'll rerun them

alexarchambault added a commit to alexarchambault/mill that referenced this pull request Dec 18, 2024
alexarchambault added a commit to alexarchambault/mill that referenced this pull request Dec 18, 2024
alexarchambault added a commit to alexarchambault/mill that referenced this pull request Dec 18, 2024
@alexarchambault alexarchambault marked this pull request as draft January 7, 2025 22:45
@alexarchambault alexarchambault marked this pull request as ready for review January 7, 2025 22:50
@alexarchambault
Copy link
Collaborator Author

@lihaoyi @lefou Can any of you re-run the Run Tests / linux (11, '{scalajslib,scalanativelib,kotlinlib,pythonlib,javascriptlib}.__.test', false) job? It seems the error is unrelated to these changes and is a flake.

Also, I'm about to undraft the 3 other PRs that depend on this one (that actually depend on each other successively). Namely #4145, #4154, and #4155. Each adds something to the previous one. #4145 should be the one with the most important changes: it changes the way Mill interfaces with coursier basically, which impacts many other Mill parts.

The PR here should be the most straightforward to review I guess.

The other two are what motivated the first two: they consist in BOM-related changes.

If you'd like me to… split them further to ease review, or re-open them with a cleaner git history to spot more easily what each adds to the previous ones, just tell me.

@lihaoyi
Copy link
Member

lihaoyi commented Jan 9, 2025

@alexarchambault kicked the jobs, also gave you write access to the repo so you can do this yourself as necessary in future

@lihaoyi
Copy link
Member

lihaoyi commented Jan 9, 2025

I've been holding off taking a look at these PRs since it looked like they were still in flux; should we look at all of them? Or just this one first?

@alexarchambault
Copy link
Collaborator Author

alexarchambault commented Jan 9, 2025

I've been holding off taking a look at these PRs since it looked like they were still in flux; should we look at all of them? Or just this one first?

As you wish, I'd say. One after the other should be easier (once the first is merged, the second one, etc.), keeping in mind that the first two are not just nice-to-have refactorings / clean-ups, but are motivated by the other two, that they make easier to implement (first one is actually motivated by the second one, itself motivated by the other two).

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

I can't spot a single @deprecated anywhere. Shouldn't we provide some API that is free of deprecated stuff and have a message to an deprecated API user?

The change itself makes sense to me. But due to the informal deprecation, it'S rather hard to spot, where (else) we still rely on the filtering.

@alexarchambault
Copy link
Collaborator Author

I can't spot a single @deprecated anywhere. Shouldn't we provide some API that is free of deprecated stuff and have a message to an deprecated API user?

I was hesitating about this. Managing deprecations while removing a parameter is more of a burden than when adding one. Basically, in a signature like

def resolveDependencies(
    repositories: Seq[Repository],
    deps: IterableOnce[Dependency],
    force: IterableOnce[Dependency],
    sources: Boolean = false,
    mapDependencies: Option[Dependency => Dependency] = None,
    customizer: Option[Resolution => Resolution] = None,
    ctx: Option[mill.api.Ctx.Log] = None,
    coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
    resolveFilter: os.Path => Boolean = _ => true,
    artifactTypes: Option[Set[Type]] = None,
    resolutionParams: ResolutionParams = ResolutionParams()
  ): Result[Agg[PathRef]]

we'd like to deprecate resolveFilter, while not breaking bin compat. Apparently, adding a @deprecated annotation to the parameter only deprecates its use in the method body, not its use when users call the method.

We can always remove the parameter, and add a shim of the former method with no default params for bin compat, but that means current users of the parameter are very likely to experience compilation errors when bumping Mill (if they rely on a default parameter), while deprecations usually only create a warning.

That said, I'm not too opiniated about doing this or what's currently in the PR (renaming of the parameter), it seems both have caveats.

@lefou
Copy link
Member

lefou commented Jan 9, 2025

I see. You mean, the synthetic providers for the default values may change in an binary incompatible way. It's a real pita, that this is still an issue in Scala.

@lefou
Copy link
Member

lefou commented Jan 9, 2025

But if the @deprecated annotation on the parameter doesn't hurt and is even recognized in the body, we should add it with actionable comment.

@lihaoyi
Copy link
Member

lihaoyi commented Jan 10, 2025

I've been trying to get @unroll support upstream into Scala 3 for about a year now, which would let us automate all these bincompat forwards. Hoping it can land soon in scala/scala3#21693

@lefou
Copy link
Member

lefou commented Jan 10, 2025

I've been trying to get @unroll support upstream into Scala 3 for about a year now, which would let us automate all these bincompat forwards. Hoping it can land soon in scala/scala3#21693

To my understanding, @unroll can't help if you want to remove a (not-last) parameter with defaults from the parameter list. Or was something added lately?

@lihaoyi
Copy link
Member

lihaoyi commented Jan 10, 2025

ah yes, it only helps for adding parameters

@alexarchambault
Copy link
Collaborator Author

Just added @deprecated annotations on the deprecatedResolveFilter parameters, even though this should create warnings in users' code.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Maybe I overlook the obvious, but since we're now no longer declare any runtime dependencies in our workers, how so we ensure we properly load the workers transitive dependencies at runtime?

Comment on lines +129 to +142
def compileModuleDeps = Seq(
build.main.api,
scoverage.api
)
def compileIvyDeps = Task {
Agg(
super.mandatoryIvyDeps() ++ Agg(
// compile-time only, need to provide the correct scoverage version at runtime
build.Deps.scalacScoverage2Plugin,
build.Deps.scalacScoverage2Reporter,
build.Deps.scalacScoverage2Domain,
build.Deps.scalacScoverage2Serializer
)
}
def mandatoryIvyDeps = Agg.empty[Dep]
Copy link
Member

Choose a reason for hiding this comment

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

What's going on with these changes? Did the semantics of the underlying resolution change in some way that we need to change this downstream code?

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.

3 participants