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 support for multiple compile/testing JDKs #14421
Add support for multiple compile/testing JDKs #14421
Conversation
…mits # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…jdk-setup-indirection
[ci skip-rust] [ci skip-build-wheels]
…le-jdks-take-2 [ci skip-rust]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust]
… sources [ci skip-rust] [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
src/python/pants/jvm/jdk_rules.py
Outdated
# TODO: verify that we're requesting the same JDK version for all `ct` members? | ||
t = ct.representative |
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.
Yea. This validation could maybe move into ClasspathEntryRequest
, and then become a field of ClasspathEntryRequest
? Not a blocker though.
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.
Good catch! I think I'd decided on CoarsenedTarget
before I knew where JDK selection would be necessary. I'll see if I can refactor that appropriately.
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.
@stuhood I think the validation side of things will require ClasspathEntryRequest.for_targets
to be re-written as a rule (or further complicated by accepting more singleton arguments) to resolve the JDK at construction time. If you're OK with that, I can do that in a separate PR before landing this?
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…get` # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…le-jdks-take-2 [ci skip-rust]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Requesting a full review now (working on tests in the meantime). Supporting validation/erroring out in the right place is going to take a bit more work than I'd like, and I'd rather land the overall support. |
src/python/pants/jvm/jdk_rules.py
Outdated
|
||
@dataclass(frozen=True) | ||
class Nailgun: | ||
classpath_entry: ClasspathEntry | ||
|
||
|
||
@dataclass(frozen=True) | ||
class JdkForClasspathRequest: |
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.
This could -- theoretically -- get folded into JdkRequest
, but I feel like that's going to overcomplicate things further
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.
(commented on the topic elsewhere before seeing this)
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.
Thanks! One blocking issue here for the repl
goal. I also think that we should swap up the option names.
src/python/pants/jvm/jdk_rules.py
Outdated
@rule | ||
async def jdk_request_for_classpath(request: JdkForClasspathRequest) -> JdkRequest: | ||
|
||
# TODO: verify that we're requesting the same JDK version for all `ct` members? | ||
t = request.cper.component.representative | ||
|
||
if not t.has_field(JvmJdkField): | ||
raise ValueError(f"Cannot construct a JDK request for a non-JVM target {t}") | ||
|
||
field = t[JvmJdkField] | ||
|
||
return JdkRequest(field) |
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.
This rule is overly coarse I think (and possibly worth fixing before landing): the request will be different for every CoarsenedTarget
, even though all the rule is going to consume is a single field.
I'd suggest moving the body of this @rule
into a static method of JdkRequest
that constructs a JdkRequest
from a CoarsenedTarget
. Alternatively, keep the JdkForClasspathRequest
type and move the body to static method there. Either way, that should reduce the number of times this rule runs to "once per distinct field value".
src/python/pants/jvm/jdk_rules.py
Outdated
|
||
@dataclass(frozen=True) | ||
class Nailgun: | ||
classpath_entry: ClasspathEntry | ||
|
||
|
||
@dataclass(frozen=True) | ||
class JdkForClasspathRequest: |
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.
(commented on the topic elsewhere before seeing this)
Co-authored-by: Stu Hood <stuhood@gmail.com>
Co-authored-by: Stu Hood <stuhood@gmail.com>
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
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.
This addresses the two most egregious issues; I'll work on efficiency as a fast-follow for this.
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.
Thanks!
Co-authored-by: Stu Hood <stuhood@gmail.com>
Co-authored-by: Stu Hood <stuhood@gmail.com>
…le-jdks-take-2 [ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
@chrisjrn : It looks like your test failures are likely a collision with the second commit in #14441... sorry about that. In short: "target generator" types like |
# Conflicts: # src/python/pants/backend/java/target_types.py # src/python/pants/backend/scala/target_types.py # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
@stuhood Looks like the tests pass again once we treat Let's address whether it should be made a |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…ake-2' into chrisjrn/13995-take-3 [ci skip-rust] [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Previously we were constructing a `JdkEnvironment` for every instance of `JvmJdkField` rather than caching by version. This refactors `JdkRequest` to no longer store a field, and instead, always store a version string or magic constant. This should reduce the number of times we download a JDK. (Fast-follow for #14421, addresses #13995)
It should be a moved field, as that's necessary for |
This adds support for a
jdk_version
on all JVM source targets as well asdeploy_jar
. Supply--jvm-default-source-jdk
to set a default for thejdk_version
field -- currently we also fall back to--jvm-jdk
, but this is deprecated and will be removed presently.Needs: tests
There's a bit more work than I'd like to support validating that a
deploy_jar
is run with an acceptable JDK version, so deferring that for a follow-up.