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

jvm_exclude with Group Only Fails Parsing by Coursier #20794

Open
NGustafson opened this issue Apr 15, 2024 · 3 comments · May be fixed by #20802
Open

jvm_exclude with Group Only Fails Parsing by Coursier #20794

NGustafson opened this issue Apr 15, 2024 · 3 comments · May be fixed by #20802
Labels
backend: JVM JVM backend-related issues bug

Comments

@NGustafson
Copy link
Contributor

Describe the bug
Running pants generate-lockfiles when a jvm_artifact contains a jvm_exclude that only specifies a group will fail with a "Failed to parse [group-name]" message from Coursier. This is contrary to the documentation for jvm_exclude which states "jvm_exclude: Exclude the given artifact and group, or all artifacts from the given group."

Pants version
2.20.0rc2

OS
MacOS

Additional info
Example Repo https://github.com/NGustafson/pants-examples/blob/main/3rdparty/jvm/BUILD
This repo has a single jvm_artifact with nothing else configured. Attempting to run pants generate-lockfiles will cause this error:

pants generate-lockfiles
[ERROR] 1 Exception encountered:

Engine traceback:
  in `generate-lockfiles` goal

ProcessExecutionFailure: Process 'Running `coursier fetch` against 1 requirement: org.slf4j:slf4j-log4j12:2.0.12' failed with exit code 1.
stdout:

stderr:
+ coursier_exe=__coursier/./cs-aarch64-apple-darwin
+ shift
+ json_output_file=coursier_report.json
+ shift
++ pwd
+ working_dir=/private/var/folders/cm/gmrdwxcn7tv_cct4dzg38w91kjyl1q/T/pants-sandbox-aM4FVB
+ __coursier/./cs-aarch64-apple-darwin fetch -r=https://maven-central.storage-download.googleapis.com/maven2 -r=https://repo1.maven.org/maven2 --no-default --json-output-file=coursier_report.json org.slf4j:slf4j-log4j12:2.0.12 --local-exclude-file PANTS_RESOLVE_EXCLUDES
Failed to parse org.slf4j
Failed to parse org.slf4j
@NGustafson NGustafson added the bug label Apr 15, 2024
@huonw huonw added the backend: JVM JVM backend-related issues label Apr 16, 2024
@huonw
Copy link
Contributor

huonw commented Apr 16, 2024

Thanks for filing an issue with a reproducer and sorry for the trouble!

I did an initial triage to check priority/regression: it looks like this behaviour has existed since 2.18.0.dev0 (PANTS_VERSION=2.18.0.dev0 pants generate-lockfiles), which seems to be the first release that had this jvm_exclude #19128, so not a regression.

@NGustafson is this something you might have a chance at trying to fix? @alonsodomin is something you can provide hints or guidance about?

@NGustafson
Copy link
Contributor Author

@huonw Thanks for checking! Yes I'd like to try fixing this.
It seems like Coursier supports group-only excludes if you set the artifact to *. Something like --exclude 'org.slf4j:*'. But this Pants syntax causes a different error jvm_exclude(group="org.slf4j", artifact="*"), so I'm going to try getting that to work first.

@alonsodomin
Copy link
Contributor

sorry for the trouble, it's true that initial implementation was wrong. This should be easy to fix, the point in which the exclusion is transformed into a coordinate string is in here:

def to_coord_str(self) -> str:

@NGustafson NGustafson linked a pull request Apr 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: JVM JVM backend-related issues bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants