From 851f4ebe87adeafd67b55b60210f161f8ee7dee5 Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 17 Aug 2016 21:29:02 -0700 Subject: Generation of all the necessary code style resources --- src/main/scala/com.drivergrp.sbt/SbtSettings.scala | 153 ++++++++++++++++++++- 1 file changed, 152 insertions(+), 1 deletion(-) (limited to 'src/main/scala/com.drivergrp.sbt/SbtSettings.scala') diff --git a/src/main/scala/com.drivergrp.sbt/SbtSettings.scala b/src/main/scala/com.drivergrp.sbt/SbtSettings.scala index 6238cf7..f3f82e1 100644 --- a/src/main/scala/com.drivergrp.sbt/SbtSettings.scala +++ b/src/main/scala/com.drivergrp.sbt/SbtSettings.scala @@ -29,7 +29,37 @@ object SbtSettings extends AutoPlugin { object autoImport { - lazy val scalaFormatSettings = Seq( + lazy val formatSettings = Seq( + resourceGenerators in Compile += Def.task { + val contents = + """# scalafmt sbt plugin config + |# refer to https://olafurpg.github.io/scalafmt/#Configuration for properties + | + |--style defaultWithAlign # For pretty alignment. + |--maxColumn 120 # For my wide 30" display. + | + |--reformatDocstrings true + |--scalaDocs + | + |--continuationIndentCallSite 4 + |--continuationIndentDefnSite 4 + | + |--rewriteTokens ⇒;=>,←;<- + |--danglingParentheses false + |--spaceAfterTripleEquals true + |--alignByArrowEnumeratorGenerator true + |--binPackParentConstructors true + |--allowNewlineBeforeColonInMassiveReturnTypes true + |--spacesInImportCurlyBraces false + | + |# --alignByOpenParenCallSite + |# --alignByOpenParenDefnSite + | + """.stripMargin + val formatFile = file(".scalafmt") + IO.write(formatFile, contents) + Seq(formatFile) + }.taskValue, scalafmtConfig in ThisBuild := Some(file(".scalafmt")), testExecution in (Test, test) <<= (testExecution in (Test, test)) dependsOn (scalafmtTest in Compile, scalafmtTest in Test)) @@ -37,6 +67,127 @@ object SbtSettings extends AutoPlugin { private lazy val compileScalastyle = taskKey[Unit]("compileScalastyle") lazy val scalastyleSettings = Seq( + resourceGenerators in Compile += Def.task { + val styleFile = file("scalastyle-config.xml") + val contents = + """ + | Scalastyle standard configuration + | + | + | + | + | + | + | + | + | package + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + """.stripMargin + IO.write(styleFile, contents) + Seq(styleFile) + }.taskValue, + scalastyleConfig := file("scalastyle-config.xml"), compileScalastyle := (scalastyle in Compile).toTask("").value, (compile in Compile) <<= ((compile in Compile) dependsOn compileScalastyle)) -- cgit v1.2.3