Warning | ||
---|---|---|
| ||
The information on this page is no longer accurate, as lcsim-based projects have switched to using maven 2. While there are currently no equivalent instructions for maven 2, please refer to the lcsim-contrib project |
Creating a Maven Project that Depends on org.lcsim
Overview
This tutorial shows how to create a Maven-based project that depends on org.lcsim, so that your code can seemlessly access this framework and all of its dependencies.
The Maven tool is used to build the org.lcsim software. It automates can be used as the build system for your project. It automates most of the low-level details of involving dependencies and building for Java projectscompiling. For instance, it can automatically download external JARs required by your project. The org.lcsim project uses this tool for its build system, as wellrequired jar files based on a repository URL. Additionally, it can build a complete project website including source code metrics, cross-reference, and JavaDocs.
Tip | ||
---|---|---|
| ||
It is always a good idea to store your projects in a source control system, such as CVS. Contact your local system administrator for instructions on setting up a module for your project. |
Directory Setup
Create a directory for your new project and go into it.
No Format |
---|
mkdir ExampleProject cd ExampleProject |
...
No Format |
---|
mkdir -p src/org/lcsim |
A directory for test directory cases should also be created.
No Format | |
---|---|
mkdir -p test/org/lcsim | |
Tip | |
Source Control | |
It is always a good idea to store your projects in a source control system, such as CVS. Contact your local system administrator for instructions on setting up a module for your project. |
Build Files
The project's root directory needs to should contain three Maven configuration files.
- project.xml - main configuration file, listing the project's core meta- information and its dependencies
- maven.xml - Maven settings, such as the default build target
- project.properties - project properties file, including source repository locations, e.g. freehep.org
...
No Format |
---|
cvs -d :pserver:anonymous@cvs.freehep.org:/cvs/lcd co lcsim
cd lcsim
cp project.xml maven.xml project.properties ..
cd ..
rm -rf lcsim
|
...
No Format |
---|
<dependency> <groupId>lcsim</groupId> <artifactId>lcsim</artifactId> <version>0.9</version> <url>http://www.lcsim.org</url> </dependency> |
Warning | ||
---|---|---|
| ||
Maven requires a specific version tag for dependencies. This means that the version string needs to updated when a new org.lcsim release is made, or the older version will be used instead. |
The org.lcsim JAR is not currently maintained as a downloadable dependency. Each project user needs to compile and build this program themselves in order to install it to the local repository.
Basic Build Command
The project can be built from the command line with this simple command.
...
Alternately, you can use the Netbeans IDE to build your Maven-based projects.
Run Plugin
The FreeHep Run Plugin can generate a run script for your project.
...
The command line syntax of the script is completely up to you.
JAS
When http://jas.freehep.org/jas3 starts, it can JAS3 can be configured to automatically load your project JAR's classes on startup.
This target will copy the project's JAR into JAS3's extensions directory, located at ~/.JAS3/extensions.
...
The class should now be available using the File -> Load command within JAS3.
Build Script
A full build command for your project, incorporating all of the above features, would look something like this.
...
This will do a clean build, skipping tests, and installing the run script to the current directory. It also puts copies the JAR files into the ~/maven/repository area /lcsim and ~/.JAS3/extensions directories.