如何构建包含目录中的IntelliJ源目录的gradle与编译时 [英] How to include build directory as source directory in intellij when compiling with gradle
问题描述
在默认情况下,作为排除的想法的Gradle插件标志着build文件夹。我怎么有这个文件夹作为源文件夹? (或避免排除它,因为它似乎是在默认情况下...)
By default, the gradle idea plugin marks the build folder as excluded. How do I include this folder as source folder? (or avoid excluding it, as it appears to be by default...)
在我的模块的build.gradle文件我用以下两种配置的尝试:
In my module build.gradle file I tried with the two following configurations:
idea {
module {
excludeDirs -= file('build/generated')
}
}
和
idea {
module {
sourceDirs += file('build/generated')
}
}
通过这两个配置文件夹生成/总是产生出现编译后的IntelliJ中排除的文件夹。
在的IntelliJ我总是要进去项目设置,模块,然后在选项卡源,从排除的文件夹中删除build文件夹,并让我的项目运行。
With those two configurations the folder build/generated always appears as excluded folders in IntelliJ after compilation. In IntelliJ I always have to go in "Project Settings", "Modules" and then in the tab "Sources" to remove the build folder from the excluded folders and let my project run.
推荐答案
改变$ C $从
file('build/generated')
到
file("$buildDir/generated")
我这里使用的是一个工作code:
I use here is a working code:
ext {
cxfOutputDir = file("$buildDir/generated-sources/cxf")
}
idea.module {
excludeDirs -= file("$buildDir")
sourceDirs += cxfOutputDir
}
这篇关于如何构建包含目录中的IntelliJ源目录的gradle与编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!