我希望使用Hibernate和Gradle从现有数据库中生成POJO。Gradle可以很容易地调用Ant任务,Hibernate有用于逆向工程数据库的ant任务。
我在web上找到了这个旧的Gradle任务定义,并将其修改为最新版本的Gradle,但是它不起作用:
ant {
taskdef(name: 'hibernatetool',
classname: 'org.hibernate.tool.ant.HibernateToolTask',
classpath: configurations.compile.asPath )
mkdir( dir: "$buildDir/generated" )
hibernatetool( destdir : "$buildDir/generated" ) {
annotationconfiguration( configurationfile:"$classesDir/hibernate.cfg.xml" )
hbm2ddl( export: false, outputfilename: 'schema.sql' )
classpath {
pathelement( path: classesDir )
}
}
} 我知道错误:
No such property: classesDir for class: org.gradle.api.internal.project.DefaultAntBuilder 如何修改它以从数据库生成架构文件?(我知道这还不能生成POJO,但这是第一步!)
我的依赖项看起来如下:
dependencies {
compile 'org.hibernate:hibernate-tools:4.0.0-CR1'
testCompile group: 'junit', name: 'junit', version: '4.10'
}发布于 2013-10-29 20:45:24
我的猜测是,您希望使用来自主源集的类输出目录:
sourceSets.main.output.classesDir如果您只使用classesDir,Gradle将尝试解析AntBuilder实例上的字段。
https://stackoverflow.com/questions/19625100
复制相似问题