我可以从代码或脚本中增强有趣的类吗?我正在使用gradle,似乎没有开箱即用的解决方案。我也在使用EBean的10.x版本。
答案 0 :(得分:0)
这可以通过gradle完成:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.ebean:ebean-agent:10.1.7'
}
}
def ebeanOutputDir = 'build/generated-ebean'
def ebeanSyncDir = 'generated/ebean'
import io.ebean.enhance.Transformer
import io.ebean.enhance.ant.OfflineFileTransform
configurations {
ebeangenerator
}
dependencies {
ebeangenerator lib.ebean_querybean_generator
}
task generateQueryBeans(type: GroovyCompile) {
source = sourceSets.main.groovy
classpath = configurations.compile + configurations.ebeangenerator
options.compilerArgs = [
'-processor', 'io.ebean.querybean.generator.Processor'
]
destinationDir = file(ebeanOutputDir)
}
task syncEBeanQuery(type: Sync) {
dependsOn tasks.generateQueryBeans
from ebeanOutputDir
into ebeanSyncDir
include "**/*.java"
}
compileGroovy {
dependsOn tasks.syncEBeanQuery
}
classes.doLast {
new OfflineFileTransform(
new Transformer(null, ''),
getClass().getClassLoader(),
"$buildDir\\classes\\main")
.process("**")
}
clean {
delete file(ebeanSyncDir)
}
apply plugin: 'idea'
idea {
module {
sourceDirs += file(ebeanOutputDir)
}
}
我在我的项目中使用了GROOVY groovyCompile
。