Skip to content

Instantly share code, notes, and snippets.

@Andrei-Pozolotin
Last active August 29, 2015 14:06
Show Gist options
  • Save Andrei-Pozolotin/820bf7c357ab0b8b5af4 to your computer and use it in GitHub Desktop.
Save Andrei-Pozolotin/820bf7c357ab0b8b5af4 to your computer and use it in GitHub Desktop.
play 3.0: a better dev/prod/test separation
grep -E -H -i "(mode.prod)|(mode.dev)|(mode.test)" . -R | wc -l
82
grep -E -H -i "(mode.prod)|(mode.dev)|(mode.test)" . -R > play.grep
./src/play-test/src/main/scala/play/api/test/TestServer.scala: port = Option(port), sslPort = sslPort, mode = Mode.Test,
./src/play-test/src/main/scala/play/api/test/Fakes.scala: private val environment = Environment(path, classloader, Mode.Test)
./src/play/src/main/scala/views/helper/requireJs.scala.html: <script type="text/javascript" data-main="@{if(play.api.Mode.Prod == play.api.Play.maybeApplication.map(_.mode).getOrElse(play.api.Mode.Dev)) module.replace(folder,folder+productionFolderPrefix) else module}" src="@core"></script>
./src/play/src/main/scala/views/play20/welcome.scala.html:@play.api.Play.maybeApplication.filterNot(_.mode != play.api.Mode.Dev).map { _ =>
./src/play/src/main/scala/play/api/package.scala: * val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
./src/play/src/main/scala/play/api/libs/Crypto.scala: case (Some("changeme") | Some(Blank()) | None) if environment.mode == Mode.Prod =>
./src/play/src/main/scala/play/api/controllers/ExternalAssets.scala: case Mode.Prod => NotFound
./src/play/src/main/scala/play/api/controllers/Assets.scala: def isDev = Play.maybeApplication.fold(false)(_.mode == Mode.Dev)
./src/play/src/main/scala/play/api/controllers/Assets.scala: def isProd = Play.maybeApplication.fold(false)(_.mode == Mode.Prod)
./src/play/src/main/scala/play/api/Application.scala: * val application = new DefaultApplication(new File("."), this.getClass.getClassloader, None, Play.Mode.Dev)
./src/play/src/main/scala/play/api/Configuration.scala: * Defaults to Mode.Dev
./src/play/src/main/scala/play/api/Configuration.scala: def load(appPath: File, mode: Mode.Mode = Mode.Dev, devSettings: Map[String, String] = Map.empty) = {
./src/play/src/main/scala/play/api/Configuration.scala: if (currentMode == Mode.Prod) Configuration(dontAllowMissingConfig) else Configuration(loadDev(appPath, devSettings))
./src/play/src/main/scala/play/api/Play.scala: case Mode.Test =>
./src/play/src/main/scala/play/api/Play.scala: def isDev(implicit app: Application): Boolean = (app.mode == Mode.Dev)
./src/play/src/main/scala/play/api/Play.scala: def isProd(implicit app: Application): Boolean = (app.mode == Mode.Prod)
./src/play/src/main/scala/play/api/Play.scala: def isTest(implicit app: Application): Boolean = (app.mode == Mode.Test)
./src/play/src/main/scala/play/api/GlobalSettings.scala: case app if app.mode == Mode.Prod => prodError
./src/play/src/main/scala/play/api/GlobalSettings.scala: case app if app.mode != Mode.Prod => views.html.defaultpages.devNotFound.f
./src/play/src/main/scala/play/api/Environment.scala: def simple(mode: Mode.Mode = Mode.Test) = Environment(new File("."), Environment.getClass.getClassLoader, mode)
./src/play/src/main/scala/play/api/mvc/Results.scala: (app.mode == play.api.Mode.Dev) && (!flash.isEmpty) && (header.status < 300 || header.status > 399))
./src/play/src/main/scala/play/api/Logger.scala: val resourceName = if (mode == Mode.Dev) "logback-play-dev.xml" else "logback-play-default.xml"
./src/play/src/main/scala/play/api/Logger.scala: if (env.mode == Mode.Dev) "logback-play-dev.xml" else "logback-play-default.xml"
./src/play/src/main/scala/play/core/system/ApplicationProvider.scala: val environment = Environment(applicationPath, this.getClass.getClassLoader, Mode.Prod)
./src/play/src/main/scala/play/core/system/ApplicationProvider.scala: Logger.init(path, Mode.Dev)
./src/play/src/main/scala/play/core/system/ApplicationProvider.scala: val environment = Environment(path, projectClassloader, Mode.Dev)
./src/play/src/main/scala/play/core/j/JavaModeConverter.scala: case play.api.Mode.Dev => play.Mode.DEV
./src/play/src/main/scala/play/core/j/JavaModeConverter.scala: case play.api.Mode.Test => play.Mode.TEST
./src/play/src/main/scala/play/core/j/JavaModeConverter.scala: case play.api.Mode.Prod => play.Mode.PROD
./src/play/src/main/java/play/Environment.java: if (env.mode().equals(play.api.Mode.Prod())) {
./src/play/src/main/java/play/Environment.java: return Mode.PROD;
./src/play/src/main/java/play/Environment.java: } else if (env.mode().equals(play.api.Mode.Dev())) {
./src/play/src/main/java/play/Environment.java: return Mode.DEV;
./src/play/src/main/java/play/Environment.java: return Mode.TEST;
./src/play/src/main/java/play/Environment.java: return mode().equals(Mode.DEV);
./src/play/src/main/java/play/Environment.java: return mode().equals(Mode.PROD);
./src/play/src/main/java/play/Environment.java: return mode().equals(Mode.TEST);
./src/play/src/test/scala/play/api/FakeApplication.scala: mode: Mode.Mode = Mode.Test,
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Prod, Some(Secret)) must_== Secret
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev, Some(Secret)) must_== Secret
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Prod, Some("changeme")) must throwA[PlayException]
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Prod) must throwA[PlayException]
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Prod, Some(" ")) must throwA[PlayException]
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Prod, Some("")) must throwA[PlayException]
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev, Some("changeme")) must_!= "changeme"
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev) must_!= ""
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev, Some(" ")) must_!= " "
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev, Some("")) must_!= ""
./src/play/src/test/scala/play/api/libs/CryptoSpec.scala: parseSecret(Mode.Dev, Some("changeme")) must_== parseSecret(Mode.Dev)
./src/play/src/test/scala/play/api/i18n/MessagesSpec.scala: val api = new DefaultMessagesApi(new Environment(new File("."), this.getClass.getClassLoader, Mode.Dev),
./src/play-integration-test/src/test/scala/play/it/http/NettyRunners.scala: def mode: Mode.Mode = Mode.Test
./src/play-integration-test/src/test/scala/play/it/http/assets/AssetsSpec.scala: override val mode = Mode.Prod
./src/play-integration-test/src/test/scala/play/it/http/ServerBenchmark.scala: val environment = Environment(new File("."), this.getClass.getClassLoader, Mode.Test)
./src/play-integration-test/src/test/scala/play/it/views/DevErrorPageSpec.scala: override val mode = play.api.Mode.Prod
./src/play-docs/src/main/scala/play/docs/DocumentationServer.scala: mode = Mode.Dev,
./src/play-docs/src/main/scala/play/docs/DocumentationApplication.scala: private val environment = Environment(projectPath, this.getClass.getClassLoader, Mode.Dev)
./src/play-ws/src/main/scala/play/api/libs/ws/ning/NingWS.scala: case Mode.Prod =>
./src/play-akka-http-server/src/main/scala/play/core/server/akkahttp/AkkaHttpServer.scala: case Mode.Test =>
./src/play-akka-http-server/src/main/scala/play/core/server/akkahttp/AkkaHttpServer.scala: case Mode.Test =>
./src/play-akka-http-server/src/main/scala/play/core/server/akkahttp/AkkaHttpServer.scala: case Mode.Dev =>
./src/play-akka-http-server/src/sbt-test/akka-http/system-property/project/Build.scala: * SBT Plugin's dev mode tests.
./src/play-akka-http-server/src/sbt-test/akka-http/compiled-class/project/Build.scala: * SBT Plugin's dev mode tests.
./src/play-jdbc/src/main/scala/play/api/db/DBModule.scala: db.connect(logConnection = environment.mode != Mode.Test)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/EvolutionsApi.scala: scripts(db, new EvolutionsReader(Environment(path, this.getClass.getClassLoader, Mode.Dev /* not used */ )))
./src/play-jdbc/src/main/scala/play/api/db/evolutions/Evolutions.scala: private def isTest: Boolean = Play.maybeApplication.exists(_.mode == Mode.Test)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/Evolutions.scala: lazy val environment = Environment(appPath, classloader, Mode.Dev)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Test => evolutions.evolve(db, scripts, autocommit)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Dev if dbConfig.autoApply => evolutions.evolve(db, scripts, autocommit)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Prod if !hasDown && dbConfig.autoApply => evolutions.evolve(db, scripts, autocommit)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Prod if hasDown && dbConfig.autoApply && dbConfig.autoApplyDowns => evolutions.evolve(db, scripts, autocommit)
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Prod if hasDown =>
./src/play-jdbc/src/main/scala/play/api/db/evolutions/ApplicationEvolutions.scala: case Mode.Prod =>
./src/play-jdbc/src/main/scala/play/api/db/BoneCPModule.scala: if (Play.maybeApplication.exists(_.mode == Mode.Dev)) {
./src/play-jdbc/src/test/scala/play/api/db/evolutions/EvolutionsReaderSpec.scala: val environment = Environment(new File("."), getClass.getClassLoader, Mode.Test)
./src/play-netty-server/src/main/scala/play/core/server/NettyServer.scala: case Mode.Test =>
./src/play-netty-server/src/main/scala/play/core/server/NettyServer.scala: case Mode.Test =>
./src/play-netty-server/src/main/scala/play/core/server/NettyServer.scala: case Mode.Dev =>
./src/play-server/src/main/scala/play/core/server/ServerConfig.scala: mode: Mode.Mode = Mode.Prod,
./src/play-server/src/main/scala/play/core/server/ServerStart.scala: mode = Mode.Prod,
./src/play-server/src/main/scala/play/core/server/ServerStart.scala: mode = Mode.Dev,
./src/play-server/src/test/scala/play/core/server/ServerStartSpec.scala: mode = Mode.Prod,
./src/play-server/src/test/scala/play/core/server/ServerStartSpec.scala: mode = Mode.Prod,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment