{"id":455,"date":"2010-03-12T22:58:20","date_gmt":"2010-03-12T17:28:20","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=455"},"modified":"2016-12-19T15:06:05","modified_gmt":"2016-12-19T09:36:05","slug":"compiling-sub-reports-in-jasper-reports","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/compiling-sub-reports-in-jasper-reports\/","title":{"rendered":"Compiling sub-reports in Jasper reports"},"content":{"rendered":"<p>In my project we needed to generate pdf reports. The tool we used to design reports is IReport 2.0.5 &amp; the plugin used is grails jasper plugin.The plugin works fine with simple reports but fails when it come to complex report which uses subreport.The problem is that the plugin compiles .jrxml file to .jasper file upto 1 level.It do not compiles subreport.<\/p>\n<p>When we compile.jrxml files using iReport, it takes the hardcoded path of the local machine &amp; hence throws an exception in other environment.<br \/>\nSo to overcome this problem i used the following script by putting it in CompileReports.groovy file under scripts folder.<\/p>\n<blockquote>\n<div class=\"code\">\n<pre lang=\"groovy\">  import org.codehaus.groovy.grails.commons.GrailsClassUtils as GCU\r\ngrailsHome = Ant.project.properties.\"environment.GRAILS_HOME\"\r\nincludeTargets &lt;&lt; new File(\"${grailsHome}\/scripts\/Init.groovy\")\r\ntarget('default': \"Compile all Jasper Reports\") {\r\n    compileAll()\r\n}\r\ntarget(compileAll: \"Compile all *.jrxml files as *.jasper\") {\r\n    depends(classpath)\r\n    def sourceDir = (config.'jasper.dir.reports'?:'reports')\r\n    Ant.echo \"sourceDir = ${sourceDir}\"\r\n    Ant.taskdef(classpathref:\"grails.classpath\",name: \"jrc\", classname: \"net.sf.jasperreports.ant.JRAntCompileTask\")\r\n    mkdir(dir:\"~\/.grails\/.jasper\")\r\n    jrc(srcdir:\"${basedir}\/web-app\/${sourceDir}\", tempdir: \"~\/.grails\/.jasper\") {include(name:\"**\/*.jrxml\")\r\n    }\r\n}<\/pre>\n<\/div>\n<\/blockquote>\n<p>To compile reports use the command:<\/p>\n<p><strong>grails compile-reports<\/strong><\/p>\n<p>Helpful links:- <\/p>\n<p>Hope it helps.<\/p>\n<p>Vishal Sahu<br \/>\nvishal@intelligrape.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my project we needed to generate pdf reports. The tool we used to design reports is IReport 2.0.5 &amp; the plugin used is grails jasper plugin.The plugin works fine with simple reports but fails when it come to complex report which uses subreport.The problem is that the plugin compiles .jrxml file to .jasper file [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":18},"categories":[7],"tags":[184,185,159,183],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/455"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=455"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/455\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}