Groovy web console

subscribe to the feed Subscribe
to this
site
multiline string regex (via #groovywebconsole)
tweet this snippet Tweet
this
script

multiline string regex

Published 3 months ago by lukeab
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def build_scala_content = """import com.iheart.sbtPlaySwagger.SwaggerPluginimport com.typesafe.sbt.SbtScalariform
import play.sbt.{PlayLayoutPlugin, PlayScala}
import sbt.{ClasspathDep, Compile, Defaults, IntegrationTest, ModuleID, Project, ProjectReference, Resolver, SimpleFileFilter, addCommandAlias, file, taskKey}
import sbt.Keys._
import scoverage.ScoverageKeys.coverageExcludedPackages
import play.sbt.routes.RoutesKeys.routesImport

object Build {

  lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")

  lazy val customSettings = Seq(
    version := "1.0",
    scalaVersion := "2.11.8",
    scalacOptions ++= Seq("-feature"),
    resolvers ++= Seq(
      Resolver.jcenterRepo,
      Resolver.sonatypeRepo("snapshots")
    ),
    fork in IntegrationTest := false,
    parallelExecution in IntegrationTest := false,
    (excludeFilter in SbtScalariform.autoImport.scalariformFormat) := new SimpleFileFilter(_.getCanonicalPath.contains("/target/")),
    coverageExcludedPackages := ".*Routes.*;.*Reverse.*;",
    compileScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Compile).toTask("").value,
    (compile in Compile) := {
      compileScalastyle.value
      (compile in Compile).value
    }
  ) ++ Defaults.itSettings ++ SbtScalariform.scalariformSettingsWithIt

  val cliAliases = Seq(
    "c" -> "compile",
    "ca" -> ";c;tc;ic;ccc",
    "catit" -> ";ca;tit",
    "ccc" -> "callcreditTest/test:compile",
    "cct" -> "callcreditTest/test",
    "cov" -> "coverage",
    "covr" -> ";coverageAggregate;coverageReport",
    "dpl" -> "docker:publishLocal",
    "e2e" -> "it:testOnly *OrderDispatchServiceEndToEndSpec",
    "e2el" -> "it:testOnly *LoanOrderDispatchServiceEndToEndSpec",
    "e2es" -> "it:testOnly *ShareOrderDispatchServiceEndToEndSpec",
    "gc" -> "gatling/gatling:compile",
    "gcl" -> "gatling/gatling:clean",
    "gt" -> "gatling/gatling:test",
    "gto" -> "gatling/gatling:testOnly",
    "gtopa" -> "gatling/gatling:testOnly *ProfitAllocationSimulation",
    "ic" -> "it:compile",
    "it" -> "it:test",
    "ito" -> "it:testOnly",
    "itoic" -> "it:testOnly com.company.investment.controller.*",
    "itois" -> "it:testOnly com.company.investment.service.*",
    "mkt" -> "it:testOnly *MarketServiceSpec",
    "mktl" -> "it:testOnly *LoanMarketServiceSpec",
    "mkts" -> "it:testOnly *ShareMarketServiceSpec",
    "ods" -> "it:testOnly *OrderDispatchServiceSpec",
    "odsl" -> "it:testOnly *LoanOrderDispatchServiceSpec",
    "odss" -> "it:testOnly *ShareOrderDispatchServiceSpec",
    "r" -> "reload",
    "rca" -> ";r;ca",
    "rcatit" -> ";r;ca;tit",
    "t" -> "test",
    "tc" -> "test:compile",
    "tit" -> ";t;it",
    "to" -> "testOnly"
  )
}"""
  
def versionmatch = build_scala_content=~ /\s*version\s*:=\s*"(?<version>.+)"\s*,/
def versionnumprefix = ""
if(versionmatch.getCount() >0 && versionmatch.hasGroup()){
  versionnumprefix = versionmatch.group("version")
  println("Version found in build.scala: ", versionnumprefix)
}else{
  //no matches, throw an error, mark failure.
  error ("No version found in project/Build.scala")
}