Output path is shared between the same module error
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?
Solution 1:
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:
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:
I resolved this by selecting "Inherit project compile output path" in the Project Structure settings window.
Solution 4:
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:
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.