什么Ant警告“引用*尚未在运行时设置......”是什么意思?

时间:2011-04-21 14:39:12

标签: ant

从Ant 1.6.5升级到1.7.1后,我的构建输出以:

开始
Warning: Reference project.classpath has not been set at runtime, but was found during
build file parsing, attempting to resolve. Future versions of Ant may support
 referencing ids defined in non-executed targets.
Warning: Reference project.test.classpath has not been set at runtime, but was found during
build file parsing, attempting to resolve. Future versions of Ant may support
 referencing ids defined in non-executed targets.

我在理解这个问题以及为什么要输出它时遇到了问题,更不用说试图摆脱它了。任何帮助将不胜感激!

编辑:

定义了类路径:

<path id="project.classpath">
        <pathelement path="./${build.dir}" />
        <path refid="libs.ant" />
        <fileset dir="${lib.dir}/dependencies/bar" includes="compile/*.jar" />
        <fileset dir="${lib.dir}/dependencies/foo" includes="provided/*.jar" />
</path>

<!-- The classpath for compiling this projects' tests -->
<path id="project.test.classpath">
        <path refid="project.classpath" />
        <fileset dir="${lib.dir}/dependencies/bar" includes="test/*.jar" />
        <fileset dir="${lib.dir}/dependencies/foo" includes="test/*.jar" />
</path>

<property name="project.classpath" refid="project.classpath" />

以这种方式引用(例如):

<classpath refid="project.classpath"/>

3 个答案:

答案 0 :(得分:3)

之前我遇到过同样的问题。只需确保在其他目标引用它之前在构建文件的开头定义“project.classpath”。您的“libs.ant”路径也应该在“project.classpath”之前定义。

在Ant 1.8中,这实际上是错误而不是警告。

答案 1 :(得分:0)

您可以在构建文件中设置classpath,如下所示,以消除此警告。见参考文献。 http://ant.apache.org/manual/using.html

<project ... >
  <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement path="${java.class.path}/"/>
    <pathelement path="${additional.path}"/>
  </path>

  <target ... >
    <rmic ...>
      <classpath refid="project.class.path"/>
    </rmic>
  </target>

  <target ... >
    <javac ...>
      <classpath refid="project.class.path"/>
    </javac>
  </target>
</project>

答案 2 :(得分:0)

除非这是一个错字,否则看起来很麻烦。为了清晰起见,你真的应该重命名,即使它不是警告的原因。它仍然听起来像project.classpath在不同的目标中定义,并以错误的顺序调用它们。您可能需要显示更多代码以获得更多帮助。

<property name="project.classpath" refid="project.classpath" />