Sunday, 31 July 2011

Creating a Multi-Module Maven Project


Install Maven plugin for Eclipse:
























Once the plugin is installed we can create a maven project like this:




















Click on Next; enter group id, artifact id, version and package; click Finish.























Now as we want to create modules inside this project, we need to change the packaging to pom. Refer screenshot.















Create a new maven module.




















Click on Next; enter package name and click Finish.

















Similarly create other modules like 'view' and 'controller'. The final pom file will look like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <groupId>com.jbasics.maven.example</groupId>
 <artifactId>mvc-parent</artifactId>
 <version>0.0.1-SNAPSHOT</version>

 <packaging>pom</packaging>
 <name>mvc-parent</name>
 <url>http://maven.apache.org</url>

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>

 <dependencies>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 <modules>
  <module>model</module>
  <module>view</module>
  <module>controller</module>
 </modules>
</project>



No comments:

Post a Comment