AWS Ant Tasks
Introducing a new AWS Labs project: AWS Ant Tasks. These are custom tasks to use within your Ant builds that allow easy access to AWS services. Ant is a commonly used tool for building Java projects, and now you can use it to deploy your project to AWS within the same build. To use these tasks, simply reference “taskdefs.xml” in the project’s jar. The services currently available are Amazon S3 and Amazon Elastic Beanstalk, with AWS OpsWorks on its way soon. If you currently develop a Java application and deploy new versions to an AWS service often, consider trying these tasks out!
Here’s an example of an Ant build that updates an Elastic Beanstalk environment with a new war file:
<project basedir="." default="deploy" name="mybeanstalkproject"> <taskdef resource="taskdefs.xml" classpath="lib/aws-java-sdk-ant-tasks-1.0.0.jar" /> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes” /> </target> <target name="war" depends="compile"> <war destfile="dist/MyProject.war" webxml="WebContent/WEB-INF/web.xml"> <fileset dir="WebContent" /> <lib dir="WebContent/WEB-INF/lib"/> <classes dir="build/classes" /> </war> </target> <target name="deploy" depends="war"> <deploy-beanstalk-app bucketName="mys3bucket" versionLabel="version 0.2" versionDescription="Version 0.2 of my app" applicationName="myapp" environmentName="myenv" file="dist/MyProject.war" /> </target> </project>
Now if you run
ant deploy, this build file will compile, war, and deploy your project to your Elastic Beanstalk environment. You can immediately view the results by heading to your environment. If you use Ant to build your project, this task has the potential to be very helpful for deploying in one step as soon as your code is ready. For more in-depth documentation and example code, check out the README documentation on GitHub.
What’s the next AWS service you’d like to see with Ant integration? Is there an Ant task you’d like to contribute to the GitHub project?