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

前端 未结 10 780
一向
一向 2021-02-02 06:18

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 l

10条回答
  •  灰色年华
    2021-02-02 06:44

    IDEA 2016.2.4

    None of these solutions worked for me.

    **** BEFORE YOU TRY THE ANY OF ABOVE. MAKE A BACKUP OF THE SBT / IDEA PROJECT IN QUESTION *****

    If I updated the 'build.sbt' then the external library dependencies on the project view did not update. Moreover, the Project Structure still showed the old dependencies. No matter what I tried IDEA would not refresh.

    The only way I could get a partial restore was to copy the '.idea' folder from another machine. SBT plugin implementation is ****ed! I removed the '.idea/libraries' folder beforehand and then IDEA did not restore this folder. I tried many times importing the project again.

    Very bad :(

    ADDENDUM: I managed to get my project working. I think SBT with IDEA is no longer at fault entirely. It could be just possible that my Apache Ivy 2 cache might have been corrupted. So I executed the following commands:

    $ rm -rf ~/.ivy2/cache/org.scalatest/scalatest_2.11/*
    $ rm -rf ~/.ivy2/cache/org.scalactic/scalactic_2.11/*
    

    Restarted IDEA with invalidate cache under the file drop down menu item. This seemed to trigger some internal action in IDEA and SBT. I also tried manually adding add JARs throught the IDE, but it got massively confused. Moral of the story is to work on two different laptops machines daily and keep them updated.

    Also double check SBT from the command line works. I was using 0.13.12

    $ sbt about
    $ sbt clean
    $ sbt test
    

    Also recheck with the SBT dependencies plugin too.

提交回复
热议问题