Search code examples
scalaintellij-ideasbtgen-idea

Intellij IDEA - Output path ...\project\target\idea-classes intersects with a source root. Only files that were created by build will be cleaned


Using Intellij IDEA with Scala plugin.

When doing a Build -> Rebuild Project I get the following make warnings:

Output path ProjectRootFolder\project\target\idea-test-classes intersects with a source root. Only files that were created by build will be cleaned.
Output path ProjectRootFolder\project\target\idea-classes intersects with a source root. Only files that were created by build will be cleaned.

The project was generated with SBT gen-idea plugin.

The two output paths mentioned in the warnings are set as output path and test output path for the build module of the project under Project Structure -> Modules -> ProjectName-build -> Paths -> Use module compile output path.

Looking at the Sources tab for both the ProjectName module and ProjectName-build modules I saw that there is no place where ProjectRootFolder\project\target was marked as Source.


Solution

  • It seems the warnings were caused by the fact that the project and . folders were marked as Sources in the ProjectName-build module.

    Since the SBT build module is not needed when using IDEA to build the project, one solution would be to generate the IDEA project without that module:

    sbt gen-idea no-sbt-build-module
    

    More details here: https://github.com/mpeltonen/sbt-idea/issues/180

    UPDATE

    Removing the build module is actually problematic since the build.scala file will show a lot of warnings because the required libraries would be missing.

    A solution would be to unmark . and project from being Sources of the build module, which is also troublesome since it would need to be done after each gen-idea.

    A better solution would be to use sbt to build the project instead of make. To achieve that remove the make before launch step in the IDEA run configuration and add a SBT products step instead.