我已经建立了gradle构建文件:
task hibernateInstrumentation {
ant.taskdef(name: 'hibernateInstrumentation' ,
classpath: project.sourceSets.main.compileClasspath.asPath,
classname: 'org.hibernate.tool.instrument.javassist.InstrumentTask'){
}
ant.hibernateInstrumentation(verbose: 'true') {
fileset(
dir: "${project.buildDir}",
inculde: 'mypackage/model/*.class'
)
}
}
compileJava.doLast {
hibernateInstrumentation
}
dependencies {
compile "org.hibernate:hibernate-core:$hibernateVersion",
compile 'org.javassist:javassist:3.18.1-GA',
// ...
}
但是当我开始学习时
时出现问题
taskdef类无法找到org.hibernate.tool.instrument.javassist.InstrumentTask 使用类加载器AntClassLoader []
project.sourceSets.main.compileClasspath.asPath
)
答案 0 :(得分:1)
问题中的代码存在拼写错误和元素嵌套错误。这对我有用:
onBindViewHolder()
使用的环境:
task hibernateInstrumentation << {
ant.taskdef(name: 'hibernateInstrumentation',
classpath: project.sourceSets.main.compileClasspath.asPath,
classname: 'org.hibernate.tool.instrument.javassist.InstrumentTask')
ant.hibernateInstrumentation(verbose: 'true') {
fileset(dir: "${project.buildDir}/classes/main") {
include(name: 'mypackage/model/*.class')
}
}
}
compileJava.doLast {
hibernateInstrumentation.execute()
}
dependencies {
def hibernateVersion = '5.0.3.Final'
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile 'org.javassist:javassist:3.18.1-GA'
// ...
}
答案 1 :(得分:0)
在正确设置类路径之前,您正在配置阶段调用ant.taskdef。您想将其移至执行阶段。类似的东西:
task hibernateInstrumentation << {
ant.taskdef ...
}