当我尝试执行自定义 gradle 任务以预编译 jsp 文件时出现错误。我的任务如下所示:
task compile_jsp(dependsOn: 'compileJava') << {
//Define master classpath
def masterpath = ant.path(id: 'master-classpath') {
fileset(dir: "${rootDir}/build/libs"){
include(name: '**.jar')
}
fileset(dir: sourceSets.main.output.classesDir) {
include(name: '**/*.class')
}
fileset(dir: "${rootDir}/src/main"){
include(name: '**/*.java')
}
}
ant.taskdef(classname: 'org.apache.jasper.JspC', name: 'jasper', classpath: configurations.jasper.asPath + masterpath)
ant.jasper(uriRoot: "${rootDir}/src/main/webapp/", outputDir: "${rootDir}/src/main/webapp/WEB-INF/" + "${compileJspOutputDir}/", webXmlFragment: "${rootDir}/src/main/webapp/WEB-INF/generated_web.xml", addWebXmlMappings: "true")
}
我得到的错误是这样的:
The value for the useBean class attribute <class> is invalid.
我认为它与项目中的类位置有关,因为如果我定义sourceSets.main.output.classesDir
类似的任务,该任务运行良好:
sourceSets.main.output.classesDir = "${rootDir}/src/main/webapp/WEB-INF/classes"
否则,我会收到上述错误。
有没有办法在不更改类目录的情况下运行它?