Running your play application with ant

I've been lately using Play framework for upgrading our software to the next level. I have to say I like it a lot, it feels like warm summer breeze after a long winter of Liferay development.

Biggest problem I've had with it so far has been integrating it with our Hudson continuous integration environment. The play command used for everything is written in Python. I wanted to use ant since Hudson has good support for it and ant is also platform independent, which is important to me since I'm developing on windows and our continuous integration is Linux.

So after some digging of the play scripts and few print statements later (first time with python for me), I was able to come up with the following ant task to run my play application:

  <target name="play-run" description="Runs the application">
        <java classname="play.server.Server" fork="yes" failonerror="yes">
            <classpath refid="play.classpath"/>
            <jvmarg line="-javaagent:${play.path}/framework/play.jar -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"/>
            <sysproperty key="" value=""/>
            <sysproperty key="play.debug" value="true"/>
            <sysproperty key="application.path" value="${basedir}"/>
For the classpath I had the following:
    <path id="play.classpath">
        <pathelement path="${play.path}/framework/classes"/>
        <fileset dir="${play.path}/framework/lib">
            <include name="*.jar"/>
        <fileset dir="${play.path}/framework">
            <include name="*.jar"/>
        <fileset dir="lib" erroronmissingdir="false">
            <include name="*.jar"/>
        <!-- Add module libraries here!! -->

Since reading the module dependencies from the application.conf with Ant seemed bit difficult I ended up creating the Play antify module for the build.xml generation, very similar to the existing idealize or eclipsify commands.

No comments:

Post a Comment