Output path is shared between the same module error
ScalaMavenIntellij IdeaScala 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.
Solution 4 - Scala
Files --> Invalidate caches and restart
- Close intellij
- delete (extenrally from intellij)
.idea
folder (backuprunConfigurations
folder if you have one). - delete the
project.iml
file - Open intellij
- Open the project again from
pom
or fromsbt
(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
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