I recently migrated my project from Maven to Gradle. In the process I faced lots of challenges, one of them is compiling JasperReport.

This post explains how to compile jasperreport’s jrxml to jasper and package jasper to the jar.


  1. JDK 1.7 or later
  2. Gradle 2

Project Structure

It’s a typical gradle structure except src/main/jasperreports which will have the *.jrxml files.

Project Root

Gradle Script

apply plugin: 'java'

repositories {
    maven{url ""}
    maven{url ""}

configurations {
    jasperreports {
        transitive = true

gradle.projectsEvaluated {
dependencies {
    jasperreports 'net.sf.jasperreports:jasperreports:5.6.0',

task compileJasperReports {
    def jasperSourceDir = file('src/main/jasperreports')
    ant {
        taskdef(name: 'jrc', classname: 'net.sf.jasperreports.ant.JRAntCompileTask', classpath: configurations.jasperreports.asPath)
        jrc(srcdir: jasperSourceDir, destdir: sourceSets.main.output.classesDir) {
            classpath(path: sourceSets.main.output.classesDir)
            include(name: '**/*.jrxml')

This build script has two maven urls which has the dependency for jasperreport which are not available in maven central repo.


When the project is build the *.jrxml files will be compiled to *.jasper filed and copied to the classes folder. So when the project is packaged these *.jrxml files will be available in classpath.


The sample project is available in Github