Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant copy classpath jars to a directory

I'm sure this has either been asked before or is pretty straightforward. But for whatever reason, I cannot seem to make it work. I want to use ant to copy the ${build.classpath} (which contains a colon separated list of jars) to the ${output.dir}/myapp/WEB-INF/lib.

I have this right now and it doesn't seem to work:

<copy toDir="${output.dir}/myapp/WEB-INF/lib">
  <fileset file="${build.classpath}" />
</copy>

It treats the whole classpath as one file. How do I get this to work?

like image 515
Mohamed Nuur Avatar asked Dec 09 '10 03:12

Mohamed Nuur


2 Answers

The Ant Manual on the copy task contains the answer for your problem. One of the example snippets it provides:

Collect all items from the current CLASSPATH setting into a destination directory, flattening the directory structure.

<copy todir="dest" flatten="true">
  <path>
    <pathelement path="${java.class.path}"/>
  </path>
</copy>
like image 131
user268396 Avatar answered Sep 20 '22 23:09

user268396


I think somethink like this should work:

<copy todir="${output.dir}/myapp/WEB-INF/lib" verbose="yes" flatten="yes" failonerror="no">    
   <fileset dir="${build.classpath}">    
      <include name="*.jar" />    
   </fileset>    
</copy>

or with wildcard in include: <include name="**/*.jar" />

like image 36
Krzysztof Miksa Avatar answered Sep 17 '22 23:09

Krzysztof Miksa