Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:16
Show Gist options
  • Save ezhov-da/5ae2a7756c3c7ed9c3333026f76aac48 to your computer and use it in GitHub Desktop.
Save ezhov-da/5ae2a7756c3c7ed9c3333026f76aac48 to your computer and use it in GitHub Desktop.
dependencies in groovy scripts
https://wakeupcode.wordpress.com/2015/07/03/managing-dependencies-in-groovy-scripts/
1) Bootstrapping groovy with bash in the groovy script:
#!/bin/bash
//usr/bin/env groovy -cp extra.jar:some-spring-jar.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?
import org.springframework.class.from.jar
//... code goes here...
println 'Wicket!'
2) Adding libraries in directory .groovy/lib for any client of your script.
3) Using Grape:
@Grab(group='commons-lang', module='commons-lang', version='2.4')
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-RC2')
import groovyx.net.http.RESTClient;
def resp = new RESTClient('http://localhost:8081').
post([path : '/something/',
body :[input1:['value'], input2:['value']],
contentType : 'application/json'])
print resp.responseData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment