Have intellij output it's files in a different directory from sbt

I typically use the sbt command line to build / test / run my projects.

However occassionally I need to debug them so I will build them with Intellij in that case.

I am auto-generating my .idea projects from my projects sbt files

I notice when I flip between either, both seem to step on each other's toes and require full rebuilds as they are overwriting each other's files in the target directorys (and even the sbt files the project/target directory project/project/target directories)

Is there any way to have intellij output it's files to a separate location than where sbt outputs it's stuff?

Previously I have accomplished this by modifying the iml files with a regex that that replaces stuff like:
    <output url="file://$MODULE_DIR$/../../apps/target/scala-2.11/classes" />

with this:
    <output url="file://$MODULE_DIR$/../../apps/target/idea-scala-2.11/classes" />

is there any what to do this with a setting?

If not is there another suggested work around? The project I am working on is pretty large and having to do full recompiles everytime really slows down development.

Incremental caches are different for IDEA and SBT. So it's bad idea to mix output directory, you are right. In any case it's much better to use single approach to compile (I use only IDEA, you can use only SBT). Debug feature is possible without IDEA compilation phase. You have two options for that:

1. Have output directories that same as SBT. Just remove "Make" step from run configuration. So it will run over SBT compilation output without compilation. Problem in this approach, that you can forget to recompile. For this you can create "SBT Task" run configuration with test:compile command. Then add step, which refer to this "SBT Task" instead of "Make" step in your run configuration.
2. You can use remote debug. So run your application from command line with remote debug VM options. Connect to this application from IDEA with "Remote Debug" run configuration.

You still can change output directories in Project Settings -> Modules -> Paths. But after SBT refresh you will lose your changes.

Best regards,
Alexander Podkhalyuzin.

You still can change output directories in Project Settings -> Modules -> Paths. But after SBT refresh you will lose your changes.

Yes I guess this is what I am asking for? Is it possible to have that be something available from sbt-ide-settings[1]?

Otherwise I suppose I can try to re-map this with a perl-script I run after I run the sbt-reimport?


EDIT: I will try #1 and update (I usually have a ~compile loop going in a terminal right next to my IDE so I am not that worried about forgetting).


Hi! Changes you're asking for are being implemented currently. Please, watch for changes in corresponding ticket on Youtrack (https://youtrack.jetbrains.com/issue/SCL-7711)


Please sign in to leave a comment.