Using EGit for Java source code management in NWDS
Update 19 Feb 2016: Additional configuration entry when using EGit with online repositories.
Java developments are becoming more common as PI/PO moves to single Java-only stack. Pure Java mappings and adapter module developments are commonplace these days to tackle the myriad challenges faced in integration projects. Together with continuous enhancements of the PI-centric functionality in Eclipse-based NWDS, NWDS is poised to become the single IDE for all PI/PO based development.
While ESR development and ID configuration changes are automatically tracked by PI’s internal version control, there is no built-in version control system for Java mappings and adapter module developments. It is not uncommon that Java source codes for these are developed and maintained on a developer’s local computer, with the compiled JAR/EAR files deployed manually into the server. This approach is a potential risk for an organization where the developer might leave the organization or the computer could get lost or damaged.
SAP’s own offering to address this gap is NetWeaver Development Infrastructure (NWDI). It is a full blown server based solution providing a complete Java development environment, which covers not just version control, but includes landscape management, transport & deployment mechanism and many more.
However, not many organizations have NWDI or are willing to invest in it. It may be that the cost is prohibitive with low ROI as most organizations that use SAP are still quite ABAP-centric with only minimal Java developments.
In this blog, I will introduce Git as an alternative to NWDI for version control management. It is an open-source lightweight and popular Source Code Management tool. In particular, there is an Eclipse-based EGit plugin that can be used within NWDS.
To install the plugin in NWDS, click Help > Install New Software
Unfortunately, as NWDS 7.31 is based on Galileo, an old version of Eclipse, therefore it is only compatible with an old version of the EGit plugin, version 2.1. Therefore, add the following update site for EGit version 2.1 – http://archive.eclipse.org/egit/updates-2.1
Select Eclipse EGit and proceed with the rest of the installation.
After installation has been completed, NWDS has to be restarted. Upon restart, it will usually prompt the following two warnings.
Warning 1 – HOME environment variable
To fix this, edit the environment variables in your computer and add HOME as a new user variable with an appropriate directory of your choice.
Warning 2 – Git installation
This can be ignored, so check the “Do not warn” checkbox and proceed.
Additionally, configure the following basic user settings under Preferences > Team > Git > Configuration
- core.autocrlf = false
- user.email = <your email>
- user.name = <your name>
If EGit is to be used to access online repositories like GitHub, add the following key-value pair to the Git configuration.
Basic Usage of EGit
I’ll cover some basic usage of EGit just to begin with. For further information, please refer to the EGit User Guide in the reference section.
Create Git repository
Change to Git Repository Exploring perspective. Click the “Create a new Git Repository” button
Provide details to the new repository. Note that the user guide recommends that the Git repository is not created within the Eclipse workspace.
Import existing project into Git repository
Switch back to Java EE perspective or any perspective with Project Explorer. Right click on project to be added and select Team > Share Project. Then select Git as the repository type.
Select the Git repository that was previously created. Once the configuration is completed, the source codes of the project will be moved to the directory of the Git repository.
Add files to be tracked and commit changes
Right click on project node and select Team > Add to Index
Subsequently, right click on project node and select Team > Commit to commit the files to be tracked by EGit. Note that binary .class files do not need to be committed, they can optionally be ignored from further commits by configuring a .gitignore file.
With EGit on NWDS, we can implement a simple solution to provide a Source Code Management system to manage Java developments for PI/PO. To reduce the risk of the valuable Java projects and source codes being on just a local machine, the Git repository can be hosted on a network directory, or even on a managed remote server.
Thank you for your contribution Eng!!!
Hey Eng Swee,
I was following these instructions but encountered a problem when cloning a Git repo. The error I got when using connection protocol https was: cannot open git-upload-pack
I fixed it by adding entry http.sslverify = false in the Git Configuration and restarting.
Edit: I was using SAP NWDS 7.3 SP16
Thanks for your comment. You are definitely right. I actually have that entry in my NWDS EGit configuration but missed including it in the instructions. I've updated the blog accordingly.
Hi Thomas/Eng Swee Yeoh ,
I put this configuration, but I continue having this problem.
I’ve restarted the NDWS many times, but the error continue.
Is there something that can i do?
Not too sure about it. The version for NWDS is really old and the Git client may not be updated to work well with latest changes of the Git server.
I suggest that you use a different Git client to clone the Git repository to your laptop, then only import it into your NWDS workspace.
Hi Eng Swee,
Any possibility to use it also for BRM and BPM (DCs)?
Many thanks in advance,
I didn't try it because I noticed that the development is split across multiple projects and folder structure so I'm not sure when moving it to a Git repo it will still remain consistent.
Maybe you can try it out and let us know 😉
did anyone try to store DCs in Git, which are also connected to NWDI -> Is that possible at all?