Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed uninstall-plugin to only display message; removed support for…

… global plugins since that makes no sense without install-plugin; removed dead code; added error handling for missing plugin during install-plugin
  • Loading branch information...
commit cd6e92cc888632a542b6a6d6f9c5284747734ecf 1 parent a7b1514
@burtbeckwith burtbeckwith authored
View
4 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/DependencyManager.java
@@ -34,14 +34,14 @@
*/
String GRAILS_CENTRAL_PLUGIN_LIST = "http://grails.org/plugins/.plugin-meta/plugins-list.xml";
-
/**
* Downloads the Grails central plugin list and saves it to the given file. The file is then parsed and the resulting XML returned
*
* @param localFile The local file
* @return The parsed XML
*/
- public GPathResult downloadPluginList(File localFile);
+ GPathResult downloadPluginList(File localFile);
+
/**
* Outputs the dependency graph to System.out
*/
View
72 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngine.groovy
@@ -63,7 +63,6 @@ class PluginInstallEngine {
protected PluginBuildSettings pluginSettings
protected BuildSettings settings
protected applicationPluginsLocation
- protected globalPluginsLocation
protected ant
protected PluginResolveEngine resolveEngine
@@ -85,7 +84,6 @@ class PluginInstallEngine {
if (md == null) throw new IllegalArgumentException("Argument [md] cannot be null")
if (ant== null) throw new IllegalArgumentException("Argument [ant] cannot be null")
- globalPluginsLocation = settings.globalPluginsDir
applicationPluginsLocation = settings.getProjectPluginsDir()
pluginSettings = pbs
this.settings = settings
@@ -122,10 +120,9 @@ class PluginInstallEngine {
*
* @param name The plugin name
* @param version The plugin version (optional)
- * @param globalInstall Whether to install globally or not (optional)
* @return true if installed and not cancelled by user
*/
- boolean installPlugin(String name, String version = null, boolean globalInstall = false) {
+ boolean installPlugin(String name, String version = null) {
installedPlugins.clear()
def pluginZip = resolveEngine.resolvePluginZip(name, version)
@@ -136,7 +133,7 @@ class PluginInstallEngine {
try {
(name, version) = readMetadataFromZip(pluginZip.absolutePath)
- return installPluginZipInternal(name, version, pluginZip, globalInstall)
+ return installPluginZipInternal(name, version, pluginZip)
}
catch (e) {
errorHandler "Error installing plugin: ${e.message}"
@@ -171,7 +168,7 @@ class PluginInstallEngine {
}
return pluginName.equals(name)
} ) {
- installPluginZipInternal name, version, zipFile, false, false, true
+ installPluginZipInternal name, version, zipFile, false, true
} else {
// Remove the plugin to prevent duplicate class compile errors with inline version.
uninstallPlugin name, version
@@ -182,9 +179,8 @@ class PluginInstallEngine {
* Installs a plugin from the given ZIP file
*
* @param zipFile The plugin zip file
- * @param globalInstall Whether it is a global install or not (optional)
*/
- boolean installPlugin(File zipFile, boolean globalInstall = false, boolean overwrite = false) {
+ boolean installPlugin(File zipFile, boolean overwrite = false) {
if (!zipFile.exists()) {
errorHandler "Plugin zip not found at location: ${zipFile.absolutePath}. Potential corrupt cache. Try running: grails --refresh-dependencies compile"
@@ -231,16 +227,15 @@ class PluginInstallEngine {
final localFile = reports[0].localFile
ant.mkdir(dir:"${settings.grailsWorkDir}/cached-installed-plugins")
ant.copy(file:localFile, tofile:"${settings.grailsWorkDir}/cached-installed-plugins/$name-${version}.zip")
- installPluginZipInternal name, version, localFile, globalInstall, overwrite
+ installPluginZipInternal name, version, localFile, overwrite
}
/**
* Installs a plugin from the given URL
*
* @param zipURL The zip URL
- * @param globalInstall Whether it is a global install or not (optional)
*/
- boolean installPlugin(URL zipURL, boolean globalInstall = false) {
+ boolean installPlugin(URL zipURL) {
def s = zipURL.toString()
def filename = s[s.lastIndexOf("/")..-1]
def file = File.createTempFile(filename[0..-4], ".zip")
@@ -252,14 +247,14 @@ class PluginInstallEngine {
catch (e) {
errorHandler "Error downloading plugin ${zipURL}: ${e.message}"
}
- installPlugin(file, globalInstall, true)
+ installPlugin(file, true)
}
protected boolean installPluginZipInternal(String name, String version, File pluginZip,
- boolean globalInstall = false, boolean overwrite = false, boolean isResolve = false) {
+ boolean overwrite = false, boolean isResolve = false) {
def fullPluginName = "$name-$version"
- def pluginInstallPath = "${globalInstall ? globalPluginsLocation : applicationPluginsLocation}/${fullPluginName}"
+ def pluginInstallPath = "$applicationPluginsLocation/$fullPluginName"
assertNoExistingInlinePlugin(name)
@@ -282,7 +277,7 @@ class PluginInstallEngine {
errorHandler "Cannot install plugin. Plugin install would override inline plugin configuration which is not allowed."
}
- def pluginXmlFile = new File("${pluginInstallPath}/plugin.xml")
+ def pluginXmlFile = new File(pluginInstallPath, "plugin.xml")
if (!pluginXmlFile.exists()) {
errorHandler("Plugin $fullPluginName is not a valid Grails plugin. No plugin.xml descriptor found!")
}
@@ -302,12 +297,9 @@ class PluginInstallEngine {
def runtimeDependencies = processPluginDependencies(pluginName,pluginXml)
// proceed _Install.groovy plugin script if exists
- def installScript = new File("${pluginInstallPath}/scripts/_Install.groovy")
+ def installScript = new File(pluginInstallPath, "scripts/_Install.groovy")
runPluginScript(installScript, fullPluginName, "post-install script")
- if (!isResolve) {
- registerPluginWithMetadata(pluginName, pluginVersion)
- }
pluginSettings.clearCache()
pluginSettings.registerNewPluginInstall(pluginZip)
@@ -464,7 +456,7 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
protected readPluginXmlMetadata(String pluginDirName) {
def pluginDir = pluginSettings.getPluginDirForName(pluginDirName)?.file
- new XmlSlurper().parse(new File("${pluginDir}/plugin.xml"))
+ new XmlSlurper().parse(new File(pluginDir, "plugin.xml"))
}
private assertGrailsVersionValid(String pluginName, String grailsVersion) {
@@ -486,18 +478,19 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
void uninstallPlugin(String name, String version = null) {
try {
String pluginKey = "plugins.$name"
- metadata.remove(pluginKey)
- metadata.persist()
+ if (metadata.remove(pluginKey)) {
+ metadata.persist()
+ }
def pluginDir
if (name && version) {
- pluginDir = new File("${applicationPluginsLocation}/$name-$version")
+ pluginDir = new File(applicationPluginsLocation, "$name-$version")
}
else {
pluginDir = pluginSettings.getPluginDirForName(name)?.file
}
if (pluginDir?.exists()) {
- def uninstallScript = new File("${pluginDir}/scripts/_Uninstall.groovy")
+ def uninstallScript = new File(pluginDir, "scripts/_Uninstall.groovy")
runPluginScript(uninstallScript, pluginDir.canonicalFile.name, "uninstall script")
if (isNotInlinePluginLocation(pluginDir)) {
ant.delete(dir:pluginDir, failonerror:true)
@@ -515,22 +508,6 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
}
}
- /**
- * Registers a plugin name and version as installed according to the plugin metadata
- * @param pluginName the name of the plugin
- * @param pluginVersion the version of the plugin
- */
- void registerPluginWithMetadata(String pluginName, pluginVersion) {
- if (settings.isRegisteredInMetadata(pluginName) || settings.notDefinedInBuildConfig(pluginName)) {
- addToMetadata(pluginName, pluginVersion)
- }
- }
-
- private def addToMetadata(pluginName, pluginVersion) {
- metadata['plugins.' + pluginName] = pluginVersion
- metadata.persist()
- }
-
private void runPluginScript(File scriptFile, fullPluginName, msg) {
if (pluginScriptRunner == null) {
return
@@ -548,8 +525,7 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
*/
boolean isNotInlinePluginLocation(File pluginDir) {
// insure all the directory is in the pluginsHome
- checkPluginPathWithPluginDir(applicationPluginsLocation, pluginDir) ||
- checkPluginPathWithPluginDir(globalPluginsLocation, pluginDir)
+ pluginDir.absolutePath.startsWith(applicationPluginsLocation.absolutePath)
}
protected postUninstall() {
@@ -564,11 +540,6 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
postInstallEvent?.call(pluginInstallPath)
}
- private checkPluginPathWithPluginDir (File pluginsHome, File pluginDir) {
- def absPluginsHome = pluginsHome.absolutePath
- pluginDir.absolutePath.startsWith(absPluginsHome)
- }
-
private boolean isCorePlugin(name) {
CORE_PLUGINS.contains(name)
}
@@ -619,13 +590,6 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
return pluginsToInstall
}
- private registerMetadataForPluginLocation(Resource pluginDir) {
- def plugin = pluginSettings.getPluginInfo(pluginDir.file.absolutePath)
- if (plugin != null) {
- 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
View
89 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginResolveEngine.groovy
@@ -47,23 +47,91 @@ final class PluginResolveEngine {
dependencyManager.createCopy(settings)
}
- void renderInstallInfo(String pluginName, Writer writer) {
- final text = new URL("http://grails.org/api/v1.0/plugin/$pluginName?format=xml").getText(connectTimeout: 500, readTimeout: 3000)
- def xml = new XmlSlurper().parseText(text)
+ void renderInstallInfo(String pluginName, String version, Writer writer) {
writer << """
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
+"""
+
+ def pluginXml
+ if (dependencyManager instanceof IvyDependencyManager) {
+ pluginXml = resolvePluginMetadata(pluginName, version)
+ if (!version) {
+ version = pluginXml.@version.text()
+ }
+ }
+ else {
+ String url = "http://grails.org/api/v1.0/plugin/$pluginName"
+ if (version) {
+ url += "/$version"
+ }
+ try {
+ final String text = new URL("$url?format=xml").getText(connectTimeout: 500, readTimeout: 3000)
+ pluginXml = new XmlSlurper().parseText(text)
+ if (!version) {
+ version = pluginXml.version.text()
+ }
+ }
+ catch (FileNotFoundException ignored) {}
+ }
+
+ if (!pluginXml) {
+ if (version) {
+ writer << """
+ERROR: Plugin '$pluginName' not found with version '$pluginVersion'
+"""
+ }
+ else {
+ writer << """
+ERROR: Plugin '$pluginName' not found
+"""
+ }
+ return
+ }
+ writer << """
Example:
grails.project.dependency.resolution = {
- ...
- plugins {
- compile ":$pluginName:${xml.version.text()}"
- }
+ ...
+ plugins {
+ compile ":$pluginName:$version"
+ }
}
"""
+
+ def repos = []
+ def ignored = [
+ 'http://plugins.grails.org',
+ 'http://repo.grails.org/grails/plugins/',
+ 'http://repo.grails.org/grails/core/',
+ 'http://svn.codehaus.org/grails/trunk/grails-plugins']
+
+ if (pluginXml.repositories.children().size()) {
+ for (repo in pluginXml.repositories.repository) {
+ String url = repo.@url.text().trim()
+ if (url in ignored) {
+ continue
+ }
+ if (url == 'http://repo1.maven.org/maven2/') {
+ url = 'mavenCentral()'
+ }
+ repos << url
+ }
+ }
+
+ if (repos) {
+ writer << """
+Additionally, add these custom repositories to the "repositories" block:
+"""
+ for (repo in repos) {
+ writer << """\
+ $repo
+"""
+ }
+ }
}
+
/**
* Renders plugin info to the target writer
*
@@ -74,6 +142,7 @@ grails.project.dependency.resolution = {
GPathResult renderPluginInfo(String pluginName, String pluginVersion, OutputStream outputStream) {
renderPluginInfo(pluginName, pluginVersion, new OutputStreamWriter(outputStream))
}
+
/**
* Renders plugin info to the target writer
*
@@ -183,11 +252,7 @@ To get info about specific release of plugin 'grails plugin-info [NAME] [VERSION
To get list of all plugins type 'grails list-plugins'
-To install latest version of plugin type 'grails install-plugin [NAME]'
-
-To install specific version of plugin type 'grails install-plugin [NAME] [VERSION]'
-
-For further info visit http://grails.org/Plugins
+For further info visit http://grails.org/plugins
'''
}
View
149 grails-bootstrap/src/test/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngineSpec.groovy
@@ -1,149 +0,0 @@
-package org.codehaus.groovy.grails.resolve
-
-import grails.util.*
-import static groovy.lang.GroovySystem.*
-import spock.lang.*
-import org.apache.ivy.core.module.id.ModuleId
-import org.apache.ivy.core.module.id.ModuleRevisionId
-
-class PluginInstallEngineSpec extends Specification {
-
- def "update existing metadata"() {
- given:
- def metadata = new MetadataStorage('plugins.test-plugin': '0.1')
- def engine = systemUnderTest(metadata)
- assert metadata['plugins.test-plugin'] == '0.1'
-
- when:
- engine.registerPluginWithMetadata('test-plugin', '2.3')
-
- then:
- metadata['plugins.test-plugin'] == '2.3'
- }
-
- def "persist to metadata when plugin defined in neither metadata nor BuildConfig"() {
- given:
- def metadata = new MetadataStorage()
- def engine = systemUnderTest(metadata)
- assert !metadata['plugins.test-plugin']
-
- when:
- engine.registerPluginWithMetadata('test-plugin', '0.1')
-
- then:
- metadata['plugins.test-plugin'] == '0.1'
- }
-
- def "do not persist to metadata when a transitive dependency exports the plugin"() {
- given:
- def metadata = new MetadataStorage()
- def engine = systemUnderTest(metadata, transitiveExported('test-plugin'))
-
- when:
- engine.registerPluginWithMetadata('test-plugin', '0.1')
-
- then:
- !metadata['plugins.test-plugin']
- }
-
- def "persist to metadata when transitive dependency does not export the plugin"() {
- given:
- def metadata = new MetadataStorage()
- def engine = systemUnderTest(metadata, transitiveNotExported('test-plugin'))
-
- when:
- engine.registerPluginWithMetadata('test-plugin', '0.1')
-
- then:
- metadata['plugins.test-plugin']
- }
-
- void "never persist to metadata when plugin is a non transitive dependency"() {
- given:
- def metadata = new MetadataStorage()
- def engine = systemUnderTest(metadata, dependency)
-
- when:
- engine.registerPluginWithMetadata('test-plugin', '0.1')
-
- then:
- !metadata['plugins.test-plugin']
-
- where:
- dependency << [exported('test-plugin'), notExported('test-plugin')]
- }
-
- private PluginInstallEngine systemUnderTest(MetadataStorage metadata, EnhancedDefaultDependencyDescriptor... dependencies = []) {
- def dependencyManager = dependencyManager(metadata.toMap(), dependencies)
- def engine = engine(dependencyManager, metadataPersistingToStorage(metadata))
- return engine
- }
-
- private IvyDependencyManager dependencyManager(registered, dependencies) {
- IvyDependencyManager.metaClass.getMetadataRegisteredPluginNames = {-> registered.keySet()}
- IvyDependencyManager.metaClass.getPluginDependencyDescriptors = {-> dependencies}
- def dependencyManager = new IvyDependencyManager('test', '0.1')
- return dependencyManager
- }
-
- private PluginInstallEngine engine(IvyDependencyManager dependencyManager, Metadata metadata) {
- def buildSettings = new BuildSettings()
- def pluginBuildSettings = new PluginBuildSettings(buildSettings)
- def engine = new PluginInstallEngine(buildSettings, pluginBuildSettings, metadata)
- // setting dependency manager after engine instantiation to avoid constructor hell
- buildSettings.setDependencyManager(dependencyManager)
- return engine
- }
-
- private Metadata metadataPersistingToStorage(storage) {
- Metadata.metaClass.persist = {-> storage.putAll(delegate)}
- return new Metadata()
- }
-
- def exported(plugin) {
- descriptor(plugin: plugin, export: true)
- }
-
- private notExported(plugin) {
- descriptor(plugin: plugin, export: false)
- }
-
- def transitiveExported(plugin) {
- descriptor(upstream: 'upstream-plugin', plugin: plugin, export: true)
- }
-
- private transitiveNotExported(plugin) {
- descriptor(upstream: 'upstream-plugin', plugin: plugin, export: false)
- }
-
- private EnhancedDefaultDependencyDescriptor descriptor(map) {
- def descriptor = new EnhancedDefaultDependencyDescriptor(new ModuleRevisionId(new ModuleId('org.test', map.plugin), '0.1'), true, 'compile')
- descriptor.plugin = map.upstream
- descriptor.export = map.export
- return descriptor
- }
-
- void cleanup() {
- metaClassRegistry.removeMetaClass IvyDependencyManager
- metaClassRegistry.removeMetaClass Metadata
- }
-
- private class MetadataStorage {
-
- private metadata = [:]
-
- MetadataStorage(map = [:]) {
- putAll(map)
- }
-
- void putAll(Map map) {
- metadata.putAll(map)
- }
-
- def getProperty(String key) {
- metadata[key]
- }
-
- Map toMap() {metadata}
- }
-}
View
12 grails-bootstrap/src/test/groovy/org/codehaus/groovy/grails/resolve/PluginResolveEngineSpec.groovy
@@ -4,16 +4,15 @@ import grails.util.BuildSettings
import spock.lang.Ignore
import spock.lang.Specification
-//@Ignore
class PluginResolveEngineSpec extends Specification {
def "Test install-plugin no longer valid message"() {
given:"An instance of the resolve engine"
- def resolveEngine = systemUnderTest()
+ def resolveEngine = systemUnderTest()
when:"We resolve the 'feeds' plugin"
def sw = new StringWriter()
- resolveEngine.renderInstallInfo("feeds", sw)
+ resolveEngine.renderInstallInfo("feeds", null, sw)
def info = sw.toString()
then:"The correct metadata is obtained"
@@ -23,13 +22,14 @@ Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
- ...
- plugins {
+ ...
+ plugins {
compile ":feeds:1.5"
- }
+ }
}
'''
}
+
def "Test that plugin-info obtains relevant plugin information in a plugin exists"() {
given:"An instance of the resolve engine"
def resolveEngine = systemUnderTest()
View
72 scripts/InstallPlugin.groovy
@@ -24,49 +24,33 @@
*/
import org.codehaus.groovy.grails.resolve.PluginResolveEngine
-includeTargets << grailsScript("_GrailsPlugins")
-
-def displayPluginInfo = { pluginName ->
-
- def settings = grailsSettings
- def pluginResolveEngine = new PluginResolveEngine(settings.dependencyManager, settings)
- def sw = new StringWriter()
- pluginXml = pluginResolveEngine.renderInstallInfo(pluginName, sw)
- grailsConsole.warn sw.toString()
-}
-
+includeTargets << grailsScript("_GrailsClean")
+includeTargets << grailsScript("_GrailsPackage")
+includeTargets << grailsScript("_PluginDependencies")
target(installPlugin:"Installs a plug-in for the given URL or name and version") {
depends(checkVersion, parseArguments, configureProxy)
- grailsConsole.warn 'The install-plugin command is deprecated and \
-may be removed from a future version of Grails. Plugin dependencies should \
-be expressed in grails-app/conf/BuildConfig.groovy. \
-See http://grails.org/doc/2.2.x/guide/conf.html#pluginDependencies.'
try {
def pluginArgs = argsMap['params']
+ if (!pluginArgs) {
+ event("StatusError", [ ERROR_MESSAGE])
+ return
+ }
- // fix for Windows-style path with backslashes
-
- if (pluginArgs) {
- if (argsMap['global']) {
- globalInstall = true
- }
-
- ant.mkdir(dir:pluginsBase)
-
- boolean installed
- def pluginFile = new File(pluginArgs[0])
- def urlPattern = ~"^[a-zA-Z][a-zA-Z0-9\\-\\.\\+]*://"
- if (pluginArgs[0] =~ urlPattern) {
- grailsConsole.warn """
+ def pluginFile = new File(pluginArgs[0])
+ def urlPattern = ~"^[a-zA-Z][a-zA-Z0-9\\-\\.\\+]*://"
+ if (pluginArgs[0] =~ urlPattern) {
+ grailsConsole.warn """
Since Grails 2.3, it is no longer possible to install plugins directly via a URL.
Upload the plugin to a Maven-compatible repository and declare the dependency in grails-app/conf/BuildConfig.groovy.
- """
- }
- else if (pluginFile.exists() && pluginFile.name.startsWith("grails-") && pluginFile.name.endsWith(".zip")) {
- grailsConsole.warn """
+"""
+ return
+ }
+
+ if (pluginFile.exists() && pluginFile.name.startsWith("grails-") && pluginFile.name.endsWith(".zip")) {
+ grailsConsole.warn """
Since Grails 2.3, it is no longer possible to install plugins directly from the file sytem.
If you wish to use local plugins then run 'maven-install' in the plugin directory to install the plugin into your local Maven cache.
@@ -74,19 +58,17 @@ If you wish to use local plugins then run 'maven-install' in the plugin director
Then inside your application's grails-app/conf/BuildConfig.groovy file declare the dependency and it will be resolved from you Maven cache.
If you make a change to the plugin simply run 'maven-install' in the directory of the plugin project again and the change will be picked up by the application (if the plugin version ends with -SNAPSHOT)
- """
-
- }
- else {
- // The first argument is the plugin name, the second
- // (if provided) is the plugin version.
- displayPluginInfo(pluginArgs[0])
- }
-
- }
- else {
- event("StatusError", [ ERROR_MESSAGE])
+"""
+ return
}
+
+ // show what to add to BuildConfig.groovy
+ def sw = new StringWriter()
+ def pluginResolveEngine = new PluginResolveEngine(grailsSettings.dependencyManager, grailsSettings)
+ String pluginName = argsMap.params[0]
+ String version = argsMap.params.size() > 1 ? argsMap.params[1] : null
+ pluginResolveEngine.renderInstallInfo(pluginName, version, sw)
+ grailsConsole.warn sw.toString()
}
catch(Exception e) {
logError("Error installing plugin: ${e.message}", e)
View
29 scripts/ListPluginUpdates.groovy
@@ -15,6 +15,9 @@
*/
import groovy.xml.dom.DOMCategory
+import org.codehaus.groovy.grails.resolve.GrailsRepoResolver
+import org.codehaus.groovy.grails.resolve.IvyDependencyManager
+
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_PluginDependencies")
@@ -44,13 +47,33 @@ def getAvailablePluginVersions = {
return plugins
}
+eachRepository = { Closure callable ->
+ def dependencyManager = grailsSettings.dependencyManager
+ if (dependencyManager instanceof IvyDependencyManager) {
+ for (resolver in dependencyManager.chainResolver.resolvers) {
+ if (resolver instanceof GrailsRepoResolver) {
+ pluginsList = resolver.getPluginList(new File(grailsWorkDir, "plugins-list-${resolver.name}.xml"))
+ if (pluginsList != null) {
+ callable(resolver.name, resolver.repositoryRoot)
+ } else {
+ grailsConsole.error "An error occurred resolving plugin list from resolver [${resolver.name} - ${resolver.repositoryRoot}]."
+ }
+ }
+ }
+ }
+ else {
+ dependencyManager.repositories.each { r ->
+ callable.call(r.id, r.url)
+ }
+ }
+}
+
def getInstalledPluginVersions = {
def plugins = [:]
- def pluginXmls = readAllPluginXmlMetadata()
- for (p in pluginXmls) {
+ for (p in readAllPluginXmlMetadata()) {
def name = p.@name.text()
def version = p.@version.text()
- plugins."$name" = version
+ plugins[name] = version
}
return plugins
}
View
7 scripts/ListPlugins_.groovy
@@ -25,8 +25,9 @@ import org.codehaus.groovy.grails.plugins.GrailsPluginInfo
* @since 0.5.5
*/
-includeTargets << grailsScript("_GrailsPlugins")
-
+includeTargets << grailsScript("_GrailsClean")
+includeTargets << grailsScript("_GrailsPackage")
+includeTargets << grailsScript("_PluginDependencies")
target(listPlugins: "Implementation target") {
depends(parseArguments,configureProxy)
@@ -35,7 +36,7 @@ target(listPlugins: "Implementation target") {
printInstalledPlugins()
}
else {
- pluginsList = grailsSettings.dependencyManager.downloadPluginList(new File("$grailsWorkDir/plugins-list-grailsCentral.xml"))
+ pluginsList = grailsSettings.dependencyManager.downloadPluginList(new File(grailsWorkDir, "plugins-list-grailsCentral.xml"))
printRemotePluginList("grailsCentral")
printInstalledPlugins()
}
View
25 scripts/PluginInfo_.groovy
@@ -15,6 +15,7 @@
*/
import grails.util.BuildSettings
+
import org.codehaus.groovy.grails.resolve.PluginResolveEngine
/**
@@ -25,28 +26,20 @@ import org.codehaus.groovy.grails.resolve.PluginResolveEngine
* @since 0.5.5
*/
-includeTargets << grailsScript("_GrailsPlugins")
-
-def displayPluginInfo = { pluginName, version ->
-
- BuildSettings settings = grailsSettings
- def pluginResolveEngine = new PluginResolveEngine(settings.dependencyManager, settings)
- pluginXml = pluginResolveEngine.renderPluginInfo(pluginName, version, System.out)
-}
-
+includeTargets << grailsScript("_GrailsPackage")
target(pluginInfo:"Implementation target") {
depends(parseArguments)
- if (argsMap.params) {
- def pluginName = argsMap.params[0]
- def version = argsMap.params.size() > 1 ? argsMap.params[1] : null
-
- displayPluginInfo(pluginName, version)
- }
- else {
+ if (!argsMap.params) {
event("StatusError", ["Usage: grails plugin-info <plugin-name> [version]"])
+ return
}
+
+ def pluginName = argsMap.params[0]
+ def version = argsMap.params.size() > 1 ? argsMap.params[1] : null
+
+ new PluginResolveEngine(grailsSettings.dependencyManager, grailsSettings).renderPluginInfo(pluginName, version, System.out)
}
setDefaultTarget("pluginInfo")
View
25 scripts/UninstallPlugin.groovy
@@ -21,29 +21,14 @@
*
* @since 1.1
*/
-includeTargets << grailsScript("_GrailsPlugins")
-includePluginJarsOnClasspath=false
+target(uninstallPlugin: "Uninstalls a plug-in for a given name") {
-target(uninstallPlugin:"Uninstalls a plug-in for a given name") {
- depends(checkVersion, parseArguments, clean)
+ grailsConsole.warn """
+As of Grails 2.3 it is not possible to install or uninstall a plugin using a script.
- if (argsMap['global']) {
- globalInstall = true
- }
-
- def pluginArgs = argsMap['params']
- if (pluginArgs) {
-
- def pluginName = pluginArgs[0]
- def pluginRelease = pluginArgs[1]
-
- uninstallPluginForName(pluginName, pluginRelease)
-
- }
- else {
- event("StatusError", ["You need to specify the plug-in name and (optional) version, e.g. \"grails uninstall-plugin feeds 1.0\""])
- }
+To remove a plugin, delete it from BuildConfig.groovy and/or application.properties.
+"""
}
setDefaultTarget("uninstallPlugin")
View
4 scripts/Upgrade.groovy
@@ -25,7 +25,9 @@
import grails.util.Metadata
-includeTargets << grailsScript("_GrailsPlugins")
+includeTargets << grailsScript("_GrailsClean")
+includeTargets << grailsScript("_GrailsPackage")
+includeTargets << grailsScript("_PluginDependencies")
UNMODIFIED_CHECKSUMS = [indexgsp:['e9f4d3450ba02fe92d55f4ae4b53dee8', 'e9f4d3450ba02fe92d55f4ae4b53dee8', '77f5ed5c2fca586a9ff1dc8e7beeb85b', '5313f072b2ed10129a446d5f648d8b41'],
errorgsp:['473b673fb3f04a60412ace1b7bc12a8c', '473b673fb3f04a60412ace1b7bc12a8c', '473b673fb3f04a60412ace1b7bc12a8c', '473b673fb3f04a60412ace1b7bc12a8c'],
View
4 scripts/_GrailsCreateProject.groovy
@@ -25,7 +25,9 @@ import grails.util.Metadata
* @since 0.4
*/
-includeTargets << grailsScript("_GrailsPlugins")
+includeTargets << grailsScript("_GrailsClean")
+includeTargets << grailsScript("_GrailsPackage")
+includeTargets << grailsScript("_PluginDependencies")
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("IntegrateWith")
View
65 scripts/_GrailsPlugins.groovy
@@ -1,65 +0,0 @@
-/*
-* Copyright 2004-2005 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-import groovy.xml.dom.DOMCategory
-
-import org.codehaus.groovy.grails.plugins.GrailsPluginInfo
-import org.codehaus.groovy.grails.resolve.PluginResolveEngine
-import grails.util.BuildSettings
-
-/**
- * Gant script that handles the installation of Grails plugins
- *
- * @author Graeme Rocher
- * @author Sergey Nebolsin
- *
- * @since 0.4
- */
-
-includeTargets << grailsScript("_GrailsClean")
-includeTargets << grailsScript("_GrailsPackage")
-includeTargets << grailsScript("_PluginDependencies")
-
-ERROR_MESSAGE = """
-You need to specify either the direct URL of the plugin or the name and version
-of a distributed Grails plugin found at http://plugins.grails.org
-For example:
-'grails install-plugin spring-security-core 1.0'
-or
-'grails install-plugin http://plugins.grails.org/grails-spring-security-core/trunk/grails-spring-security-core-1.0.zip"""
-
-globalInstall = false
-
-target(cachePlugin:"Implementation target") {
- depends(configureProxy)
- fullPluginName = cacheKnownPlugin(pluginName, pluginRelease)
-}
-
-target(installDefaultPluginSet:"Installs the default plugin set used by Grails") {
- for (plugin in grailsSettings.defaultPluginMap) {
- def zipName = "grails-${plugin.key}-${plugin.value}"
- def pluginZip = new File(grailsSettings.grailsHome, "plugins/${zipName}.zip")
- if (!pluginZip.exists()) {
- pluginZip = new File(grailsSettings.grailsWorkDir, "plugins/${zipName}.zip")
- }
- if (pluginZip.exists()) {
- doInstallPluginZip pluginZip
- }
- else {
- doInstallPlugin plugin.key, plugin.value
- }
- }
-}
View
105 scripts/_PluginDependencies.groovy
@@ -15,8 +15,6 @@
*/
import org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader
-import org.codehaus.groovy.grails.resolve.GrailsRepoResolver
-import org.codehaus.groovy.grails.resolve.IvyDependencyManager
import org.codehaus.groovy.grails.resolve.PluginInstallEngine
/**
@@ -35,12 +33,10 @@ includeTargets << grailsScript("_GrailsProxy")
// Properties
pluginsList = null
-globalInstall = false
-pluginsBase = "${grailsWorkDir}/plugins".toString().replaceAll('\\\\','/')
// Targets
-target(resolveDependencies:"Resolve plugin dependencies") {
- depends(parseArguments, initInplacePlugins)
+target(resolveDependencies: "Resolve plugin dependencies") {
+ depends(parseArguments, classpath)
// we get the 'build' and 'test' dependencies because that is the scope that
// includes all possible plugins in all scopes
def pluginZips = grailsSettings.pluginTestDependencies + grailsSettings.pluginBuildDependencies
@@ -53,25 +49,7 @@ target(resolveDependencies:"Resolve plugin dependencies") {
installEngine.checkPluginsToUninstall(pluginZips)
}
-target(initInplacePlugins: "Generates the plugin.xml descriptors for inplace plugins.") {
- depends(classpath)
-}
-
-/**
- * Generates the 'plugin.xml' file for a plugin. Returns an instance
- * of the plugin descriptor.
- */
-generatePluginXml = { File descriptor, boolean compilePlugin = true ->
- projectPackager.generatePluginXml(descriptor, compilePlugin)
-}
-
-target(loadPluginsAsync:"Asynchronously loads plugins") {
- Thread.start {
- loadPlugins()
- }
-}
-
-target(loadPlugins:"Loads Grails' plugins") {
+target(loadPlugins: "Loads Grails' plugins") {
def pluginLoader = new GrailsProjectPluginLoader(grailsApp, classLoader, buildSettings, eventListener)
pluginManager = pluginLoader.loadPlugins()
grailsApp = pluginLoader.grailsApplication
@@ -97,30 +75,6 @@ runPluginScript = { File scriptFile, fullPluginName, msg ->
}
}
-readMetadataFromZip = { String zipLocation, pluginFile=zipLocation ->
- def installEngine = createPluginInstallEngine()
- installEngine.readMetadataFromZip(zipLocation)
-}
-
-/**
- * Uninstalls a plugin for the given name and version
- */
-uninstallPluginForName = { name, version=null ->
- def pluginInstallEngine = createPluginInstallEngine()
- pluginInstallEngine.uninstallPlugin name, version
-}
-
-/**
- * Installs a plugin for the given name and optional version
- */
-installPluginForName = { String name, String version = null ->
- PluginInstallEngine pluginInstallEngine = createPluginInstallEngine()
- if (name) {
- event("InstallPluginStart", ["$name-$version"])
- pluginInstallEngine.installPlugin(name, version, globalInstall)
- }
-}
-
private PluginInstallEngine createPluginInstallEngine() {
def pluginInstallEngine = new PluginInstallEngine(grailsSettings, pluginSettings, metadata, ant)
pluginInstallEngine.eventHandler = { eventName, msg -> event(eventName, [msg]) }
@@ -160,56 +114,3 @@ protected void resetClasspath() {
classpathSet = false
classpath()
}
-
-doInstallPluginFromURL = { URL url ->
- withPluginInstall {
- def installEngine = createPluginInstallEngine()
- installEngine.installPlugin url, globalInstall
- }
-}
-
-doInstallPluginZip = { File file ->
- withPluginInstall {
- def installEngine = createPluginInstallEngine()
- installEngine.installPlugin file, globalInstall, true
- }
-}
-
-doInstallPlugin = { pluginName, pluginVersion = null ->
- withPluginInstall {
- def installEngine = createPluginInstallEngine()
- installEngine.installPlugin pluginName, pluginVersion, globalInstall
- }
-}
-
-eachRepository = { Closure callable ->
- def dependencyManager = grailsSettings.dependencyManager
- if(dependencyManager instanceof IvyDependencyManager) {
- for (resolver in dependencyManager.chainResolver.resolvers) {
- if (resolver instanceof GrailsRepoResolver) {
- pluginsList = resolver.getPluginList(new File(grailsWorkDir, "plugins-list-${resolver.name}.xml"))
- if (pluginsList != null) {
- callable(resolver.name, resolver.repositoryRoot)
- } else {
- grailsConsole.error "An error occurred resolving plugin list from resolver [${resolver.name} - ${resolver.repositoryRoot}]."
- }
- }
- }
- }
- else {
- dependencyManager.repositories.each { r ->
- callable.call(r.id, r.url)
- }
- }
-
-}
-
-private withPluginInstall(Closure callable) {
- try {
- fullPluginName = callable.call()
- }
- catch (e) {
- logError("Error installing plugin: ${e.message}", e)
- exit(1)
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.