大佬教程收集整理的这篇文章主要介绍了Gradle Ant 任务性能下降 (XDoclet),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
一直在将旧的 Maven 构建迁移到 Gradle,并且在转换后遇到了重大问题。
该项目使用 xdoclet 生成 hibernate.cfg.xml。生成此文件时,与 Maven 相比,Gradle 将平均增加 2 倍的构建时间。使用 inputs/outputs
避免在后续构建中工作,Gradle 的构建时间是 Maven 的一半。
因此,生成 hibernate.cfg.xml 的初始构建极大地影响了采用。
这里是 Gradle 任务(改编自 Maven antrun 执行):
task generateHibernateConfig {
outputs.file( file("${project.projectDir}/src/main/resources/hibernate.cfg.xml") )
dolast {
ant.echo(message: "GeneraTing Hibernate Configuration")
ant.taskdef(
name: "hibernatedoclet",classname: "xdoclet.modules.hibernate.HibernateDocletTask",classpath: ant.references["xdoclet.task.classpath"]
)
ant.hibernatedoclet(destDir: "${project.projectDir}/src/main/resources",verbose: "false"
) {
fileset(dir: "${project.projectDir}/src/main/java") {
include(name: "**/*.java")
// a few excluded classes redacted
}
hibernate(version: "3.0")
hibernatecfg(dialect: "org.hibernate.dialect.DB2Dialect",datasource: "java:comp/env/jdbc/Example",transactionManagerFactory: "org.hibernate.transaction.CMTtransactionFactory",transactionManagerLookup: "org.hibernate.transaction.WebSphereExtendedJTAtransactionLookup",showsql: "false",version: "3.0") {
otherProperty(name: "hibernate.cache.use_second_level_cache",value: "true")
otherProperty(name: "hibernate.cache.use_query_cache",value: "true")
otherProperty(name: "hibernate.cache.region.factory_class",value: "net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory")
otherProperty(name: "hibernate.transaction.flush_before_completion",value: "true")
otherProperty(name: "hibernate.transaction.auto_close_session",value: "true")
otherProperty(name: "hibernate.connection.provIDer_class",value: "org.hibernate.connection.DatasourceConnectionProvIDer")
otherProperty(name: "hibernate.jdbc.use_get_generated_keys",value: "false")
}
}
}
}
使用以下方法导入所需的类:
ant.path(ID: "xdoclet.task.classpath",LOCATIOn: configurations.antBuild.asPath)
来自 dependencIEs
闭包:
antBuild libs.xdoclet
antBuild libs.xdocletFixedHibernate
antBuild libs.xdocletModule
antBuild libs.xdocletJavadoc
antBuild libs.log4j
antBuild libs.hibernateCore
gradlew clean build --deBUG
下面的性能下降点。此日志重复。 (可能是假的)
2021-04-20T13:21:47.037+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] Couldn't load resource hibernate-generator-params-{0}.xml
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-propertIEs.xdt loaded from ant loader
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] Couldn't load resource hibernate-propertIEs.xml
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] Couldn't load resource hibernate-propertIEs-{0}.xml
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-subclass.xdt loaded from ant loader
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-joined-subclass.xdt loaded from ant loader
2021-04-20T13:21:47.038+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-query.xdt loaded from ant loader
2021-04-20T13:21:47.039+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-query.xdt loaded from ant loader
2021-04-20T13:21:47.039+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-sql-query.xdt loaded from ant loader
2021-04-20T13:21:47.039+1200 [DEBUG] [org.gradle.API.internal.project.ant.AntLoggingAdapter] resource xdoclet/modules/hibernate/resources/hibernate-sql-query.xdt loaded from ant loader
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的Gradle Ant 任务性能下降 (XDoclet)全部内容,希望文章能够帮你解决Gradle Ant 任务性能下降 (XDoclet)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。