我一直在使用 Netbeans 及其默认的基于 ant 的构建集成开发一个 java 项目。由于 ant 的不足,我打算切换到基于 gradle 的构建。
问题在于该项目分为三个不同的模块:
- 注释模块(包含多个注释处理器)
- 数据库模块
- UI 模块
UI 模块和数据库模块使用注释模块中的注释处理器。 UI 模块依赖于数据库模块。
我尝试的build设置如下所示:
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
apply plugin: "net.ltgt.apt"
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
apt files('processor/Annotations.jar')
compileOnly files('processor/Annotations.jar')
}
我尝试动态集成模块,但是 gradle 构建过程没有生成应由注释处理器生成的类。此外,我已经尝试使用注释模块的预编译版本,但这也不起作用。
我的问题:
- 如何集成注释模块以便 gradle 构建正常运行?
- 如何将注释模块动态集成到构建过程中?
最佳答案
通常您会使用project dependency
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
apt project(':annotations')
compileOnly project(':annotations')
}
关于java - 将本地注释处理器项目集成到 gradle 构建中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45167098/