Le mer. 9 mars 2022 à 23:48, Nils Breunese <n...@breun.nl> a écrit :

> Steve Hannah <st...@weblite.ca> wrote:
>
> > I'm trying to achieve better integration into VSCode with my project
> > archetype. The way that the VSCode maven extension seems to prefer to
> work
> > is for users to explicitly "run" a goal from a plugin of the project.
> >
> > You can see the VSCode instructions for running a JavaFX app as an
> example
> > here:
> >
> https://code.visualstudio.com/docs/java/java-gui#_run-the-javafx-application
> >
> > Basically, the user expands the Maven > Project > Plugins > JavaFX node,
> > then right clicks the "javafx:run" goal, which is defined in the JavaFX
> > maven plugin.
> >
> > In the JavaFX example, that javafx:run goal actually spawns a new process
> > that runs the app, which seems to break debugging.
> >
> > With my own projects, I generally bind my "Run" goal to the "verify"
> phase
> > so that running "mvn verify" will run my project.  This work OK in
> IntelliJ
> > and NetBeans (although I need to do some contortions to make debugging
> > work), but doesn't seem to mesh with VScode's way of doing things.
> >
> > What I would like is to create a custom "run" goal in my plugin so that
> > VSCode can run or debug this goal - and the goal should trigger
> everything
> > up to the "verify" lifecycle - without having to spawn a new process.
> >
> > I've been hitting walls in maven for years now, and I have a feeling that
> > this is not possible.  Can someone either set me straight (i.e. inform me
> > that it is possible), or confirm that, indeed, it is not possible?
>
> The Maven build lifecycle consists of phases [0] and you can bind plugin
> goals to phases. As far as I know it doesn’t work the other way around, so
> you can’t make a plugin goal execute particular phases, which seems to be
> what you’re asking. It should be the other way around: you can associate a
> plugin goal with a phase and then when you execute that phase all previous
> phases will have been executed, and your plugin goal will be executed.
>

This is not entirely true. A mojo can be annotated with @Execute() to
execute a lifecycle up to a given phase before the mojo itself is executed.
That's the difference between jar:jar and jar:jar-no-fork for instance.

>

Reply via email to