3
votes

I have a grails application, and I'm trying to store all my .jrxml reports in src/reports. Since I can point at files with the jasper compiler, this works fine. However, now my reports need to be localized, and each report needs its own localization.

I have packages like this in src/reports:
com.stefankendall.blah.blah
com.stefankendall.a.b
com.stefankendall.c

In iReport 4.0.2, I can specify the exact folder of each bundle on the classpath, but can I do this within my running grails application?

Scraping together documentation, I have this:

src/reports/com/stefankendall/a/report1.jrxml
src/reports/com/stefankendall/a/report1_Bundle/report1.properties, report1_en_US.properties...

In my running application, report_Bundle doesn't appear to be on the classpath, so the jasper reports bomb. Is there a way to specify this path when I'm invoking jasper through groovy? Alternatively, can I somehow add src/reports to the classpath and drilldown somehow from the report?

1

1 Answers

0
votes

There may be a better way, but...

_Events.groovy:

eventClasspathStart = {
    addResourceBundlesToClasspath()
}


private def addResourceBundlesToClasspath(){
    classpathSet = false
    File reportsDir = new File("src/reports")
    reportsDir.eachDirRecurse { File directory ->
        if( directory.name.endsWith("_Bundle") ){
            println "Adding ${directory.getAbsolutePath()} to classpath"
            rootLoader.addURL( directory.toURL() )
        }
    }
}