Search code examples
intellij-ideaplayframeworksbtsbt-idea

Why does sbt insist on using 0.1-SNAPSHOT for project version?


I am using IDEA 13.1.5 Ultimate edition and sbt 0.13.5 (per Play Activator default config) and here's my current build.sbt:

name := """my-first-app"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file("."))
  .enablePlugins(PlayJava)
  .aggregate(myLibrary)
  .dependsOn(myLibrary)

lazy val myLibrary = (project in file("myLibrary"))
  .enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

libraryDependencies ++= Seq(
  "net.sf.jsefa" % "jsefa" % "1.1.1.RELEASE"
)

I am seeing two issues:

1) sbt is for some reason trying to resolve wrong version of myLibrary project - for some reason it's trying to resolve 0.1-SNAPSHOT instead of what 1.0-SNAPSHOT version (which is what I would expect); for example, sbt update returns this:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: mylibrary#mylibrary_2.11;0.1-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run 'last root/*:update' for the full output.
[error] (root/*:update) sbt.ResolveException: unresolved dependency: mylibrary#mylibrary_2.11;0.1-SNAPSHOT: not found

I cannot understand why - I've done a full-text search on local .ivy repo cache, local .m2 repo cache, the whole project directory, cleaned them all manually, invalidated the IDEA cache + restarted the IDE, and still I cannot find any reference to a file containing 0.1-SNAPSHOT except in the target/ folders which obviously means something is supplying this information but I cannot determine what that is.

I have also tried doing activator clean and then manually deleting target/ folders but I simply don't see where this information is coming from.

2) upon creating the lazy val myLibrary = project line in build.sbt and refreshing the IDEA project, I would expect IDE to create the sbt conventional directory structure in the myLibrary project folder, however, it does nothing. Surely, there must be a way to create this default directory structure instead of me creating the structure manually?

What am I missing here?


Solution

  • You only specified the version of the root build, not your library. 0.1-SNAPSHOT is sbt's default version if none is specified.

    You either have to create a build.sbt in your myLibrary and specify the version there, or if you want to use a single global version number, you can use version in ThisBuild := "1.0-SNAPSHOT".

    IntelliJ offers an option to create missing folders automatically, go to Preferences, search for sbt and check Create directories for empty content roots automatically.