Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 136 lines (116 sloc) 4.14 kb
7995c9f @graemerocher ignoring test temporarily, as due to infrastructure issues it is not abl...
graemerocher authored
1 /*
2 * Copyright 2004-2005 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 import groovy.xml.dom.DOMCategory
18 import org.codehaus.groovy.grails.plugins.GrailsPluginInfo
19
20 /**
21 * Gant script that handles the listing of Grails plugins
22 *
23 * @author Sergey Nebolsin
24 *
25 * @since 0.5.5
26 */
27
28 includeTargets << grailsScript("_GrailsPlugins")
29
30
31 target(listPlugins: "Implementation target") {
32 depends(parseArguments,configureProxy)
33
34 def repository = argsMap.repository
35 if (repository) {
36 eachRepository { name, url ->
37 if (name == repository) {
38 printRemotePluginList(repository)
39 printInstalledPlugins()
40 }
41 }
42 }
43 else if (argsMap.installed) {
44 printInstalledPlugins()
45 }
46 else {
47 eachRepository { name, url ->
48 printRemotePluginList(name)
49 return true
50 }
51 printInstalledPlugins()
52 }
53
54 println '''
55 To find more info about plugin type 'grails plugin-info [NAME]'
56
57 To install type 'grails install-plugin [NAME] [VERSION]'
58
59 For further info visit http://grails.org/Plugins
60 '''
61 }
62
63 private printInstalledPlugins() {
64
65 def installedPlugins = []
66 def pluginInfos = pluginSettings.getPluginInfos()
67 for (GrailsPluginInfo info in pluginInfos) {
68 installedPlugins << formatPluginForPrint(info.name, info.version, info.title)
69 }
70
71 if (installedPlugins) {
72 installedPlugins.sort()
73 println """
74 Plug-ins you currently have installed are listed below:
75 -------------------------------------------------------------
76 ${installedPlugins.join(System.getProperty("line.separator"))}
77 """
78
79 }
80 else {
81 println "You do not have any plugins installed."
82 }
83 }
84
85 private printRemotePluginList(name) {
86
87 def plugins = []
88 use(DOMCategory) {
89 pluginsList?.'plugin'.each {plugin ->
90 def version
91 def pluginLine = plugin.'@name'
92 def versionLine = "<no releases>"
93 def title = "No description available"
94 if (plugin.'@latest-release') {
95 version = plugin.'@latest-release'
96 versionLine = "<${version}>"
97 }
98 else if (plugin.'release'.size() > 0) {
99 // determine latest release by comparing version names in lexicografic order
100 version = plugin.'release'[0].'@version'
101 plugin.'release'.each {
102 if (!"${it.'@version'}".endsWith("SNAPSHOT") && "${it.'@version'}" > version) {
103 version = "${it.'@version'}"
104 }
105 }
106 versionLine = "<${version} (?)>\t"
107 }
108 def release = plugin.'release'.find {rel -> rel.'@version' == version}
109 if (release?.'title') {
110 title = release?.'title'.text()
111 }
112 plugins << formatPluginForPrint(pluginLine, versionLine, title)
113 }
114 }
115
116 // Sort plugin descriptions
117 if (plugins) {
118 plugins.sort()
119 println """
120 Plugins available in the $name repository are listed below:
121 -------------------------------------------------------------
122 ${plugins.join(System.getProperty("line.separator"))}
123 """
124
125 }
126 else {
127 grailsConsole.error "No plugins found in repository: ${name}. This may be because the repository is behind an HTTP proxy."
128 }
129 }
130
131 formatPluginForPrint = { pluginName, pluginVersion, pluginTitle ->
132 "${pluginName.toString().padRight(20, " ")}${pluginVersion.toString().padRight(16, " ")} -- ${pluginTitle}"
133 }
134
135 setDefaultTarget("listPlugins")
Something went wrong with that request. Please try again.