Support class that configures the Grails classpath when executing command line scripts.
Constructor and description |
---|
ClasspathConfigurer
(PluginPathDiscoverySupport pluginPathSupport, BuildSettings settings, boolean skipPlugins) |
ClasspathConfigurer
(BuildSettings build, boolean skipPlugins) |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addDependenciesToURLs(java.util.Set<java.lang.String> excludes, java.util.List<java.net.URL> urls, java.util.List<java.io.File> runtimeDeps) |
|
protected void |
addLibs(java.io.File dir, java.util.List<java.net.URL> urls, java.util.Collection<?> excludes) Adds all the JAR files in the given directory to the list of URLs. |
|
protected void |
addPluginLibs(java.io.File pluginDir, java.util.List<java.net.URL> urls, BuildSettings settings) Adds all the libraries in a plugin to the given list of URLs. |
|
protected void |
addUrlsToRootLoader(java.net.URLClassLoader loader, java.net.URL[] urls) |
|
static void |
cleanResolveCache(BuildSettings settings) |
|
java.net.URLClassLoader |
configuredClassLoader() |
|
protected java.net.URL[] |
getClassLoaderUrls(BuildSettings settings, java.io.File cacheDir, java.util.Set<java.lang.String> excludes, boolean skipPlugins) Creates a new root loader with the Grails libraries and the application's plugin libraries on the classpath. |
|
void |
setExitOnResolveError(boolean exitOnResolveError) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Adds all the JAR files in the given directory to the list of URLs. Excludes any "standard-*.jar" and "jstl-*.jar" because these are added to the classpath in another place. They depend on the servlet version of the app and so need to be treated specially.
Adds all the libraries in a plugin to the given list of URLs.
pluginDir
- The directory containing the plugin.urls
- The list of URLs to add the plugin JARs to.
A Groovy RootLoader should be used to load GrailsScriptRunner, but this leaves us with a problem. If we want to extend its classpath by adding extra URLs, we have to use the addURL() method that is only public on RootLoader (it's protected on URLClassLoader). Unfortunately, due to the nature of Groovy's RootLoader a declared type of RootLoader in this class is not the same type as GrailsScriptRunner's class loader because the two are loaded by different class loaders.
In other words, we can't add URLs via the addURL() method because we can't "see" it from Java. Instead, we use reflection to invoke it.
loader
- The root loader whose classpath we want to extend.urls
- The URLs to add to the root loader's classpath.Creates a new root loader with the Grails libraries and the application's plugin libraries on the classpath.