Much ado about scripting, Linux & Eclipse: card subject to change


Using EasyAnt with Ivy to fetch latest compile-time and run-time dependencies

Just started playing with Ivy and EasyAnt today.

Here's a quick guide to getting started with multi-module Ant builds (because the EasyAnt Examples documentation is incomplete). This also demonstrates Ivy's ability to pull the latest version of a dependency from a repository. (And I get to finally try out Alex Gorbatchev's SyntaxHighlighter.)

1. Download:

wget -O /tmp/

2. Install as root, usable by all:

sudo su; 
unzip /tmp/ -d /opt/easyant-0.5-beta1; \
cd /opt/easyant-0.5-beta1; \
mkdir modules repository cache; \
chmod -R g+rw *; chgrp -R users *; \

3. Compile multi-module example's core jar:

export EASYANT_HOME=/opt/easyant-0.5-beta1; \
cd /opt/easyant-0.5-beta1/example/example-multimodule/example-core; \
$EASYANT_HOME/bin/easyant -p; \

4. Verify compiled jar:

unzip -l /opt/easyant-0.5-beta1/example/example-multimodule/example-core/target/artifacts/example-core.jar

5. Publish jar:

$EASYANT_HOME/bin/easyant repo-management:install-artifact -Dorg=org.apache.easyant \
  -Dmodule=example-core -Drev=0.1 -Dartifact=target/artifacts/example-core.jar \
  -Dinstall.override=true -Dto.resolver=local

6. Verify published:

unzip -l /opt/easyant-0.5-beta1/repository/org.apache.easyant/example-core/0.1/example-core.jar; \
cat /opt/easyant-0.5-beta1/repository/org.apache.easyant/example-core/0.1/example-core.ivy
<ivy-module version="1.0">
    <info organisation="org.apache.easyant" module="example-core" revision="0.1"/>

7. Compile multi-module example's Hello World jar:

cd /opt/easyant-0.5-beta1/example/example-multimodule/example-hello-world; $EASYANT_HOME/bin/easyant

8. Verify compiled jar:

unzip -l /opt/easyant-0.5-beta1/example/example-multimodule/example-hello-world/target/artifacts/example-hello-world.jar

8. Run Hello World app:

cd /opt/easyant-0.5-beta1/example/example-multimodule/example-hello-world; $EASYANT_HOME/bin/easyant run:run
     [java] Hello World !

Total time: 2 seconds

9. Now, recompile the core jar, republish it as 0.2, then recompile the Hello World jar. Verify that the Hello World compilation used the newer 0.2 version instead.

cd /opt/easyant-0.5-beta1/example/example-multimodule/example-core; $EASYANT_HOME/bin/easyant; \
$EASYANT_HOME/bin/easyant repo-management:install-artifact -Dorg=org.apache.easyant \
  -Dmodule=example-core -Drev=0.2 -Dartifact=target/artifacts/example-core.jar \
  -Dinstall.override=true -Dto.resolver=local; unzip -l \
/opt/easyant-0.5-beta1/repository/org.apache.easyant/example-core/0.2/example-core.jar; \
cat /opt/easyant-0.5-beta1/repository/org.apache.easyant/example-core/0.2/example-core.ivy; \
cd /opt/easyant-0.5-beta1/example/example-multimodule/example-hello-world; \
$EASYANT_HOME/bin/easyant; $EASYANT_HOME/bin/easyant run:run
:: loading settings :: file = /opt/easyant-0.5-beta1/ivysettings.xml
[ivy:resolve] :: resolving dependencies :: org.apache.easyant#example-hello-world;working@x2lappy
[ivy:resolve]  confs: [default, test]
[ivy:resolve]  found org.apache.easyant#example-core;0.2 in local
[ivy:resolve]  [0.2] org.apache.easyant#example-core;latest.revision
[ivy:resolve] :: resolution report :: resolve 30ms :: artifacts dl 1ms


Jean-Louis said...

Hi Nick,

We've just released easyant 0.6 with a lot of improvements on multi module support.

We also wrote a short tutorial to document this feature

Hope this will help you to understand how easyant works.

Jean Louis Boudart