- Bill Burlein
- Bryan Williams
- Celina Buczkowska
- Daniel Ryerson
- David Ensinger
- Fred Faulkner
- Jeff Brown
- John Kraus
- Josh Durbin
- Justin Pittman
- KC Dunstan
- Mark Daugherty
- Matt Van Bergen
- Matthew Young
- Melissa Geoffrion
- Michael Kang
- Michael Paull
- Michael Chan
- Michael Hodgdon
- Molly McDaniel
- Nadia Maciulis
- Pat McLoughlin
- Paul Michelotti
- Puru Hemnani
- Robb Winkle
- Rohit Srinath
- Tom Kelly
A better way to manage Maven dependencies in Adobe CQ5
Sunday, January 27, 2013
When starting a new CQ5 project, setting up a Maven POM with project dependencies can be an unnecessarily time-consuming task. Dependencies specified in the POM file must match those provided by the CQ5 OSGi container to prevent deployment and runtime issues, and the process of manually extracting Maven metadata from OSGi bundles in the Felix console is tedious and error-prone. We can do better, and fortunately, Adobe has provided the Maven Archiva Servlet to streamline this process.
The Archiva servlet is commonly used to allow a CQ5 instance to function as a Maven repository, but there is an additional, undocumented feature of the servlet that generates a POM file for all of the installed bundles in the OSGi container. From the generated POM file, we can copy the dependencies as needed into our project POM without any additional work to verify artifact IDs, versions, etc.
After downloading and installing the Maven Archiva Servlet package, this URL can be used to generate the POM file:
...or using cURL:
curl http://localhost:4502/maven/repository/com/day/cq5-parent/0.0.1-SNAPSHOT/cq5-parent.pom > pom.xml
<dependencyManagement> section of the generated POM can then be merged into an existing project's parent POM as necessary. With this section defined, specifying dependencies in child modules requires only the
<artifactId> for each dependency.
In a typical multi-module CQ5 Maven project, defining a dependency management section is helpful for several reasons:
- As your project code evolves, it's highly likely that you will be using additional CQ5 and Sling libraries. Defining the set of all libraries provided by the container, regardless of whether they are immediately needed, reduces future effort.
<dependencyManagement>section allows for the convenience of defining these available dependencies for possible later use without polluting the
<dependencies>section of the POM with unused artifacts.
- Complex projects may have several modules with overlapping dependencies. Using a dependency management section, versions and scopes are defined in one place, which eliminates redundant specification in module POMs.
A well-defined Maven dependency strategy coupled with the Archiva Servlet tool greatly simplifies the bootstrapping process for new CQ5 projects.
Interested in more specialized AEM/CQ know-how? Attend our CIRCUIT Conference this June in Chicago. For registration, our call for speakers, and all the other relevant details, head to www.circuit.citytechinc.com
A longtime enthusiast of logic and problem solving, it seems appropriate that Mark would be inspired by software ideas and technologies...
- Groovy Component Composition With Traits
- Adobe Summit - I Remember When Geometrixx was just a Shapes Company
- New Features for the venerable AEM Groovy Console
- Resolution Independence with SVG in Adobe AEM (formerly CQ)
- Five Good Reasons to Use Grunt for Front End CQ Development
- Creating a Custom Content Importer for AEM/CQ5
- CT Tag Manager: A Generic Tag Management System for CQ
- CITYTECH Speakers' Top Session Picks for CIRCUIT, an AEM Developer Conference
- Forecast for Adobe Summit: Sunny and Bright
- More AEM/CQ5 SEO Best Practices: Redirects, Vanity URLs, and XML Sitemaps