Using EGit to quickly create an Adapter Module’s EJB & EAR project
Creating an Adapter Module for PI takes a bit of an effort as we have to create the EJB and EAR projects in NWDS and set up all the necessary build paths and deployment descriptor files.
As I start to use EGit/Git to manage my NWDS projects, I’ve come to find different ways it can enhance my workflows. One such area is in setting up template EJB & EAR projects for custom adapter module. There is already other approaches like the blog below is using templates for adapter module projects.
The benefit of using EGit is that the projects will be automatically version-managed by Git once the template is cloned into NWDS.
Below are the steps on how to quickly set up an adapter module project using template content from GitHub.
The steps below are based on NWDS 7.31. EGit needs to be installed and configured first as detailed in Installation and Initial Configuration sections of the following blog.
Step 1 – Clone Git repository from GitHub to NWDS
Go to the Git repository via the link below, and select Copy to clipboard.
In NWDS, switch to Git perspective – Window > Open Perspective > Other > Git Repository Exploring
Click the Clone Git Repository button
A window will pop up with pre-populated value of the GitHub URL details. Accept the default value and click Next.
It will load the GitHub branch details. Click Next again.
Finally, it will prompt for a destination of the local Git repository. Browse to the appropriate folder and select Finish.
The contents will be downloaded from GitHub to the local Git repository. The screenshot below shows the new (arbitrarily named) Git repository new-module.
Step 2 – Import EJB and EAR projects
The contents in the Git repository already consists of the template EJB and EAR projects for a custom adapter module. This content will need to be imported into NWDS’s project explorer.
Right click on the Git repository and select Import Projects.
Select Import existing projects and click Next.
Select both EJB and EAR projects and click Finish.
After import has completed. Switch to the Java EE perspective and both the EJB and EAR projects will be listed in the Project Explorer.
Step 3 – Refactor project contents
Now just refactor the project contents according to the development naming conventions and requirements.
Rename EAR project.
Update provider name in application-j2ee-engine.xml in EAR project.
Rename EJB project.
Rename package in EJB project.
Rename EJB 3.0 Session Bean.
Rename ejb-j2ee-engine.xml deployment descriptor. Ensure that this matches the name of the session bean above.
Rename ejb-jar.xml deployment descriptor. Ensure that the name and package path matches above changes.
Step 4 – Commit initial content to Git (Optional)
Once all the changes have been done, optionally commit an initial version to the Git repository.
With this, the EJB and EAR projects are now ready for further development according to project requirements.
With this simple and easy steps, we can quickly establish a new custom adapter module project and dive right into the design and development details. We no longer need to remember the details of setting up the project configuration correctly, which can be quite repetitive (which I also find hard to remember at times with so many screens involved).
Once the Git repository is cloned, with just a few refactoring steps, the project is ready for development. Additionally, it benefits from already being tracked by Git.