A more IDEA-like model for making multi-module Maven projects

IDEA is surely the greatest thing since sliced bread.  Maven is pretty darn good too.  Why don't these two great tastes taste great together?

Most projects have more than one artifact, thus multi-module Maven builds are the norm.  IDEA is very smart about handling projects with multiple *IDEA* modules.  You hit CTRL-F9, and IDEA figures out which projects have had source changes since the last compile, those modules are compiled in order and no more.

Why doesn't IDEA do the same thing for Maven modules?  What IDEA should do is determine which open Maven modules have source changes since the last installed version in the local repo, compile *and install* those artifacts in the local repo.  (If intall doesn't occur, dependent modules will fail to pick up changes).

The current model is ridiculous, especially by IDEA standards.  Developers have to follow in their minds which projects own the source files that have changed, carefully select those project's install targets, in order, and run them.  I have a multi-module Maven build with ears, wars and Flex components with 30 Maven modules - for starters.  The current model is unworkable.  The workaround is to build everything or large swaths of everthing which takes forever (especially when working with Flex - no fault of IDEA's).  Another workaround is to add Maven builds with -amd switch and -pl list, the options of which will change day to day or hour to hour depending on what you are working on (and there's no way to assign keystrokes to these build AFAICT).

Am I missing something or did IDEA miss the boat on Maven integration?

A quick fix would be an option in the Maven settings that default all Maven makes to do install instead of package, but smart time-checked dependency checking is the right thing.

Michael Bushe
Principal
Mindful Software
mindfulsoftware.com

5 comments
Comment actions Permalink

My understanding of the maven support in (version 9) is that each maven module is imported as an Idea module. Idea then manages the inter-module dependencies on its own, i.e. you don't need to do the maven install to have up-to-date dependency artifacts.

This worked quite well for me so far. You just need to have all the modules imported with the right versions and IDEA will manage the dependcies.

Wallaby

0
Comment actions Permalink

Are you importing the Maven multi-module or are you importing each Maven module separately.

I have many Maven multi-module projects, one with 33 modules in it.

I import the Maven multi-module, and IDEA imports all the others. Changes in one module are seen in the other modules.

When I run unit tests in one module, it picks up the changes in the other modules because IDEA looks at the classes directories of the other modules not the jar files.

Would be interested to know how you are configuring your projects in IDEA that are giving you these problems.

0
Comment actions Permalink

Michael, please create a YouTrack issue and attach a sample project that shows the problem.

Thanks.

0
Comment actions Permalink

Sorry for the slow response, I asked the question then went on vacation.  :-)

The replies are correct - if you have Maven poms that build Java classes then IDEA points to the latest classes and knows about dependencies between projects and everything is hunky-dory.

The problem arises if a pom uses the actual jar'ed artifact and not just loaded classes.  Some common example when this arises:

- The pom uses the maven-assembly plugin, which pulls the packaged artifact from the repo from one Maven project into (usually) the target of the depending project.  This could be used for resource bundles, OSGi bundles or configuration properties.
-  The pom is a war or ear pom that deploys the packaged jar.
- (My case) The pom is a flexmojo's pom that builds a Flex swc (Flex library)  or Flex module (swf) that a Flex application loads at runtime as a unit.  In Flex, classes are loaded in a bundle (swf or swc).

I'll create the YouTrack.

Michael Bushe
Principal
Mindful Software
mindfulsoftware.com

0

Please sign in to leave a comment.