Setup com.equalize.xpi.af.modules Adapter Module project in NWDS easily using EGit
When I first shared on SCN the custom adapter modules that I developed, I hoped that it would be beneficial to others who require similar solutions for their requirement. My intention was to bridge some of the gaps in SAP’s own standard offering (some gaps which have been around for far too long!) by providing highly reusable solutions.
I have been pleasantly surprised by the response of SCN members to the com.equalize.xpi.af.modules suite of adapter modules (FormatConversionBean, AttachmentSplitterBean and DynamicAttributeChangeBean). As I have provided the EAR file that can be used for direct deployment to PI/PO 7.31/7.4 (and I believe it should also work in PI/PO 7.3), many have deployed it on their systems and provided feedback that the modules are working well. Some have also provided feedback on issues and bugs which have helped me improve the modules further.
Occasionally, there are some requests on setting up the project in NWDS (based on the source codes I provide in GitHub) in order to further customize the solution. Although the blog Recompile com.equalize.xpi.af.modules as EJB 2.1 modules in NWDS 7.1x was written with the intention to enable those working on older PI systems to compile the modules, the procedures are also relevant for NWDS 7.3x and higher.
As I use EGit more and more in my daily routine, it has provided various valuable ways to enhance my workflow such as using EGit to quickly create an Adapter Module’s EJB & EAR project.
Similarly, for those working on NWDS 7.3x and higher and interested in customizing these adapter modules, it is much easier to use EGit to setup the project from the GitHub repository (instead of the steps in the blog for NWDS 7.1x). I have since restructured the GitHub repository so that it can be easily cloned and imported into an Eclipse/NWDS workspace. In this blog, I will share the steps of how this can be achieved relatively easily. I hope this will be useful for those who are interested in customizing/enhancing this solution further.
Note: This blog assumes that a working setup of an NWDS installation is already in place. There are many blogs in SCN that already covers that topic.
1. EGit installation and configuration
EGit comes pre-installed in an NWDS 7.5 bundle. For NWDS 7.3x, follow the Installation section of the following blog.
Once it is installed, complete the Initial Configuration section of the above blog.
2. PI Adapter Module library files
Although NWDS 7.3x onwards provides built in XPI Adapter Libraries, these are reduced copies and do not contain all classes compared to the libraries which are on the system. Some of the logic in the custom adapter modules refer to some classes which are not available in these reduced libraries. As such, the following JAR files need to be retrieved from the PI system.
Refer to the following Wiki for the location of these files and how to get them.
3. Apache POI library files
Download the following Apache POI 3.9 library files, and extract the JAR files to a folder named Apache_POI in the local file system.
Step by Step Procedure
Step 1 – Clone Git repository and Import Projects to NWDS
Go to the Git repository on the following site and click Copy to clipboard.
In NWDS, switch to Git perspective, and select Clone a Git repository.
The cloning wizard will be auto populated with the GitHub repository details. Click Next twice.
Select an appropriate location to store the Git repository locally. In the same step, select Import all existing projects after clone finishes.
Switch to the Java EE perspective, and the following 4 projects will be listed in the Project explorer. The first two are the EAR and EJB projects, followed by a standalone testing project, and lastly a Java project which the EJB project is dependent on.
Step 2 – Resolve JRE System Library
The projects were originally developed using SAP JVM 6. If a different JDK is used in your system, the JRE System Library needs to be updated accordingly.
Right click on the EJB project, select Build Path > Configure Build Path.
For example, if this was imported into an NWDS 7.5 installation (which supports Java 8), we can switch it to JDK 1.8.
Step 3 – Resolve classpath variable for Apache POI libraries
The Apache POI libraries need to be bundled together in the EAR file during deployment. As such, they are included in the build path of the EJB project as classpath variables.
Go to Window > Preferences > Java > Build Path > Classpath Variables. Select New.
Add a new entry named EXT_LIB, and select the parent folder where the Apache_POI folder reside. In the example below, select Library.
Save all the settings and when the following prompt is displayed, select Yes.
Step 4 – Resolve user library for PI adapter module libraries
Since the PI adapter module library files already exists in the system, they do not need to be bundled in the EAR file. Instead they are referenced in the EJB project as user libraries.
Go to Windows > Preferences > Java > Build Path > User Libraries. Select New.
Add a new user library named PI_LIB.
Click Add External JARs to the new user library.
Select the following two JAR files (which should already be downloaded based on the Prerequisite section).
Save all the settings. At this point, all the build path should be resolved and all classes should compile and build successfully.
For this point, furthercustomization to the codes can be performed.