Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fully clean, re-resolve and rebuild a Scala sbt-managed project in IDEA?

TL;DR: How can I fully reconcile all dependencies in IntelliJ when SBT file changes

I have a SBT project setup in IntelliJ. For the most part if works like a charm, but it is quite a pain for me, to change the version of the dependencies and compilers.

What I hope to do, is to update my SBT file, and click something like clean project in IntelliJ, so it gets up to date.

The best menu item I have found is Rebuild project. It reads new dependencies, but keeps the old ones around, so External Libraries contains multiple versions of the Scala runtime and 3rd party libraries.

To get around this I can close IntelliJ and delete all files in .idea/libraries. When I restart IntelliJ it will re-resolve the dependencies. It works, but manually deleting metadata files indicates that I am doing the wrong thing.

like image 369
Tobber Avatar asked Mar 20 '15 12:03

Tobber


People also ask

How do I clear my sbt cache?

You can use Pretty Clean to clean the all of dev tools caches including SBT. PrettyClean also cleans the SBT project's target folder.

How compile sbt project in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.

What does sbt clean compile do?

Removes all generated files from the target directory. Compiles source code files that are in src/main/scala, src/main/java, and the root directory of the project. Automatically recompiles source code files while you're running SBT in interactive mode (i.e., while you're at the SBT command prompt).


1 Answers

To refresh IntelliJ after changes made in *.sbt files:

  • Open the SBT Project pane (Menu View / Tool WIndows / SBT)
  • Right click on your SBT project
  • Select Refresh external project

enter image description here

like image 141
Polymerase Avatar answered Sep 28 '22 07:09

Polymerase