Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2012 19:22
Show Gist options
  • Save anonymous/4355113 to your computer and use it in GitHub Desktop.
Save anonymous/4355113 to your computer and use it in GitHub Desktop.
compiling jasper subreports, gem jasper-rails
def self.compile_subreports(jasper_file)
sub_reports_path = Dir.new File.dirname(jasper_file)
load_jrxml_files = sub_reports_path.entries.select { |entry| File.extname(entry) == ".jrxml" }
load_jrxml_files.each do |subreport_jrxml_file|
subreport_jasper_file = "#{File.basename(subreport_jrxml_file, '.jrxml')}.jasper"
file_exists = !File.exist?(subreport_jasper_file) || (File.exist?(subreport_jrxml_file)
file_outdated = File.mtime(subreport_jrxml_file) > File.mtime(subreport_jasper_file))
if file_exists && file_outdated
JasperCompileManager.compileReportToFile(subreport_jrxml_file, subreport_jasper_file)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment