views:

183

answers:

2

Hi All

I was wondering if someone knows a way to invoke a specific maven module build from IntelliJ that will also build ( or use already compiled classes ) from depended modules.

So for instance if I would like to build the module "Model" in the picture and only it , it seems reasonable for me to click the package step on it. But what is actually does it invokes the mvn package step inside this specific module rather than "mvn -am -pl module-name" from the root module , which also builds all the dependencies.

So is there something that I just don't know ?

alt text

+1  A: 

You know the mvn command line well! To put this command line into IDEA, right click on your root project, one of the options will be "Create ... [package]".

Make these edits:

  1. set the name to something like "Make Model [install]"
  2. In the goals box, enter your command line, i.e. "-am -pl model install"

I know these aren't strictly goals, but it seems they are passed directly to maven. (Tested in IDEA 9.0.1)

When you run this command, it will now make Model - and the modules it depends on. Equally useful is the "-amd" to make all dependent moduels to verify that changes to Model haven't broken other modules. Having to create Run commands is not quite as elegant as the built-in UI, but you can associate these commands with hotkeys for quick access.

Hope this helps! mdma

PS: A small aside. Package is currently your default build goal - this may not work as intended with multi-module builds, since the latest built classes are not accessible to dependent modules - using install as the default goal is recommended to ensure the most recently built versions of artefacts are used by dependents. If you're concerned that installing might add a broken artefact to the local repo and break all your local builds, use a separate local repo for each project (use a custom settings.xml.)

mdma
Thanks for the tip , I didn't know that I can use a custom repo for project builds.For the answer , I wanted to know if there is a integrated UI solution from the IDEA rather than creating a shortcut for each module.
Roman
As far as I know threre is no integrated solution as yet, but of course, someone might have created a nifty plugin to add "make module" and "make dependents" to the context menu on each module. I'll take a quick look to see what's involved.
mdma
A: 

I do it this way (Idea 8.1.4)

  • Open run dialog (shift-f10 on windows)
  • Click + and pick Maven to add a Maven build config
  • Fill in the form, adding
  • 1 working directory
  • 2 maven command line options
  • 3 maven goals
  • 4 profiles

This is no different than running from command line. Which is what I am assuming you want.

sal