PlayFramework and SBT release plugin run with test play app configuration

163 views Asked by At

Play 2.5

Is there a way to automatically load a test configuration when running the release task in SBT-release https://github.com/sbt/sbt-release.

Currently, I have to run this command and explicitly specify the test config file.

sbt "release with-defaults" -Dconfig.resource=application-test.conf

runTest step is one of the releases steps build.sbt Is it possible to make it pick up the test config automatically?

releaseProcess <<= thisProjectRef apply { ref =>
  import sbtrelease.ReleaseStateTransformations._
  Seq[ReleaseStep](
    loginToAwsEcr(ref),
    checkSnapshotDependencies,
    inquireVersions,
    runClean,
    runTest,
    setReleaseVersion,
    commitReleaseVersion,
    tagRelease,
    releaseStepTask(sbtdocker.DockerKeys.dockerBuildAndPush),
    uploadBeanstalkBundle(ref),
    setNextVersion,
    commitNextVersion,
    pushChanges
  )
}

project/plugins.sbt

addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.4")

I tried to add

javaOptions in Test += "-Dconfig.file=conf/application-test.conf"

but it doesn't work.

1

There are 1 answers

0
maestr0 On

I was missing one important thing. JVM needs to be forked for tests in order to pick up the -D params.

fork in Test := true

javaOptions in Test += "-Dconfig.file=conf/application-test.conf"

now when I run sbt test or sbt "release with-defaults" the test config file gets automatically loaded.