Maven: Creating new project

This is a walk through creating a new project with Maven. You only need to go through this process once per project, at its inception.

Assumptions

This document assumes that you have followed instruction at Maven: Installing and properly set up settings.xml as described in Maven: 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 
Table 1. Substitutions
groupId The namespaced group where this project should live, for example, com.jivesoftware.intel
artifactId The name of this project, for example, 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
5.0.x 5.0.x-SNAPSHOT
CAUTION:
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 can 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. For the exact location, especially if you are using Windows, see Maven: settings.xml for licensed customers and partners.

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
Table 2. Substitutions
groupId The namespaced group where this project should live, for example, com.jivesoftware.intel
artifactId The name of this plugin, for example, 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

First you want to make sure your project is clean, so run mvn clean from the project root (top level). Next, import your project to SVN:

export SVN_EDITOR=vi (for Mac/*nix) OR set SVN_EDITOR=edit (for Windows)
svn mkdir -m "setup"  https://svn.yourserver.com/svn/<customer-project>
svn import -m "importing original project" . https://svn.yourserver.com/svn/<customer-project>/trunk
svn mkdir -m "setup"  https://svn.yourserver.com/svn/<customer-project>/branches
svn mkdir -m "setup" https://svn.yourserver.com/svn/<customer-project>/tags
Table 3. Substitutions
<customer-project> The name of your customer project

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

  • Delete the base directory you've created. After running the import you need to remove the originals because they are not versioned.  If you ran an update it would return an error like ". is not a working copy".
  • Check out your newly imported project from Subversion into a blank base customer directory, for example:
    svn co https://svn.jivesoftware.com/svn/ext/customer/<customer-project>/trunk/ .
  • Storing your IDE project files in SVN is a bad idea, and will lead to confusion.  Tell Subversion to ignore IDEA files and target directories from the base directory:
    svn propedit svn:ignore .
  • Your editor will appear.  Add the patterns you want to get rid of, like this:
    target
    projectFilesBackup
    dummyCustomerSite.iml
    dummyCustomerSite.iws
    dummyCustomerSite.ipr
    .DS_STORE
  • Do a svn commit to get your svn:ignore properties to change. For example, svn commit . -m "Ignore the junk"
  • Now do the same from your ./web directory and any of your plugin directories, to avoid putting junk into SVN.

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 UTF-8 is recommended.

Step 5: Build your project

The very first time you build your project, use the following command from the top-level project directory: mvn -Djive.setup=false install. This will force you into the Jive setup screens the next time that you start the app server.

Note: It's alright to run mvn clean install your project root. You'll never be forced into the setup screens again, unless you build from the top with mvn -Djive.setup=false install.

For subsequent builds, it may only be necessary for you to build at the web or plugin levels by using mvn clean package within the module's directory. If you want to build multiple plugins and web at once, run mvn install from the top-level directory.

Step 6: Generate IDE project files

For information, see the steps at Maven: Using with IDEA.