Groovy script in Maven project

I have a maven project and a groovy script associated with one. Script is self-sufficient and it runs successfully from command promt (groovy script.groovy). But when I run script from IDEA I get different errors. As I understand reasons of errors are maven dependencies.
1. If maven project has a dependency on groovy, groovy starts running from maven's repository (groovy.jar and groovy.home located in /.m2/...). Resolved it this way: right click on project ,“Add Framework support” and add Groovy from “real” groovy.home (not from maven).
2. But then a met the error I can't resolve:
java.lang.LinkageError: loader constraint violation: loader (instance of groovy/lang/GroovyClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"

I think IDEA loads all dependencies from pom file even they are not using in groovy.

I could not find any instructions how to create groovy scripts in the maven projects. Is there any way to run groovy script in IDEA without influence of maven? Or may be some advice how to configure groovy/project to avoid linkage error?

1 comment
Comment actions Permalink

You can run this script using gmaven-plugin, may be this help.
Add following code to pom.xml


then create maven run configuration with command "groovy:execute" and run it.

Please sign in to leave a comment.