Changes between Version 1 and Version 2 of Obsolete/Development/Code/Maven


Ignore:
Timestamp:
Mar 10, 2011, 5:01:49 PM (15 years ago)
Author:
munoz
Comment:

NCM components build

Legend:

Unmodified
Added
Removed
Modified
  • Obsolete/Development/Code/Maven

    v1 v2  
    44[[TOC(inline)]]
    55
    6 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.
     6Maven is a Java-based system that provides a standard file format for
     7build information, well-defined build lifecycle, and plugin framework
     8for extensions.  There also exist standard repositories in which both
     9development and production packages (artifacts) can be maintained.
     10The maven plugins are also available through standard maven
     11repositories, allowing the core maven code to be very small.  Any real
     12build, however, will require a large number of additional plug-ins
     13that are downloaded automatically and cached on the user's machine.
    714
    815== Installing Maven ==
    916
    10 To download and install maven see the [http://maven.apache.org/ 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`.
     17To download and install maven see the [http://maven.apache.org/ maven website].
     18
     19Essentially the only required dependency is a recent, certified
     20version of a Java Virtual Machine.  This installation provides a
     21command line interface to maven, the primary command being `mvn`.
    1122
    1223Maven also integrates well with Eclipse.  The [http://m2eclipse.sonatype.org/ m2eclipse plugin] is recommended.
     
    1425== Running Maven ==
    1526
    16 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.
     27Running maven should be as simple as checking out the Quattor code and
     28then running `mvn package`.  This will prepare the sources, compile
     29them (if necessary), and package the results.  If on a machine which
     30supports RPM packaging, RPM packages will be produced.  In all cases,
     31appropriate tarballs will be generated.
    1732
    18  
     33== Directory structure to use with Maven ==
     34
     35Quattor modules that should be built with Maven will have the
     36following structure:
     37
     38 * ChangeLog
     39 * pom.xml (project file)
     40 * src
     41   * main
     42     * pan
     43       * components
     44         * <component name>     
     45           * config.pan: What users will tipically include from their
     46             profiles. Everything else is included directly or
     47             indirectly from here.
     48           * schema.pan: Component's schema
     49           * config-common.pan: Component's basic
     50             configuration. Usually it doesn't need any human
     51             edition. But if you need any extra files, include them
     52             here.
     53           * config-rpm.pan: Installs the component's RPM.
     54           * config-xml.pan: If you don't want an RPM, but prefer to
     55             ship the component's code directly in its profile.
     56             
     57
     58     * perl
     59       * <component name>.pm: Code
     60       * <component name>.pod: Documentation.
     61
     62Please note that there are no ".cin" files anymore. Files are not
     63renamed anymore with the new build tools.
     64
     65== Using Maven to build an NCM component ==
     66
     67Add the LAPP nexus repository to your `~/.m2/settings.xml` file. An
     68example looks like this:
     69
     70{{{#!xml
     71<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
     72  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     73  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
     74                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
     75  <localRepository/>
     76  <interactiveMode/>
     77  <usePluginRegistry/>
     78  <offline/>
     79  <pluginGroups/>
     80  <servers/>
     81  <mirrors/>
     82  <proxies/>
     83  <profiles>
     84    <profile>
     85      <id>quattor-plugins</id>
     86      <pluginRepositories>
     87        <pluginRepository>
     88          <id>quattor-releases</id>
     89          <url>http://lapp-repo01.in2p3.fr:8081/nexus/content/repositories/releases/</url>
     90        </pluginRepository>
     91      </pluginRepositories>
     92    </profile>   
     93  </profiles>
     94  <activeProfiles/>
     95</settings>
     96}}}
     97
     98=== Creating the basic structure for the component ===
     99
     100You'll get the basic directory structure for the component with:
     101
     102{{{#!sh
     103mvn archetype:generate \
     104    -DarchetypeArtifactId=cfg-module \
     105    -DarchetypeGroupId=org.quattor.maven \
     106    -DarchetypeVersion=1.3 \
     107    -DarchetypeRepository=http://lapp-repo01.in2p3.fr:8081/nexus/content/repositories/releases/
     108}}}
     109
     110With all this, you can now write your code!
     111
     112=== Importing an existing component into the new structure ===
     113
     114First of all, go to the old structure, with the old build tools and
     115run `make` there. It will expand all placeholders, and you'll get the
     116files you really want to import.
     117
     118Next, remove all those heavy headers we used to have. Instead, the
     119following, lighter header:
     120
     121{{{#!perl
     122# ${license-info}
     123# ${developer-info}
     124# ${author-info}
     125# ${build-info}
     126}}}
     127
     128will give the same information, and will get expanded by Maven.
     129
     130Now, copy the generated files into the correct places. Perl and pode
     131code are obvious. Then, your old `config.tpl` should become your new
     132`config-common.pan`, and your old `schema.tpl` should become your new
     133`schema.pan`.
     134
     135And that's it. You can add the new hierarchy to SVN and get rid of the
     136old one. :)
     137
     138== Actually building the software ==
     139
     140To build it, you just need to be on the top level directory, and run:
     141
     142{{{#!sh
     143mvn -P quattor-plugins clean package
     144}}}
     145
     146It will ask a number of questions. If you want it to be completely
     147interactive, you can run it with `-batch`.
     148
     149Now, all your files (tarballs, RPMs, whatever) are in the `target`
     150subdirectory.
     151
     152== Open questions ==
     153
     154  * Do the new tools interact with SVN?
     155  * Do they tag as well?