12

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.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
empire29
  • 3,729
  • 6
  • 45
  • 71

4 Answers4

19

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

Project properties

The above will run:

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

Then it will become available under "Custom"

Custom Action

JScoobyCed
  • 10,203
  • 6
  • 34
  • 58
  • Today I'm so confused cause of this, I want to make custom actions too for my project but I don't know whats wrong when I try to add custom actions that new actions always disabled and I can't add execute goals. – muhkanda Jan 31 '22 at 07:39
9

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: Adding new Maven action button to toolbar

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.

Glenn Lawrence
  • 2,844
  • 1
  • 32
  • 38
7

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:

http://i.snag.gy/Ldjg3.jpg

Ev0oD
  • 1,395
  • 16
  • 33
  • Hi thanks a lot, your solution worked for me in NetBeans 8.1. – Ivan Marjanovic May 22 '16 at 11:28
  • THANK YOU! Great help! BTW. if you want to remove the global action (in 8.2), click "Hide from Toolbar" then "OK" and only then "Remove" or the icon will remain visible. If you forget, just create another action with the same name and remove it as described above. – tomorrow Oct 17 '18 at 21:04
2

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.

mkleint
  • 2,281
  • 1
  • 14
  • 17