简体   繁体   中英

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?

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 .

I was facing similar issue. Sub-projects were not building and the sbt was failing trying to locate to remote repositories, while upgrading to Play 2.3.6 and Scala 2.11.1. Earlier with Play 2.2 and Scala 2.10 everything was working fine. Now I am getting everything working by putting

scalaVersion in ThisBuild := "2.11.1" 

in the root or main build.sbt

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