Introduction
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.
Assumptions
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
Substitutions
groupId
| The namespaced group where this project should live. e.g. com.jivesoftware.intel
|
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
|
---|
5.0.x | 5.0.x-SNAPSHOT |
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
Substitutions
groupId
| the namespaced group where this project should live. e.g. com.jivesoftware.intel
|
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
- 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
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 wack the originals because they
are not versioned. If you ran an update it would complain ". is not a working copy"
-
Check out your newly imported project from Subversion into a blank base customer directory,
e.g.
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:
target
projectFilesBackup
dummyCustomerSite.iml
dummyCustomerSite.iws
dummyCustomerSite.ipr
.DS_STORE
-
Do a svn commit to get your svn:ignore properties to change. e.g. 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
UTF8 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 OK 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
See the steps here
Maven: How to
use with IDEA