java - IntelliJ IDEA annotation processing doesn't generate sources in configured forlder
问题描述
I'm struggling with IntelliJ Idea (IntelliJ IDEA 2018.3.2 (Ultimate Edition)), Gradle, and Immutables library. What I'm trying to do is generating sources in the generated
directory as expected by the configuration at Using annotation processor in IDE > IntelliJ IDEA.
At the moment the result I get is that both compiled classes and sources are put inside /build/classes/java/main
Have you got the same issues? Do you have suggestions to solve the problem? I'm looking for answers but I didn't find a working solution yet.
解决方案
是的,默认情况下,Gradle 将所有生成的源代码与编译的源代码放在一起。请像这样配置它:
def generatedJavaSourcesPath = "$buildDir/generated-sources/java"
def generatedJavaSourcesDir = file(generatedJavaSourcesPath)
compileJava {
options.compilerArgs = [
// Override the directory where to place generated source files.
"-s",
generatedJavaSourcesPath
]
}
并将生成的源添加到项目中
sourceSets {
main {
java {
srcDir generatedJavaSourcesDir
}
}
}
只需将其添加到build.gradle
推荐阅读
- c# - 从存储桶 xxx 获取对象文件名.xlsx 时出错。确保它们存在并且您的存储桶与此函数位于同一区域?
- tableau-api - Tableau 运行总和不会计算所有月份
- vue.js - vue.js 将组件挂载到应用根目录
- python - 将 UNIX 时间戳转换为以秒为单位的时间长度
- csv - 在 Windows 中使用 sed 将分隔文件通过管道传输到 csv
- html - iFrame 默认滚动位置
- ios - 无法获取另一个类中 var 的值
- jenkins - Jenkins 动态代理 - 从 VM 克隆与节点/代理/标签冲突
- vba - 通过单元格错误循环公式的语法
- vb.net - 需要帮助使用 DataRepeater 过滤