My plan is to take an existing project and slowly transform it to something else. To this aim I took the brutal approach and simply copied the folder of the project as it was to a new folder.
When I ran sbt in the new folder, it resolved some dependencies and recompiled all the sources. This is kind of expected, because the project registry may have contained reference to the absolute path where the project resided earlier and sbt may have detected that it changed.
However when I went back to the old project folder, to which I made no modification and ran sbt in that folder, it recompiled all the sources as well in the original project.
This is a puzzle for me. Why did this happen? Is there a magic link between projects residing in different folders that I'm missing?
The simplest explantion might be that compilation was not up-to-date when you copied the original project. If that was the case, copying the project would have updated the file modified dates and triggered a recompilation for the new folder. Similarly, when going back to the old folder again, it would still be out-of-date, and sbt would recompile all sources again.
Oftentimes I have troubles with sbt downloading its dependencies when behind a corporate firewall when trying to "Load a project from existing sources" -> sbt. It eventually times out and leaves my project in the following state:
there is some problem when
I can at this point download all my dependencies through the sbt-terminal tool (or the command-line) but Intellij will still keep this "view", instead of correctly showing me the diverse folders the project contains (like src/, test/, etc).
Is there a way to fix this?
Thanks
I also have had this problem multiple times. I usually close IntelliJ, clean its repository rm -rf .idea/, and then open the project folder (instead of importing it). It's always done the job for me.
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.
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
When you save the SBT file, IntelliJ IDEA normally refreshes the project. But if it doesn't, you can do it manually.
There is a Refresh All SBT Projects button in the SBT Panel:
On the occasion that IDEA is still confused, not finding packages you just added:
From the File menu:
It's a pretty big hammer, requiring a restart of the app, and multi-minute rebuild of the IntelliSense index. But it's occasionally the only thing that will get IDEA to recognize your new SBT packages.
try following steps:
close IntelliJ
backup whole project folder
delete .idea folder
delete target folder
delete project/target folder
reopen IntelliJ and import as a sbt project
Note this is only for SBT projects
Another heavy hammer but seems to work.
Close IntelliJ
Delete .idea folder
Import app from existing sources
Has happened to me before, and yes, is a PITA.
What I usually do is to manually remove the dependencies from the project, all of them, then let sbt re-import what is actually needed. Don't do it on the UI though, since even having multiple selection, will ask for confirmation for EVERY dependency! (you will be clicking "Yes, I'm sure" for an hour), instead, go and delete directly from the .iml project file on your .idea/modules directory.
I was using different versions of sbt and scala across different proejcts and IntelJi got confused somehow. I am only able to resolve the issue by removing the sbt and ivy2 cache folders:
rm -rf ~/.ivy2
rm -rf ~/.sbt
Agree, that's a PITA. Nothing helped me (I tried "Invalidate/Restart", removing files from ".idea/libraries" and restarting).
The only way to overcome the problem for me was to manually remove project-related folders from the IntelliJIdea cache. I removed these folders from the following places (I use OSX and IntelliJ-Idea 14):
/Users/{UserName}/Library/Caches/IntelliJIdea14/compiler/{ProjectName}
/Users/{UserName}/Library/Caches/IntelliJIdea14/compile-server/{ProjectName}
This helped me, hope it will save time for someone.
If you are using the activator through a terminal/shell/command prompt use the following command:
activator clean
Or just "clean" on the sbt shell through intellij
It should help reset things and next time you run or compile, it should go through it from scratch.
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.
What worked for me was to:
1) Close IntelliJ
2) delete .idea/libraries internals
3) Start IntelliJ
4) right-clicked pom.xml Maven > Reimport
After that there were no old versions and duplicate libraries in the External Libraries.
I downloaded spring-social-facebook and spring-social-linked in and built the sources as per the README of the github repo for the projects
After I did ./gradlew eclipse and nce I have imported the project into Eclipse, the build path is not set up correctly.
I tried a few manual set up but did not go very far with that.
I am not a gradle user.
I found out that when you do File -> Import -> Existing projects into workspace in Eclipse, I was using the wrong directory to start from.
When you initially clone the git repository, you have a spring-social-linkedin directory created which is the one you then cd to to do the gradlew operations. And then you have a second one which is created : git/spring-social-linkedin/spring-social-linkedin.
This is this second one you need to select as the root directory to look at when you import the project into eclipse and everything will work fine.
Probably obvious for gradle knowledgeable people...
When I export my project to a zip, and then try to import it on another computer I always get this error:
Created dir: C:\Users\martins0011\Documents\NetBeansProjects\Movicol\build\web\WEB-INF\classes
Created dir: C:\Users\martins0011\Documents\NetBeansProjects\Movicol\build\web\META-INF
Copying 1 file to C:\Users\martins0011\Documents\NetBeansProjects\Movicol\build\web\META-INF
Copying 63 files to C:\Users\martins0011\Documents\NetBeansProjects\Movicol\build\web
C:\Users\martins0011\Documents\NetBeansProjects\Movicol\nbproject\build-impl.xml:846: C:\Users\martins0011\Documents\NetBeansProjects\Movicol\web\WEB-INF does not exist.
BUILD FAILED (total time: 0 seconds)
What causes this error?
I fixed it creating the folder WEB-INF manually on the directory of the project... weird bug, but solved, I can run it now! thanks alot anyway Eric!
I had the same issue while building a web project(JSP) on netbeans 7.2, then I created the WEB_INF manually and the project was successfully rebuilt. Note that this missing file comes from GIT hub upon fetching the web project, at least in my case.
I had the same problem in this year (2020) and I solved by copying and adding the webinf file into the web file in my project. And it doesn't matter where you take this file(webinf) it'll work from every project you choose to copy it.