History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: MNG-1916
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Nils Fredrik Gjerull
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven 2

Making it possible for plug-in to add modules to the reactor programatically

Created: 03/Jan/06 02:01 PM   Updated: 24/Jun/07 08:24 AM
Component/s: Plugin API, Reactor and workspace
Affects Version/s: None
Fix Version/s: 3.0

Time Tracking:
Not Specified

Complexity: Expert


 Description  « Hide
I would like to be able to specify a number of directories as plug-in directories, automatically discover every plug-in in those directories and include them in the reactor. As I understands it the reactor with it's modules (org.apache.maven.execution.ReactorManager) is created in org.apache.maven.DefaultMaven. If I understands this correctly maven plug-ins can't add projects to the reactor programatically.

My proposition to solve this is to add a phase which will be executed after the pom.xml is parsed, but before the information stored in Model/MavenProject is used, and most importantly before the ReactorManager is created. Then you can add information to the MavenProject programatically, increasing the flexibility for plug-ins.

I am not fluent in the maven2 code base, but it seems to me that this require quite a lot of changes to the code. As I understands it the life cycle starts after the ReactorManager is made, and therefore after the information in Model have started to be used.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Brett Porter - 03/Jan/06 04:43 PM
"it seems to me that this require quite a lot of changes to the code".

This is correct. We should be discussing the problem, not the solution. I don't think programmatic addition of modules is the right answer.

"would like to be able to specify a number of directories as plug-in directories, automatically discover every plug-in in those directories and include them in the reactor."

So what you'd like to have is wildcarded <modules> ?


Nils Fredrik Gjerull - 04/Jan/06 06:48 AM
Wildcarded <modules> would certainly help. As commented in issue MNG-1915 I am working on making a maven2 plug-in for JPF. This is the reason I would like to specify a number of directories and have all subdirectories containing jpf plug-ins included in the reactor.

I would like to have more fine grained control of which of this subdirectories should be included. One example would be to only include directories containing pom.xml, plugin.xml and plugin-fragment.xml files. This is however not essential, so wildcarded <modules> would probably do the trick.


Kenney Westerhof - 22/Jun/07 05:09 PM
Are you talking about just adding modules (maven 2 projects) to the reactor, or are you talking about maven2 plugins?
For now I'll assume that 'plug-ins included in the reactor' means 'modules included in the reactor'.

So, what's the problem with adding module sections for your modules manually?

Can't profile's be used, activating on the existence of a file, and adding a module there? You'd have to specify 1 profile per module though.

solution 3: write a replacement component for the core and put it in $M2_HOME/extensions, that'll do a workspace scan for your files and add the modules
to the proper pom, or just add them to the reactor.

solution 4: write a plugin, and create a pom that uses that plugin. The plugin will fork a new maven build with whatever set of projects you like.
Take a look at the maven-it-plugin in the sandbox, it basically does the same thing: it runs src/it/*/pom.xml.

I think having <modules>*/</modules> will cause too much problems. Right now, m2 will quit if you specify a module dir that doesn't have a pom.xml,
so that behaviour must change. Further, i think you only want to add directories as modules that contain a certain file. That would require an extensive
change to the pom. Even extensions won't work here, since you cannot alter the reactor once it's running.


Nils Fredrik Gjerull - 24/Jun/07 08:24 AM
I am actually speaking about two different kinds of plug-ins one is the maven plug-in, the other kind of plug-in is the Java Plug-in Framework (JPF) plug-in. Your are right in writing that JPF plug-ins is the same as a maven module. A bit confusing use of terms there.

What I wanted to do was to have one master module and several sub-modules. First the sub-modules would be built, the maven life-cycle would run until the package phase. In the integration-test phase all the sub-modules should be moved into the target directory of the master module. The essence is that a JPF program need a number of sub-modules to be able to run. It need a bootstrap module and a set of core JPF plug-ins.

Is there a way to make the master module run the build process for every sub-module until the package phase and then take over the control?