Compile Jasper reports from Maven using ant task?

How can I compile jarper jrxml files using the Maven task and JRAntCompileTask ant? I tried using the maven plugin to compile jasper report files, but it is still in beta and this caused a lot of problems. I would like to see the configuration in pom.xml.

+4
source share
3 answers

How can I compile jarper jrxml files using the Maven task and JRAntCompileTask ant?

You can use custom ant Tasks with the Maven AntRun Plugin . See the example in Using tasks not included in ant jar .

+1
source

You can try jasperreports-maven-plugin so you don't need to use ant, Here is an example .

+1
source

Here is a complete example that solves problems with Eclipse m2e reporting errors with the maven configuration, has reports that are clearly installed in a separate folder, and has class configurations.

Just remember to put your .jrxml files in the src / main / jasperreports folder and you are set up - every time you change the report, the jasper files will be restored.

pom.xml:

<properties> <jasperreports.version>5.0.0</jasperreports.version> </properties> <build> <pluginManagement> <plugins> <!--This plugin configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <versionRange>[1.0-beta-2,)</versionRange> <goals> <goal>compile-reports</goal> </goals> </pluginExecutionFilter> <action> <execute /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> <sourceDirectory>src/main/java</sourceDirectory> <resources> <resource> <directory>src/main/java</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> </resource> <resource> <!-- Include the generated reports in classpath --> <directory>target/jasper</directory> </resource> <resource> <!--Folder with .jrxml report files --> <directory>src/main/jasperreports</directory> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <configuration> <!-- Folder where compiled reports will be generated --> <outputDirectory>${project.build.directory}/jasper</outputDirectory> </configuration> <executions> <execution> <goals> <goal>compile-reports</goal> </goals> <phase>generate-sources</phase> </execution> </executions> <dependencies> <dependency> <groupId>org.codehaus.mojo</groupId> <artifactId>jasperreports-maven-plugin</artifactId> <version>1.0-beta-2</version> <exclusions> <exclusion> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>${jasperreports.version}</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>4.2.0</version> </dependency> </dependencies> </plugin> </plugins> </build> ... 
+1
source

All Articles