Build jGuard with Maven 2

Last modified by RaffaelloPelagalli on 2008/07/31 15:46

Build jGuard with maven 2

since 1.0 series, jGuard use maven 2. you have to download the latest maven 2 archive, install it, and create a MAVEN_HOME variable. this variable need to be referenced too in your operation system PATH.

system variables required

  • a M2_REPO variable pointing to your maven 2 repository need also to be created.
  • a JAVA_4_HOME variable is needed pointing to your jdk 4(1.4) home
  • a JAVA_5_HOME variable is needed pointing to your jdk 5(1.5) home

define the settings.xml

jguard needs to use a java 4 and a java 5 compiler to build its sources. to bound the variable defined in the related pom.xml files, you have to insert into your maven2 settings.xml(located into your ~/.m2 directory) file the corrresponding variables.

<?xml version="1.0" encoding="UTF-8"?>

tip: before set the M2_REPO var run the install procedure. The maven2 will download all requires libraries to your local repository (located at user home dir) from some remote maven2 repositories configured. one is set by default to

to test if maven 2 is correctly installed, you need to test this code:

mvn -version

you should have a response like this:

Maven version: 2.0.4

Install jGuard

to build jguard with tests, simply execute on project jguard:

mvn install
it will automatically build projects from jguard: jguard-core, jguard-ext, … if you want to skip the tests during build, execute
mvn install -Dmaven.test.skip=true

you can install jguard on maven with a specified profile (for example called 'distribution'):

mvn install -Pdistribution
you can not build one module separatly, each module is part of a single project jguard. A build is successfull if every jguard sub-project builds successfully.

how it works under the hood

jGuard declare some dependencies in its maven2 configuration files: so, maven2 will look into its local repository.

if it does not found the required jar, it tries to download automatically the related jar from remote repositories. if it succeed, it imports it into the local repository.

more details on maven2 at you can also download freely a great pdf book on maven 2 provided by mergere, and written by vincent massol and jason van zyl:

Run tests

to run tests on jguard projects, run

mvn test
to run tests on one jguard module only, you have either to run the junit tests from another tool (eclipse for example), or launch the maven command directly at the root of the module.

to highlight some stack traces thrown by unit tests on the console, you have to launch this command:

mvn -Dsurefire.useFile=false test

test jguard-swing-example

mvn exec:exec -e

test wars on jetty application server

mvn org.mortbay.jetty:maven-jetty-plugin:run

activate traces

maven 2 can generate more trace for a better understanding of what's under the hood. to activate trace, you can add to your maven 2 command the -e parameter.

mvn -e install

Release jGuard bundle for sourceforge purpose

to create a new release of jguard, run

mvn"Builder name" assembly:assembly -Pdistribution
it builds the project with your user name, generates the javadoc, and create a tar.gz, a tar.bz2 and a zip containing the jars and wars, the sources and the docs. this instruction refers to the profile called distribution, which points to the assembly descriptor (for example distribution-all.xml).

another way to do it, less flexible but more direct, is to run:

mvn"Builder name" assembly:assembly -Ddescriptor=src/main/assembly/distribution-all.xml

to use the distribution-all.xml assembly descriptor.

Create jGuard bundle for maven repository purpose

to release jGuard on a maven repository, we need to create an upload bundle with this command:

mvn"Builder name" source:jar javadoc:jar repository:bundle-create

like this maven plugin doesn't support multi-modules project, we need to create a bunsle for each module.

Install some libraries directly in your local repository

sometimes, you cannot grab libraries from remote repositories, for legal reasons. you can directly install libraries on your local repository with this command:

mvn install:install-file -DgroupId=~~yourGroupId~~ -DartifactId=~~yourArtifactId~~ -Dversion=~~yourVersion~~ -Dpackaging=jar -Dfile=~~path/to/your/file~~

generate an html output of the docbook documentation

mvn -e docbkx:generate-html

generate the pdf output of the docbook documentation

mvn -e docbkx:generate-pdf

build the related maven site

mvn site

deploy the artifacts of the release on our remote repository

mvn deploy

sometimes, username and password bound to the remote repository (present in settings.xml) are note detected by maven2. you can fix it with this command:

mvn deploy -Dusername=yourSourceforgeUserName -Dpassword=yourSourceforgePassword

note that only jGuard members granted to upload some content on the jguard filesystem on sourceforge can do this operation.

deploy the site on sourceforge

mvn site:deploy
Created by diabolo512 on 2006/06/25 00:12

jGuard team copyright 2004-2009