[fedora-java] aether-ant-tasks and XMvn

Mikolaj Izdebski mizdebsk at redhat.com
Wed Sep 11 17:41:57 UTC 2013


Aether Ant Tasks in Fedora are now able to resolve artifacts from system
repository using XMvn.  This makes it easier to maintain packages built
with Ant without the need to use build-classpath or build-jar-repository.

A big advantage of Aether Ant Tasks is that they support transitive
dependencies.  This means that if package is using Aether Ant Tasks to
build then it doesn't need to be updated when a transitive dependency is
added or removed.

Let me follow with self explanatory example:

$ cat build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:aether="antlib:org.eclipse.aether.ant" default="test">

  <taskdef uri="antlib:org.eclipse.aether.ant"
           resource="org/eclipse/aether/ant/antlib.xml"/>

  <aether:dependencies id="my-dep">
    <dependency groupid="junit" artifactid="junit" version="SYSTEM"/>
  </aether:dependencies>

  <target name="test">
    <aether:resolve dependenciesref="my-dep">
      <path refid="cp" classpath="compile"/>
    </aether:resolve>

    <!-- Display what's the resulting classpath -->
    <property name="mycp" refid="cp"/>
    <echo message="${mycp}"/>
  </target>
</project>


$ ant -Dxmvn.ant.enable=true
Buildfile: /build.xml

test:
[aether:resolve] Resolving artifacts
     [echo] /usr/share/java/junit.jar:/usr/share/java/hamcrest/core.jar

As we can see project dependency with all *transitive dependencies* was
resolved correctly by Ant.  I had to do two things: add <taskdef>
defining Aether tasks (basically a single line of boilerplate) and set
property "xmvn.ant.enable" (this property is needed only for now as this
feature is still experimental).

Because XMvn requires Maven, "local mode" of aether-ant-tasks will work
only if maven-local is installed.  This can be changed in future, but
would require additional work, which I'd rather avoid unless people find
this feature useful and start using it.

Let me know if you have any comments.

--
Mikolaj Izdebski
IRC: mizdebsk


More information about the java-devel mailing list