Invoking Actions other than Build and Clean & Buil

2020-02-05 03:56发布

问题:

I am new to NetBeans and am trying to define and run various custom goals for my Maven proj. My Maven proj uses a number of plugins; once for building the Java classes, another for pre-compiling JSPs, another for building an OSGi bundle, and another for deploying to my dev app server.

It seems that by default, NetBeans has Build, and Clean & Build as easily accessible "build options" in the main toolbar bar. These trigger the install goal which runs through the entire build processes (compiles everything and deploys to my dev).

In NetBeans, I can edit the Properties for the project, and define a "development" profile, and then define custom actions (or modify the default NetBeans actions).

How do I:

  1. Invoke Actions that aren't Build or Clean & Build in NetBeans

  2. Define only certain goals for specific plugins to run, and invokes those actions.

回答1:

First go to the Project Properties > Actions and create your MVN build

The above will run:

mvn install -P initdb,initdb-qa -DskipTest=true -Dprop.name=dev

Then it will become available under "Custom"



回答2:

This is really just a comment on @Ev0oD's answer, but I want to add an image so it has to be a separate answer.

After I created the toolbar button using:

Tools -> Options -> Java -> Maven -> Execution -> Edit Global Custom Goal Definitions

I then had to add the button to the toolbar using:

View -> Toolbars -> Customize (or just right click the toolbar header and select Customize)

I could then see the new button in the "Maven" group in this dialog:

I then had to drag the button onto a toolbar as shown. Note: Don't try to drag it to the blank part on the right of the toolbar header as this won't work.



回答3:

If you want to use some custom goals on more projects and you want to have a quick access to them, you can use global custom goals, that are present in NetBeans 8.0.1 (not sure in which version they were introduced).

Access Tools -> Options -> Java -> Maven -> Execution -> Edit Global Custom Goal Definitions...

There you can add many of these and they will be present for all projects in the Custom section, as shown in the accepted answer.

A good thing is you can add it also to the Toolbar by clicking (Show in toolbar) and selecting one of six different colors of icon available. You will end up with something like this:



回答4:

alternatively you can use the Custom popup on project node and within the Custom... action's dialog, setup goals for execution and eventually remember the setup for subsequent executions. The remembered item will appear in the same popup menu. For global (for every project) goal definitions, please see the global options.