0

I have a super wonderful task that populates a path id...

    <ivy:cachepath organisation="XXXX" module="ZZZZ" revision="0.2.4-SNAPSHOT" inline="true"  pathid="mypath"/>

Without writing complex Java code is there a way to convert "mypath" into something the ant task could accept? I'd really like to specifically delete these cache files (I"m working around a bug in Ivy that it doesn't actually re-fetch snaphots).

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
user959690
  • 602
  • 9
  • 16
  • YOu can ignore the ivy part. Its not really very important to the discussion other than it provides a pathid. I just want to delete the files that are populated in "mypath" – user959690 Jul 16 '13 at 19:35
  • I don't mean to be insensitive, but if you want to delete the content of an ANT path... Why not just use an alternative empty path. Need to check, but I think the contents of the path are immutable in ANT. – Mark O'Connor Jul 16 '13 at 20:33

2 Answers2

1

This worked for me:

<path id="test">
    <pathelement path="${basedir}/foo"/>
    <pathelement path="${basedir}/bar"/>
</path>
<delete>
    <path refid="test"/>
</delete>

I didn't use <ivy:cachepath/>, but I did create a Path ID and was able to delete the individual elements using the Path as an refid.

David W.
  • 105,218
  • 39
  • 216
  • 337
0

Don't understand what you're trying to do. Most ANT tasks accept classpath references, which is what the ivy cachpath task creates. Secondly deleting files from the ivy cache seems suspect... Sort of defeats the purpose of using ivy :-)

But you asked, so I'd recommend using an ivy retrieve instead as follows:

  <ivy:retrieve pattern="${build.dir}/lib/[artifact](-[classifier]).[ext]">
     <dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="default"/>
     <dependency org="org.slf4j" name="slf4j-simple" rev="1.7.5" conf="default"/>
  </ivy:retrieve>

  <path id="mypath">
     <fileset dir="${build.dir}/lib" includes="*.jar"/>
  </path>

Note:

  • Nested dependency declarations requires ivy > 2.3.0

Update 1

I suspect your ivy "bug" fetching snapshots is actually an issue with your ivy settings file. Only ibilio resolvers understand Maven's internal mechanism for tracking snapshots. For more information read about the "m2compatible" and "useMavenMeta" options.

Update 2

Are you publishing snapshots from ivy into a Maven repository like Nexus?

Yeah... That's a known issue. Possible work-arounds to consider are here:

My advise would be to avoid snapshot releases unless you need to work with Maven projects. ivy has a wonderful buildnumber task that makes generating unique builds a snap. Opinions differ.

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • I don't want to retrieve I want to delete. How can I delete everything listed in "mypath"? – user959690 Jul 16 '13 at 19:24
  • Part of the problem is that my question was "edited". My original question was now to pass the "mypath" into – user959690 Jul 16 '13 at 19:34
  • Post-processing the path is very complicated. First use a pathconvert to turn the path into a property, then use a javascript (or another 3rd party task like groovy) to split the property up and rebuild a new path.... As I stated in my update I highly suspect your underlying root cause has a much much simpler solution. – Mark O'Connor Jul 16 '13 at 19:45
  • @user959690 The edit did not change the question. I simply added an ivy tag. – Mark O'Connor Jul 16 '13 at 19:52
  • is what we use but Ivy doesn't update as we push new changes to the Nexus server. – user959690 Jul 16 '13 at 20:07