jbang icon indicating copy to clipboard operation
jbang copied to clipboard

feat: Switched Shrinkwrap for Maven/Aether API

Open quintesse opened this issue 2 years ago • 14 comments

The code takes into account the user's settings.xml, so things like repository authentication and proxies should now work.

Fixes #1077

quintesse avatar Sep 16 '22 12:09 quintesse

Ok, there's still an issue with the new code not taking into account the JBANG_REPO setting.

quintesse avatar Sep 16 '22 16:09 quintesse

Codecov Report

Base: 0.00% // Head: 0.00% // No change to project coverage :thumbsup:

Coverage data is based on head (f162de7) compared to base (9a3d4c9). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@          Coverage Diff           @@
##            main   #1456    +/-   ##
======================================
  Coverage   0.00%   0.00%            
======================================
  Files        107     109     +2     
  Lines       6587    6800   +213     
  Branches    1076    1109    +33     
======================================
- Misses      6587    6800   +213     
Flag Coverage Δ
Linux 0.00% <0.00%> (ø)
Windows 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/java/dev/jbang/catalog/CatalogUtil.java 0.00% <0.00%> (ø)
src/main/java/dev/jbang/cli/Export.java 0.00% <0.00%> (ø)
src/main/java/dev/jbang/cli/JBang.java 0.00% <ø> (ø)
...main/java/dev/jbang/dependencies/ArtifactInfo.java 0.00% <ø> (ø)
.../java/dev/jbang/dependencies/ArtifactResolver.java 0.00% <0.00%> (ø)
...n/java/dev/jbang/dependencies/DependencyCache.java 0.00% <0.00%> (ø)
...in/java/dev/jbang/dependencies/DependencyUtil.java 0.00% <0.00%> (ø)
...n/java/dev/jbang/dependencies/MavenCoordinate.java 0.00% <0.00%> (ø)
...rc/main/java/dev/jbang/dependencies/MavenRepo.java 0.00% <ø> (ø)
src/main/java/dev/jbang/source/RunContext.java 0.00% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Sep 16 '22 17:09 codecov[bot]

running this I get these failed tests locally:

TestExport > testExportPortableNoclasspath() FAILED
    java.lang.AssertionError at TestExport.java:67

TestExport > testExportWithClasspath() FAILED

maxandersen avatar Sep 17 '22 09:09 maxandersen

nice with 0.5 MB smaller distro though ;)

❯ ls -l ~/.jbang/bin/jbang.jar .rw-r--r-- 6.4M max 18 Jul 21:12 /Users/max/.jbang/bin/jbang.jar ❯ ls -l build/install/jbang/bin/jbang.jar .rw-r--r-- 5.8M max 17 Sep 11:17 build/install/jbang/bin/jbang.jar

maxandersen avatar Sep 17 '22 09:09 maxandersen

running this I get these failed tests locally:

You might have to investigate yourself because all tests run fine for me locally and they've passed online as well.

quintesse avatar Sep 17 '22 09:09 quintesse

You might have to investigate yourself because all tests run fine for me locally and they've passed online as well.

turned out our tests was broken and tested lib was missing from current directory rather than the temporary dir we exported to. Thus it failed locally for me as I had a 'lib' dir.

pushed a commit that fixes the tests.

maxandersen avatar Sep 19 '22 20:09 maxandersen

on app created with jbang init -t qrest wonka.java that states:

//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.11.2.Final}@pom
//DEPS io.quarkus:quarkus-resteasy

running jbang wonka.java I got this output:

jbang wonka.java
[jbang] Resolving dependencies...
[jbang]           io.quarkus:quarkus-resteasy:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-vertx-http:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-core:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-ide-launcher:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-development-mode-spi:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-bootstrap-runner:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-security-runtime-spi:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-credentials:jar:2.11.2.Final
[jbang]           io.quarkus.arc:arc:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-mutiny:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-smallrye-context-propagation:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-vertx-http-dev-console-runtime-spi:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-vertx:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-netty:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-vertx-latebound-mdc-provider:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-resteasy-server-common:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-arc:jar:2.11.2.Final
[jbang]           io.quarkus:quarkus-resteasy-common:jar:2.11.2.Final
[jbang] Dependencies resolved
[jbang] Building jar...
[jbang] Running external post build for io.quarkus.launcher.JBangIntegration
[jbang] Post build with io.quarkus.launcher.JBangIntegration
Sep 19, 2022 10:14:45 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.4.2.Final
Sep 19, 2022 10:14:46 PM io.quarkus.deployment.QuarkusAugmentor run
INFO: Quarkus augmentation completed in 1559ms

why is it not showing resolve of io.quarkus:quarkus-bom:2.11.2.Final@pom?

and do we really need to show the individual downlaods unless in verbose? actually what does each line signifies ? it does not seem to be printed when downloading more as that is what will be resolved?

maxandersen avatar Sep 19 '22 20:09 maxandersen

running jbang jreleaser-snapshot@jreleaser it seems stuck at "resolving dependencies..." ...then suddenly prints out list of dependencies.

as if we are printing what we resolve AFTER downlaod completed. It should be when resolution/downloads starts.

maxandersen avatar Sep 19 '22 20:09 maxandersen

why is it not showing resolve of io.quarkus:quarkus-bom:2.11.2.Final@pom?

Well, that's actually because I'm filtering out @pom entries, if not every line would be duplicated, once for the @pom and another one for the @jar. In this case you're right it should show it, but see below.

and do we really need to show the individual downlaods unless in verbose?

We don't need to but it's definitely the easiest to implement. I'm just getting a bunch of events that I'm printing out. At that point of printing there's no concept of what artifacts were passed as primary dependencies and which are secondary sub dependencies.

actually what does each line signifies ? it does not seem to be printed when downloading more as that is what will be resolved?

Not sure what you're trying to say here. It's printing each artifact that needs to be downloaded at the moment it starts downloading it.

as if we are printing what we resolve AFTER downlaod completed. It should be when resolution/downloads starts.

It's definitely printing before. I'll have to investigate that one to see if something special is happening.

quintesse avatar Sep 20 '22 09:09 quintesse

running jbang jreleaser-snapshot@jreleaser it seems stuck at "resolving dependencies..."

Not sure what's going on tbh, but the old code has the same problem. The only difference is is that because in the old code we just blindly print out the list of dependencies while in the new code we actually get notified when a download starts. So I think the wait is for something else before any downloads are started.

In fact it might be because it's using jitpack.io, perhaps that's the slow part...

quintesse avatar Sep 20 '22 12:09 quintesse

In fact it might be because it's using jitpack.io, perhaps that's the slow part...

This does indeed seem to be the case. It's downloading a lot of maven_metadata.xml files for each artifact. Some of these take a very long time, even though they're quite small. And because you're running the snapshot version they get downloaded every time.

quintesse avatar Sep 20 '22 12:09 quintesse

Ok, logging should now be very similar to what it was before except for the improvement that artifacts will be logged in order they are handled by Maven. And --verbose will show all dependencies, not just the ones mentioned in the source code.

quintesse avatar Sep 20 '22 20:09 quintesse

i tried latest, its behavior is better but:

a) the indent seems overly big now. Like could just be 2 spaces not the 10+ now b) i still dont see printing for when download starts. could it be we are not flushing the stream so it does not print until buffer reaches certain size?

maxandersen avatar Sep 21 '22 20:09 maxandersen

a) the indent seems overly big now. Like could just be 2 spaces not the 10+ now

I agree, but it's what it was before :-) Btw, our indents tend to use 3 spaces, shall we use that here as well?

b) i still dont see printing for when download starts. could it be we are not flushing the stream so it does not print until buffer reaches certain size?

Not sure what you mean. Can you give an example of what you're executing, what you're seeing and what you expected to see?

Edit: as I mentioned before, make sure the artifact really need to be downloaded, eg by manually deleting them form the M2 cache. Otherwise Maven will not redownload them!

quintesse avatar Sep 21 '22 22:09 quintesse

with latest fixes this looks perfect!

maxandersen avatar Sep 23 '22 06:09 maxandersen