Reputation: 194
How do you access a class path resource from src/main/resources with a Groovy script? The following script works in MuleStudio, but does not work in Mule Maven standalone. Is there a way to write the script where it can pull the correct resource from MuleStudio and Mule Maven standalone?
<scripting:component doc:name="Script">
<scripting:script engine="Groovy"><![CDATA[
def command = "src/main/resources/shellscript/shellscriptfile.sh"
def cmd = command.execute()
cmd.waitFor()]]>
</scripting:script>
</scripting:component>
Upvotes: 1
Views: 1685
Reputation: 33413
You should load the command as a classpath resource instead of trying to build a path that works in all cases:
def command = this.getClass().getResource('/shellscript/shellscriptfile.sh').path
def cmd = command.execute()
cmd.waitFor()
Upvotes: 1