简体   繁体   中英

Set changing scala project dependency in Intellij IDEA 14 (for code completion and inspection)

I'm currently developing a multi-project Scala application in IntelliJ IDEA 14 with SBT. Projects have dependencies ( dependency projects ) between them and I need IntelliJ IDEA to inspect code from all projects, at least, from the projects I use from the current project ( working project ). I need IntelliJ IDEA to update this inspection (eg syntax highlighting) automatically after a change in a dependency project.

This is what I've tried:

  • I've tried to add a project as a library but the problem is that IntelliJ IDEA seems not to recognize the .scala files and packages.

  • I've also tried to set a compiled .jar of the working project as a library and set sbt in the dependency project to package the project into a .jar file every time I change a file: running ~package in the sbt console of the dependency project. But it seems that this daemon prevents IntelliJ IDEA from reading the newly created .jar file in the working project. If I package the project manually after making a change, it works properly (I get code inspection and classes are loaded properly).

  • I've tried SBT Multi-Project too but while this settings work for compiling the working project and the dependecy project, I don't get the IntelliJ IDEA code inspection that I need, everything that is not in the working project is highlighted in red. Or maybe I'm doing it wrong, here is the code (that's all I have done):

    lazy val wcommon = RootProject(file("../WCommon")) val wrepository = Project(id = "application", base = file(".")).dependsOn(wcommon)

Any suggestion?

Your last attempt with RootProject(...) should work, I use that very same method in numerous multi-project builds. Do you have auto-import enabled on your build file in IDEA? I've had issues with indexing/caching issues so I'd also try restarting IDEA after making sure your build file is appropriately imported. If you are still having issues I'd then check to make sure the WCommon project is opening cleanly in IDEA by itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM