Maven: How To Create a New Maven Project

Maven: How To Create a New Maven Project


This document will walk you through creating a new project with Maven.  You'll only need to go through this process once per project, at its inception.


This document assumes that you have done this: How-To: Install Maven  and properly set up: settings.xml - For Licensed Customers and Partners.  It assumes you have secured access to the Jive Maven repository, and have a local SVN repository for your own customizations.

If you are reading this document to get some information about joining an existing maven project, start with Step 4 after checking out the existing project.

Step 1: Create a new base project

New project templates in Maven are called archetypes.  You will want to run the archetype in the top level directory where you store your projects. For example, if you store your code in~/code you'll cd into that directory.

Run this command (with the 3 substitutions listed below):

mvn archetype:create -e -DarchetypeGroupId=com.jivesoftware.maven -DarchetypeArtifactId=maven-jive-plugin-archetype -DarchetypeVersion=4.0.x-SNAPSHOT -DgroupId=com.jivesoftware.dummycustomer -DartifactId=dummyCustomerSite 

groupId The namespaced group where this project should live.  e.g.
artifactId The name of this project, e.g., openPort

The -DarchetypeVersion property should reflect the major version of Jive you are using.  Use the following table to determine what the value of the property should be.

Jive Version
-DarchetypeVersion value
Do NOT modify the value to reflect the current point release of Jive that you are using.  The values listed above should be included exactly as they appear.

To specify your exact version, you will want to edit, for example, the element  <jive.version>5.0.1</jive.version> in the pom.xml generated. 
If you've configured your settings.xml file correctly, Maven will download all that it needs and complete without error. You will have a nice new folder called "dummyCustomerSite" in your current directory.

The primary reason this step might fail is if you haven't put settings.xml in the right location, namely the ~/.m2 directory.  This file does NOT go alongside your source code.  See settings.xml - For Licensed Customers and Partners for the exact location, especially if you are using Windows.

Step 2: Add plugins

Any time you want to add a new plugin, you will run the following command from within your new project directory.  In the above example that would be from within "dummyCustomerSite".

mvn archetype:create -e -DarchetypeGroupId=com.jivesoftware.maven -DarchetypeArtifactId=maven-jive-plugin-archetype -DarchetypeVersion=4.0.x-SNAPSHOT -DgroupId=com.jivesoftware.module1 -DartifactId=module1

groupId the namespaced group where this project should live.  e.g.
artifactId the name of this plugin e.g., virus-scan

Again, refer to the table above to determine the value for the -DarchetypeVersion property.

Instead, to specify an exact version, edit the generated pom.xml  <jive.version>5.0.1</jive.version> as above.

Maven will register the plugin with the root pom.xml so if you run package or compile from the root directory, the child plugin will be packaged as well.

Step 3: Add to SVN

export SVN_EDITOR=vi (for Mac/*nix) OR set SVN_EDITOR=edit (for Windows)

svn mkdir -m "setup"<customer-project>

svn import -m "importing original project" .<customer-project>/trunk

svn mkdir -m "setup"<customer-project>/branches

svn mkdir -m "setup"<customer-project>/tags

<customer-project> The name of your customer project

When the editor appears, add a comment and then write and quit

svn co<customer-project>/trunk/ .

svn propedit svn:ignore .

  • Your editor will appear.  Add the patterns you want to get rid of, like:






Step 4: Set up your database

Your default development database should be PostgreSQL.  If you have it installed, it should be straightforward for you to manually create a new database from the command line or pgAdmin.

The database name must be the format <artifactId>-<customer.version>.  For example, dummyCustomerSite-1.0-SNAPSHOT.  Encoding UTF8 is recommended.

Step 5: Build your project

Step 6: Generate IDE project files

See the steps here Maven: How to use with IDEA