开发者

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?


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>


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" />


I think you should put all your colon separated jar files to one root folder. If it is not possible then create a separate task that put those jar files into one folder(may be temporary). And assign ${build.classpath} to that folder. Use <fileset dir="${build.classpath}"/> in your copy clause.

I hope, it should help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜