Ant classpath Order

孤街浪徒 提交于 2019-11-30 04:48:09

问题


How do I set the classpath order in ant?

Specifically, When I am trying to run my ant build, I need it to pick up a class in a jar (jaxws-api.jar) instead of the same class which is in the jre. I am currently setting the classpath to explicitly include those jars however it seems to still pick up the jre first. What I am looking for is some type of equivalent to Order/Export in eclipse under the "Build Configuration" menu.

Edit: I'll be more explicit. I have some classes which were generated with CXF 2.1.3. They call javax.xml.ws.Service#getPort(QName, Class, WebServiceFeature...). I am using Java version 1.6.02. This method does not exist in that class in that version. However, it does exist in the jaxws version of the class (and later versions of the JRE class). When I try to do an ant build, the JRE class is always picked up first before the jaxws version. This makes my compilation fail. How can I modify my classpath to put the JRE last?

I can't change the JRE version, so please don't suggest that as a fix unless it is the only possible one.


回答1:


Looks like you need to use the bootclasspath setting in the Javac or Java Ant task.

You can always do ant -v to get verbose output of your Ant build.




回答2:


Jars in the ant classpath are placed in the order you declare them.




回答3:


I had the same problem with Google web toolkit and a servlet 3.0 API file. I needed to make sure my servlet API jar was before the GWT library jars. Here is something that worked:

<path id="classpath">
        <filelist>
            <file name="${build.input}/__lib__/servlet-api.jar"/>
        </filelist>
        <fileset dir="${build.input}/__lib__">
            <include name="*.jar" />
        </fileset>
        <fileset dir="${build.input}/WEB-INF/lib">
            <include name="*.jar" />
        </fileset>
    </path>

Note the jar that needs to be first is listed first in a filelist, then I can add jars from other directories. I tried the bootclasspath in the accepted answer and it did not work.



来源:https://stackoverflow.com/questions/939757/ant-classpath-order

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