Using Eclipse IDE and a couple of plugins, you will be able to debug Groovy scripts that’s deployed on a cloud system.
- Go to https://tools.hana.ondemand.com and check which Eclipse version is compatible with SAP Cloud Platform Tools. As of the time of writing, this is the Oxygen version (4.7).
- Download and install the above Eclipse version from https://www.eclipse.org/downloads/. Pick the package for Java developers. If not available yet on your system, also download and install an appropriate JDK first.
- Install the following plugins in Eclipse
- Eclipse Groovy Development Tools. You should be able to find the update site URL for the version suitable for your Eclipse version at https://github.com/groovy/groovy-eclipse/wiki.
- SAP Cloud Platform Tools and SAP Cloud Platform Integration Tools. The update site URL can be found during step 1 above.
- Add SAP server
- Enable the Servers view. Go to Window > Show View > Other…, and select “Servers”
- Click on the link in the Servers view.
- Select SAP > SAP Cloud Platform. Specify the region host for your cloud platform installation, give the server an appropriate name (doesn’t really matter), and click Next.
- Specify the server information as well as your SAP account credentials on the next screen, then click Finish.
- The SAP Cloud Platform server should now appear in the Servers View. To start debugging on it.
- right click and select Restart in Debug.
- Select Groovy > Groovy Project
- Give the project a name and click Finish
- Add the groovy file that you wish to debug into the project. Note that the file name must be identical to the file that is uploaded in the system for Eclipse to recognize it.
- Open the groovy file and place a debug point on it. Then, trigger the script execution from the cloud system. The processing should be halted at the debug point within Eclipse, and you can debug the script.
- The first time this happens, you may see the following prompt advising you to switch to Debug perspective. Tick the checkbox and click Yes.
- The first time, the debug point will arrive at a byte code file instead of the groovy file in your project, such as this:
To resolve this, right click anywhere inside of the Debug view, and select Edit Source Lookup.
Click on Add > Java Project > tick the Groovy project created earlier.
After that, the debug point should move to your groovy file:
- The first time this happens, you may see the following prompt advising you to switch to Debug perspective. Tick the checkbox and click Yes.