Version 4 (modified by 13 years ago) (diff) | ,
---|
Using Maven Build Tools
TracNav
Table of Contents
Maven is a Java-based system that provides a standard file format for build information, well-defined build lifecycle, and plugin framework for extensions. There also exist standard repositories in which both development and production packages (artifacts) can be maintained. The maven plugins are also available through standard maven repositories, allowing the core maven code to be very small. Any real build, however, will require a large number of additional plug-ins that are downloaded automatically and cached on the user's machine.
Installing Maven
To download and install maven see the maven website.
Essentially the only required dependency is a recent, certified
version of a Java Virtual Machine. This installation provides a
command line interface to maven, the primary command being mvn
.
Maven also integrates well with Eclipse. The m2eclipse plugin is recommended.
Running Maven
Running maven should be as simple as checking out the Quattor code and
then running mvn package
. This will prepare the sources, compile
them (if necessary), and package the results. If on a machine which
supports RPM packaging, RPM packages will be produced. In all cases,
appropriate tarballs will be generated.
Directory structure to use with Maven
Quattor modules that should be built with Maven will have the following structure:
- ChangeLog
- pom.xml (project file)
- src
- main
- pan
- components
- <component name>
- config.pan: What users will tipically include from their profiles. Everything else is included directly or indirectly from here.
- schema.pan: Component's schema
- config-common.pan: Component's basic configuration. Usually it doesn't need any human edition. But if you need any extra files, include them here.
- config-rpm.pan: Installs the component's RPM.
- config-xml.pan: If you don't want an RPM, but prefer to ship the component's code directly in its profile.
- components
- pan
- main
- perl
- <component name>.pm: Code
- <component name>.pod: Documentation.
Please note that there are no ".cin" files anymore. Files are not renamed anymore with the new build tools.
Using Maven to build an NCM component
Add the LAPP nexus repository to your ~/.m2/settings.xml
file. An
example looks like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository/> <interactiveMode/> <usePluginRegistry/> <offline/> <pluginGroups/> <servers/> <mirrors/> <proxies/> <profiles> <profile> <id>quattor-plugins</id> <pluginRepositories> <pluginRepository> <id>quattor-releases</id> <url>http://lapp-repo01.in2p3.fr:8081/nexus/content/repositories/releases/</url> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles/> </settings>
Creating the basic structure for the component
You'll get the basic directory structure for the component with:
mvn archetype:generate \ -DarchetypeArtifactId=cfg-module \ -DarchetypeGroupId=org.quattor.maven \ -DarchetypeVersion=1.3 \ -DarchetypeRepository=http://lapp-repo01.in2p3.fr:8081/nexus/content/repositories/releases/
With all this, you can now write your code!
Importing an existing component into the new structure
First of all, go to the old structure, with the old build tools and
run make
there. It will expand all placeholders, and you'll get the
files you really want to import.
Next, remove all those heavy headers we used to have. Instead, the following, lighter header:
# ${license-info} # ${developer-info} # ${author-info} # ${build-info}
will give the same information, and will get expanded by Maven.
Now, copy the generated files into the correct places. Perl and pode
code are obvious. Then, your old config.tpl
should become your new
config-common.pan
, and your old schema.tpl
should become your new
schema.pan
.
And that's it. You can add the new hierarchy to SVN and get rid of the old one. :)
Actually building the software
To build it, you just need to be on the top level directory, and run:
mvn -P quattor-plugins clean package
It will ask a number of questions. If you want it to be completely
interactive, you can run it with -batch
.
Now, all your files (tarballs, RPMs, whatever) are in the target
subdirectory.
Open questions
(LF) How is tagging done?
(Cal) This is an open question. At the moment only someone with access to the Quattor nexus server can do a full release of something. Either we need to give this right to everyone, or rely on a continuous integration server to do it for us. I prefer the second option, but it needs to be discussed at the workshop.
Follow-up on ticket #225