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

Re-introduce Mill special handling of ivydeps, overhaul test classpath management to allow testing #2476

Merged
merged 26 commits into from
Apr 29, 2023

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Apr 28, 2023

Fixes #2474

These were overlooked in #2377 and deleted, and were not covered by any tests. But it's straightforward to put them back.

Major Changes

  1. Put back MillIvy.scala and call it in MillBuildRootModule.scala

Testing

  1. I added an example test example/misc/6-contrib-import to both exercise the code as well as serve as an example we can include in our docs

  2. In order to allow usage of contrib module in .local integration and example tests, I moved the handling of Mill test classpath overrides from Util.millProjectModule to CoursierSupport#resolveDependencies. This lets us be more override contrib modules dependency resolution, even though they don't have a neat single location for us to call our millProjectModule helper.

  3. I refactored millProjectModule to not need a key, so we just compute the key based on the dependency name, keeping them consistent and removing an unnecessary degree of freedom

  4. The local-testing-classpath-overrides were moved from using JVM system properties to instead use classpath resources: we look for overrides in mill/local-test-overrides/*. This should remove any security worries:

    1. Before you only needed to modify the JVM props or JAVA_OPTS environment variable, and could replace the code of a Mill module to any local filesystem path
    2. Now, you need access to modify the Mill classpath to trigger the test overrides, and at that point you already have access to modifying the Mill classfiles being executed anyway

While it probably was not strictly necessary to clean up the test classpath overrides logic as part of this PR, the status quo in master was a pile of hacks, and I didn't feel like adding another hack to get .local testability of contrib libraries working. With these changes, contrib libraries work the same as the existing Mill test classpath overrides, and things are cleaned up so much that the net lines of code for this PR is negative

There's still more cleanup to do in build.sc, but those can come in follow up PRs

@lihaoyi lihaoyi changed the title Re-introduce Mill special handling of ivydeps Re-introduce Mill special handling of ivydeps, overhaul test classpath management to allow testing Apr 28, 2023
@lihaoyi lihaoyi marked this pull request as ready for review April 29, 2023 14:03
@lihaoyi lihaoyi requested review from lefou and lolgab April 29, 2023 14:03
@lihaoyi
Copy link
Member Author

lihaoyi commented Apr 29, 2023

This should also be reviewable I think

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.

Looks good to me.

@lihaoyi lihaoyi merged commit fff545a into com-lihaoyi:main Apr 29, 2023
@lefou lefou added this to the 0.11.0-M9 milestone Apr 29, 2023
lihaoyi added a commit that referenced this pull request May 21, 2023
Should fix #2533, which was
broken by #2476

Just requires shuffling `def testDeps` and related definitions around to
make them available outside `MillScalaModule`. They moved to
`MillCoursierModule`, which in order to satisfy their dependencies had
to be converted to `MillJavaModule`. The overall logic of the build is
unchanged

Tighted up the test artifact resolution logic for `.local`
example/integration tests. Previously, they would ignore the
`artifactSuffix`, which is why tests exercising `runBackground` like
`example.web[1-todo-webapp].local` passed despite the bug. With the more
strict test artifact resolution, this bug gets surfaced properly on
`main`, and is fixed by this PR
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.

Mill special syntaxes to import plugins and contrib modules dont't work anymore
2 participants