- Andrew Kos
- Bill Burlein
- Bryan Williams
- Celina Buczkowska
- Daniel Ryerson
- Jeff Brown
- John Kraus
- Joseph Mak
- Josh Durbin
- Mark Daugherty
- Matt Van Bergen
- Matthew Young
- Melissa Geoffrion
- Michael Kang
- Michael Chan
- Michael Hodgdon
- Mike Motherway
- Molly McDaniel
- Nadia Maciulis
- Pat McLoughlin
- Paul Michelotti
- Puru Hemnani
- Rohit Srinath
- Ryan Lunka
- 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.
A longtime enthusiast of logic and problem solving, it seems appropriate that Mark would be inspired by software ideas and technologies...
- CVE-2013-4810: a(nother) Hack that Needn’t Happen
- Responsive Image Rundown
- Application Performance Management
- AWS Cross-Zone Load Balancing solves Akamai DNS caching
- Content Optimization Using Testing and Targeting
- Making User Experience Personal
- Top 5 Things we are Looking Forward to at AWS re:Invent
- Apache Felix: Service resolution, selecting from multiple resolved candidates
- CITYTECH Awarded the AWS MSP Competency
- Unlocking CQ's Fixed Templates: Part 2