javaantbuildplayframeworkantbuilder

Execute play from Ant script


I'm looking for a way to run play dist through an Ant build script. I've looked into using the exec task but it is not working for me. Here is what I tried:

<target name="deploy">
    <exec executable="play">
        <arg value="dist" />
    </exec>    
</target>

I'm getting this error:

C:\Users\path\to\build.xml:39: Execute failed: java.io.IOException: Cannot run program "play": CreateProcess error=2, The system cannot find the file specified

Play is already in my Path environment variable and I can execute it from the command line by typing play so that isn't the problem. I'm not allowed to use absolute paths due to sysadmin constraints.

Any ideas?


Solution

  • Ended up manually searching for the Play executable and storing the property to use in the exec task:

    <exec executable="where" outputproperty="play.dir" osfamily="windows">
            <arg value="play.bat" />
    </exec>
    <exec executable="which" outputproperty="play.dir" osfamily="unix">
            <arg value="play" />
    </exec>
    
    <exec executable="${play.dir}" dir=" ... ">
            <arg value="dist" />
    </exec>