In the last article I used maven to resolve dependencies for play modules. This article does the same, but uses ivy. I chose ivy, because it seems the best suited tool for play (also check the discussion on the mailing list). In order to understand it, it is not needed but easier to have read the maven based article before.
The main disadvantage of Maven (from the play perspective) is its core feature: Maven comes with a full life cycle package (testing, packaing) including dependencies, where as ivy's only right to exist is dependency resolution.
As I could not get ivy to work in standalone mode (the jar files were not copied into the lib directory), we will have to stick with using ivy as an addition to ant - this how it is supposed to be used anyway.
1. Create the build.xml file
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="play-module-foo" default="run">
<target name="retrieve" description="--> retrieve dependencies with ivy">
<ivy:retrieve />
</target>
</project>
The build file is also available here.
2. Create the ivy.xml file
Like in the maven file, it is important to exclude certain dependencies, which already ship with play and to include the dependencies. Before I do a lot of useless copy & paste, check the file here. If you take a closer look, you will also note, that I removed the javadoc and sources from the dependency resolution.
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="org.playground" module="play-module-foo" />
<dependencies defaultconf="*->*,!sources,!javadoc">
<dependency org="org.freemarker" name="freemarker" rev="2.3.16" />
<exclude module="activation" />
<exclude module="antlr" />
<exclude module="backport-util-concurrent" />
<exclude module="bcprov-jdk15" />
<exclude module="c3p0" />
<exclude module="cglib-nodep" />
<exclude module="commons-beanutils" />
<exclude module="commons-codec" />
<exclude module="commons-fileupload" />
<exclude module="commons-httpclient" />
<exclude module="commons-lang" />
<exclude module="commons-logging" />
<exclude module="core" />
<exclude module="dom4j" />
<exclude module="ehcache" />
<exclude module="ejb3-persistence" />
<exclude module="ezmorph" />
<exclude module="filters" />
<exclude module="geronimo-servlet_2.5_spec" />
<exclude module="groovy-all" />
<exclude module="gson" />
<exclude module="hibernate" />
<exclude module="hibernate-core" />
<exclude module="hibernate-commons-annotations" />
<exclude module="hibernate-entitymanager" />
<exclude module="hsqldb" />
<exclude module="jamon" />
<exclude module="jaxen" />
<exclude module="jsr107cache" />
<exclude module="jta" />
<exclude module="junit" />
<exclude module="log4j" />
<exclude module="lucene-analyzers" />
<exclude module="lucene-core" />
<exclude module="mail" />
<exclude module="oval"/>
<exclude module="snakeyaml" />
<exclude module="slf4j-api" />
<exclude module="slf4j-log4j12" />
</dependencies>
</ivy-module>
Go here for the ivy.xml file.
3. Run the ant task
ant -lib /usr/share/java/ivy.jar retrieve
This ant task automatically copies the files into the lib/ directory no config needed. You might need to adapt your ivy path. Varies per operating system.
That's it, you're done. Next step could be publishing, but I did not dig that far yet.