Output path is shared between the same module error

ScalaMavenIntellij Idea

Scala Problem Overview


When I try to compile any class in my project I get the error below:

Error scala: Output path .../eval/target/test-classes is shared between: Module 'eval' tests, Module 'eval' tests
      Output path .../eval/target/classes is shared between: Module 'eval' production, Module 'eval' production
      Please configure separate output paths to proceed with the compilation.

I've seen how to set the output path in IDEA and I've done it. But as the error claims that it is shared between the same module I couldn't solve it.

Obs.: Using Maven and IntelliJ IDEA.

Please, can anyone help?

Scala Solutions


Solution 1 - Scala

all you need to do is:

  • synchronize both modules (right click > Synchronize)
  • re-import pom.xml for both modules (right click > Maven > Re Import)

Enjoy

Solution 2 - Scala

Set up the output paths for your modules to different directories, as explained here: https://www.jetbrains.com/idea/help/configuring-module-compiler-output.html

On Project "Open Module Settings" -> Modules -> Paths -> Output/Test path

Solution 3 - Scala

I resolved this by selecting "Inherit project compile output path" in the Project Structure settings window.

enter image description here

Solution 4 - Scala

  1. Files --> Invalidate caches and restart
  2. Close intellij
  3. delete (extenrally from intellij) .idea folder (backup runConfigurations folder if you have one).
  4. delete the project.iml file
  5. Open intellij
  6. Open the project again from pom or from sbt (or whatever source build tool you have.

Solution 5 - Scala

I had this happen with the root module in a multi-module project. Since the root module was just a placeholder, it didn't actually contain any code, but IDEA still complained that it was sharing an output path ([project]/build) between test and production.

The fix was to add

plugins {
  id "java"
}

at the top of the root build.gradle file (applying the otherwise unnecessary Java plugin) and reimporting the project. This allowed IDEA to pick up the Java-default [project]/build/classes/main and [project]/build/classes/test output directories.

Solution 6 - Scala

Open up the module settings and look for errors. Fix said errors and everything should work.

Solution 7 - Scala

Problem solved!

I have reset backward and forward my git repository many times and close-reopen idea after some of it. When finaly IDEA shows a red message at the right top while it was starting. It says something like: the project has already a eval module, and if I want to delete eval module. Yes, it was quite confusing, but I click on delete and my problem disappear. I guess that for some reason I become with 2 eval modules and it delete one of it solving output path error.

Solution 8 - Scala

For a Spark project, the IDE created _2.11 versions of SBT modules. I had to delete them by hand.

Solution 9 - Scala

enter image description here

Idea itself reports an error, the prompt is already very obvious, calm analysis can solve; Open Project Structure --> modules. Delete or reconfigure outputPath,The computer is the most honest

Solution 10 - Scala

This is really a response to @habitat's comment on @Corey Klein 's answer. If someone with enough reputation wants to edit, please go ahead...

I had the same problem with the setting being reset every time I refreshed the project. My solution (with Gradle, although I'm guessing there is an equivalent Maven plugin) was to add

apply plugin: 'idea'
idea {
    module {
        inheritOutputDirs = true
    }
}

Solution 11 - Scala

For gradle, I delete the .idea folder and reopen the project. Everything is recovery.

Solution 12 - Scala

I had 2 differently named versions of the same module and needed to delete one to avoid this clash. This is what worked for me:

In IntelliJ IDEA go to File -> Project Structure -> Modules -> Your Project -> Paths

Ensure each Modules "Output path" and "Test output path" locations are unique across all your modules. If you have more than one module with the same paths, you can specify unique paths for every module or as in my case, delete the module that you do not require as it was a duplicate of an existing module

Solution 13 - Scala

I face the same issue i resolve this by deleting .iml2 from the module which was created by intellij.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexandre Cançado CardosoView Question on Stackoverflow
Solution 1 - ScalaYonatan MamanView Answer on Stackoverflow
Solution 2 - ScalaDreamFlasherView Answer on Stackoverflow
Solution 3 - ScalaCory KleinView Answer on Stackoverflow
Solution 4 - ScalaTomer Ben DavidView Answer on Stackoverflow
Solution 5 - ScalaDavid MolesView Answer on Stackoverflow
Solution 6 - Scalabradley.ayersView Answer on Stackoverflow
Solution 7 - ScalaAlexandre Cançado CardosoView Answer on Stackoverflow
Solution 8 - ScalaDyinView Answer on Stackoverflow
Solution 9 - ScalaPooklyView Answer on Stackoverflow
Solution 10 - ScalaBenjamin BermanView Answer on Stackoverflow
Solution 11 - ScalasalexinxView Answer on Stackoverflow
Solution 12 - ScalaMikeView Answer on Stackoverflow
Solution 13 - ScalaJatin DemlaView Answer on Stackoverflow