rhythmic-battery-45198
12/31/2021, 1:45 AMdeploy_jar
target in my java project. The jar is required by one of python classes. Is there any way to represent this type of dependency a BUILD file?hundreds-father-404
12/31/2021, 1:57 AMrhythmic-battery-45198
12/31/2021, 2:16 AMrhythmic-battery-45198
12/31/2021, 2:17 AMhundreds-father-404
12/31/2021, 2:24 AMdeploy_jar
generate ResourceSourceField
so that when you depend on it, it's like depending on resource
but where it gets generated by ~running ./pants package
first
https://www.pantsbuild.org/docs/plugins-codegen
To do this, you'll want to add a private sources
field to deploy_jar
like this: https://github.com/pantsbuild/pants/blob/fe112bf20e9e7cfe4a2c746316ebc2655c428697/src/python/pants/core/target_types.py#L142-L145. You're just doing this to hook into codegen. Use a "plugin field" to extend the existing deploy_jar
target: https://www.pantsbuild.org/docs/target-api-extending-targets
Then, in your codegen rule, you'll call await Get(BuiltPackage, DeployJarFieldSet, field_set)
I think. This essentially calls ./pants package
. You can then return the resulting BuiltPackage.digest
in the GeneratedSources
for your codegen rule
We're happy to help more if you have questions along the way 🙂 Feel free to ask questions here or in #C01CQHVDMMW
We may want to generalize that cross-language relationship in core Pants, but in the meantimerhythmic-battery-45198
12/31/2021, 2:30 AMhappy-kitchen-89482
12/31/2021, 9:12 PMpython_sources
, say, depends on a pex_binary
, then IIRC we package that PEX and make it available as a runtime resource for the python sources. This seems no different in principle, so we almost certainly want to support this in core Pants.hundreds-father-404
12/31/2021, 9:46 PMpython_distribution
and then we install that into the venv via your PR from a few months ago?happy-kitchen-89482
01/01/2022, 5:37 AM