views:

955

answers:

1

I've been reading about maven reactor and am confused by its terminology usage. I've read the a multi-module is a reactor, that you can manipulate the maven reactor and that the reactor is a plugin. What exactly is the reactor?

I've also noticed a strange, seeming non-correlation of the use of the [reactor] tag here on SO.

+10  A: 

The reactor is the part of Maven that allows to execute a goal on a set of modules. As mentioned in the Maven 1.x documentation on multi-modules builds (the reactor concept was already there in Maven 1.x), while modules are discreet unit of work, they can be gathered together using the reactor to build them simultaneously and:

The reactor determines the correct build order from the dependencies stated by each project in their respective project descriptors, and will then execute a stated set of goals. It can be used for both building projects and other goals, such as site generation.

As explained, the reactor is what makes multi-modules build possible: it computes the oriented graph of dependencies between modules, derive the build order from this graph (that's why cyclic dependencies are disallowed, which is good thing anyway) and then execute goals on the modules. In other words, a "multi-modules build" is a "reactor build" and a "reactor build" is a "multi-modules build".

In Maven 2.x, the support of multi-modules build has been very much improved and the reactor became something transparent to Maven users. But it's still there and is used under the hood.

In September 2008 (i.e. a long time after the rollout of Maven 2), a reactor plugin has been created to make it possible to interact (again) more closely with the Maven reactor. Brett Porter blogged about it in Reactor: My New Favourite Maven Plugin.

Most of the reactor plugin features are now natively supported (since Maven 2.1.0). See Maven Tips and Tricks: Advanced Reactor Options.

Pascal Thivent
I couldn't have asked for a better answer!
harschware
Thanks. Glad you found it useful.
Pascal Thivent