You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Creating a Maven Project that Depends on org.lcsim

Overview

Maven can be used as the build system for your project. org.lcsim uses this tool
for its build. This tool handles most (if not all) of the low-level details of
dependencies and building.

Basic Setup

The dependent project's root directory should contain three configuration files
for Maven.

  • maven.xml - sets secondary project goals such as using XDoc
  • project.xml - main configuration file listing the project's information and its dependencies
  • project.properties - settings for Maven such as source repository locations e.g. freehep.org

All of these files can be copied from org.lcsim's root directory.

In the dependent project's project.xml file, the following should be inserted to make it depend
on org.lcsim, itself.

<dependency>
  <groupId>lcsim</groupId>
  <artifactId>lcsim</artifactId>
  <version>0.9</version>
  <url>http://www.lcsim.org</url>
</dependency>

org.lcsim is not maintained as a downloadable JAR file. Each project user should compile and
build this program themselves.

Source code should be put into a src/ directory. Probably the directory path for source code should be org/lcsim,.

Once the above steps are performed, typing maven should build the project into the target/ directory.

Run Plugin

The FreeHep Run Plugin can generate a run script for your project.

To enable this functionality, insert the following into the project.xml file.

<dependency>
  <groupId>freehep</groupId>
  <artifactId>freehep-run-plugin</artifactId>
  <version>1.1.1</version>
  <url>http://java.freehep.org/maven/freehep/plugins</url>
  <type>plugin</type>
</dependency>

Maven also needs to know what class to be executed. This goes into the project.properties file.

maven.jar.mainclass=my.classpath.myMain

To build the script, execute the following target.

maven -Drun.install=$(pwd) run:install 

A run script named after your project should now be placed into the bin directory.

This script sets up the classpath and executes the main function of the specified class.

public static void main(String[] args)

The script can be run from the current directory, as follows.

./bin/myProject [args]

The command line syntax of the script is completely up to you.

JAS

This target will copy the project's JAR into JAS3's extensions directory at ~/.JAS3/extensions.

maven jas:install

The version number will be stripped out of the JAR name, and any existing JAR by the same name will be overwritten.

When JAS loads, it will automatically load this JAR, making your project classes available from within JAS, itself.

Build Script

A full build command for your project could be something like this.

maven -Dmaven.test.skip=true -Drun.install=$(pwd) clean jar:install jas:install run:install

This will do a clean build, skipping tests and installing the run script to the current directory.
It also puts the JAR files into the ~/maven/repository area and ~/.JAS3/extensions.

  • No labels