1 .. _odl-parent-developer-guide:
3 ODL Parent Developer Guide
4 ==========================
12 The ODL Parent component for OpenDaylight provides a number of Maven
13 parent POMs which allow Maven projects to be easily integrated in the
14 OpenDaylight ecosystem. Technically, the aim of projects in OpenDaylight
15 is to produce Karaf features, and these parent projects provide common
16 support for the different types of projects involved.
18 These parent projects are:
20 - ``odlparent-lite`` — the basic parent POM for Maven modules which
21 don’t produce artifacts (*e.g.* aggregator POMs)
23 - ``odlparent`` — the common parent POM for Maven modules containing
26 - ``bundle-parent`` — the parent POM for Maven modules producing OSGi
29 The following parent projects are deprecated, but still used in Carbon:
31 - ``feature-parent`` — the parent POM for Maven modules producing
32 Karaf 3 feature repositories
34 - ``karaf-parent`` — the parent POM for Maven modules producing Karaf 3
37 The following parent projects are new in Carbon, for Karaf 4 support (which
38 won’t be complete until Nitrogen):
40 - ``single-feature-parent`` — the parent POM for Maven modules producing
41 a single Karaf 4 feature
43 - ``feature-repo-parent`` — the parent POM for Maven modules producing
44 Karaf 4 feature repositories
46 - ``karaf4-parent`` — the parent POM for Maven modules producing Karaf 4
52 This is the base parent for all OpenDaylight Maven projects and
53 modules. It provides the following, notably to allow publishing
54 artifacts to Maven Central:
56 - license information;
58 - organization information;
60 - issue management information (a link to our Bugzilla);
62 - continuous integration information (a link to our Jenkins setup);
64 - default Maven plugins (``maven-clean-plugin``,
65 ``maven-deploy-plugin``, ``maven-install-plugin``,
66 ``maven-javadoc-plugin`` with HelpMojo support,
67 ``maven-project-info-reports-plugin``, ``maven-site-plugin`` with
68 Asciidoc support, ``jdepend-maven-plugin``);
70 - distribution management information.
72 It also defines two profiles which help during development:
74 - ``q`` (``-Pq``), the quick profile, which disables tests, code
75 coverage, Javadoc generation, code analysis, etc. — anything which
76 is not necessary to build the bundles and features (see `this blog
77 post <http://blog2.vorburger.ch/2016/06/improve-maven-build-speed-with-q.html>`__
80 - ``addInstallRepositoryPath``
81 (``-DaddInstallRepositoryPath=…/karaf/system``) which can be used to
82 drop a bundle in the appropriate Karaf location, to enable
83 hot-reloading of bundles during development (see `this blog
84 post <http://blog2.vorburger.ch/2016/06/maven-install-into-additional.html>`__
87 For modules which don’t produce any useful artifacts (*e.g.* aggregator
88 POMs), you should add the following to avoid processing artifacts:
95 <groupId>org.apache.maven.plugins</groupId>
96 <artifactId>maven-deploy-plugin</artifactId>
102 <groupId>org.apache.maven.plugins</groupId>
103 <artifactId>maven-install-plugin</artifactId>
114 This inherits from ``odlparent-lite`` and mainly provides dependency and
115 plugin management for OpenDaylight projects.
117 If you use any of the following libraries, you should rely on
118 ``odlparent`` to provide the appropriate versions:
126 - ``commons-fileupload``
160 - core OSGi dependencies (``core``, ``compendium``\ …)
184 This list is not exhaustive. It is also not cast in stone;if you
185 would like to add a new dependency (or migrate a dependency), please
186 contact `the mailing list <https://lists.opendaylight.org/g/kernel-dev>`__.
188 ``odlparent`` also enforces some Checkstyle verification rules. In
189 particular, it enforces the common license header used in all
195 * Copyright © ${year} ${holder} and others. All rights reserved.
197 * This program and the accompanying materials are made available under the
198 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
199 * and is available at http://www.eclipse.org/legal/epl-v10.html
202 where “\ ``${year}``\ ” is initially the first year of publication, then
203 (after a year has passed) the first and latest years of publication,
204 separated by commas (*e.g.* “2014, 2016”), and “\ ``${holder}``\ ” is
205 the initial copyright holder (typically, the first author’s employer).
206 “All rights reserved” is optional.
208 If you need to disable this license check, *e.g.* for files imported
209 under another license (EPL-compatible of course), you can override the
210 ``maven-checkstyle-plugin`` configuration. ``features-test`` does this
211 for its ``CustomBundleUrlStreamHandlerFactory`` class, which is
217 <artifactId>maven-checkstyle-plugin</artifactId>
220 <id>check-license</id>
224 <phase>process-sources</phase>
226 <configLocation>check-license.xml</configLocation>
227 <headerLocation>EPL-LICENSE.regexp.txt</headerLocation>
228 <includeResources>false</includeResources>
229 <includeTestResources>false</includeTestResources>
230 <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
232 <!-- Skip Apache Licensed files -->
233 org/opendaylight/odlparent/featuretest/CustomBundleUrlStreamHandlerFactory.java
235 <failsOnError>false</failsOnError>
236 <consoleOutput>true</consoleOutput>
245 This inherits from ``odlparent`` and enables functionality useful for
248 - ``maven-javadoc-plugin`` is activated, to build the Javadoc JAR;
250 - ``maven-source-plugin`` is activated, to build the source JAR;
252 - ``maven-bundle-plugin`` is activated (including extensions), to build
253 OSGi bundles (using the “bundle” packaging).
255 In addition to this, JUnit is included as a default dependency in “test”
261 This inherits from ``odlparent`` and enables functionality useful for
264 - ``karaf-maven-plugin`` is activated, to build Karaf features — but
265 for OpenDaylight, projects need to use ``“jar”`` packaging (**not**
266 ``“feature”`` or ``“kar”``);
268 - ``features.xml`` files are processed from templates stored in
269 ``src/main/features/features.xml``;
271 - Karaf features are tested after build to ensure they can be activated
272 in a Karaf container.
274 The ``features.xml`` processing allows versions to be omitted from
275 certain feature dependencies, and replaced with “\ ``{{version}}``\ ”.
280 <features name="odl-mdsal-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
281 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
282 xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
284 <repository>mvn:org.opendaylight.odlparent/features-odlparent/{{VERSION}}/xml/features</repository>
287 <feature name='odl-mdsal-broker-local' version='${project.version}' description="OpenDaylight :: MDSAL :: Broker">
288 <feature version='${yangtools.version}'>odl-yangtools-common</feature>
289 <feature version='${mdsal.version}'>odl-mdsal-binding-dom-adapter</feature>
290 <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
291 <feature version='${project.version}'>odl-mdsal-common</feature>
292 <feature version='${config.version}'>odl-config-startup</feature>
293 <feature version='${config.version}'>odl-config-netty</feature>
294 <feature version='[3.3.0,4.0.0)'>odl-lmax</feature>
296 <bundle>mvn:org.opendaylight.controller/sal-dom-broker-config/{{VERSION}}</bundle>
297 <bundle start-level="40">mvn:org.opendaylight.controller/blueprint/{{VERSION}}</bundle>
298 <configfile finalname="${config.configfile.directory}/${config.mdsal.configfile}">mvn:org.opendaylight.controller/md-sal-config/{{VERSION}}/xml/config</configfile>
301 As illustrated, versions can be omitted in this way for repository
302 dependencies, bundle dependencies and configuration files. They must be
303 specified traditionally (either hard-coded, or using Maven properties)
304 for feature dependencies.
309 This allows building a Karaf 3 distribution, typically for local testing
310 purposes. Any runtime-scoped feature dependencies will be included in the
311 distribution, and the ``karaf.localFeature`` property can be used to
312 specify the boot feature (in addition to ``standard``).
314 single-feature-parent
315 ~~~~~~~~~~~~~~~~~~~~~
317 This inherits from ``odlparent`` and enables functionality useful for
320 - ``karaf-maven-plugin`` is activated, to build Karaf features, typically
321 with ``"feature"`` packaging (``"kar"`` is also supported);
323 - ``feature.xml`` files are generated based on the compile-scope dependencies
324 defined in the POM, optionally initialized from a stub in
325 ``src/main/feature/feature.xml``.
327 - Karaf features are tested after build to ensure they can be activated
328 in a Karaf container.
330 The ``feature.xml`` processing adds transitive dependencies by default, which
331 allows features to be defined using only the most significant dependencies
332 (those that define the feature); other requirements are determined
333 automatically as long as they exist as Maven dependencies.
335 ``configfiles`` need to be defined both as Maven dependencies (with the
336 appropriate type and classifier) and as ``<configfile>`` elements in the
337 ``feature.xml`` stub.
339 Other features which a feature depends on need to be defined as Maven
340 dependencies with type “xml” and classifier “features” (note the plural here).
342 ``feature-repo-parent``
343 ~~~~~~~~~~~~~~~~~~~~~~~
345 This inherits from ``odlparent`` and enables functionality useful for
346 Karaf 4 feature repositories. It follows the same principles as
347 ``single-feature-parent``, but is designed specifically for repositories
348 and should be used only for this type of artifacts.
350 It builds a feature repository referencing all the (feature) dependencies
356 This allows building a Karaf 4 distribution, typically for local testing
357 purposes. Any runtime-scoped feature dependencies will be included in the
358 distribution, and the ``karaf.localFeature`` property can be used to
359 specify the boot feature (in addition to ``standard``).
361 Features (for Karaf 3)
362 ----------------------
364 The ODL Parent component for OpenDaylight provides a number of Karaf 3
365 features which can be used by other Karaf 3 features to use certain
366 third-party upstream dependencies.
370 - Akka features (in the ``features-akka`` repository):
372 - ``odl-akka-all`` — all Akka bundles;
374 - ``odl-akka-scala-2.11`` — Scala runtime for OpenDaylight;
376 - ``odl-akka-system-2.4`` — Akka actor framework bundles;
378 - ``odl-akka-clustering-2.4`` — Akka clustering bundles and
381 - ``odl-akka-leveldb-0.7`` — LevelDB;
383 - ``odl-akka-persistence-2.4`` — Akka persistence;
385 - general third-party features (in the ``features-odlparent``
388 - ``odl-netty-4`` — all Netty bundles;
390 - ``odl-guava-18`` — Guava 18;
392 - ``odl-guava-21`` — Guava 21 (not intended for use in Carbon);
394 - ``odl-lmax-3`` — LMAX Disruptor;
396 - ``odl-triemap-0.2`` — Concurrent Hash-Trie Map.
398 To use these, you need to declare a dependency on the appropriate
399 repository in your ``features.xml`` file:
403 <repository>mvn:org.opendaylight.odlparent/features-odlparent/{{VERSION}}/xml/features</repository>
405 and then include the feature, *e.g.*:
409 <feature name='odl-mdsal-broker-local' version='${project.version}' description="OpenDaylight :: MDSAL :: Broker">
411 <feature version='[3.3.0,4.0.0)'>odl-lmax</feature>
415 You also need to depend on the features repository in your POM:
420 <groupId>org.opendaylight.odlparent</groupId>
421 <artifactId>features-odlparent</artifactId>
422 <classifier>features</classifier>
426 assuming the appropriate dependency management:
430 <dependencyManagement>
433 <groupId>org.opendaylight.odlparent</groupId>
434 <artifactId>odlparent-artifacts</artifactId>
435 <version>1.8.0-SNAPSHOT</version>
436 <scope>import</scope>
440 </dependencyManagement>
442 (the version number there is appropriate for Carbon). For the time being
443 you also need to depend separately on the individual JARs as
444 compile-time dependencies to build your dependent code; the relevant
445 dependencies are managed in ``odlparent``'s dependency management.
447 | The suggested version ranges are as follows:
449 - ``odl-netty``: ``[4.0.37,4.1.0)`` or ``[4.0.37,5.0.0)``;
451 - ``odl-guava``: ``[18,19)`` (if your code is ready for it, ``[19,20)``
452 is also available, but the current default version of Guava in
455 - ``odl-lmax``: ``[3.3.4,4.0.0)``
457 Features (for Karaf 4)
458 ----------------------
460 There are equivalent features to all the Karaf 3 features, for Karaf 4.
461 The repositories use “features4” instead of “features”, and the features
462 use ``odl4`` instead of ``odl``.
464 The following new features are specific to Karaf 4:
466 - Karaf wrapper features (also in the ``features4-odlparent``
467 repository) — these can be used to pull in a Karaf feature
468 using a Maven dependency in a POM:
470 - ``odl-karaf-feat-feature`` — the Karaf ``feature`` feature;
472 - ``odl-karaf-feat-jdbc`` — the Karaf ``jdbc`` feature;
474 - ``odl-karaf-feat-jetty`` — the Karaf ``jetty`` feature;
476 - ``odl-karaf-feat-war`` — the Karaf ``war`` feature.
478 To use these, all you need to do now is add the appropriate dependency
479 in your feature POM; for example:
484 <groupId>org.opendaylight.odlparent</groupId>
485 <artifactId>odl4-guava-18</artifactId>
486 <classifier>features</classifier>
490 assuming the appropriate dependency management:
494 <dependencyManagement>
497 <groupId>org.opendaylight.odlparent</groupId>
498 <artifactId>odlparent-artifacts</artifactId>
499 <version>1.8.0-SNAPSHOT</version>
500 <scope>import</scope>
504 </dependencyManagement>
506 (the version number there is appropriate for Carbon). We no longer use version
507 ranges, the feature dependencies all use the ``odlparent`` version (but you
508 should rely on the artifacts POM).