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

Add BOM support for compileIvyDeps, runIvyDeps, and BOM test dependencies #4068

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

Conversation

alexarchambault
Copy link
Contributor

@alexarchambault alexarchambault commented Dec 3, 2024

Checking what the CI says, this embeds #3924 for now

 Conflicts:
	docs/modules/ROOT/pages/fundamentals/library-deps.adoc
	example/fundamentals/library-deps/bom-1-external-bom/build.mill
	example/fundamentals/library-deps/bom-2-dependency-management/build.mill
	scalalib/src/mill/scalalib/JavaModule.scala
	scalalib/src/mill/scalalib/PublishModule.scala
	scalalib/test/src/mill/scalalib/BomTests.scala
lihaoyi pushed a commit that referenced this pull request Dec 6, 2024
With the main task first, the compile-only one second, and the runtime
one third

This makes it easier to change these methods, add related ones, etc.

This is already part of #4068.
Opening the PR here to make it easier to review the changes here, and
those of #4068 if the one here
gets merged
 Conflicts:
	scalalib/src/mill/scalalib/JavaModule.scala
	scalalib/src/mill/scalalib/PublishModule.scala
	scalalib/test/src/mill/scalalib/BomTests.scala
@alexarchambault

This comment was marked as outdated.

@alexarchambault alexarchambault marked this pull request as ready for review December 10, 2024 14:51
@lihaoyi
Copy link
Member

lihaoyi commented Dec 14, 2024

@alexarchambault not sure if I did the merge right, but seems like it might need more fixes to get a green CI

Comment on lines +210 to +218
def extraBomIvyDeps: Task[Agg[BomDependency]] = Task.Anon { Agg.empty[BomDependency] }

/**
* Dependency management entries that are not meant to be overridden or changed by users.
*
* This is mainly used to add dependency management entries of the main module to its test
* modules.
*/
def extraDepManagement: Task[Agg[Dep]] = Task.Anon { 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.

Do these really need to be Task.Anons? Not sure about BomDependency, but at least Agg[Dep] is serializable and can be a normal Task right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These can be made normal Tasks, yes

Comment on lines +514 to +521
allBomIvyDeps().toSeq.map(_.withConfig(Configuration.compile)) ++ extraBomIvyDeps().toSeq
val depMgmt = processedDependencyManagement(
(extraDepManagement().toSeq ++ depManagement().toSeq)
.map(bindDependency())
.map(_.dep)
)

addBoms(bomDeps0, depMgmt, overrideVersions = overrideVersions)
Copy link
Member

Choose a reason for hiding this comment

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

Can we refactor processDependency, processCompileDependency, and processRunDependency to share the logic between them via an anonymous task. That will help make it easier to see the core differences between them.

I'm also not clear about the differences here:

  • processCompileDependency uses compileDepManagement(), and processRunDependency uses runDepManagement
  • processDependency and processCompileDependency both use extraDepManagement but processRunDependency does not. Why?
  • Only processDependency seems to use extraBomIvyDeps, while processCompileDependency and processRunDependency do not. Why?

Copy link
Contributor Author

@alexarchambault alexarchambault Dec 16, 2024

Choose a reason for hiding this comment

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

I'm trying a different approach to this PR's changes in #4145. Rebasing the PR here on top of it should get rid of these additional methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should also simplify the way BOMs are handled when taking scopes into account. I've been having issues reconciling Mill's compileIvyDeps / ivyDeps / runIvyDeps (where scopes are known beforehand) with how scopes are handled in BOMs (not known beforehand, dependencies from all scopes are mixed, and BOMs can change the scope if it's undefined).

* added to them. This should be used when propagating the dependencies transitively
* to other modules.
*/
def processedCompileIvyDeps: Task[Agg[BoundDep]] = 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.

Let's make these normal Tasks rather than Task.Anons?

@lihaoyi
Copy link
Member

lihaoyi commented Dec 16, 2024

Left some comments. @alexarchambault also please fill out the PR description, that will make it easier to review and maintain since we won't need to reverse engineer what you already have in your head

@alexarchambault
Copy link
Contributor Author

I'll probably close this PR. By relying on #4145, #4154 offers simpler / better support for BOMs / scopes.

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.

2 participants