Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid adding a 'root' scala sbt project in IntelliJ when defining github dependencies?

I'm using IntelliJ with SBT plugin and I've added the following lines to build.sbt in order to add a dependency to a private github repository:

lazy val g = RootProject(uri("ssh://[email protected]/XXXX/myrepo.git"))

lazy val root = project in file("myproject") dependsOn g

After running sbt, my referenced project is successfully cloned, but build fails due to output path clashes between my base project and a root project that is automatically added each time I refresh sbt after modifying build.sbt.

like image 454
mi.iwanowski Avatar asked Oct 20 '22 04:10

mi.iwanowski


1 Answers

I was having this same issue awhile back.

I'm not sure what causes it but I know that if you use the multi-project setup for sbt (root/project/build.scala) instead of the simple one (root/build.sbt) Intellij respects your settings.

Try the multi-project setup like this and see if it solves your problem:

import sbt.Keys._
import sbt._

lazy val g = RootProject(uri("ssh://[email protected]/XXXX/myrepo.git"))

object MyProjectBuild extends Build {
  lazy val project = Project("myproject", file(".")) // <-- Make sure to name your project what you want the module to be named
    .settings(
      name := "myproject", // <-- Same here
      version := "1.0",
      scalaVersion := "2.11.4",
      libraryDependencies ++=Seq(
        "org.scalatest" % "scalatest_2.11" % "2.2.0" % "test",
      )
    ).dependsOn(g)
}
like image 70
Matt Foxx Duncan Avatar answered Oct 27 '22 10:10

Matt Foxx Duncan