Browse files

(GRAILS-9421) Checking that plugin is already installed as inline one…

… is done via info that is stored in pluin descriptor instead of checking grails.plugin.location.'some name'
  • Loading branch information...
1 parent ae20a3c commit f28502850bf2ea2500deff6d7a8a5a213bb8a998 @alexeysergeev alexeysergeev committed Nov 13, 2012
View
37 ...s-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngine.groovy
@@ -208,20 +208,12 @@ class PluginInstallEngine {
def (name, version) = readMetadataFromZip(zipFile.absolutePath)
/*
- * Determine if the plugin is currently configured to be used inline by
- * checking to see if the configured inline plugin names end with the
- * name of the plugin to be installed. This is necessary as the plugin
- * can be declared using the full vector in settings.groovy for an
- * inline plugin (i.e. com.mycompany:my-plugin). If the plugin is NOT
- * configured to run inline, install it. Otherwise, remove the previously
- * installed ZIP file if present to prevent duplicate class errors during
- * compilation.
- *
- * TODO: Also remove the installed plugin's paths from the classpath to
- * avoid errors about not being able to find the src folders AFTER
- * the plugin has been uninstalled.
+ * Determine if the plugin is currently configured to be used inline.
+ * If the plugin is NOT configured to run inline, install it.
+ * Otherwise, remove the previously installed ZIP file if present
+ * to prevent duplicate class errors during compilation.
*/
- if (!inlinePlugins.find { it.key.endsWith(name) } ) {
+ if (!isInlinePlugin(name)) {
installPluginZipInternal name, version, zipFile, false, false, true
} else {
// Remove the plugin to prevent duplicate class compile errors with inline version.
@@ -418,12 +410,10 @@ class PluginInstallEngine {
/*
* If the plugin to be installed is currently configured to be inline,
- * do not install it. This is because we want to use the inline over
- * the modified dependency artifact. The comparison to find the inline
- * plugin uses "endsWith", as inline plugins can be declared with a full
- * vector in settings.groovy (i.e. 'com.mycompany:my-plugin")
+ * do not install it. This is because we want to use the inline over
+ * the modified dependency artifact.
*/
- if (inlinePlugins.find { it.key.endsWith(name) } ) {
+ if (isInlinePlugin(name)) {
return true
}
@@ -787,4 +777,15 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
registerPluginWithMetadata(plugin.name, plugin.version)
}
}
+
+ /**
+ * Checks whether plugin is inline.
+ * @todo most probably it is required to search for plugin not just by name but also using its goupdId
+ * @param name The plugin name
+ * @return true iff plugin is inline one
+ */
+ private boolean isInlinePlugin(String name) {
+ GrailsPluginInfo info = pluginSettings.getPluginInfoForName(name);
+ return (info != null) && pluginSettings.getInlinePluginDirectories().find {it == info.getPluginDir()}
+ }
}

0 comments on commit f285028

Please sign in to comment.