-
Notifications
You must be signed in to change notification settings - Fork 861
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
Maven project reload implementation #7655
Conversation
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.
Looks sane to me.
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.
adding my obligatory: "I don't like priming" comment ;) It is too much IDE magic, projects could be primed by running a goal (with log showing in the output window IMO, e.g dependency:go-offline
).
Features like priming or the invasive compile-on-save are from times when build tools like maven were lacking features (and times without mvnd and before NVMe).
NB is also currently breaking mvn 4 split repos during project initialization #6190, I never had time to look into this unfortunately so far.
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Show resolved
Hide resolved
Yes, this is in the queue. It's just I/we need 'wait-for-pending-load' earlier. Priming is not necessary soldified by this API semantics as the declared quality "RESOLVED" in this API only asks to make dependencies available "somehow". |
I share @mbien concerns with priming, and think your queue priority might need a rethought. But what's the intended use cases here? No loads / reloads without user interaction? eg. executing |
java/maven/src/org/netbeans/modules/maven/queries/MavenReloadImplementation.java
Outdated
Show resolved
Hide resolved
Basically "any operation that I need a certain project state for". You may be satisfied with project dependencies from the last-read state .... or you'd like to get current dependencies even though it means wait for reload. At the moment, one cannot check & wait after new After POM modification (i.e. adding dependency, adding a plugin/configuration), one better wait for the model to (re)load before doing further actions or inspections. Similar for build.gradle At the moment, we do not have such indicators/functions - or partially and unique in each gradle/maven/ant, and there are already implementations that fork branches based on project type or ignore the condition in a hope it "will work somehow" ... and it usually does, but exhibits time-related bugs right after modification or checkout.
I'm lost, can you be more specific ? |
Thanks! I'm concerned about introducing anything that might auto-execute the build tool without warning, particularly but not exclusively if the projects aren't trusted. It should be clear when any operation results in tool execution. I can understand the need to reload with POM modification, but that shouldn't happen auto-magically. With that comment, I particularly meant making sure we don't get into a situation like with the need to add a warning in the Micronaut wizard that was downloading and executing any old
That depends on who the "we" is that needs this feature! 😉 Most of us are putting our spare time into this. |
Note: currently one could execute ACTION_PRIME with the same effect... and Maven does not implement trust concept, at the moment. This API contains a flag to mark the project trusted ( processed by the implementation), so if Maven impl some day implements trust checks, it will be able to fail the request with a documented status.
The fact is, that POM reload already happens mostly automagically, for all opened projects. Maven module itself schedules a reload on the background as well as Gradle. But an observer/client lacks a handle to wait for that schedule to complete. This API does does not do that on itself though - it needs "someone" who requests a refresh.
Maven / Gradle display at least cancellable progress indicator. The implementation is free to prompt the user (i.e. Maven impl might be changed to prompt before launching the priming build, since at that time, it already knowns some artifacts are missing). BTW - neither gradle or maven does do that atm when doing "priming" or "full_online" load. If one requests NbGradle.Quality.FULL_ONLINE on a trusted project, it will happily download all the world.
Yeah, I realized that while you were replying and ashamed deleted the comment. sorry. @neilcsmith-net ... as I am replying, I am getting a feeling that the API does not actually make things more "automagic", but the discussion abot it itself surfaces some areas that are automagic already for years. It seems to me that the API just formalizes actions .... and we can discuss (even separately) what policies should be set up (and then enforced by the API core). |
No worries! 😄 Yes, I know there's quite a bit of reloading going on already. I guess the thing that concerns me is that ideally we should be delegating to the build tool execution more as @mbien says, but then it opens up more concerns with the things we're doing auto-magically executing things we have less control over?! When I did the initial
That's just making me think that the base API implementation is possibly the place to have a (possibly pluggable) UI that all requests go through. |
Re.: trust - Maven is in a little better than gradle here. As maven is declarative (with exceptions of scripting plugins), the malicious artifact would have to be signed + come from a plugin repository .... so if
Gradle is bad, since the build.gradle checked out from a random git is executable itself with no sanbox and fs access, so trust needs to be tight. In fact I originally had a prototype of ProjectTrust ;)) similar to Gradle that would just mark a folder (or its parent) as 'trusted' + TrustProvider SPI that could (based on its own logic) make a project (folder) trusted. But I shelved into the work queue :) IMHO these policymaking discussions should happen on mailing list perhaps to get broader attention. I would like to trim down the discussion in this PR just to things that the API (or its maven impl) makes "more open" than they are now (IMHO: none, as things like priming or force-maven-load can be done with Maven friend apis even now)
|
yep. I wanted to do that between releases since it is a broader topic where priming is only one aspect, but since this here is fresh i quickly wrote it down today: https://lists.apache.org/thread/lgfvt0649rlg83j46bcczxj30y87qh95 |
OK, I would like to focus the PR discussion back to what this PR's code does. The API itself does not say "how" (that's up to the implementation), just gives the client a way to request a certain project state - and blocks the operation (failed The Reload API implementation in this PR now does just what would be done if the code was maven module's friend and used the existing friend APIs. We should still (elsewhere) argue if there should be a defined policy, or what that policy should be and why. But it's out of scope of this PR I think, since it does not introduce anything not done already - it actually hides the details behind an abstract API. |
Fine from my perspective. I think the issue of making things explicit and controllable is better handled in (a possibly future iteration) of |
java/maven/src/org/netbeans/modules/maven/problems/MavenModelProblemsProvider.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/queries/MavenPrimingReloadImplementation.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/modelcache/MavenProjectCache.java
Outdated
Show resolved
Hide resolved
88d86d3
to
6ea5e5e
Compare
Last call ... will merge Maven impl as soon as I resolve the conflicts. |
65680f2
to
9bda082
Compare
Squashed + rebased on the API PR (merged to master). |
9bda082
to
4149b28
Compare
saw this after merging something to master:
https://github.com/apache/netbeans/actions/runs/10592522502 |
@mbien thanks; will try to stress-test and fix. |
Followup to #7651, implementation for Maven.
The implementation adapts maven internal project reloading to project reload SPI. It reports broken projects, project with missing dependencies and performs priming build to resolve the dependencies.