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

Map packaging to non-optional #2718

Merged
merged 2 commits into from Jun 19, 2023

Conversation

dwijnand
Copy link
Contributor

@dwijnand dwijnand commented Mar 17, 2023

Fixes #2377. Depends on coursier/test-metadata#8.

@dwijnand dwijnand force-pushed the failure-isnt-optional branch 5 times, most recently from 55337bd to c5bba09 Compare March 23, 2023 08:20
@dwijnand dwijnand marked this pull request as ready for review March 23, 2023 08:52
@dwijnand
Copy link
Contributor Author

@alexarchambault let me know what you think? I think it's just that typo in MavenRepositoryInternal, and everything else is just the cascade effect of that. I tried to keep the intent of the rest of the tests.

@dwijnand
Copy link
Contributor Author

dwijnand commented Apr 4, 2023

Hey @alexarchambault (or @julienrf) any chance this could be reviewed, merged and released, please?

@alexarchambault
Copy link
Member

@dwijnand I'll have a closer look later, but at first sight, this is not a trivial change… Packaging has been optional on purpose. Some dependencies do miss a JAR, and they shouldn't fail.

About the repo linked in #2377, I'd need to have a closer look, but at first, I'd assume the repository to be broken.

@alexarchambault
Copy link
Member

That said, if I read #2377 (comment) correctly, and if your change is only about the case where the dependency has an explicit <packaging>jar</packaging>, that might work…

Copy link
Collaborator

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

IIUC #2377 (comment) there is an inconsistency between the way Coursier reads a dependency from a pom or from the command-line.

From the command-line (e.g. cs fetch javax.media:jai_core:1.1.3,type=jar), when we set the type to jar, Coursier fails to resolve the dependency if the .jar file is absent.

However, when the dependency is read from a pom file with <packaging>jar</packaging>, Coursier marks the .jar file as optional and does not fail the resolution if the file is absent.

This PR fixes this inconsistency, so the approach looks good to me. Please see my other comments below.

AFAIU, this PR may not completely address the linked issue because it will not, by default, expand dependency descriptors to type=jar,optional=false.

@@ -803,6 +803,7 @@ object InstallTests extends TestSuite {

val scala2CompilerJars =
Seq(
"https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change related to the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course. It was previously missing, before this fix.

@@ -223,7 +223,6 @@ https://repo1.maven.org/maven2/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.jar
http://repository.mapr.com/maven/org/apache/hadoop/hadoop-yarn-server-nodemanager/2.7.0-mapr-1808/hadoop-yarn-server-nodemanager-2.7.0-mapr-1808.jar
http://repository.splicemachine.com/nexus/content/groups/public/com/splicemachine/splice_encoding/2.8.0.1915-SNAPSHOT/splice_encoding-2.8.0.1915-20190427.010754-1.jar
https://repo1.maven.org/maven2/software/amazon/ion/ion-java/1.0.1/ion-java-1.0.1.jar
https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.6.7.1/jackson-databind-2.6.7.1.jar
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this change necessary?

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 fix removes the duplicate jackson-databind jar (there's one on line 121).

@alexarchambault
Copy link
Member

I agree with @julienrf comments. I'd like to take the time to understand why the databind and the scala-xml changes are necessary

@dwijnand
Copy link
Contributor Author

dwijnand commented May 4, 2023

AFAIU, this PR may not completely address the linked issue because it will not, by default, expand dependency descriptors to type=jar,optional=false.

I don't know what that means, outside of not making packaging=jar non-optional..

@julienrf
Copy link
Collaborator

julienrf commented May 5, 2023

I don't know what that means, outside of not making packaging=jar non-optional..

I might be missing something, but what I meant is that with this PR Courser will not set the packaging to jar by default when reading dependencies from a pom. It will still have to be specified explicitly in the pom. Probably, this is fine and should not hold this PR.

@alexarchambault
Copy link
Member

I'll try to find time to have a closer look in the coming days (until next Monday say, don't merge until then)

@dwijnand
Copy link
Contributor Author

Thank you ❤️

@alexarchambault
Copy link
Member

So I had a closer look at the changes in test fixtures that looked suspicious. #2776 and #2777 deal with those. I just pushed a rebased version of the original code of this PR, and the diff looks much nicer now 🎉

I don't feel like writing a long explanation about this right now, given it's quite late for me 😬 I might tomorrow or later during the week.

In any case, thanks for having pushed for this, @dwijnand! I'll merge if the CI gets green (it should), and this'll be part of the next release.

@dwijnand
Copy link
Contributor Author

dwijnand commented Jun 2, 2023

Very nice, thank you. It's green, btw.

@dwijnand
Copy link
Contributor Author

@alexarchambault could we merge this, please?

@alexarchambault alexarchambault merged commit 7d4122f into coursier:main Jun 19, 2023
22 checks passed
@dwijnand dwijnand deleted the failure-isnt-optional branch June 26, 2023 08:16
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.

cs fetch caches a POM with no artifact, and fails to download on subsequent runs with different repositories
3 participants