On Wed, Mar 9, 2022 at 3:53 PM Nils Breunese <n...@breun.nl> wrote:

> Steve Hannah <st...@weblite.ca> wrote:
>
> > VSCode does let you execute phases,
> > but the "phase" model doesn't work well when you are working on
> > desktop application.  You expect there to be an action to "run" the app
> and
> > a separate action to "build" the app.
>
> I don’t generally work on desktop application projects, but I don’t think
> it should be fundamentally different from working on web server
> applications.
>
> The Maven build lifecycle, like the name suggests, is aimed at building
> projects. While a plugin goal might let you run something there is no
> specific build lifecycle phase for that. I generally let my IDE do the
> running, instead of involving Maven.
>
> But you can pass both a phase and a plugin goal to Maven to run something,
> for instance like this:
>
>     ./mvnw package spring-boot:run
>
> Or like this:
>
>     ./mvnw verify exec:java
>
> I don’t know about VSCode, but an IDE should generally know when to build
> a project (via Maven or otherwise) when you run it. Running the built
> project can also be done without Maven, which is generally what I do when
> not using an IDE:
>
>     Build: ./mvnw verify
>     Run: java -jar target/my-app-1.0.0-SNAPSHOT.jar
>
> >    Neither of those are in the
> > lifecycle.  What I typically do is bind the "run" to the lifecycle so
> that
> > it will happen if I do `mvn verify`.
>
> Maven let’s you do that of course, but semantically that is a bit of a
> hack, because the verify phase’s role is to ‘run any checks on results of
> integration tests to ensure quality criteria are met’ [0].
>
> By the way, Maven let’s you define a default goal [1], which can also
> include phases and you could set to something like ‘verify exec:java’, so
> that when you run Maven without specifying any specific phases or goals,
> that will be executed. Maybe that would be helpful for you?
>
> Nils.
>
> [0]:
> https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
> [1] https://maven.apache.org/pom.html#Build_Element



-- 
Steve Hannah
Web Lite Solutions Corp.

Reply via email to