# Compile Jasper Reports w/Kotlin During Build?

**URL:** https://discuss.gradle.org/t/compile-jasper-reports-w-kotlin-during-build/33108
**Category:** Help/Discuss
**Created:** [September 9, 2019, 3:30pm UTC](https://discuss.gradle.org/t/compile-jasper-reports-w-kotlin-during-build/33108 "2019-09-09T15:30:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tkofford](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@tkofford](https://discuss.gradle.org/u/tkofford)
#### Post date: [September 9, 2019, 3:30pm UTC](https://discuss.gradle.org/t/compile-jasper-reports-w-kotlin-during-build/33108/1 "2019-09-09T15:30:21Z")

</div>

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?](https://discuss.gradle.org/t/how-to-compile-jasperreports-jrxml-files-during-build-process/7222/6)

---

<div class="post-metadata">

### Author: ![tkofford](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@tkofford](https://discuss.gradle.org/u/tkofford)
#### Post date: [September 10, 2019, 2:30pm UTC](https://discuss.gradle.org/t/compile-jasper-reports-w-kotlin-during-build/33108/2 "2019-09-10T14:30:12Z")

</div>

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)
> }
> 
> ```
