tkofford
(Todd Kofford)
September 9, 2019, 3:30pm
1
My question is very similar to the following post in the old forum, but I use kotlin for my gradle build instead of groovy. I think I have most of the groovy solution converted, except I keep having problems with the “jrc” ant task params:
How to compile JasperReports (.jrxml) files during build process?
tkofford
(Todd Kofford)
September 10, 2019, 2:30pm
2
Figured it out myself. Below is what I ended up going with:
val jasperreports by configurations.creating
dependencies {
jasperreports("net.sf.jasperreports:jasperreports:6.9.0")
}
val compileJasperReports = tasks.register("compileJasperReports") {
description = "Compiles source jasper reports files."
doLast {
println("running compileJasperReports task")
val jasperSourceDir = file(relativePath("src/main/resources/reports"))
val jasperTargetDir = file("build/classes/java/main/reports")
println("jasperSourceDir = " + jasperSourceDir)
println("jasperTargetDir = " + jasperTargetDir)
ant.withGroovyBuilder {
"taskdef"("name" to "jrc", "classname" to "net.sf.jasperreports.ant.JRAntCompileTask", "classpath" to jasperreports.asPath)
jasperTargetDir.mkdirs()
"jrc"("srcdir" to jasperSourceDir, "destdir" to jasperTargetDir, "includes" to "**/*.jrxml")
}
}
}
tasks.classes {
dependsOn(compileJasperReports)
}