Vita Rara: A Life Uncommon

Compiling JasperReports JRXML Files with Maven


Categories: |

I recently started using JasperReports in Quadran. I'm using Maven to manage the Quadran project, and I wanted the JasperReports to fit into the process like everything else.

There is a Maven plugin in the Mojo collection for compiling jrxml files. Currently the plugin is in the sandbox, so you will need to check it out of Subversion and install it yourself in your local Maven repository.

At a command prompt I did the following on OS X. You'll have to adapt this to your operating system.

  • svn co http://svn.codehaus.org/mojo/trunk/mojo/mojo-sandbox/jasperreports-maven-plugin/
  • cd jasperreports-maven-plugin/
  • mvn install

That will install the JasperReports Maven plugin into your local repository. Now you need to configure your pom.xml file to use the plugin. You will need to add the following to your build -> plugins section:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jasperreports-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile-reports</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

The plugin expects your jrxml files to be in src/main/jasperreports. The compiled jasper files are placed in target/classses. You can have subdirectories and these will be preserved in the target/classes directory.

new SVN address

svn.codehaus.org/mojo/trunk/sandbox/jasperreports-maven-plugin

new SVN address

http://svn.codehaus.org/mojo/trunk/sandbox/jasperreports-maven-plugin