Task 5: Creating a Maven Project Manually

The simplest way to create a Maven project is to create a new directory and create a pom.xml inside of it. Once you've determined the dependencies and plugins you want to use, you'd add them to the POM.

Since Maven is all about convention over configuration, it provides a lot of default settings for you. All projets extend from a Super POM provided by Maven which sets sane and standard defaults. The combination of your project's POM along with the Super POM combine to form an Effective POM. You can view this POM by , using the effective-pom goal from the help plugin.

Create a Simple Maven Project

To create a simple Maven project named hello, do this:

prompt> mkdir hello
prompt> cd hello

In your new hello directory create the file pom.xml with the following contents:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>hello</artifactId>
  <version>1.0.-SNAPSHOT</version>
</project>

To view the effective POM (or "super POM") for a project:

prompt> mvn help:effective-pom
...
Effective POMs, after inheritance, interpolation, and profiles are applied:
...
<project xmlns="http://maven.apache.org/POM/4.0.0" ... >
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>hello2</artifactId>
  <version>1.0-SNAPSHOT</version>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
...lots more...