Hi All,
We have a use case where we need to add a 3rd party aem package that is not available in public or private remote maven repository. We need to include this 3rd party aem package and deploy to AEM cloud environment using cloud manager. I came across this documentation that suggests using local, filesystem based repository which can committed via git repo. Here is the link to the documentation: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/deploy.... Has anyone tried this before? Documentation is a bit vague and does not explain quite well how to set up a local filesystem based maven repo and how you should embed the package in all/pom.xml etc. Any help you could provide would be greatly appreciated.
Regards,
SKM_AEM
Solved! Go to Solution.
Views
Replies
Total Likes
Local filesystem repo means to create a repository as part of your project code base. (hence maintained in SCM)
In order to do so,
mvn install:install-file \ -Dfile=your_3rd_party_package/jar \ -DgroupId=your_group_id \ -DartifactId=your_artifact_id \ -Dversion=your_version \ -Dpackaging=based_on_your_packaging\ -DlocalRepositoryPath=path_to_project_repository created in step 1
Above method can be used when you have the package readily available as either content-package packaging or as an OSGi bundle.
If you have the source code and would like to build as part of the project code base, you can create separate module and use
I suggest to arrive at the approach based on the nature/type of the dependency and how you would like to maintain the same on a long run.
Hey all,
Anyone has encountered this need before? How to solve it?
Thanks,
SKM
Local filesystem repo means to create a repository as part of your project code base. (hence maintained in SCM)
In order to do so,
mvn install:install-file \ -Dfile=your_3rd_party_package/jar \ -DgroupId=your_group_id \ -DartifactId=your_artifact_id \ -Dversion=your_version \ -Dpackaging=based_on_your_packaging\ -DlocalRepositoryPath=path_to_project_repository created in step 1
Above method can be used when you have the package readily available as either content-package packaging or as an OSGi bundle.
If you have the source code and would like to build as part of the project code base, you can create separate module and use
I suggest to arrive at the approach based on the nature/type of the dependency and how you would like to maintain the same on a long run.
Hi @Vijayalakshmi_S ,
Thank you so much for your help. I installed the aem package using maven install-file to a local repository. I see that package in ~/.m2/repository/... and tried to add the <repository> in the main project pom.xml. I also added the dependency and embed in the all/pom.xml. But when I build using 'maven clean install' it fails with the message that it could not resolve dependencies for project xxx.xxx.xxx.all:content-package:1.0.0-SNAPSHOT: Failure to find a yyy.yyy.zip:1.0.0 (3rd party aem pkg) in https://repo.adobe.com/nexus/content/groups/public. Also, in my eclipse IDE it shows an error in the all/pom.xml file where I have added the dependency for the yyy.yyy.zip (missing artifact). Perhaps I am not including the <repository> in the parent pom.xml in a proper place, I added it towards the end of the file. Is that the right place to add?
Thanks again for your help.
SKM_AEM
Here is my parent pom.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- | Copyright 2015 Adobe Systems Incorporated | | Licensed under the Apache License, Version 2.0 (the "License"); | you may not use this file except in compliance with the License. | You may obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable law or agreed to in writing, software | distributed under the License is distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | See the License for the specific language governing permissions and | limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.testProject</groupId> <artifactId>testProject</artifactId> <packaging>pom</packaging> <version>1.0.0-SNAPSHOT</version> <name>Test Project</name> <description>Test Project</description> <modules> <module>all</module> <module>core</module> <module>ui.apps</module> <module>ui.apps.structure</module> <module>ui.config</module> <module>ui.content</module> <module>it.tests</module> <module>dispatcher</module> <module>ui.tests</module> </modules> <properties> <aem.host>localhost</aem.host> <aem.port>4502</aem.port> <aem.publish.host>localhost</aem.publish.host> <aem.publish.port>4503</aem.publish.port> <sling.user>admin</sling.user> <sling.password>admin</sling.password> <vault.user>admin</vault.user> <vault.password>admin</vault.password> <frontend-maven-plugin.version>1.12.0</frontend-maven-plugin.version> <core.wcm.components.version>2.17.12</core.wcm.components.version> <bnd.version>5.1.2</bnd.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <aem.sdk.api>2021.11.6058.20211123T163652Z-211000</aem.sdk.api> <aemanalyser.version>1.2.2</aemanalyser.version> <componentGroupName>Test Project</componentGroupName> </properties> <build> <plugins> <!-- Maven Release Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <scmCommentPrefix>[maven-scm] :</scmCommentPrefix> <preparationGoals>clean install</preparationGoals> <goals>install</goals> <releaseProfiles>release</releaseProfiles> </configuration> </plugin> <!-- Maven Source Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.1</version> <inherited>true</inherited> </plugin> <!-- Maven Enforcer Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-maven</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireMavenVersion> <version>[3.3.9,)</version> </requireMavenVersion> <requireJavaVersion> <message>Maven must be executed with a Java 8 JRE or higher.</message> <version>1.8.0</version> </requireJavaVersion> </rules> </configuration> </execution> </executions> </plugin> <!-- Maven Compiler Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.3.0</version> <configuration> <tarLongFileMode>posix</tarLongFileMode> </configuration> </plugin> <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>${frontend-maven-plugin.version}</version> <configuration> <nodeVersion>v10.13.0</nodeVersion> <npmVersion>6.9.0</npmVersion> </configuration> <executions> <execution> <id>install node and npm</id> <goals> <goal>install-node-and-npm</goal> </goals> </execution> <execution> <id>npm install</id> <goals> <goal>npm</goal> </goals> </execution> </executions> </plugin> <!-- Maven Jar Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.2</version> </plugin> <!-- Maven Clean Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>3.0.0</version> </plugin> <!-- BND Maven Plugin --> <plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <version>${bnd.version}</version> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd><![CDATA[ Bundle-Category: ${componentGroupName} # export all versioned packages except for conditional ones (https://github.com/bndtools/bnd/issues/3721#issuecomment-579026778) -exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}} # reproducible builds (https://github.com/bndtools/bnd/issues/3521) -noextraheaders: true -snapshot: SNAPSHOT Bundle-DocURL: -plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin -plugin org.apache.sling.bnd.models.ModelsScannerPlugin ]]></bnd> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.caconfig.bnd-plugin</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.bnd.models</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>scriptingbundle-maven-plugin</artifactId> <version>0.5.0</version> </dependency> </dependencies> </plugin> <plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-baseline-maven-plugin</artifactId> <version>${bnd.version}</version> </plugin> <!-- Maven Resources Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <!-- Maven Compiler Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> </plugin> <!-- Maven Installer Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <!-- Maven Surefire Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> <!-- Maven Failsafe Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.22.1</version> </plugin> <!-- Maven Deploy Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <!-- Apache Sling Plugin --> <plugin> <groupId>org.apache.sling</groupId> <artifactId>sling-maven-plugin</artifactId> <version>2.4.0</version> <configuration> <slingUrl>http://${aem.host}:${aem.port}/system/console</slingUrl> <deploymentMethod>WebConsole</deploymentMethod> </configuration> </plugin> <!-- HTL Maven Plugin --> <plugin> <groupId>org.apache.sling</groupId> <artifactId>htl-maven-plugin</artifactId> <version>2.0.2-1.4.0</version> <configuration> <failOnWarnings>true</failOnWarnings> </configuration> </plugin> <!-- Jackrabbit FileVault Package Plugin --> <plugin> <groupId>org.apache.jackrabbit</groupId> <artifactId>filevault-package-maven-plugin</artifactId> <extensions>true</extensions> <!-- <version>1.1.6</version> --> <version>1.0.4</version> <configuration> <filterSource>src/main/content/META-INF/vault/filter.xml</filterSource> <validatorsSettings> <jackrabbit-nodetypes> <options> <!-- use the nodetypes and namespaces from the aem-nodetypes.jar provided in the plugin dependencies --> <cnds>tccl:aem.cnd</cnds> </options> </jackrabbit-nodetypes> </validatorsSettings> </configuration> <dependencies> <dependency> <groupId>biz.netcentric.aem</groupId> <artifactId>aem-nodetypes</artifactId> <version>6.5.7.0</version> </dependency> </dependencies> </plugin> <!-- AEM Analyser Plugin --> <plugin> <groupId>com.adobe.aem</groupId> <artifactId>aemanalyser-maven-plugin</artifactId> <version>${aemanalyser.version}</version> <extensions>true</extensions> </plugin> <!-- Content Package Plugin --> <plugin> <groupId>com.day.jcr.vault</groupId> <artifactId>content-package-maven-plugin</artifactId> <version>1.0.2</version> <configuration> <targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL> <failOnError>true</failOnError> <userId>${vault.user}</userId> <password>${vault.password}</password> </configuration> </plugin> <!-- Maven Enforcer Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>3.0.0-M3</version> </plugin> <!-- Maven Dependency Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.0.0</version> </plugin> <!-- Build Helper Maven Plugin --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.0.0</version> </plugin> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <versionRange>[1.0.0,)</versionRange> <goals> <goal>enforce</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-dependency-plugin </artifactId> <versionRange> [2.2,) </versionRange> <goals> <goal>copy-dependencies</goal> <goal>unpack</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId> org.codehaus.mojo </groupId> <artifactId> build-helper-maven-plugin </artifactId> <versionRange> [1.5,) </versionRange> <goals> <goal> reserve-network-port </goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> <profiles> <!-- Development profile: install only the bundle --> <profile> <id>autoInstallBundle</id> <!-- To enable this feature for a bundle, the sling-maven-plugin (without configuration) needs to be included: <plugin> <groupId>org.apache.sling</groupId> <artifactId>sling-maven-plugin</artifactId> </plugin> --> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.sling</groupId> <artifactId>sling-maven-plugin</artifactId> <executions> <execution> <id>install-bundle</id> <goals> <goal>install</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </profile> <profile> <id>autoInstallPackage</id> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.jackrabbit</groupId> <artifactId>filevault-package-maven-plugin</artifactId> <executions> <execution> <id>create-package</id> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.day.jcr.vault</groupId> <artifactId>content-package-maven-plugin</artifactId> <executions> <execution> <id>install-package</id> <goals> <goal>install</goal> </goals> <configuration> <targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </profile> <profile> <id>autoInstallPackagePublish</id> <activation> <activeByDefault>false</activeByDefault> </activation> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.jackrabbit</groupId> <artifactId>filevault-package-maven-plugin</artifactId> <executions> <execution> <id>create-package</id> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.day.jcr.vault</groupId> <artifactId>content-package-maven-plugin</artifactId> <executions> <execution> <id>install-package-publish</id> <goals> <goal>install</goal> </goals> <configuration> <targetURL>http://${aem.publish.host}:${aem.publish.port}/crx/packmgr/service.jsp</targetURL> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </profile> </profiles> <!-- ====================================================================== --> <!-- D E P E N D E N C I E S --> <!-- ====================================================================== --> <dependencyManagement> <dependencies> <dependency> <groupId>com.adobe.aem</groupId> <artifactId>aem-sdk-api</artifactId> <version>${aem.sdk.api}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.adobe.cq</groupId> <artifactId>core.wcm.components.core</artifactId> <version>${core.wcm.components.version}</version> </dependency> <!-- Testing --> <dependency> <groupId>org.junit</groupId> <artifactId>junit-bom</artifactId> <version>5.6.2</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>3.3.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-junit-jupiter</artifactId> <version>3.3.3</version> <scope>test</scope> </dependency> <dependency> <groupId>junit-addons</groupId> <artifactId>junit-addons</artifactId> <version>1.4</version> <scope>test</scope> </dependency> <dependency> <groupId>io.wcm</groupId> <artifactId>io.wcm.testing.aem-mock.junit5</artifactId> <version>4.1.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.adobe.cq</groupId> <artifactId>core.wcm.components.testing.aem-mock-plugin</artifactId> <version>${core.wcm.components.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>uk.org.lidalia</groupId> <artifactId>slf4j-test</artifactId> <version>1.0.1</version> <scope>test</scope> </dependency> </dependencies> </dependencyManagement> <repositories> <repository> <id>project.local</id> <name>project</name> <url>file:${maven.multiModuleProjectDirectory}/repository</url> </repository> </repositories> </project>
After using the mentioned command, you should see the respective package in the repository folder that you have created in project code base (Not under ./m2 unless you have specified that location in that command)
About the use of repositories in pom.xml, the location you have specified is fine (within <project>), just try using the below for <url>
<url>file://${project.basedir}/repository</url>
If this is not picking, try using the <repositories> entry tied to a profile.
Thanks again @Vijayalakshmi_S , You were correct, I had a typo in the mvn install:install-file command and after fixing that, it did install it correctly in the local project ./repository folder. I added the repositories in both location as you suggested and my build on machine is working fine. I will checkin everything and see if the cloud manager build also succeeds.
Much appreciate your help!
-SKM_AEM
Hi @Vijayalakshmi_S
I am trying to use this functionality of adding 3rd part dependency from local and followed all the steps as mentioned. I can see the package under the repository folder with base directory, but while building the project I do not see this package getting deployed to my local instance.
Am I missing anything here?
Thanks,
Asutosh
Cross check the below
Hi @Vijayalakshmi_S
Yes I am using the below in main pom.xml
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file://${project.basedir}/repository</url>
</repository>
</repositories>
Using embedd in all module pom.xml
<embedded>
<groupId>com.connector</groupId>
<artifactId>aem-connector-project.all</artifactId>
<type>zip</type>
<target>/apps/project-vendor-packages/container/install.author</target>
</embedded>
What else missing here?
Thanks
Declare this connector package as dependency (within <dependencies>) in all/pom.xml
<dependency> <groupId>com.connector</groupId> <artifactId>aem-connector-project.all</artifactId> <version>Version of connector as available in local project repo</version> <type>zip</type> </dependency>
[Webinar | AEM GEMs] Looking under the hood - Cloud Manager 2022 | Register: https://adobe.ly/3t4jfgp & Ask Questions related to this Webinar: https://adobe.ly/3O0rdzd
Date &Time: Wednesday, June 15, 2022 - 8 am PDT OR 5 pm CET OR 8.30 pm IST
Speakers: Remus Stratulat & Shankari Panchapakesan
Share this within your Organisation and with your AEM peers!!
Views
Replies
Total Likes
[Webinar | AEM GEMs] Looking under the hood - Cloud Manager 2022 | Register: https://adobe.ly/3t4jfgp & Ask Questions related to this Webinar: https://adobe.ly/3O0rdzd
Date &Time: Wednesday, June 15, 2022 - 8 am PDT OR 5 pm CET OR 8.30 pm IST
Speakers: Remus Stratulat & Shankari Panchapakesan
Share this within your Organisation and with your AEM peers!!
Views
Replies
Total Likes
Sharing a blog which explains how to use Third-party bundles when:
- Hosted in restricted Maven repo
- Local repo (i.e. when maven repositories cannot be used)
https://techrevel.blog/2023/09/27/managing-third-party-dependencies-in-aem/
Views
Replies
Total Likes
Views
Likes
Replies