Toni Rodriguez
Toni Rodriguez

Reputation: 129

Generate .jasper with maven plugin

I´m looking to improve the performance of my application, which has two types of reports, and compile then at execution time like this :

  final JasperDesign design = JRXmlLoader.load(input);

  final JasperReport compiledReport = JasperCompileManager.compileReport(design);

This code executes every time when the user wants to see the report on the app. To avoid this, I´m trying to execute the compilation of the .jrxml through maven jasperreports plugin, but it doesn't work, and there isn't an error on console. The .jasper files don't appear in my directory "outputDirectory".

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jasperreports-maven-plugin</artifactId>
        <executions>
         <execution>
              <phase>compile</phase>
            <inherited>false</inherited>
            <goals>
                <goal>compile-reports</goal>
            </goals>
         </execution>
        </executions>
        <configuration>
         <sourceDirectory>src/main/resources/reports</sourceDirectory>
        <outputDirectory>src/main/resources/reports/jasper</outputDirectory>
            <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
        </configuration>
    </plugin>

Upvotes: 5

Views: 15924

Answers (2)

Kavinda Jayakody
Kavinda Jayakody

Reputation: 786

This was the pom config I used

<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>

Upvotes: 1

Jason
Jason

Reputation: 4130

I know this is old, but this happened to me when I defined the plugin in the <pluginManagement> section of the POM instead of in <plugins>.

Upvotes: 1

Related Questions