IntelliJ IDEA 13: new Scala SBT project hasn't src directory structure generated

送分小仙女□ 提交于 2019-12-02 22:01:32

Normally it should create these folders automatically. It may take a while though - it takes couple of seconds in my case.

When creating project make sure you have selected Scala -> SBT, then proceed with the wizard.

Once the Finish is clicked, the project will be loaded. This part takes couple of seconds, and I can see no src/main/scala nor src/test/scala generated until it's done. Observe the bottom of the screen to see when it's done.

Once the process is finished, you'll see the folders.

If that's not the case, check the settings. You should have the Create directories for empty content roots automatically checked. You may want to check Use auto-import to automatically propagate changes in the build.sbt.

After changing the settings (if the change is required) you may need to refresh the project, as seen in picture below.

Zaptree

This can also happen if you do not have a JDK selected. For some reason you no longer get the option to select an SDK so you must make sure you have configured this before hand. To fix this do the following:

From the welcome screen, go to 
Configure -> Project defaults -> Project structure and add the jdk.

Source: What's the reason for "Error:Cannot determine Java VM executable in selected JDK"?

aleung

Thanks to lpiepiora, with his hint I find out the reason.

Because my sbt is newly installed, there is nothing in ~/.ivy2/cache/ and ~/.sbt/boot/. sbt needed to download required dependencies from repositories on network. It happened that my proxy to internet had something wrong, download stuck.

And also need to notice that, if quit IntelliJ IDEA when sbt is running in background, the next time you'll get error of waiting for some lock file. Have to remove the lock file on filesystem and restart IntelliJ IDEA again.

After fixed the network problem, everything work as promised. It requires several minutes, depends on network speed, to download required jar files. After finished, the src/ directory structure is created.

I followed the instructions in this thread but I had a java crash in the final phase in sbt with the configuration bellow and I think this info maybe useful:

The problem happened with IDEA 2016.2, sbt 0.13.8 (I tried later to import using 0.13.12 but the crash was the same), scala 2.11.8 and ubuntu 16.04.

The only way I could make it work was to use java 8 instead of 9.

error: error while loading package, Missing dependency 'object java.lang.Object in compiler mirror', required by /home/jbamaral/.sbt/boot   at xsbt.boot.Boot.main(Boot.scala)
... 
stack log here
...
[error] scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!