You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Thomas Scheffler <th...@uni-jena.de> on 2010/09/06 12:20:02 UTC

import of build-dependencies.xml

Hi,

I'm currently stuck with maven integration in ANT. I want to use maven 
dependency management in Ant to resolve dependencies.

With the latest version of maven-ant-tasks (2.1.1) I am still not 
successful. My main problem is that I cannot import the generated 
build-dependencies.xml and if it doesnt exists run artifact:dependencies.

Here is a small part of my build.xml


<import file="${build}/build-dependencies.xml" optional="true" />
<condition property="build-dependencies.present">
   <available file="${build}/build-dependencies.xml" />
</condition>

<target name="init-mvn-dependencies"
         unless="build-dependencies.present">
   <path id="maven-ant-tasks.classpath"
         path="lib/maven-ant-tasks-2.1.1.jar"/>
   <typedef
      resource="org/apache/maven/artifact/ant/antlib.xml"
      uri="antlib:org.apache.maven.artifact.ant"
      classpathref="maven-ant-tasks.classpath"/>
   <artifact:pom id="application.pom" file="${basedir}/config/pom.xml"/>
   <artifact:dependencies
      pathId="application.jars"
      filesetId="dependency.fileset"
      pomRefId="application.pom"
      cacheDependencyRefs="true"
      versionsId="dependency.versions"
      dependencyRefsBuildFile="${build}/build-dependencies.xml"/>
</target>

<target name="init-dependencies"
           if="build-dependencies.present"
           depends="maven-dependencies.init-dependencies" />

<target name="mvn-init"
         unless="application.jars"
         depends="init-dependencies,init-mvn-dependencies">
   <echo>dependencyRefsBuildFile: ${build}/build-dependencies.xml</echo>
   <property resource="config/application.properties"
             classpathref="application.jars"/>

[...]

some targets depend on "mvn-init" and thus on "init-dependencies" or 
"init-mvn-dependencies" (depending on the property 
"build-dependencies.present"). The problem is that when the property is 
not set the targets ("init-dependencies") dependencies 
("maven-dependencies.init-dependencies" - declared in 
${build}/build-dependencies.xml) must be present. The "if" attribute is 
evaluated after the dependencies are resolved.

How can I import a ant build file and run it's default target, getting 
all properties declared in it or run "init-mvn-dependencies" if the 
imported file does not exists?

As my build file is imported by several submodules I cannot use the 
maven-ant-task integrated cache mechanism. It will result in 
ClassCastException after the second run of artifact:dependencies in a row.

I'm using Ant 1.8.1

regards

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import of build-dependencies.xml

Posted by David Weintraub <qa...@gmail.com>.
2010/9/6 Thomas Scheffler <th...@uni-jena.de>:
> Hi,
>
> I'm currently stuck with maven integration in ANT. I want to use maven
> dependency management in Ant to resolve dependencies.

Have you looked at Ivy? It does exactly what you want to do (use Maven
dependencies in Ant), and it is much easier to use than trying to use
the Ant <maven> tasks to do what you want.

Ivy is an addition to Ant that handles dependencies much like Maven
does, and even uses Maven's repositories. And, Ivy is very easy to use
and integrate into existing Ant build.xml scripts.

-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org