Thursday, May 24, 2012

Compile Jasper reports with Maven Plugin

jasperreports-maven-plugin is a plugin which is used to convert all the jrxml files(Designed templtes) to .jasper files.
  
 <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>
                            <!--  jrxml file  directory-->
                            <sourceDirectory>src\\main\\resources\\reports\\template</sourceDirectory>
                            <sourceFileExt>.jrxml</sourceFileExt>
                            <compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler>
                            <!--  Destination for jasper file -->
                            <outputDirectory>src\\main\\resources\\reports\\jasper</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <!-- These plugins are used to specify correct version for jrxml xml validation -->
                    <dependency>
                        <groupId>net.sf.jasperreports</groupId>
                        <artifactId>jasperreports</artifactId>
                        <version>4.5.0</version>
                    </dependency>
                   
                    <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.16</version>
                    </dependency>

       
                </dependencies>
            </plugin>

        </plugins>
    </build>

Add it in pom.xml. This is will do the compilation.

Regards,
Kaleeswaran.S

2 comments:

  1. There is an error running the plugin:
    [ERROR] Failed to execute goal org.codehaus.mojo:jasperreports-maven-plugin:1.0-beta-2:compile-reports (default) on project EByington-recursos: Error compiling report design : Informe.jrxml: Error compiling report design : Informe.jrxml : Language "groovy" not supported by this report compiler.
    [ERROR] Expecting "java" instead.

    Any ideas for this? im using groovy for some expressions in the .jrxml file.

    ReplyDelete
    Replies
    1. I know this is an old question but add this dependency (Update the version too):

      org.codehaus.groovy
      groovy-all
      2.0.1
      compile
      true

      Delete