Open Docjones opened 1 month ago
The exception is rooted in Jasperreports itself. Which version of Jasperreports are you using? For version 7 this might help you, as you are using the Jdt compiler. Otherwise you might want to try out another compiler.
Hello @f-cramer - thanks for your help. Unfortunately, that did not help. Here is my complete build.gradle:
buildscript {
configurations {
all {
resolutionStrategy {
force "net.sf.jasperreports:jasperreports:7.0.1"
}
}
}
repositories {
maven {
url idsPublicURL
}
}
dependencies {
// classpath "com.github.gmazelier:jasperreports-gradle-plugin:0.4"
// classpath "net.sf.jasperreports:jasperreports-functions:7.0.1"
classpath "net.sf.jasperreports:jasperreports-jdt:7.0.1"
}
}
//apply plugin: "com.github.gmazelier.jasperreports"
plugins {
id("io.github.f-cramer.jasperreports") version "0.0.3"
}
jasperreports {
srcDir = file('src/main/reports')
tmpDir = file('tmp')
outDir = file('reports')
srcExt = '.jrxml'
outExt = '.jasper'
compiler = 'net.sf.jasperreports.engine.design.JRJdtCompiler'
keepJava = false
validateXml = true
verbose = true
useRelativeOutDir = true
classpath.from(configurations.compileClasspath)
}
However, IF i change the line:
force "net.sf.jasperreports:jasperreports:7.0.1"
from buildscript.configurations to
force "net.sf.jasperreports:jasperreports:6.20.0"
everything works...
The plugin does not use Gradles script classpath, but its own (the one you are setting in the second to last line of your build.gradle
).
The easiest way to add jasperreports-jdt
would be to just add it as a compileOnly
dependency. If you do not want to pollute your Java compileClasspath
, you can also create a new configuration, add the dependency to it and then add it to the plugin classpath
An untested version could look like this (note the dependencies
block above the jasperreports
configuration):
buildscript {
configurations {
all {
resolutionStrategy {
force "net.sf.jasperreports:jasperreports:7.0.1"
}
}
}
repositories {
maven {
url idsPublicURL
}
}
dependencies {
// classpath "com.github.gmazelier:jasperreports-gradle-plugin:0.4"
// classpath "net.sf.jasperreports:jasperreports-functions:7.0.1"
}
}
//apply plugin: "com.github.gmazelier.jasperreports"
plugins {
id("io.github.f-cramer.jasperreports") version "0.0.3"
}
dependencies {
compileOnly "net.sf.jasperreports:jasperreports-jdt:7.0.1"
}
jasperreports {
srcDir = file('src/main/reports')
tmpDir = file('tmp')
outDir = file('reports')
srcExt = '.jrxml'
outExt = '.jasper'
compiler = 'net.sf.jasperreports.engine.design.JRJdtCompiler'
keepJava = false
validateXml = true
verbose = true
useRelativeOutDir = true
classpath.from(configurations.compileClasspath)
}
I just released version 0.0.4. The update allows you to add the jdt-dependency to a new configuration called jasperreportsClasspath
, that is automatically added to the classpath of the compileAllReports
task. This way you can avoid to pollute your Java compile classpath
Hmm - i tried your suggestions, but it still does not work using force "net.sf.jasperreports:jasperreports:7.0.1"
tbh - i dont even know, why the buildscript-section has been added.
we dont have any java-based code in that certain repository - we just maintain our .jrxml-reports and use gradle to create the .jasper output for a central report-service. i would have expected, that the minimal woring build.gradle looks like this:
plugins {
id("io.github.f-cramer.jasperreports") version "0.0.4"
}
repositories {
maven {
url idsPublicURL
}
}
dependencies {
jasperreportsClasspath "net.sf.jasperreports:jasperreports-functions:7.0.1"
jasperreportsClasspath "net.sf.jasperreports:jasperreports-jdt:7.0.1"
jasperreportsClasspath "net.sf.jasperreports:jasperreports:7.0.1"
}
jasperreports {
srcDir = file('src/main/reports')
tmpDir = file('tmp')
outDir = file('reports')
srcExt = '.jrxml'
outExt = '.jasper'
compiler = 'net.sf.jasperreports.engine.design.JRJdtCompiler'
keepJava = false
validateXml = true
verbose = true
useRelativeOutDir = true
classpath.from()
}
But unfortunately, i still get "Unable to load report" :/
It might be a silly question, but did you convert your jrxml files to the new xml format that was introduced with JasperReports 7? The old files are no longer working and also lead to the error you described.
That's by far no silly question and most likely the cause for the resolutionStrategy we had in the buildScript. I will have to check our report-service for the current supported version and will revert back to you - thank you again for your excellent support 👍
Hello - i switched from the former gradle plugin (gmazelier/gradle-jasperreports) to your version due to the abandonded status of gmazelier/gradle-jasperreports.
i am getting an "Unable to load report" message upon compiling:
running gradle with
--stacktrace
yielded only sparse additional information...Here is (part of) my build.gradle: