Groovy Examples

Go to list of examples

Use External JAR Library with Groovy IDE

Use External JAR Library with Groovy IDE

In Cloud Integration Flow editor, you can upload JAR files and they will be available for your Groovy scripts.

To use JAR files with Groovy IDE Desktop edition, you can add special comments at the start of the script. Since these are just comment lines, it doesn't affect your Flows.

//groovyide.com:jar:file:${Location of Jar file}

Then, you can import Java classes as usual.

Script

Try it on Groovy IDE
// These lines are ignored in Cloud Integration runtime:

//groovyide.com:jar:file:C:/opt/jars/jackson-core-2.12.5.jar
//groovyide.com:jar:file:C:/opt/jars/jackson-databind-2.12.5.jar
//groovyide.com:jar:file:C:/opt/jars/jackson-annotations-2.12.5.jar

//imports will not give error:
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.type.CollectionType;

import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {
    
	return message;
}