SBT:定义不同的运行配置文件

时间:2017-01-05 14:06:40

标签: scala build sbt

TL;博士; 有两种不同的执行模式。 (1)是正常运行模式,(2)是激活FlightRecorder的分析模式。在(2)中,javaOptions应该被增强。

长版 鉴于@Eugene Yokota提出了答案我更新问题w.r.t.已经提供的答案。

我的 build.sbt currenty如下所示:

lazy val Profile = config("profile") extend(Runtime)

lazy val commonSettings = Seq(
  organization := "org",
  version := "0.0.1",
  scalaVersion := "2.12.0",
  scalacOptions ++= Seq(
    "-encoding", "utf8",
    "-deprecation",
    "-feature",
    "-language:dynamics",
    "-language:reflectiveCalls",
    "-language:postfixOps",
    "-language:implicitConversions",
    "-unchecked",
    "-target:jvm-1.8"),
  fork := true,
  javaHome := Some(file("/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home")),
  javaOptions ++= Seq("-d64", "-Xms1024m", "-Xmx4048m")
)

lazy val main = (project in file("."))
  .configs(Profile)
  .settings(commonSettings: _*).
  settings(
    name := "benchmark-scroll",
    libraryDependencies ++= Seq(
      "xxx"
    )
  ).
  settings(inConfig(Profile)(Classpaths.configSettings ++ Defaults.configTasks ++ Defaults.resourceConfigPaths ++ Seq(
    javaOptions ++= Seq(
      "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder",
      "-XX:StartFlightRecording=settings=profiling-expensive",
      "-XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=."
    ))
  ): _*)

建议的答案说现在应该能够使用sbt "profile:run Benchmark"使用新配置文件运行。

0 个答案:

没有答案