sbt add java project

前端 未结 4 1933
青春惊慌失措
青春惊慌失措 2021-01-22 15:14

Working on some scala software in IDEA IntelliJ. (It also features Android if it is essential). Suppose I have two projects:

P1, written in scala, uses sbt as the build

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 15:27

    • P2/Java: put it under Maven, install it into your local maven repository
    • P1/Scala: in build.sbt add an Library Depdendency to P2/Java, e.g. libraryDependencies += "xyz" % "xyz" % "xyz". Now all dependencies of P2 are also accessible in P1
    • As an option for "more convenience": IntelliJ allows you to add an Project Structure (F4) Module Dependency to an separate Java module. If you combine the both things above, you can change P2, and those changes are reflected instantly in P1. Otherwise you would have an binary maven/jar reference, and any change in P2 would need a maven publish, which is not convenient if you own both source bases P1 and P2 and change a lot both of them. Side note: Any refresh on build.sbt would remove this explicity added IntellIJ-project-struture-module-dependency to P2. So I propose to turn sbt auto-import off in Intellij and the dependency is kept any time you restart IntelliJ

提交回复
热议问题