DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20093>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20093 Cannot add condition under <project> scope Summary: Cannot add condition under <project> scope Product: Ant Version: 1.5.3 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Core AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Conceptually, I think you should be able to use <condition> task at the <project> scope the same as you can use <property> type. In this case, it seems very arbitary as to what considered a task and what is considered a type. It appears to be an artifact of the design. Look at the <selector> type which is allowed to be at the <project> scope. It does a similar thing as <condition> except for files instead of properties. Please consider making <condition> a core type rather than a task. I wanted to set some properties conditionally, and then load a property file "properties/project.txt" which sets more properties based on the ${BUILD_DIR} property. Since <condition> is a task, I cannot put it directly under the <project> but instead I have to put it inside a task. So, I created an "init" target and inside there I can add the <conditions> and then load the properties and then all my other tasks can depend on "init" target. This works fine except that I also need to initialize some filesets which use those properties for use in several targets. I used to have these filesets defined directly under <project> tag and then they were available using refid="filesetname". However, now that I set the properties in "init" task, I have to define the filesets later. When I define the filesets in the "init" task, I found that the refids were not valid in the targets, e.g. "compile" that depended on "init". The only workaround I have found is to redefine the filesets in each target "compile", "install", etc. but that is really ugly. <?xml version="1.0"?> <project name="sample" default="compile" > <property file="${basedir}/properties/local_unix.txt"/> <property file="${basedir}/properties/local_windows.txt"/> <condition name="BUILD_DIR" value="${UNIX_BUILD_DIR}"> <os name="unix"/> </condition> <condition name="BUILD_DIR" value="${WINDOWS_BUILD_DIR}"> <os name="windows"/> </condition> <property file="${basedir}/properties/build.txt"/> <path id="classpath"> .... </path> ------------ATTEMPTED WORKAROUND. PROBLEM WITH "classpath"----------- <?xml version="1.0"?> <project name="sample" default="compile" > <property file="${basedir}/properties/local_unix.txt"/> <property file="${basedir}/properties/local_windows.txt"/> <target name="init"> <condition name="BUILD_DIR" value="${UNIX_BUILD_DIR}"> <os name="unix"/> </condition> <condition name="BUILD_DIR" value="${WINDOWS_BUILD_DIR}"> <os name="windows"/> </condition> <property file="${basedir}/properties/build.txt"/> <!-- This doesn't work. Cannot refer to "classpath" in compile target --> <path id="classpath"> .... </path> </target> <target name="compile" depends="init" > ....