April 26, 2020
Estimated Post Reading Time ~

How to include all AEM dependencies in AEM6

Prior to CQ6, you have to add dependencies for each class you are using in your pom.xml, Way to find dependencies was (Maven org http://mvnrepository.com or using adobe central https://repo.adobe.com/nexus/content/groups/public/ through dependency finder http://localhost:4502/system/console/depfinder). With CQ6 now all dependencies are provided through one artifactID.

Prerequisite: Maven, CQ Project Set-Up
Include following line in your dependency management for your pom.xml (Depending upon project this could be at any location usually it is your Project parent pom)

<dependencyManagement>
<!-- All Your Third party dependency -->
<!-- AEM 6.0 -->

<!-- All AEM Dependencies for JSP compilation -->

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
<version>6.0.0.1</version>
<scope>provided</scope>
</dependency>

<!-- All AEM 6.1 Dependency added to end of file -->

<dependency>
<groupId>com.adobe.cq.social</groupId>
<artifactId>cq-socialcommunities-api</artifactId>
<version>1.7.197</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
<classifier>obfuscated-apis</classifier>
</dependency>

</dependencyManagement>


Note that this version could change depending upon new releases of CQ, You can track them from http://repo.adobe.com/nexus/content/repositories/releases/com/adobe/aem/aem-api/

Some Trick: Note that above will include all AEM-API dependencies, another way to check what minimum dependency is needed is to create a multi-module project using AEM plugin for eclipse more example http://docs.adobe.com/content/docs/en/dev-tools/aem-eclipse.html.

You can also upload uber-jar with apis classifiers instead of obfuscate-apis classifiers to your Nexus or dependency management system.

To upload this uber-jar to your nexus you can use something like,

mvn deploy:deploy-file -Durl=YOUR-REPO -Dfile=uber-jar-6.1.0-apis.jar -DartifactId=uber-jar -Dversion=6.1.0 -DgroupId=com.adobe.aem -Dclassifier=apis -Dpackaging=jar -DrepositoryId=YOUR-REPO-ID

Once you have uber-jar with apis classifier ready, You can use something like

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.1.0</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>


I see that minimum these are needed when you use this,

<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>

<!-- Other Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
</dependency>
</dependencies>


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.