forked from gpc/export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportGrailsPlugin.groovy
68 lines (56 loc) · 2.16 KB
/
ExportGrailsPlugin.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
import org.apache.commons.logging.LogFactory
class ExportGrailsPlugin {
// the plugin version
def version = "1.7-SNAPSHOT"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.3 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
"grails-app/views/error.gsp"
]
def title = "Export Plugin" // Headline display name of the plugin
// URL to the plugin's documentation
def documentation = "http://grails.org/plugin/export"
def author = "Grails Plugin Collective"
def authorEmail = "[email protected]"
def description = '''\
This plugin offers export functionality supporting different formats e.g. CSV, Excel, Open Document Spreadsheet, PDF and XML
and can be extended to add additional formats.
'''
def license = 'APACHE'
def organization = [name: 'Grails Plugin Collective', url: 'http://github.com/gpc']
def issueManagement = [system: 'JIRA', url: 'http://jira.grails.org/browse/GPEXPORT']
def scm = [url: 'https://github.com/gpc/grails-export']
def doWithSpring = {
//This is only necessary here, because later on log is injected by Spring
def log = LogFactory.getLog(ExportGrailsPlugin)
"exporterFactory"(de.andreasschmitt.export.exporter.DefaultExporterFactory)
try {
ExportConfig.exporters.each { key, value ->
try {
//Override default renderer configuration
if(application.config?.export."${key}"){
value = grailsApplication.config.export."${key}"
}
Class clazz = Class.forName(value, true, new GroovyClassLoader())
//Add to spring
"$key"(clazz) { bean ->
bean.scope = "prototype"
}
}
catch(ClassNotFoundException e){
log.error("Couldn't find class: ${value}", e)
}
}
}
catch(Exception e){
log.error("Error initializing Export plugin", e)
}
catch(Error e){
//Strange error which happens when using generate-all and hibernate.cfg
log.error("Error initializing Export plugin")
}
}
}