Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building with Intellij 2017.2 /out directory duplicates files in /build directory

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?

like image 691
Peter Avatar asked Jul 18 '17 18:07

Peter


2 Answers

IntelliJ IDEA is no longer sharing the output with Gradle, please see this ticket for details.

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.

like image 115
CrazyCoder Avatar answered Nov 01 '22 15:11

CrazyCoder


File | Project Structure | Project Settings | Modules | Paths tab | Compiler output

Select 'Inherit project compile output path' to continue using /build for build artifacts

like image 14
Peter Avatar answered Nov 01 '22 16:11

Peter