Skip to content

Instantly share code, notes, and snippets.

@Timshel
Created November 21, 2013 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Timshel/7581175 to your computer and use it in GitHub Desktop.
Save Timshel/7581175 to your computer and use it in GitHub Desktop.
Play221 with scalariform formatting before compilation
# Control the activation of the scalariform plugin (default false).
application.scalariform.enable=true
# Path to the configuration properties :
#application.scalariform.config.path="conf/scalariform.properties"
name := "play221"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)
play.Project.playScalaSettings ++ scalariformConf
import sbt._
import Keys._
import com.typesafe.config._
object ApplicationBuild extends Build {
val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()
lazy val scalariformConf: Seq[Setting[_]] = {
import scala.util.control.Exception._
val useScalariform = (catching(classOf[ConfigException]) opt conf.getBoolean("application.scalariform.enable")).getOrElse(false)
if( useScalariform ){
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._
val confPath = ( catching(classOf[ConfigException]) opt
conf.getString("application.scalariform.config.path") ).getOrElse("conf/scalariform.properties")
val formattingPreferences = PreferencesImporterExporter.loadPreferences(confPath)
com.typesafe.sbt.SbtScalariform.scalariformSettings ++ Seq( ScalariformKeys.preferences := formattingPreferences )
} else { Nil }
}
}
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Scalariform formatting
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
alignSingleLineCaseStatements=true
compactControlReadability=true
compactStringConcatenation=true
doubleIndentClassDeclaration=true
formatXml=true
indentLocalDefs=true
indentPackageBlocks=true
indentSpaces=2
multilineScaladocCommentsStartOnFirstLine=true
preserveSpaceBeforeArguments=false
preserveDanglingCloseParenthesis=false
rewriteArrowSymbols=false
spaceBeforeColon=false
spaceInsideBrackets=false
spacesWithinPatternBinders=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment