我正在处理多模块项目并使用gradle anttask生成jasper报告。我正在使用Gradle ant任务
我的项目结构是: -
`RootProject -A
module-B ---> some classes are using from here during jasper report generation.
module-C ---> added ant task in build.gradle and .jrxml files are in this module.
`
.jrxml文件位于module-C中,当我生成报告时,它正在搜索
对于模块B中存在的某些类。
因为我在module-c中的anttask下定义了类路径 -
classpath(path: sourceSets.main.output.classesDir)
它无法从模块B获得classess。请告知如何获取执行jaspertask时所需的类
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'war'
group = 'org.C'
version = '1.0.0'
description = 'C Module'
sourceSets {
main {
java { srcDir 'src' }
resources { srcDir 'resources' }
}
test {
java {
srcDir 'test'
}
}
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenLocal()
//added other repositories as per the requirement
}
configurations {
jasperreports {
transitive = true
}
}
gradle.projectsEvaluated {
processResources.dependsOn(compileJasperReports)
}
dependencies {
jasperreports 'net.sf.jasperreports:jasperreports:5.6.0',
'org.codehaus.groovy:groovy-all:2.3.6'
}
task compileJasperReports {
def jasperSourceDir = file('src/main/jasper')
ant {
taskdef(name:'jrc',classname:'net.sf.jasperreports.ant.
JRAntCompileTask',classpath:configurations.jasperreports.asPath)`
sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
sourceSets.main.output.classesDir.mkdirs()
jrc(srcdir: jasperSourceDir, destdir:sourceSets.main.output.classesDir) {
**classpath(path: sourceSets.main.output.classesDir)**
//Here i need to add the classes directory of module-B classes--HOW to add the module-B classes so the .jrxml can access that and generate the report..
include(name: '**/*.jrxml')
}
}
}
dependencies {
compile project(':B')
//provided other dependencies as per build needs.
}
错误: -
[ant:jrc] File : C:\Users\TEST\Desktop\Project\C\src\main\jasper\Test.jrxml ... FAILED.
[ant:jrc] Error compiling report design : C:\Users\TEST\Desktop\Project\C\src\main\jasper\Test.jrxml
[ant:jrc] net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
[ant:jrc] 1. java.lang.ClassNotFoundException: org.B.ClassName
[ant:jrc] at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java