Java – how to perform ant path mapping in the ‘War’ task?

I have several jar file schema sets, such as

<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 that contains the Lib element:

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

However, in this way, the WEB-INF / lib I finally get contains the subdirectories in my schema:

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

Is there any way to flatten this, so the jar file appears at the top level under WEB-INF / lib, no matter what the directory specified in the pattern is? I looked at mapper, but it seems that you can't use them in lib

Solution

You can try using the mappedresources element (ant 1.8)

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

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

If you have a typical web project, it's best to split the web application library and general library into different folders, and make WEB-INF / lib contain only those needed at runtime In this way, you can avoid conflicts and your project will be clearer to other developers

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>