Run JUnit tests with SBT

Finally, I’ve discovered, that I have to add the following settings to the subproject: lazy val webapp = project settings( Seq( projectDependencies ++= Seq( …. “org.scalatest” %% “scalatest” % “2.2.2” % Test, “junit” % “junit” % “4.11” % Test, crossPaths := false, “com.novocode” % “junit-interface” % “0.11” % Test ) ): _* ) It is … Read more

How to Add Environment Profile Config to SBT

You can do this by creating a custom configuration. val ProfileDev = config(“dev”) extend(Runtime) val ProfileQA = config(“qa”) extend(Runtime) val root = (project in file(“.”)). configs(ProfileDev, ProfileQA). // add config here! settings( name := “helloworld”, …. ). settings(inConfig(ProfileDev)(Classpaths.configSettings ++ Defaults.configTasks ++ Defaults.resourceConfigPaths ++ Seq( unmanagedResourceDirectories += {baseDirectory.value / “src” / configuration.value.name / “resources”} )): _*). … Read more

How to change setting inside SBT command?

With the help from sbt mailing list, I was able to create a solution as follows: def publishSnapshot = Command.command(“publish-snapshot”) { state => val extracted = Project extract state import extracted._ val eVersion = getOpt(version).get // getting current version runTask(publish in Compile, append(Seq(version := “newVersion”), state), true ) state }

How to set main class in build?

The main Class must be fully qualified with the package: Compile/mainClass := Some(“myPackage.aMainClass”) This will work for run and it will set the Main-Class in the Manifest when using the package task. The main class for these tasks can be set separately as in: mainClass in (Compile, run) := Some(“myPackage.aMainClass”) mainClass in (Compile, packageBin) := … Read more

Build.scala, % and %% symbols meaning

From the official documentation: http://www.playframework.com/documentation/2.1.1/SBTDependencies Getting the right Scala version with %% If you use groupID %% artifactID % revision instead of groupID % artifactID % revision (the difference is the double %% after the groupID), SBT will add your project’s Scala version to the artifact name. This is just a shortcut. You could write … Read more

How to set heap size for sbt?

You need SBT_OPTS, here’s what I use in my .bash_profile: export SBT_OPTS=”-Xmx1536M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT” UPDATE: To get your 2G heap space you can use this: export SBT_OPTS=”-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT” NOTE: SBT MUST BE LATEST VERSION Older versions of sbt contain bugs that override these settings, use brew upgrade sbt … Read more

How to access a secured Nexus with sbt?

Here’s what I did (sbt 0.13 + artifactory – setup should be similar for nexus): 1) Edited the file ~/.sbt/repositories as specified here: http://www.scala-sbt.org/0.13.0/docs/Detailed-Topics/Proxy-Repositories.html [repositories] local my-ivy-proxy-releases: http://repo.company.com/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] my-maven-proxy-releases: http://repo.company.com/maven-releases/ 2) Locked down my artifactory to disable anonymous access. 3) Created a credentials file in ~/.sbt/.credentials realm=Artifactory Realm host=artifactory.mycompany.com user=username password=password 4) Created a … Read more