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

[internal] Refactor JVM artifact mapping code #13905

Merged
merged 5 commits into from
Dec 16, 2021

Conversation

Eric-Arellano
Copy link
Contributor

Four different refactors as prework for #13621.

# 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]
# 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]
"""Maps JVM unversioned coordinates to target `Address`es and declared packages."""

artifacts: FrozenDict[UnversionedCoordinate, tuple[tuple[Address, ...], tuple[str, ...]]]

def addresses_for_coordinates(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused

@@ -156,42 +142,57 @@ def find_all_jvm_provides_fields(targets: AllTargets) -> AllJvmTypeProvidingTarg
class ThirdPartyPackageToArtifactMapping:
mapping_root: FrozenTrieNode

def addresses_for_symbol(self, symbol: str) -> FrozenOrderedSet[Address]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simply converted into a method rather than free function. Only line 147 changed

Comment on lines -168 to -178
group = tgt[JvmArtifactGroupField].value
if not group:
raise ValueError(
f"The {JvmArtifactGroupField.alias} field of target {tgt.address} must be set."
)

artifact = tgt[JvmArtifactArtifactField].value
if not artifact:
raise ValueError(
f"The {JvmArtifactArtifactField.alias} field of target {tgt.address} must be set."
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Target API already validates that these are set.

Comment on lines -71 to -72
# TODO: error if no resolves for the target. Wait to change until we automatically set a
# default resolve.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that we a) decided to not have [jvm].default_compatible_resolves in #13902, and b) we plan to set a default for default_resolve, this won't be able to happen soon. There will always be a resolve defined.

@@ -35,3 +42,35 @@ def resolves(self) -> dict[str, str]:
@property
def default_resolve(self) -> str | None:
return cast(str, self.options.default_resolve)

def resolves_for_target(self, target: Target) -> tuple[str, ...]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this is checking that all resolves are recognized, which we did not do before.

# 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]
@@ -18,14 +20,19 @@ def register_options(cls, register):
register(
"--resolves",
type=dict,
# TODO: Default this to something like {'jvm-default': '3rdparty/jvm/default.lockfile'}.
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

@Eric-Arellano Eric-Arellano enabled auto-merge (squash) December 16, 2021 22:40
@Eric-Arellano Eric-Arellano merged commit b2d4a7c into pantsbuild:main Dec 16, 2021
@Eric-Arellano Eric-Arellano deleted the jvm-refactors branch December 16, 2021 23:11
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