pro-crafting / Jasper-report-maven-plugin

A fast jasper report maven plugin
Apache License 2.0
24 stars 2 forks source link

Jasper file created is empty #50

Open neo7BF opened 9 months ago

neo7BF commented 9 months ago

I'm using this plugin in a spring web application and it produces empty .jasper files while with the original official plugin (in beta) they are produced correctly. Can you tell me what the problem is?

Thank you.

Java version:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Jasper Reports version used:

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.20.5</version>
</dependency>

New plugin configuration (produces empty .jasper files):

<plugins>
<plugin>
<groupId>com.pro-crafting.tools</groupId>
<artifactId>jasperreports-plugin</artifactId>
<version>3.5.6</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>jasper</goal>
</goals>
</execution>
</executions>
<configuration>
<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
<sourceDirectory>src/main/webapp/resources/jasperreports</sourceDirectory>
<outputDirectory>src/main/webapp/resources/jasper-compiled</outputDirectory>
<outputFileExt>.jasper</outputFileExt>
<xmlValidation>true</xmlValidation>
<verbose>false</verbose>
<numberOfThreads>4</numberOfThreads>
<failOnMissingSourceDirectory>true</failOnMissingSourceDirectory>
<sourceScanner>org.codehaus.plexus.compiler.util.scan.StaleSourceScanner</sourceScanner>
</configuration>
</plugin>
</plugins>

<repositories>
     <repository>
         <id>jaspersoft-third-party</id>
         <url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
     </repository>
</repositories>

Old plugin configuration (jasper files are produced correctly):

             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>jasperreports-maven-plugin</artifactId>
                 <version>1.0-beta-2</version>
                 <configuration>
<sourceDirectory>src/main/webapp/resources/jasperreports</sourceDirectory>
<outputDirectory>src/main/webapp/resources/jasper-compiled</outputDirectory>
                 </configuration>
                 <executions>
                     <execution>
                         <phase>compile</phase>
                         <goals>
                             <goal>compile-reports</goal>
                         </goals>
                     </execution>
                 </executions>
                 <dependencies>
                     <dependency>
                         <groupId>net.sf.jasperreports</groupId>
                         <artifactId>jasperreports</artifactId>
                         <version>6.20.5</version>
                     </dependency>
                     <dependency>
                         <groupId>org.codehaus.groovy</groupId>
                         <artifactId>groovy-all</artifactId>
                         <version>2.0.1</version>
                         <scope>compile</scope>
                         <optional>true</optional>
                     </dependency>
                 </dependencies>
             </plugin>
LeonardoALARCON commented 9 months ago

I had the same problem and I fixed it by deleting the configuraton parameter <sourceScanner>org.codehaus.plexus.compiler.util.scan.StaleSourceScanner</sourceScanner>. It works because 'org.codehaus.plexus.compiler.util.scan.StaleSourceScanner' it's the default value.

Postremus commented 9 months ago

Hi @neo7BF, sorry for the late response.

I am not able to reproduce this issue yet.

Here is my sample project. Simply run mvn clean process-sources to execute the plugin. The .jasper should be in target/compiled afterwards.

one-report.zip

Are you able to reproduce your issue with this sample project?

Postremus commented 8 months ago

I figured something out. When the outputdirectory already contains an empty jasper file, it is not overwritten with new content.

Postremus commented 8 months ago

Currently, the default is to use the org.codehaus.plexus.compiler.util.scan.StaleSourceScanner to check if a report needs to be recompiled. Only reports are compiled, where either the .jasper does not exists, or where the .jasper file is older then the source .jrxml file.

If, by any chance, any other process now modifies the compiled .jasper file, then it still exist and is newer then the source file. So no recompilation is done here.

Another supported source scanner is the SimpleSourceInclusionScanner. This one just searches what source files exists, and always recompiles all of them. You can use that one if it is a regular occurence in your workflow that compiled jasper files get modified.

<sourceScanner>org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner</sourceScanner>

Postremus commented 8 months ago

@neo7BF Can you confirm if my observations (see previous comment) are correct? Can you give any more details how this is happening for you?