Using code from open source
Before you begin make sure that you create a project and a deployment package for Digital Service application (or smart library) development.
You can use the Java code from a third party code (such as code that is available as open source in Github) in your smart bundle. To use the third party code in your smart bundle, you need to specify the dependency in the pom.xml file located in the bundle project.
To add the third party dependencies to your smart bundle
Add the dependency of the third party code in the pom.xml file located in the bundle project. For more information, see Dependencies.
For example, in the work-order-lib\bundle\pom.xml file, add a dependency of a library from Apache Commons to perform CSV parsing.<dependencies>
<!-- Add a custom dependency to bring in 3rd party code. -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1</version>
<!-- Use the default scope of “compile” since this code is not in the AR Server -->
<scope>compile</scope>
</dependency>Set up the dependencies in the maven bundle plugin .
For example:. . .
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>${rx-sdk.bundleName}</Bundle-Name>
<Bundle-SymbolicName>${rx-sdk.bundleId}</Bundle-SymbolicName>
<Bundle-Activator>com.example.bundle.MyApplication</Bundle-Activator>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Bundle-Description>${rx-sdk.bundleDescription}</Bundle-Description>
<Bundle-Vendor>${rx-sdk.bundleDeveloperId}</Bundle-Vendor>
<RxBundle-FriendlyName>${rx-sdk.bundleFriendlyName}</RxBundle-FriendlyName>
<RxBundle-IsApplication>${rx-sdk.bundleIsApplication}</RxBundle-IsApplication>
<!-- Include any 3rd party dependencies -->
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
</instructions>
</configuration>
</plugin>Run the following command to navigate to the bundle directory and build the bundle :
mvn clean installFor example:
projects> cd work-order-lib\bundle
bundle> mvn clean install- Verify the bundle.
For example, open the bundle work-order-lib\bundle\target\com.example.work-order-lib.1.0-SNAPSHOT.jar and check the dependent library is distributed at the root location of the bundle. - Load the pom.xml file in Eclipse. Ensure that the project (for work-order-lib) is updated with the new pom.xml file settings.
This enables the use of CSV library.
- Modify the required class in the Java code to use the library.
Build and deploy the new code using the following command:
mvn clean install -Pexport -Pdeploy