如何构建包含目录中的IntelliJ源目录的gradle与编译时 [英] How to include build directory as source directory in intellij when compiling with gradle

查看:989
本文介绍了如何构建包含目录中的IntelliJ源目录的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆