Maven Multiple Module Projects

 

Multiple Module Projects

* See Multiple Module Projects for detailed instructions.

Setup Multiple Module Projects

* Create a new directory named step-by-step
* cd to the new directory
* Create a new Maven simple project:

  1.  
  2. mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse
  3.  

* cd to guide-ide-eclipse directory
* Modify pom.xml and change packaging value from jar to pom

  1.  
  2. <packaging>pom</packaging>
  3.  

* Issue Maven commands to build three additional child projects

  1.  
  2. mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse-site
  3. mvn archetype:create -DgroupId=guide.ide.eclipse.core -DartifactId=guide-ide-eclipse-core
  4. mvn archetype:create -DgroupId=guide.ide.eclipse.module1 -DartifactId=guide-ide-eclipse-module1
  5.  

* Steps 7 and 8 automatically done for you already with Maven 3.0.4
* cd to guide-ide-eclipse-module1
* Edit pom.xml to add dependency for guide-ide-eclipse-core

  1.  
  2. <dependency>
  3. <groupId>guide.ide.eclipse.core</groupId>
  4. <artifactId>guide-ide-eclipse-core</artifactId>
  5. <version>1.0-SNAPSHOT</version>
  6. </dependency>
  7.  

Check Into SVN

* Important! Check or import all projects into SVN before continue. For example, import step-by-step directory to SVN trunk
* Remove guide-ide-eclipse directory form workspace after it's been imported into SVN

Setup Eclipse SVN Repository Location

* Start Eclipse
* Select workspace directory, e.g. C:\work\sandbox\maven\eclipseplugin\workspace\step-by-step
* Install Subclipse if not already done

* Select Window > Show View > Other > SVN Repositories
* If not already done, add SVN repository where the project was checked in, e.g. file:///C:/work/sandbox/maven/eclipseplugin/svn

Checkout All Projects

* See this post on how to manually checkout multi module Maven projects from SVN.
* You'll need to add a classpath variable named M2_REPO to point to your local Maven repository.

Checkout Individual Project

* Setup SVN repository as shown in previous section
* From SVN Repositories view, right click guide-ide-eclipse-module1 and select checkout
* Select Checkout as a project in the workspace

* Go to the checkout directory, e.g. C:\work\sandbox\maven\eclipseplugin\workspace\step-by-step_2\guide-ide-eclipse-module1
* Issue following Maven commands:

  1.  
  2. mvn eclipse:eclipse
  3.  
  4. # If you want to download sources as well
  5. mvn eclipse:eclipse -DdownloadSources=true
  6.  

* From Eclipse, refresh guide-ide-eclipse-module1 project
* You'll need to add a classpath variable named M2_REPO to point to your local Maven repository, e.g. C:\Users\Jimmy\.m2\repository

* Final checked out Java project:

References

* Maven Eclipse Plugin
* Maven Eclipse Plugin: Usage
* Multiple Module Projects

This entry was posted in maven and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*