The below was added to one of my <target>
tags to have all the javascript files in a single directory compressed. These files retain their original name. To do this for CSS simply switch the 'js' to 'css' and update the paths accordingly.
This was done with YUI Compressor 2.4.7 and I run the Ant build script it in Eclipse Juno without any changes to class paths or other modifications of settings.
<!-- Minimizing Javascript files -->
<echo message="Compressing Javascript files at location: ${build.root}/resources/js/*.js" />
<java jar="c:/dev/lib/yuicompressor-2.4.7/build/yuicompressor.jar" fork="true">
<arg value="${build.root}/resources/js/*.js" /> <!-- input path for JS files -->
<!--<arg value="-v" /> --><!-- Turn on verbose -->
<arg value="-o" />
<arg value="'.js$:.js'" />
<arg value="${build.root}/resources/js/*.js" /> <!-- output path for JS files -->
<classpath>
<pathelement location="c:/dev/lib/yuicompressor-2.4.7/build/yuicompressor.jar"/>
</classpath>
</java>
Please feel free to improve this answer. The solution above works for me, but I'm no expert.