-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
make bloop aware of runtime dependencies #1843
Conversation
I need to change my approach: the generated bloop config references classes in the mill out path. This had me very confused as changes to my code didn't register properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two concerns:
First, I think the transitive dependency calculation isn't correct, because it includes also compile-time dependencies transitively, which is wrong. I also realize this issue was already present before your PR, but as you touched this code, I wanted to point it out. And at this point, I'd like to request a test case resembling a project with multiple modules and ensuring the classpaths and run-classpaths are correct, which brings me to the other point.
This is a contrib module, where we don't enforce the same strict quality standards. I guess this means, we can just merge as is, with missing tests and such. But as Bloop is used by many users (I guess), we should address my first concern.
Oh, and thanks for creating this PR. Totally forget that, as I were so concentrated on the implementation. |
I wrote the classpaths down how I think they should be used by bloop. But please beware that I haven't tested them. val compileClasspath = T.task {
val depModules = (module.compileModuleDeps ++ module.recursiveModuleDeps).distinct
// dep modules ++ ivy deps ++ unmanaged
depModules.map(classes) ++
module.resolvedIvyDeps().map(_.path) ++
module.unmanagedClasspath().map(_.path)
}
val runtimeClasspath = T.task {
// dep modules ++ ivy deps ++ unmanaged
module.recursiveModuleDeps.map(classes) ++
module.resolvedRunIvyDeps().map(_.path) ++
module.unmanagedClasspath().map(_.path)
} I don't know how bloop is handling resources, so I completely ignored that part. |
I tried recompiling mill with these changes and the generated bloop config seemingly works for my setup! That is, postgres driver and slf4j-adapter is made available only during runtime. |
Great. Do you intend to add a test case, too? If not, maybe you could share your |
I can have a look at it! How do you imagine the test should look like? A simple build definition, running bloopimpl and then comparing the output to a predefined expected result, or something more involved? |
Great. Yes, just comparing the generated output looks good to me. We do something similar in |
06948e7
to
588f38c
Compare
I amended the existing tests in BloopTests.scala. I think I got it working, and also added a check for compile-time dependencies while at it. I couldn't figure out how to get access to the resolved ivy deps so there's some extra in-place filtering done in the assertions to make sure that all deps except |
2be1c82
to
72216d3
Compare
The failing tests seem to be related to something else.. |
Yeah, I'm already trying to fix them. This PR looks good to me now. Let's rebase/merge on main branch once I've pushed my test changes and if we are green, we can merge. |
Sounds good! |
@megri Can you rebase this PR on latest main branch, please? |
Done! |
Thank you! |
At the moment, mill generates bloop configurations without setting the runtime classpath of Java modules. This makes bloop fall back to
project.classpath
which corresponds with required compile-time classpath. It makes sense to put stuff like slf4j-adapters, postgres-drivers and such—dependencies that are only required during runtime—in the JVM-configuration.The following discussion on the bloop issue tracker highlights the requirements and the accepted solution: scalacenter/bloop#1233
scalacenter/bloop#1244
This pull-request simply outputs the
runClasspath
target toBloopConfig.Platform.Jvm#classpath
. I'm not a 100 % sure this is the correct approach, but it corresponds to what gets put on the classpath when having mill run a project (as far as I can tell, from looking atmill inspect app.run
.