tags:

views:

62

answers:

1

I have several JAR file pattern sets, like

  <patternset id="common.jars">
 <include name="external/castor-1.1.jar" />
 <include name="external/commons-logging-1.2.6.jar" />
 <include name="external/itext-2.0.4.jar" />
     ...
  </patternset>

I also have a war task containing a lib element:

   <lib dir="${src.dir}/jars">
      <patternset refid="common.jars"/>
      <patternset refid="web.jars"/>
         ...
   </lib>

Like this however, I end up with a WEB-INF/lib containing the subdirectories from my patterns:

WEB-INF/lib/external/castor-1.1.jar
WEB-INF/lib/external/...

Is there any way to flatten this, so the JAR files appear top-level under WEB-INF/lib, regardless of the directories specified in the patterns? I looked at mapper but it seems you cannot use them inside lib.

A: 

You can try to use mappedresources element (Ant 1.8+)

<mappedresources>
    <!-- Fileset here -->
    <globmapper from="external/*.jar"
        to="*.jar"/>
</mappedresources>

http://ant.apache.org/manual/CoreTypes/resources.html#mappedresources

If you have a typical web project it is better to split the web-app libraries and general-purpose libraries in different folders and leave WEB-INF/lib to have only those needed at runtime. This way you'll avoid collisions and also your project will look much clearer to other developers.

Juriy