-
Notifications
You must be signed in to change notification settings - Fork 159
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
refactor: Put MIMA in action #1604
Conversation
Just now spotted: while the build and tests pass OK (!) locally, the resulting distro is totally broken, and for some reason is missing almost all of the (runtime) classes and many more.... 😞 Yup: https://imperceptiblethoughts.com/shadow/configuration/minimizing/ is pulling out all the bits |
Personally I'd be happy to use something made by people who actually understand Maven, because what we did with JBang was just cobble different things from different sources and different versions together, without understanding things fully, and just pray it works. |
As I stand currently, in this moment, will have to probably create step-by-step PRs, as I keep discovering "issues" (bugs maybe?), and have to solve them to keep going. For example very first bug I saw is re localRepository: |
Also, am currently playing on "two fronts", since MIMA 1.0.1 release added some new stuff (like maveniverse/mima@5719b7b) so my goal is to make MIMA provide "fully configured" miniMaven, while JBang only have to care about it's own specific overrides. (like JBANG_REPO is)... |
Well exactly because it returns a "factory default" it never returns |
No, that is not correct. User may have settings.xml in default place ( |
Just FTR I pushed this change to different branch as am getting a bit lost, or am just digging too deep: Goals:
|
Sure, but that would still be a result, right? I mean the settings.xml can't "unset" the local repo, or can it? I do understand that the implementation is wrong for the reasons you mention, I'm just wondering if it not returning |
Indeed, right now JBang doesn't change those parameters during an invocation, but I wrote that code to be flexible in that aspect "just in case". |
@@ -26,6 +28,10 @@ | |||
public class Project { | |||
@Nonnull | |||
private final ResourceRef resourceRef; | |||
|
|||
@Nonnull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to come up with a different solution for this because Project is a model object and cannot contain anything that is not directly related top project management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at it in-depth yet, but I'm guessing this would need to be reversed, perhaps have some kind of factory that given a Project can return a RootContext.
FYI, will pick up this once resolver 1.9.10 and maven 3.9.2 are out. |
This was on my TODO-SOON list (like one of these days), are you saying it would be better to wait for those new versions? |
Yes, i'd wait, we are not in hurry 😄 |
@cstamas a question: what is the object that we should try to cache/not create too often and that we have to make sure to close? I'm just trying to figure out where exactly to fit the creation of the Knowing how best to create/cache will help me select the best way forward |
Yes, ideally a Explanation: constructing "root" (very first) context could be considered "heavy" operation, while customizing (child) context and closing it is "light" operation -- as root still keeps constructed resolver components. Customization allows to use alt local repo, enforce update from remote, change involved remote reposes, etc. |
Tomorrow vote for resolver 1.9.10 ends, will do a mima release and pick this up. If you want to toy with it, look at latest "static" addition (I think MIMA version I use here did not yet have it), it is equivalent of deprecated ServiceLocator runtime (no guice/sisu involved, much lighter) https://github.com/maveniverse/mima/tree/main#runtimes |
Ok, because I'm basically looking for a solution that is very similar to what you had before the "A bit bigger commit". Where the resolving is almost like a kind of service that can simply be called, Trying to pass it all the way down from the Now, they ideal solution might be to make it part of the existing So another idea (hack) I had was that we could have some singleton manager that would keep track of contexts and close them once we exit the app. |
It will work if you make it as before "A bit bigger commit". Actually, I'd revert that commit fully, as I went to completely wrong direction. So for start, doing in as it was before it would be ok (and using static uber runtime) and see the startup penalty.... and later we could improve by refactoring? |
Ok, perfect. It's what I had done locally already as a starting point. I'll push that for now and then we update to the new version when it's out and then we can compare any startup differences. |
Sisu is bad candidate for "minification", so i pushed:
|
Locally 7 tests fail, but mostly due "unexpected" (junit tmp) location of local repo/resolved file, while otherwise assertions looks they should pass... |
Ok, I'll take a look at those tests. Thanks! |
build.gradle
Outdated
@@ -189,7 +182,11 @@ shadowJar { | |||
//exclude(dependency('org.slf4j:slf4j-api:.*')) | |||
exclude(dependency('org.slf4j:slf4j-nop:.*')) | |||
exclude(dependency('org.jboss.logging:jboss-logging:.*')) | |||
exclude(dependency('eu.maveniverse.maven.mima:.*')) | |||
exclude(dependency('eu.maveniverse.maven.mima.runtime:.*')) | |||
exclude(dependency('org.apache.maven.resolver:.*')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines now with static-uber runtime could be removed, as minimize removed almost all of resolver (due implicit uses via JSR330 that minimize was unaware of).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, given that mima.runtime goes in via ServiceLocator, maybe not.... (unsure does minimize plugin "knows" about ServiceLocator pattern, as it does not know about Sisu index either).
build.gradle
Outdated
} | ||
append 'META-INF/sisu/javax.inject.Named' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unneded: already merged in static-uber runtime (unless we bring in some other Sisu stuff) -- is safe to be left as is
@cstamas it seems this is because MIMA isn't honoring the |
We could simply add that to |
yup, not honoring |
1.1.2 synced to central w/ 1.1.2 my local test results:
pushing changes... |
whoops - things broke?
pretty sure it passed earlier ? |
the dependencies it fails on in case @cstamas can spot if somehow special: org.openjfx:javafx-base:jar:mac-aarch64:18.0.2 |
Yup, can confirm. Seems remoteRepositories are empty (so nowhere to resolve from), will look into it a bit later. |
The semantics of .repositories() changed, as it was not possible to configure MIMA without remote repositories but sometimes you need that. Before, it always prepended Central. Also, there is new "op" what to do with provided list, when repositories discovered from settings.xml are considered as well.
Pushed fix, locally passes OK: in 2.4 I changed the Depending on intent here (I just guessed), in case |
Btw, resolver 2.0.0-alpha-2 just released, it introduces new HTTP/2 transport based on JDK 11 java.net.http.HttpClient (that is naturally dependency-less) and boosts around 20% in download perf when target (like Central) supports HTTP/2 (it does). Speed is pretty much same as "apache" transport when target is HTTP/1.1 (like some Maven Repo Manager....). MIMA will soon start supporting resolver 2.0.0 (probably in parallel with 1.9..x line) and once JBang upgrades to MIMA, following resolver updates will be trivial (just update MIMA). For JBang this may be interesting, as it drops requirement for ASF httpClient, jcl-over-slf4j... |
Can that be done in a way so when run on java 8 it will still fallback? |
btw. about: "Also, there is new "op" what to do with provided list, did we ever consider repos from settings.xml ? that wouldn't be what I expect...unless its purely for the case where no repos specified in jbang? |
Yes, mvn4 does exactly that:
The "jdk" transport is actually multi-release JAR that is "no op" on Java8: |
MIMA always did consider reposes from settings.xml, and I assumed this is what you want... IF that is not the case, OP.REPLACE needs to be set and then jbang "drives" (and reposes from settings.xml are neglected/replaced with those specifified in repositories). MIMA mimics what Maven does in a way: reposes specified in contextOverrides are like POM specified RemoteReposes, and are merged (op.PREPEND, the default) to those discovered in settings.xml. But, for flexibility, I added the "op" that can op.APPEND and op.REPLACE as well... if JBang does not want to care for settings reposes, it should use op REPLACE then... |
It's mainly for repos - default in jbang have been nothing spécified- we add central. If you specify something you control all the repos. I wonder if we should have a "magic" settings.xml repo name that lets user place it. Or a flag that says honor settings.xml... |
I'd consider wrong to not observe settings.xml defined reposes, but I can understand it can be overwhelming and why would someone want to ignore those. So, yes, exposing this on jbang (honor or do not honor reposes in settings.xml) with sensible default (i guess as current intent: ignore) would make sense. |
Rationale to not honor it is reproducibility/consistency to ensure that a jbang script will run the same by default. Totally get that it would be nice to honor settings repositories - but that I feel should be optin not opt out. |
...i'm being blind - where is it you say we should set this in this PR to not have repos from settings.xml included? |
It picks up latest Resolver 1.9.18 that causes less surprises to Windows users.
Here you are: (sadly spotless behaves very strange). |
@@ -52,7 +52,7 @@ rm -rf ~/.jbang/cache | |||
echo Testing with `which jbang` | |||
|
|||
## init ## | |||
assert "jbang init $SCRATCH/test.java" | |||
assert "jbang --verbose init $SCRATCH/test.java" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO can be undone, I think that was done early in this PR, probably had some issue so needed debug logs for resolver?
@@ -521,7 +521,7 @@ void testAliasWithRepo(@TempDir File output) throws IOException { | |||
" \"aliases\": {\n" + | |||
" \"aliaswithrepo\": {\n" + | |||
" \"script-ref\": \"dummygroup:dummyart:0.1\",\n" + | |||
" \"repositories\": [ \"http://dummyrepo\" ]\n" + | |||
" \"repositories\": [ \"https://dummyrepo\" ]\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is http now allowed anymore or ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is allowed (only HTTPS or HTTP) or not is matter of setup/config. For example if you have something like this in your settings.xml (user or system): https://github.com/apache/maven/blob/master/apache-maven/src/assembly/maven/conf/settings.xml#L160-L166 then HTTP is blocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just minor questions - all big important stuff looks resolved now!
Lets do this - thank you! @all-contributors please add @cstamas for code |
I've put up a pull request to add @cstamas! 🎉 |
Yay! 🎉 |
Re-use MIMA in ArtifactResolver, and properly handle repoSys shutdown.
About MIMA https://github.com/maveniverse/mima