Skip to content

Map packaging to non-optional#2718

Merged
alexarchambault merged 2 commits intocoursier:mainfrom
dwijnand:failure-isnt-optional
Jun 19, 2023
Merged

Map packaging to non-optional#2718
alexarchambault merged 2 commits intocoursier:mainfrom
dwijnand:failure-isnt-optional

Conversation

@dwijnand
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

dwijnand commented Apr 4, 2023

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

@alexarchambault
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@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.


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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread modules/coursier/jvm/src/test/scala/coursier/FetchTests.scala
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

Thank you ❤️

@alexarchambault alexarchambault force-pushed the failure-isnt-optional branch from c5bba09 to 3ef649f Compare May 30, 2023 01:37
@alexarchambault
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

dwijnand commented Jun 2, 2023

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

@dwijnand
Copy link
Copy Markdown
Contributor Author

@alexarchambault could we merge this, please?

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