views:

465

answers:

4

I have a multi-module Maven project in a Subversion repository with many developers working on it with Eclipse + M2Eclipse. Now if a developer adds a module, others need to do an SVN update from the command line (as Eclipse doesn't see the common root of the Maven project), and import the new module manually as an Eclipse project.

Is there a way to do this automatically?

My project structure looks like this:

Working Copy                  Eclipse Workspace

working copy root   -X->
 +- parent          --->      +- parent
 |   \- pom.xml               |   \- pom.xml
 +- child1          --->      +- child1
 |   \- pom.xml               |   \- pom.xml
 +- child2          --->      +- child2
     \- pom.xml                   \- pom.xml
+1  A: 

You can have a pom in the root, that will have parent, child1, child2, etc as modules. After SVN update if there a new module was added, you can run

mvn eclipse:clean eclipse:m2eclipse

from the eclipse tools button (right of the debug and run buttons)

If you are using TortoiseSVN you can set a post-update client side hook, but each developer will have to set it independently.

David Rabinowitz
I think the original question was about the Eclipse plugin ( M2Eclipse ) , not thee maven-eclipse-plugin.
Robert Munteanu
There is no need to add a pom to the root to run a multi-modules build (and the OP is using a flat-layout to be able to update the parent pom.xml from eclipse I guess). The post-udpate client-side hook is an idea though but it wont solve the whole problem.
Pascal Thivent
A: 

May be buckminster project can help you check FAQ. Hope it helps

Nikolay Ivanov
A: 

Is there a way to do this automatically?

To do what? To avoid importing the new module manually as an Eclipse project? AFAIK, this is currently not supported, you'll have to add it manually (it should be possible to do it programmatically though, there is such a request for the Maven Eclipse plugin - MECLIPSE-75 - couldn't find one for Maven Intergration for Eclipse).

That said, does adding a module really happen so often? Your situation might be different but, to my experience, you'll reach a stable point quite fast and adding a module will become something unusual.

Nevertheless, good team communication is the best solution I found to deal with this. When a developer add a new module, it is a duty for him to let others team members know that he introduced a change and to describe the required steps to take the modification into account. Nobody is omniscient, nobody can read in others mind, active communication is the key to good collaboration.

Pascal Thivent
We are about to do a major refactoring on the product, and thus projects will come and go a lot in the coming months. There are a lot of developers working on the projects, and I wouldn't like these changes to stop them every time.
Lóránt Pintér
I've faced this situation on a project with more that 100 developers geographically distributed and, as I said, communication is your best weapon. That said, I still believe you'll reach a stable point relatively quickly.
Pascal Thivent
A: 

you can also use maven-eclipse-plugin

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
                <wtpversion>2.0</wtpversion>
                <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
            </configuration>
        </plugin>

refresh the project after importing it from svn

or you can also right click the project and click on 'enable dependency management'

surajz