mavenantmaven-ant-tasks

Can't use property in ant buildfile from referenced pom


(I hope I phrased the title correctly!)

I have an ant buildfile which is referencing a maven pom like so:

 <artifact:dependencies filesetId="dependency.fileset" useScope="compile">
    <pom file="pom.xml"/>
 </artifact:dependencies>

 <copy todir="${jar.location}">
    <fileset refid="dependency.fileset" />
    <mapper type="flatten" />
 </copy>

In pom.xml, some of the dependencies use a property in place of a hard-coded version number. But the copy task doesn't seem to resolve that property - it's trying to use "jarname-{app.version}" literally. I tried setting the value for "app.version" somewhere in the buildfile, to no effect. What am I doing wrong??

Thanks for any input!


Solution

  • As stated on the maven site, you should use artifact:pom to get that info:

    <artifact:pom id="mypom" file="pom.xml" />
    
    <artifact:dependencies filesetId="dependency.fileset" useScope="compile" pomRefId="mypom" />
    

    If you have profiles to process:

    <artifact:pom id="maven.project" file="pom.xml">
      <profile id="my-profile"/>
    </artifact:pom>