| 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. |
| | 6 | Maven is a Java-based system that provides a standard file format for |
| | 7 | build information, well-defined build lifecycle, and plugin framework |
| | 8 | for extensions. There also exist standard repositories in which both |
| | 9 | development and production packages (artifacts) can be maintained. |
| | 10 | The maven plugins are also available through standard maven |
| | 11 | repositories, allowing the core maven code to be very small. Any real |
| | 12 | build, however, will require a large number of additional plug-ins |
| | 13 | that are downloaded automatically and cached on the user's machine. |
| 18 | | |
| | 33 | == Directory structure to use with Maven == |
| | 34 | |
| | 35 | Quattor modules that should be built with Maven will have the |
| | 36 | following 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 | |
| | 62 | Please note that there are no ".cin" files anymore. Files are not |
| | 63 | renamed anymore with the new build tools. |
| | 64 | |
| | 65 | == Using Maven to build an NCM component == |
| | 66 | |
| | 67 | Add the LAPP nexus repository to your `~/.m2/settings.xml` file. An |
| | 68 | example 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 | |
| | 100 | You'll get the basic directory structure for the component with: |
| | 101 | |
| | 102 | {{{#!sh |
| | 103 | mvn 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 | |
| | 110 | With all this, you can now write your code! |
| | 111 | |
| | 112 | === Importing an existing component into the new structure === |
| | 113 | |
| | 114 | First of all, go to the old structure, with the old build tools and |
| | 115 | run `make` there. It will expand all placeholders, and you'll get the |
| | 116 | files you really want to import. |
| | 117 | |
| | 118 | Next, remove all those heavy headers we used to have. Instead, the |
| | 119 | following, lighter header: |
| | 120 | |
| | 121 | {{{#!perl |
| | 122 | # ${license-info} |
| | 123 | # ${developer-info} |
| | 124 | # ${author-info} |
| | 125 | # ${build-info} |
| | 126 | }}} |
| | 127 | |
| | 128 | will give the same information, and will get expanded by Maven. |
| | 129 | |
| | 130 | Now, copy the generated files into the correct places. Perl and pode |
| | 131 | code 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 | |
| | 135 | And that's it. You can add the new hierarchy to SVN and get rid of the |
| | 136 | old one. :) |
| | 137 | |
| | 138 | == Actually building the software == |
| | 139 | |
| | 140 | To build it, you just need to be on the top level directory, and run: |
| | 141 | |
| | 142 | {{{#!sh |
| | 143 | mvn -P quattor-plugins clean package |
| | 144 | }}} |
| | 145 | |
| | 146 | It will ask a number of questions. If you want it to be completely |
| | 147 | interactive, you can run it with `-batch`. |
| | 148 | |
| | 149 | Now, all your files (tarballs, RPMs, whatever) are in the `target` |
| | 150 | subdirectory. |
| | 151 | |
| | 152 | == Open questions == |
| | 153 | |
| | 154 | * Do the new tools interact with SVN? |
| | 155 | * Do they tag as well? |