Grails

GrailsScriptRunner has hardcoded rule for skipPlugins Class Loading

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.2 final
  • Fix Version/s: None
  • Component/s: ContinuousBuild
  • Labels:
    None

Description

http://github.com/grails/grails/blob/master/grails/src/java/org/codehaus/groovy/grails/cli/GrailsScriptRunner.java

There is a check near line 402 like the following:

boolean skipPlugins = "UninstallPlugin".equals(scriptName)||"InstallPlugin".equals(scriptName);

There should be a convention or a script argument that allows the developer to control the class loading of plugin jar files.

For ContinousBuild I have the need to create grails scripts that can perform changes to the set of installed plugins.

Uninstall of a plugin fails if the class loader has already loaded the plugin jar files.

Activity

Hide
Graeme Rocher added a comment -

Yes this is a rather nasty hack, can you suggest a convention?

Show
Graeme Rocher added a comment - Yes this is a rather nasty hack, can you suggest a convention?
Hide
Trevor Hawrysh added a comment -

My immediate need would be fixed by changing the line in question from using equals method to using startsWith method

boolean skipPlugins = scriptName.startsWith("Uninstall") || scriptName.startsWith("Install") || scriptName.startsWith("Upgrade") ;

This would allow the scripts I created in GRAILS-6034 to function as built and I would not have to hack my way into the InstallPlugin script.

Show
Trevor Hawrysh added a comment - My immediate need would be fixed by changing the line in question from using equals method to using startsWith method boolean skipPlugins = scriptName.startsWith("Uninstall") || scriptName.startsWith("Install") || scriptName.startsWith("Upgrade") ; This would allow the scripts I created in GRAILS-6034 to function as built and I would not have to hack my way into the InstallPlugin script.
Hide
Trevor Hawrysh added a comment -

As for a final solution I suggest that

The ONLY plugin jar resources to be loaded are those specified with a scope of 'build' in the 'dependencies' section of the BuildConfig.groovy file.

Thus, the line

URL[] urls = getClassLoaderUrls(settings, scriptCacheDir, existingJars, skipPlugins);

should be changed to something like

URL[] urls = getClassLoaderUrls(settings, scriptCacheDir, existingJars, BUILD_SCOPED_JARS);

Show
Trevor Hawrysh added a comment - As for a final solution I suggest that The ONLY plugin jar resources to be loaded are those specified with a scope of 'build' in the 'dependencies' section of the BuildConfig.groovy file. Thus, the line URL[] urls = getClassLoaderUrls(settings, scriptCacheDir, existingJars, skipPlugins); should be changed to something like URL[] urls = getClassLoaderUrls(settings, scriptCacheDir, existingJars, BUILD_SCOPED_JARS);

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Last Reviewed: