I assume that it happens that your Groovy file compiles and ends up being a class in your binary directory (classpath). Instead of loading it at the url, try loading the script class.
Class scriptClass = getClass().classLoader.loadClass('com.corp.MyConfig') ConfigObject config = new ConfigSlurper().parse(scriptClass)
source share