1

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?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
quantum
  • 3,000
  • 5
  • 41
  • 56

2 Answers2

2

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.

Marius Soutier
  • 11,184
  • 1
  • 38
  • 48
  • Hm, interesting - I had no idea that checkbox was off, thanks for that! Yes, IDEA is now creating the expected structure but even after setting the build to [1.0-SNAPSHOT](https://imageshack.com/i/f0jSxdqop), I am still finding old [0.1-SNAPSHOT](https://imageshack.com/i/paUeIZLsp) files (leftovers from my previous experiments) in the project target folder (links show the pictures). How do I get rid of them and what needs to be invoked to clean that folder all together? – quantum Oct 06 '14 at 18:54
  • Nope, still the same - have tried putting `ThisBuild` on both `scalaVersion` and `name` Settings. I have also tried to create a `build.sbt` file in the `myLibrary` project to see if that will override the version - nothing. For some reason I am also seeing my `~/.sbt/boot` folder with three different scala versions (2.10.2, 2.10.4, 2.11.1) even though I expect there to see just the latest one. Could this be connected? – quantum Oct 06 '14 at 19:13
  • But does it resolve correctly now? I think the resolution cache there is only relevant to sbt, which probably still uses Scala 2.10. – Marius Soutier Oct 06 '14 at 19:16
  • I would say yes - changing the version in `build.sbt`, making `root` depend on `myLibrary` (via `lazy val root = (project in file(".")).dependsOn(myLibrary).aggregate(myLibrary)`), and then doing `activator clean compile`, the activator output seems to be changing as I change the `myLibrary` version (e.g. `... [info] Resolving mylibrary#mylibrary_2.11;1.1-SNAPSHOT ...`). However, that `target/` folder still contains references to `0.1-SNAPSHOT` which is disconcerting. Is there a better way to see the dependency tree in sbt? Something akin to what maven produces perhaps? – quantum Oct 06 '14 at 19:26
  • Sure, `sbt dependencies`, although I wouldn't worry about that too much. My guess is that it is related to sbt and thus normal. – Marius Soutier Oct 06 '14 at 20:19
  • Well, it seems it's working as expected - root project now handles its own version and child library gets its own through separate `build.sbt` file. I still don't understand why I need to put the `in ThisBuild` incantation on the `scalaVersion` Setting (my experiments tell me that without that, sbt simply uses `0.1-SNAPSHOT`). EDIT: note to self, the directive is located on [Scopes](http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Scopes.html) doc page. – quantum Oct 06 '14 at 20:46
  • hint: use `inspect` and review `Delegates`. – Jacek Laskowski Oct 08 '14 at 19:48
0

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

lennon310
  • 12,503
  • 11
  • 43
  • 61
PainPoints
  • 461
  • 8
  • 20