'Import new Maven module in Eclipse automatically

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


Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

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.

Solution 4:[4]

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'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Rabinowitz
Solution 2 Nikolay Ivanov
Solution 3
Solution 4 surajz