Roland Tepp
Roland Tepp

Reputation: 8511

Why does Eclipse ant editor warn me

I am having some trouble (annoyance really) with ANT editor in Eclipse where it is displaying me a warning "Reference build.classpath not found." on the following block:

<target name="generate" depends="..., mvn-depends">
    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
        <classpath refid="build.classpath" />
    </taskdef>
    ...
</target>

With mvn-depends target looking like this:

<target name="mvn-depends">
    <artifact:dependencies pathId="build.classpath">
        <pom refid="my.pom" />
    </artifact:dependencies>
</target>

The rest of the references to build.classpath in the build file are not throwing any warnings and the and build runs just fine without any errors, so it does not seem to be amounting to much.

Still, ignoring a warning makes me feel sort of dirty every time I have to edit that file. Specifically, not knowing if this is a bug in Eclipse ant build file validation code or a potential problem in the way the build file has been structured, that Eclipse has identified.

If anyone has any ideas on why this warning is being shown and whether it is safe to ignore or maybe even disable from preferences and would care to share that knowledge, I would definitely be grateful for the knowledge.

Edit:

As requested, here is an example of a reference to build.classpath that does not cause any warnings:

<javac deprecation="off" debug="on" source="1.7" target="1.7" encoding="UTF-8"
       includeantruntime="false" memoryMaximumSize="512M" fork="true">
    <classpath refid="build.classpath" />
</javac>

Upvotes: 4

Views: 865

Answers (2)

Dante WWWW
Dante WWWW

Reputation: 2739

As the editor could recognize refids and other elements that Ant specifies, I guess that the editor does something similar to Ant's build file parsing process.

That is, parse this ant build file into a Project object, and references in <taskdef> may be checked, while <javac> may not.

Since the build.classpath is set during runtime and it is set by something other than things like <classpath>, Eclipse may not find it.

I don't have strong prove about this. But something can be done to make us know more.

  • First, copy the <javac> to the same target where the warned <taskdef> exists, to see if the <javac> gets a warning;

  • Then, copy the <taskdef> to the same target where the presetdefed <javac> exists, to see if the <taskdef> still gets a warning;

  • Third, in target "generate", comment out the <taskdef> part, and check if the <xjc ... /> call gets a warning.

For the first one, I expect "NO", while for the other two, I expect "YES". Otherwise, my guess is wrong.

And it makes sense that it is just a warning -- things Eclipse can't find in editing time could exist during runtime.

Upvotes: 1

Java-Seekar
Java-Seekar

Reputation: 1770

Make sure you have given the path element location correctly as bellow.

<property name="dependencyfinder.home" value="C:/DependencyFinder"/>

<path id="dependencyfinder">
    <pathelement location="${dependencyfinder.home}/lib/aaa.jar"/> 
</path>


<taskdef classname="com.sun.tools.xjc.XJCTask">
    <classpath refid="dependencyfinder"/>
</taskdef>

Note: DependencyFinder has a folder lib and lib has aaa.jar

Please check the bellow link for more information
Click here

Upvotes: 0

Related Questions