让 Ant <javac> 识别类路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/722774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 18:43:26  来源:igfitidea点击:

Getting Ant <javac> to recognise a classpath

javaantclasspath

提问by Paul Fisher

I have an Apache Ant build file with a <javac>command that requires four specific JARs to be on the build classpath. I've tried to do this:

我有一个 Apache Ant 构建文件,其中的<javac>命令需要在构建中包含四个特定的 JAR classpath。我试过这样做:

<project basedir=".." default="build_to_jar" name="Transnet Spectrum Analyzer">
    <property environment="env"/>
    <property name="src" value="src"/>
    <property name="libsrc" value="library_sources" />
    <property name="build" value="build"/>
    <property name="dist" value="dist"/>
    <property name="target" value="1.5"/>
    <property name="libraries" value="./libraries"/>

    <fileset dir="." id="TSA.classpath">
        <include name="${libraries}/rxtx/RXTXcomm.jar" />
        <include name="${libraries}/commons-logging-1.1.1.jar" />
        <include name="${libsrc}/JCommon/jcommon-1.0.15.jar" />
        <include name="${libsrc}/JFreeChart/jfreechart-1.0.12.jar" />
    </fileset>

    <target name="compile" depends="clean,init" description="compile the source " >

        <echo>Compile from ${src} to ${build}</echo>

        <javac destdir="${build}" source="${target}" target="${target}">
            <compilerarg value="-Xlint:unchecked"/>
            <src path="${src}"/>
            <classpath path="TSA.classpath" />
        </javac>
    </target>

    <!-- blah blah blah -->
</project>

…but none of the files specified in TSA.classpathappear to show up. How do I include these files in my classpath?

...但 中指定的文件TSA.classpath似乎都没有出现。如何在我的类路径中包含这些文件?

采纳答案by William Brendel

Here's an example from a project I am currently working on. I suspect you can modify it to work for your situation.

这是我目前正在从事的项目中的一个示例。我怀疑您可以修改它以适合您的情况。

<path id="master-classpath">
  <fileset dir="${web.dir}/WEB-INF/lib">
    <include name="*.jar"/>
  </fileset>

  <fileset dir="${appserver.lib}">
    <include name="servlet*.jar"/>
  </fileset>

  <pathelement path="${build.dir}"/>
</path>

...

<javac destdir="${build.dir}">
  <src path="${src.dir}"/>
  <classpath refid="master-classpath"/>
</javac>

回答by TofuBeer

Try this:

尝试这个:

 <classpath refid="TSA.classpath"/>

回答by Joachim Sauer

Try

尝试

<javac ... classpathref="TSA.classpath">

or

或者

<javac ...>
    ...
    <classpath refid="TSA.classpath" />
</javac>