Sample project for Gradle and JasperReport
Switch branches/tags
Nothing to show
Clone or download
seenukarthi Update
Fixing Markdown headings
Latest commit 2930909 Nov 16, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main Restructure Aug 4, 2014
.gitignore Gradle Setup Aug 4, 2014 Update Nov 16, 2017
build.gradle Compiling phase changed to processResources. Aug 4, 2014
settings.gradle Restructure Aug 4, 2014


Recently I 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