Bernie Noel
Bernie Noel

Reputation: 304

Is it possible to create a standalone JAR web app with Play Framework?

I'm trying to create a standalone JAR application, which will be executed from command line like this:

$ java -jar foo.jar --port=8080

I want to use Play Framework. Is it possible to create something like this? I want to use Java and Maven. I want to stay away from that "activators" or downloading of Play. Just plain old simple Maven dependencies. Possible?

Upvotes: 1

Views: 1554

Answers (2)

alexfi
alexfi

Reputation: 390

As mentioned here it is possible. Look at the documentation (Default SBT layout). Quote from the play 2.4.0 documentation:

You also have the option of using the default layout used by SBT and Maven. Please note that this layout is experimental and may have issues. In order to use this layout, use disablePlugins(PlayLayoutPlugin). This will stop Play from overriding the default SBT layout [...]

I haven't tested it, but I think this is a good point to start at :)

P.S.: Let us know if it is possible!

Upvotes: 1

biesior
biesior

Reputation: 55798

To stay away from activator and Play download just on your dev-machine call cmd: ./activator dist (activator.bat dist for Windows) it will create a ZIP file in the target/universal/ directory containing scripts for both: Unixes and Windows within the bin directory.

So you can launch your app like (unix sample, after unzipping)

/your-app-dir/target/universal/your-app-1.0-SNAPSHOT/bin/your-app -Dhttp.port=8080

Of course, nothings prevents you from creating additional shell script/BAT file for simplicity this path

Upvotes: 3

Related Questions