maven插件编译iReport源文件

以下代码实现,maven编译打包后将.jrxml文件编译成.jasper文件.

 

在pom.xml中进行配置

<dependencies>
	<dependency>
		<groupId>net.sf.jasperreports</groupId>
		<artifactId>jasperreports</artifactId>
		<version>3.7.0</version>
	</dependency>
</dependencies>

<!--不打包jrxml文件-->
<build>
	<resources>
		<resource>
			<directory>src/main/resources</directory>
			<filtering>true</filtering>
			<excludes>
				<exclude>**/*.jrxml</exclude>
			</excludes>
		</resource>
	</resources>
	<plugins>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>jasperreports-maven-plugin</artifactId>
			<configuration>
				<sourceDirectory>src/main/resources</sourceDirectory>
				<outputDirectory>target/classes</outputDirectory>
			</configuration>
			<executions>
				<execution>
					<goals>
						<goal>compile-reports</goal>
					</goals>
				</execution>
			</executions>
			<dependencies>
				<dependency>
					<groupId>net.sf.jasperreports</groupId>
					<artifactId>jasperreports</artifactId>
					<version>3.7.0</version>
				</dependency>
			</dependencies>
		</plugin>
	......
	</plugins>
</build>

 需要注意的是,java类中对jasper文件进行解析的jar包版本需要和pom.xml文件中的版本一致。

 

你可能感兴趣的:(IREPORT)