Create the Firstcup Parent Maven Project
Contents
Now we will create our first Java EE project. In order to predefine maven dependencies and plugins, a parent project will contain a pom.xml file which defines all project scoped dependencies and plugins.
Switch now to the JBoss Developer Studio. Follow these steps to create the Firstcup Parent project:
Select File -> New -> Project ->Maven -> Maven Project
Because we will have two maven modules collected under this parent project, and one of it is a pure REST resource project, there is not much that is shared between the two projects. If you want to learn more about multi-module maven projects, see http://books.sonatype.com/mvnex-book/reference/multimodule-sect-simple-parent.html.
The first dialog after you selected to create a new maven project looks like this:
It is important that you activate the checkbox “Create a simple project (no archetype selection). After clicking on ‘Next’ you will see:
Enter your groupId and artifactId or just use the ones in the screenshot. Most importantly, select the packking type “pom”. This will make this project a parent project. Click ‘Finish’ and you are done. After the project was created, you need to modify its pom.xml file. Copy the following pom definition and overwreite the projects pom.xml with it:
<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.neuromechanics</groupId> <artifactId>firstcup</artifactId> <version>7.0.5</version> <packaging>pom</packaging> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <failOnMissingWebXml>false</failOnMissingWebXml> <version.jboss.bom>9.0.0.Beta2</version.jboss.bom> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.wildfly.bom</groupId> <artifactId>jboss-javaee-7.0-with-hibernate</artifactId> <version>${version.jboss.bom}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <pluginManagement> <plugins> <!-- The Maven Surefire plugin tests your application. Here we ensure we are using a version compatible with Arquillian --> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> </plugin> <!-- The WildFly Maven Plugin deploys your war to a local WildFly container --> <!-- To use, set the JBOSS_HOME environment variable and run: mvn package wildfly:deploy --> <plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>1.0.2.Final</version> </plugin> </plugins> </pluginManagement> </build> </project>
Pay particular attention to the ‘org.wildfly.bom.jboss’ groupId and corresponding artifactId of ‘javaee-7.0-with-hibernate’. This BOM defines versions for most Java EE libraries. When using in our parent project, we don’t need to specify version elements in the maven modules which we will later create under this parent project. Well, that’s not particularly true for the plugins for which we still need to specify version numbers. In general, using POM inheritance allows you to add common dependencies for universal dependencies like JUnit or Log4J to all submodules (which we don’t).
Later,when we create the two submodules, the above pom.xml will automatically be updated with these modules. They are put into a ‘modules’ XML element just like this:
<modules> <module>dukes-age</module> <module>firstcup-war</module> </modules>