Jasper Reports w / Maven - How to specify Java version to compile?

Can I tell which version of Java to use when compiling .jrxml files with Jasper reports in Maven (using jasperreports-maven-plugin)? I saw this blog post claiming that Jasper uses the “default virtual machine on your computer” and not “the same version of maven-compiler-plugin”. If I cannot change or guarantee the JAVA_HOME environment variable, how can I get Jasper to compile with Java6 ?

Here is a snippet from my pom.xml:

<plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <version>1.0-beta-2</version> <configuration> <outputDirectory>${project.build.directory}/classes</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>5.0.1</version> </dependency> </dependencies> </plugin> <plugin> </plugins> 

When looking at Codehaus Docs , you can use a parameter, but it does not say how to indicate which version of Java.

Thanks!

+10
java maven jasper-reports
source share
2 answers

According to this problem, the following options may help you:

 <configuration> ... <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler> ... </configuration> 

1.0-beta-2, however, does not have these properties, so a later version is needed. You can use the snapshot plugin version from here , create the plugin yourself from the source code. As far as I can tell, the plugin code from the trunk supports these parameters.

+9
source share

I had to make some additional settings:

  • install eclipse: jdtcore as an exception in jasperresports;
 <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>5.6.0</version> <exclusions> <exclusion> <groupId>eclipse</groupId> <artifactId>jdtcore</artifactId> </exclusion> </exclusions> </dependency> 
  • install org.eclipse.jdt.core.compiler:ecj as a plugin dependency;

JasperReports-Maven Plugin:

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <version>1.0-beta-4-OPENNMS-20160912-1</version> <configuration> <outputDirectory>src/main/webapp/WEB-INF/reports</outputDirectory> <maven.compiler.source>${compileSource}</maven.compiler.source> <maven.compiler.target>${compileSource}</maven.compiler.target> <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler> </configuration> <executions> <execution> <phase>process-classes</phase> <goals> <goal>compile-reports</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.4.1</version> </dependency> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>5.6.0</version> </dependency> <dependency> <groupId>net.sf.barcode4j</groupId> <artifactId>barcode4j</artifactId> <version>2.0</version> </dependency> </dependencies> 

Note: the dependency order of the jasperreports-maven-plugin was relevant to me (don't ask me why).

+1
source share

All Articles