An OSGi bundle is a Java™ archive file that contains Java code, resources, and a manifest that describes the bundle and its dependencies. The bundle is the unit of deployment for an application. This article is meant for developers wanting to create OSGi service or a servlet using AEM Forms 6.4 or 6.5. To build your first OSGi bundle please follow the following steps:
Install the supported version of JDK. I have used JDK1.8. Make sure you have added JAVA_HOME in your environment variables and is pointing to the root folder of your JDK installation.
Add the %JAVA_HOME%/bin to the path
Do not use JDK 15. It is not supported by AEM.
Open a new command prompt window and type:
java -version. You should get back the version of JDK identified by the
Maven is a build automation tool used primarily for Java projects. Please follow the following steps to install maven on your local system.
mavenin your C drive
M2_HOMEwith a value of
C:\maven\apache-maven-3.6.0. In my case, the mvn version is 3.6.0. At the time of writing this article the latest maven version is 3.6.3
%M2_HOME%\binto your path
mvn -version. You should see the mvn version listed as shown in the screenshot below
Install the latest version of eclipse
Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.
To create your first maven project, please follow the following steps:
aemformsbundlesin your C drive
mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=36 -D appTitle="My Site" -D appId="mysite" -D groupId="com.mysite" -D aemVersion=6.5.13
On successful completion you should see a build success message in your command window
mvn eclipse:eclipsefrom the command line. The command reads your pom file and creates Eclipse projects with correct metadata so that Eclipse will understand project types, relationships, classpath, etc.
Go to File -> Import and select Existing Maven Projects as shown here
Select the c:\aemformsbundles\mysite by clicking the Browse button
You may select to import the appropriate modules depending on your needs. Select and import the core module only, if you are only going to create Java code in your project.
Click Finish to start the import process
Project is imported into Eclipse and you will see a number of
src/main/java under the
mysite.core folder. This is the folder in which you will be writing most of your code.
You will need to include the AEMFD client sdk in your project to take advantage of various services that come with AEM Forms. Please refer AEMFD Client SDK to include the appropriate client SDK in your Maven project. You will have to include the AEM FD Client SDK in the dependencies section of
pom.xml of the core project as shown below.
<dependency> <groupId>com.adobe.aemfd</groupId> <artifactId>aemfd-client-sdk</artifactId> <version>6.0.122</version> </dependency>
To build your project, please follow the following steps:
mvn clean install -PautoInstallBundle
http://localhost:4502. The bundle will also be available on the file system at
C:\AEMFormsBundles\mysite\core\targetand can be deployed using Felix web console