Java 使用 Intellij 2017.2 构建 /out 目录会复制 /build 目录中的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45174989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Building with Intellij 2017.2 /out directory duplicates files in /build directory
提问by Peter
After updating to Intellij 2017.2, building my project creates an /out
directory that contains generated source files and resource files. These files duplicate files that are already contained in /build
and result in duplicate class
compiler errors for the generated classes. Any ideas on a fix I need in Gradle or IntelliJ?
更新到 Intellij 2017.2 后,构建我的项目会创建一个/out
包含生成的源文件和资源文件的目录。这些文件复制了已包含在生成的类中的文件,/build
并导致duplicate class
编译器错误。关于我需要在 Gradle 或 IntelliJ 中修复的任何想法?
回答by Peter
File | Project Structure | Project Settings | Modules | Paths tab | Compiler output
档案 | 项目结构 | 项目设置 | 模块 | 路径选项卡 | 编译器输出
Select 'Inherit project compile output path' to continue using /build
for build artifacts
选择“继承项目编译输出路径”以继续/build
用于构建工件
回答by CrazyCoder
IntelliJ IDEA is no longer sharing the output with Gradle, please see this ticket for details.
IntelliJ IDEA 不再与 Gradle 共享输出,有关详细信息,请参阅此票证。
You can either override it via the following configuration:
您可以通过以下配置覆盖它:
allprojects {
apply plugin: 'idea'
idea {
module {
outputDir file('build/classes/main')
testOutputDir file('build/classes/test')
}
}
if(project.convention.findPlugin(JavaPluginConvention)) {
// Change the output directory for the main and test source sets back to the old path
sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
sourceSets.test.output.classesDir = new File(buildDir, "classes/test")
}
}
or delegate the build to Gradle: File | Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner => Delegate IDE build/run actions to gradle.
或将构建委托给 Gradle:文件 | 设置 | 构建、执行、部署 | 构建工具 | 摇篮 | Runner => 将 IDE 构建/运行操作委托给 gradle。
回答by leo
Here is my understanding:
以下是我的理解:
Basically, this is a work-around for an incompatibility issue between
Gradle build path
andIDEA output path
.
- the issue is - https://github.com/gradle/gradle/issues/2315
- the solution is - keep these two directories seperate, therefore you have two (
out/
andbuild/
) https://youtrack.jetbrains.com/issue/IDEA-189063
基本上,这是解决
Gradle build path
和之间不兼容问题的解决方法IDEA output path
。
- 问题是 - https://github.com/gradle/gradle/issues/2315
- 解决方案是 - 将这两个目录分开,因此您有两个(
out/
和build/
) https://youtrack.jetbrains.com/issue/IDEA-189063