1

I have a sbt build file that use 1 plugin and 3 dependencies:

scalaVersion := "2.10.4"

val reflect = Def.setting { "org.scala-lang" % "scala-reflect" % "2.10.4" }

val compiler = Def.setting { "org.scala-lang" % "scala-compiler" % "2.10.4" }

lazy val macrosSettings = Project.defaultSettings ++ Seq(
addCompilerPlugin("org.scala-lang.plugins" % "macro-paradise_2.10.4-SNAPSHOT" % "2.0.0-SNAPSHOT"),
libraryDependencies ++= {
  import Dependencies._
  Seq(play_json, specs2, reflect.value)
}
)

lazy val Macros = Project(id="IScala-Macros", base=file("macros"), settings=macrosSettings)

However the compiler gave me the following error in compiling IScala-Macros:

[warn]  :: org.scala-lang#scala-compiler;2.10.4-SNAPSHOT: not found
[warn]  :: org.scala-lang#scala-library;2.10.4-SNAPSHOT: not found
[warn]  :: org.scala-lang#scala-reflect;2.10.4-SNAPSHOT: not found

this seems like a bug as I don't want them to resolve to 2.10.4-SNAPSHOT, but only 2.10.4, is it a bug of sbt? If not, where does this SNAPSHOT come from?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
tribbloid
  • 4,026
  • 14
  • 64
  • 103

1 Answers1

1

There are a couple of issues in this build.sbt build definition so I highly recommend reading the document Macro Paradise where you can find the link to a project that for an end-to-end example, but in a nutshell working with macro paradise is as easy as adding the following two lines to your build (granted you’ve already set up SBT to use macros).

As to the issues in this build, I don't see a reason for Def.setting for the depdendencies reflect and compiler, and moreover I'm unsure about the dependency in addCompilerPlugin. Use the one below where Def.setting is used to refer to the value of the scalaVersion setting. I still think addCompilerPlugin should follow the sample project above.

import Dependencies._

scalaVersion := "2.10.4"

val reflect = Def.setting {
  "org.scala-lang" % "scala-reflect" % scalaVersion.value
}

val compiler = Def.setting {
  "org.scala-lang" % "scala-compiler" % scalaVersion.value
}

lazy val macrosSettings = Project.defaultSettings ++ Seq(
  addCompilerPlugin("org.scala-lang.plugins" % "macro-paradise_2.10.4-SNAPSHOT" % "2.0.0-SNAPSHOT"),
  libraryDependencies ++= Seq(
    play_json,
    specs2,
    reflect.value
  )
)

lazy val Macros = Project(id="IScala-Macros", base=file("macros"), settings=macrosSettings)
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Sorry the original build file is very long and convoluted: I modify from this: https://github.com/mattpap/IScala/blob/master/project/Build.scala Namely I change scalaVersion from 2.10.2 to 2.10.4 – tribbloid Jul 19 '14 at 19:46
  • Let me fork a new git project on this to show you the complete file – tribbloid Jul 19 '14 at 19:47
  • OK I have forked a new branch: https://github.com/tribbloid/IScala/blob/master/project/Build.scala – tribbloid Jul 19 '14 at 21:28
  • The problem become latent as I switched macro-paradise to a newer artifact, however it's reason is still unknown to me. I later switched to maven from sbt due to some jar hell issue, as sbt has very scarce plugin to handle it – tribbloid Jul 24 '14 at 20:50
  • What Maven plugin did you use to resolve *"the jar hell issue"*? Would you mind updating my answer to complete it as per your solution? I'd appreciate. If you accepted it afterwards, I wouldn't mind :) – Jacek Laskowski Jul 24 '14 at 20:52