We would like to compile jrxml automatically as we build our web application.
Mechanics
We use Maven 2 JasperReports Plugin to compiles JasperReports xml design files to Java source and .jasper serialized files.
We use Maven 2 JasperReports Plugin to compiles JasperReports xml design files to Java source and .jasper serialized files.
How to do it
1. edit nig-web/pom.xml
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 | <dependencies> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>4.0.1</version> </dependency> </dependencies> <build> ... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <version>1.0-beta-2</version> <executions> <execution> <goals> <goal>compile-reports</goal> </goals> <configuration> <!-- define where is your jrxml file --> <sourceDirectory>src\\main\\java\\gov\\fdc\\nig\\report\\templates</sourceDirectory> <sourceFileExt>.jrxml</sourceFileExt> <compiler>net.sf.jasperreports.compilers.JRGroovyCompiler</compiler> <!-- define where is the jasper file will be generated --> <outputDirectory>src\\main\\resources\\report\\jasper</outputDirectory> </configuration> </execution> </executions> <dependencies> <!--note this must be repeated here to pick up correct xml validation --> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>4.0.1</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.7.5</version> </dependency> </dependencies> </plugin> </plugins> </build> |
2. mvn install
3. check result
Benefits
1. Automate jrxml compilation process
2. We won't forget to compile jrxml file and lead to our program read old jasper file
No comments:
Post a Comment