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

I had to make some additional configurations:

  • set eclipse:jdtcore as exclusion 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>
  • set org.eclipse.jdt.core.compiler:ecj as 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 dependencies order of plugin jasperreports-maven-plugin was relevant for me (don't ask me why).


According to this issue the folllowing parameters can 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 the later version is necessary. You can either use a snapshot plugin version from here, of build a plugin from source code yourself. As far as I can see, plugin code from trunk supports these parameters.