What does the Ant warning "Reference * has not been set at runtime..." mean?
Since the upgrade from Ant 1.6.5 to 1.7.1, my build output starts off with:
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.
I have problems understanding this and why it is outputted, let alone trying to get rid of it. Any help would be appreciated!
EDIT:
Classpath is defined:
<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" />
It is referenced (e.g. in ) in this way:
<classpath refid="project.classpath"/>
I had the same issue before. Just make sure the "project.classpath" is defined in the beginning of the build file before other targets reference it. Also your "libs.ant" path should be defined before "project.classpath".
In Ant 1.8 this will actually be error instead of warning.
You can set classpath in the build file as following, to get rid of this warning. See reference. 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>
Unless this is a typo, it looks like trouble. You really should rename one for clarity even if it isn't the cause of the warning. It still sounds like project.classpath is defined in different targets and they are called in the wrong order. You may need to show more code for more help.
<property name="project.classpath" refid="project.classpath" />
精彩评论