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 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

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

How to use sbt from behind proxy?

sbt respects the usual environment variables for http proxy settings: export JAVA_OPTS=”$JAVA_OPTS -Dhttp.proxyHost=yourserver -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password” (That’s of course, assuming Unix (Linux/OSX etc). On windows you could just set the same environment variable (%JAVA_OPTS%) as usual in the Windows way.) Then run sbt as usual: sbt Switching between proxy/no-proxy should be a matter of setting … Read more