Ant problem with condition and import

I'm running into a problem with Ant using condition & import. I'm wondering if this should work in IDEA and I'm doing something wrong or if I've found a known issue...

This is at the start of my project's Ant build.xml

<condition property="import.path" value="../another_dir" else="">
        <not><isset property="ci"/></not>
<import file="${import.path}/build.xml"/>


When I try this in IDEA7, I get the error '${import.path} does not exist'
As a workaround, I can define import.path as an Ant property in IDEA and fix the problem.

Is IDEA7 supposed to understand condition?
IDEA9 appears to, although running imported targets fails for some reason
I do not have IDEA8 to try it there


1 comment
Comment actions Permalink

Earlier versions of IDEA's ant support did not recognize properties that were set in tasks other than the 'property' task. It was more of a limitation than a bug. This is what you are running in to. IDEA 8 had some nice improvements to the ant support. One of them was to eliminate the limitation you are seeing. You are seeing that improvement in the IDEA 9 EAP you tried.

Back when I was using IDEA 7, I used a similar workaround as you mention. I'd put in a target (which I named "placeholders" or "properties-listing") that was never actually called. In it I simply added <property> definitions for properties defined in tasks other than the property task to eliminate the IDE's error highlighting. A horrible hack since code should never be put into an application to work around development tool issues; but sometimes you gotta do what you gotta do. As you have seen, this issue has been improved in later versions of IDEA.

As for your comment on IDEA 9 having problems with imported targets, I just ran in IDEA 9 (EAP #10322) a complex build we have that makes extensive use of imported build files and targets. It ran without issue. So I'm not sure what the problem you had might be.


Please sign in to leave a comment.