This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathplugin-info.groovy
71 lines (62 loc) · 2.53 KB
/
plugin-info.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import groovy.xml.*
description("Prints information about the given plugin") {
usage "grails plugin-info [PLUGIN NAME]"
argument name:"Plugin Name", description:"The name of the plugin"
flag name:'snapshots', description:"Whether to list snapshot versions"
}
def pluginRepoURL = "https://repo.grails.org/grails/plugins3/org/grails/plugins"
def pluginName = args[0]
def includeSnapshots = flag('snapshots')
try {
console.addStatus "Plugin Info: ${pluginName}"
def mavenMetadata = new XmlSlurper().parseText(new URL("${pluginRepoURL}/${pluginName}/maven-metadata.xml").text)
def latestVersion = mavenMetadata.versioning.release.text()
if(!latestVersion) {
latestVersion = mavenMetadata.versioning.latest.text()
}
console.addStatus "Latest Version: ${latestVersion}"
allVersions = mavenMetadata.versioning.versions.version*.text()
if(!includeSnapshots) {
allVersions = allVersions.findAll {
!it?.endsWith('-SNAPSHOT')
}
}
console.addStatus "All Versions: ${allVersions.join(',')}"
def pluginInfo
if(latestVersion.endsWith('-SNAPSHOT')) {
def versionMetadata = new XmlSlurper().parseText(new URL("${pluginRepoURL}/${pluginName}/${latestVersion}/maven-metadata.xml").text)
def snapshotVersion = versionMetadata.version.text()
pluginInfo = new XmlSlurper().parseText(new URL("${pluginRepoURL}/${pluginName}/${latestVersion}/${pluginName}-${snapshotVersion}-plugin.xml").text)
}
else {
pluginInfo = new XmlSlurper().parseText(new URL("${pluginRepoURL}/${pluginName}/${latestVersion}/${pluginName}-${latestVersion}-plugin.xml").text)
}
if(pluginInfo) {
console.addStatus "Title: ${pluginInfo.title.text()}"
def desc = pluginInfo.description.text()
if(desc) {
console.log('')
console.log(desc)
console.log('')
}
console.log "* License: ${pluginInfo.license.text()}"
if(pluginInfo.documentation) {
console.log "* Documentation: ${pluginInfo.documentation.text()}"
}
if(pluginInfo.issueManagement) {
console.log "* Issue Tracker: ${pluginInfo.issueManagement.@url.text()}"
}
if(pluginInfo.scm) {
console.log "* Source: ${pluginInfo.scm.@url.text()}"
}
console.log """* Definition:
dependencies {
compile "org.grails.plugins:${pluginName}:${latestVersion}"
}
"""
}
}
catch(Throwable e) {
console.error "Failed to display plugin info: ${e.message}", e
return false
}