[edit] This answer is for the Play 1. series! *
You must write your own module, then your commands will go to the commands.py , ref file: http://www.playframework.org/documentation/1.2.4/releasenotes-1.1#commands
You can look at existing modules to get inspiration, for example: https://github.com/sim51/logisima-play-yml/blob/master/commands.py
Basically, you define the necessary commands and start them from the "execute" method, for example:
COMMANDS = ['namespace:command'] def execute(**kargs): command = kargs.get("command") app = kargs.get("app") args = kargs.get("args") env = kargs.get("env") if command == "namespace:command": do_something()
if you want to run something java - often happens! -
def do_something(): java_cmd = app.java_cmd([], None, "play.modules.mymodule.MyClass", args) try: subprocess.call(java_cmd, env=os.environ) except OSError: print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). " sys.exit(-1) print
Ps.
creating a custom module is as simple as:
play new-module mymodule
This is a primer: http://playframework.wordpress.com/2011/02/27/play-modules/ , given that the official Play! modular documentation is very limited in this regard.
change
I thought I would add some information:
Before you can execute your commands, you must CREATE your module. It does not work, like everyone else, with dynamic compilation.
play build-module mymodule
new-module / build-module expects the module to be at the root of the project folder, but if you have a lot, it will become a mess. build-module module-srcs/mymodule works fine.