Search code examples
javascalaplayframeworksbtplayframework-2.2

Detect application mode (DEV, TEST, PROD) during build in Play Framework 2.x application


Good day all,

I'd like to be able to detect the mode that a Play application will use during build. Meaning I'd like to execute certain tasks within my Build.scala/build.sbt depending on whether the application is started in DEV or in PROD mode for instance.

The reason I need this is because we (the team) have implemented Grunt.js into the build process by adding it to the playRunHooks. Depending on whether the application is running in DEV mode or not we want to enable/disable some Grunt tasks.

I know I can check the application mode from within the actual application using Play.isDev and the like, is there a similar mechanism available for within the build files?

If not I would really only need to know the command that was issued by the developer (run, start, dist, stage etc.) but I can't seem to find a straight forward way of getting to know this either.

Can anyone point me in the right direction? Thank you in advance!


Solution

  • Any build tasks that are added to playRunHooks are only executed on "play run". If you do "play stage" or "play dist" those tasks are never executed.