mi.iwanowski
mi.iwanowski

Reputation: 51

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.

Upvotes: 5

Views: 1200

Answers (1)

Matt Foxx Duncan
Matt Foxx Duncan

Reputation: 2094

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)
}

Upvotes: 3

Related Questions