Exclude jar from ant classpath

旧街凉风 提交于 2019-12-31 03:28:05

问题


I'm trying to make a "clean maven" setup on some legacy project that uses ant scripts. I don't know much about ant, so my question might seem naive.

I'm almost done, but the delivery ant script is failing, due to a redundancy in the classpath. If I understand the build, those lines should add to the classpath every lib in the "provided" scope :

<artifact:dependencies pathid="dependency.classpath" scopes="provided">
    <pom file="./pom.xml"/>
</artifact:dependencies>

And then this one :

<path id="completecp">
    <fileset dir="${ant.home}/lib">
        <include name="*.jar" />
    </fileset>
    <path refid="dependency.classpath" />
</path>

Add those dependencies to the libs in the ant.home directory.

The trouble is, I'm using a maven pom that is dependent on a parent pom that I can't modify, and as a result, there are THREE different versions of Ant in my classpath : two from the POM (1.5 et 1.7.1) and one from Eclipse (1.8.2). I've tried (desperately !) addind some maven exclusions, but failed miserably.

So I thought : maybe there is a way of excluding jars from the Ant classpath. I've tried putting :

<exclude name="*ant\1.7.1\ant-1.7.1.jar"/>
<exclude name="*ant\1.5\ant-1.5.jar"/>

in the fileset part, but it doesn't work. Is there a way of excluding those redundant jar ?


回答1:


Try this way:-

<exclude name="**/ant/1.7.1/ant-1.7.1.jar"/>
<exclude name="**/ant/1.5/ant-1.5.jar"/> 



回答2:


Try using forward slash instead of back slash, i.e.

<exclude name="*ant/1.7.1/ant-1.7.1.jar"/>



来源:https://stackoverflow.com/questions/10205592/exclude-jar-from-ant-classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!