MavenTutorial

From Java CoG Kit

Jump to: navigation, search

Contents

Multi-module development--Local Repository Vs. Remote Repository

Precompiled versions of the cogkit are stored on our Maven Repository server at www.cogkit.org/maven/repository. This enables third party developers to use the Java CoG Kit easily, though it can create some problems with CoG Kit developers working in more than one module.

Say you are working in two modules, util and cogkit-core. You make the changes in util then you cd to cogkit-core and issue an mvn package assembly:assembly. Maven will NOT know about the changes you've made in util even though it is a dependency. Instead, Maven looks to the local repository, finds an older compiled version of util and uses this to compile the cogkit-core package. In order to make the changes you make in one module available to others you must issue an mvn install (changes only available on your machine) or mvn deploy (changes pushed to remote Maven Repository)

Adding a Module

Common Maven Targets

Brief descriptions of common Maven targets are listed below. Here, 'root' refers to the directory that contains all the submodules of the project and the global pom.xml. If things were checked out as described in section , then this will be the org-cogkit directory.

mvn clean

Deletes all target directories (compiled code).

This command may be issued inside a module to clean that module only or at the root to clean all modules.

mvn compile

Compile classes and place them in the target/classes directory.

This command may be issued inside a module or at the root.

mvn package

Creates a jar file containing the compiled classes of the module. This jar will not contain any dependencies so will not be able to run on its own.

This command may be issued inside a module or at the root.

mvn install

Calls mvn package to create the jar, then installs this jar into the local Maven repository. The pom.xml, containing the metadata about the jar's dependencies is also installed in the local repository.

This command may be issued inside a module to install that module only or at the root to install all modules.

mvn assembly:assembly

This command creates a directory and several archives suitable for distrbution. They contain the compiled class files of the module in their own jar, all dependent jars, all the modules resources, its dependencies' resources, and any of the module's scripts.

In general you ONLY command this command as follows: mvn package assembly:assembly as it tends to fail without the package target (this may be a bug).

This command should ONLY be issued inside a module and NOT at the root.

Continuum Integration Server

The Continuum Integration Server from Apache is a continuous integration server that is integrated with Maven. Continuum is easy to setup and runs/compiles/executes any maven target on a regular basis, generating and saving results of these compilations. This is just like the nightly builds of the ant build system.

Setting up Continuum--Linux

  1. Ensure that you have Maven installed and it is in your path (and the path of the user that will be running the server).
  2. Download the package from Apache.
  3. Unzip the archive.
  4. cd to 'continuum-1.0.*'
  5. sudo bin/linux/run.sh start
  6. Wait several minutes
  7. Access the Continuum server by going to http://localhost:8080/continuum/ or specify the actual hostname if it is running on a remote machine.
  8. Complete the setup specified on the screen. You will have to create three directories on your machine (build, working, development) and provide these directory names to the continuum server (this is described on the setup page).
  9. After the setup, login.
  10. Click the Add Project --> Maven 2.0+ Project Button
  11. Enter the following URL in the M2 POM Url field: http://svn.sourceforge.net/viewcvs.cgi/*checkout*/cogkit/trunk/five/pom.xml
  12. After clicking submit, you should see a page with the CoG Kit Project and all the sub-modules listed.
  13. Click 'Build Now'
  14. This will take some time as the sources are downloaded and built. Refresh or click on the 'projects' button to see an update of the status.

You can find more information about setting up the Continuum server at the Continuum Getting Started Guide.

Webstart Plugin

The webstart plugin is still in development. Therefore the process for obtaining it is non-standard. To find more information on the plugin see this page.

Compilation

  1. svn co http://svn.codehaus.org/mojo/trunk/mojo/webstart-maven-plugin/
  2. cd webstart-maven-plugin/
  3. mvn install

Generating a Key & Self-signing jars

This section tells you how to generate a key that can be used to self-sign jar files. Really this should only have to be done once.

  1. keytool -genkey -keystore cogKey -alias cogkituser
  2. keytool -selfcert -alias cogkituser -keystore cogKey
  3. jarsigner -keystore cogKey -storepass YOURPASS your-jar.jar cogkituser
Personal tools
Collaboration and Jobs