-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegenGrailsPlugin.groovy
executable file
·94 lines (82 loc) · 3.26 KB
/
RegenGrailsPlugin.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import org.codehaus.groovy.grails.plugins.regen.GeneratorArtefactHandler
import org.codehaus.groovy.grails.plugins.regen.DefaultGrailsGeneratorClass
import org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler
import org.codehaus.groovy.grails.commons.DomainClassArtefactHandler
class RegenGrailsPlugin {
// the plugin version
def version = "0.2.13"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.2.1 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = ['scripts/_Events.groovy']
// TODO Fill in these fields
def author = "Richard Lemieux"
def authorEmail = "[email protected]"
def title = "Plugin summary/headline"
def description = '''\\
Brief description of the plugin.
'''
def artefacts = [ GeneratorArtefactHandler ]
def providedArtefacts = [
//FirstDomainGenerator,
//SaveDomainGenerator
]
def watchedResources = [
//"file:./src/generators/views/*Generator.groovy",
//"file:./src/generators/**/*Generator.groovy"
"file:./grails-app/generators/**/*Generator.groovy"
]
/*
def providedArtefacts = [
DefaultGrailsPropertyViewGenerationStep,
FirstViewGenerationStep,
HookMergeViewGenerationStep,
SaveViewGenerationStep
]
*/
def onChange = { event ->
if(application.isArtefactOfType(GeneratorArtefactHandler.TYPE, event.source)) {
application.addArtefact(GeneratorArtefactHandler.TYPE, new DefaultGrailsGeneratorClass(event.source))
}
/*
} else if(application.isArtefactOfType(DomainClassArtefactHandler.TYPE, event.source)) {
} else if(application.isArtefactOfType(ControllerArtefactHandler.TYPE, event.source)) {
//} else if(event.source.name.endsWith(".gsp")) { // is source a Class or a String ?
} else if(event.source.endsWith(".gsp")) {
*/
//} else {
// def regenSrv = applicationContext.regenConsoleService
// regenSrv.artefactChanged(event.source)
//}
}
// URL to the plugin's documentation
def documentation = "http://grails.org/plugin/regen"
def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
}
def doWithSpring = {
for(generator in application.generatorClasses) {
log.debug "Configuring generator $generator.fullName"
if (generator) {
"${generator.fullName}"(generator.clazz) { bean ->
bean.scope = "prototype"
bean.autowire = "byName"
}
process(org.codehaus.groovy.grails.plugins.regen.GenerationProcess)
}
}
}
def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}
def doWithApplicationContext = { applicationContext ->
// TODO Implement post initialization spring config (optional)
}
def onConfigChange = { event ->
// TODO Implement code that is executed when the project configuration changes.
// The event is the same as for 'onChange'.
}
}