I have a really long class path using a <path />
section. On a different machine, lots of the jars dont exist. How can I check the pathelements all exist?
Asked
Active
Viewed 523 times
0

Hugh Perkins
- 7,975
- 7
- 63
- 71
-
Have you considered using ivy to manage your dependencies? That way your build has a record of what it depends on and the jars get pulled down (from Nexus?) and cached by each build machine. Dependency management is a Maven feature that can be built into your ANT build. You'll never look back! – Mark O'Connor Oct 11 '12 at 21:39
-
Considering I'm behind a really slow firewall (ie, the one around China), downloading single-threaded is stupidly slow. I need to use a download accelerator like 'axel' to download things at a reasonable speed. Also, I'd like to only have to download each file across the filewall only once. So, no, maven's not really an option ;-) – Hugh Perkins Oct 12 '12 at 00:21
-
Maven and/or Ivy mirrors are the typical solution to your problem. – Patrice M. Oct 12 '12 at 00:47
-
Use a Maven repository manager like Nexus to cache artifacts on the other side of the firewall. Files not available from Maven repositories can be uploaded and stored in the Nexus managed repository. Finally the ivy plugin for ANT understands Maven repositories which means this solution works for all Java build technologies – Mark O'Connor Oct 12 '12 at 00:53
-
Well, ok, it's not just about the firewall, I also have a crazy slow network connection to a geographically local server, so any copying between the server and me would also need a download accelerator. – Hugh Perkins Oct 13 '12 at 02:47
1 Answers
2
Use the present selector :
<project>
<fileset dir="/home/rosebud/temp/dir1" includes="*.jar" id="srcfileset">
<present present="srconly" targetdir="/home/rosebud/temp/dir2"/>
</fileset>
<echo>Missing files => ${toString:srcfileset}</echo>
</project>
echoes all files only present in /home/rosebud/temp/dir1
If all files from /home/rosebud/temp/dir1 would be present in /home/rosebud/temp/dir2, the fileset would be empty.
If you need to finish your build in case of missing files use :
<project>
<fileset dir="/home/rosebud/temp/dir1" includes="*.jar" id="srcfileset">
<present present="srconly" targetdir="/home/rosebud/temp/dir2"/>
</fileset>
<fail message="Missing files => ${toString:srcfileset}">
<condition>
<resourcecount refid="srcfileset" when="greater" count="0" />
</condition>
</fail>
</project>

Rebse
- 10,307
- 2
- 38
- 66
-
This will show me the discrepancy between two directories. I can get this already using rsync. But my jars are in diverse directories, and the directories are pretty full, so mirroring the directories is not a solution. Before anyone says, putting all the jars into a single directory is also not the solution I'm looking for ;-) – Hugh Perkins Oct 12 '12 at 04:45
-
If using a similar directorystructure in all those directories it should work when adjusting the includes attribute of fileset !? – Rebse Oct 12 '12 at 12:33
-
Basically I need something that works like this: for( jarpath : classpathrefid ) { if( !new File(jarpath).exists ) { throw new RuntimeException(); } . (Only, in ant xml of course). – Hugh Perkins Oct 13 '12 at 02:46