"Unable to use @Grab in Groovy script to add maven dependencies to classpath"
Hi,
I want to use the "Execute Script" RM operator to run a Groovy script using the HTTPBuilder module.
The Groovy script uses @Grab to add the required dependencies and runs perfectly in the GroovyConsole.
But when I run it from the RapidMiner UI in the "Execute Script" operator, I get the following error :
Process failed:
The scripting engine Groovy reported an error in the script: org.codehaus.groovy.control.
MultipleCompilationErrorsException: startup failed, Script1.groovy: 8: unexpected token: import @ line 8, column 1.
1 error
NB: I also tried to use the modified execute script plugin proposed by Steffen in another post but it didn't work either.
I want to use the "Execute Script" RM operator to run a Groovy script using the HTTPBuilder module.
The Groovy script uses @Grab to add the required dependencies and runs perfectly in the GroovyConsole.
But when I run it from the RapidMiner UI in the "Execute Script" operator, I get the following error :
Process failed:
The scripting engine Groovy reported an error in the script: org.codehaus.groovy.control.
MultipleCompilationErrorsException: startup failed, Script1.groovy: 8: unexpected token: import @ line 8, column 1.
1 error
Any fix or workaround available ?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.001">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.1.001" expanded="true" name="Process">
<process expanded="true" height="684" width="884">
<operator activated="true" class="execute_script" compatibility="5.1.001" expanded="true" height="60" name="Execute Script" width="90" x="255" y="165">
<parameter key="script" value="@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-RC2' ) import groovyx.net.http.* import static groovyx.net.http.ContentType.* import static groovyx.net.http.Method.* def http = new HTTPBuilder( 'http://ajax.googleapis.com' ) // perform a GET request, expecting JSON response data http.request( GET, JSON ) { uri.path = '/ajax/services/search/web' uri.query = [ v:'1.0', q: 'Calvin and Hobbes' ] headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4' // response handler for a success response code: response.success = { resp, json -> println resp.statusLine // parse the JSON response object: json.responseData.results.each { println " ${it.titleNoFormatting} : ${it.visibleUrl}" } } // handler for any failure status code: response.failure = { resp -> println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}" } }"/>
</operator>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
</operator>
</process>
NB: I also tried to use the modified execute script plugin proposed by Steffen in another post but it didn't work either.