Thanks Jan. I have another requirement for checking two property values. My solution doesn't work well for this requirement. The scriptselector solution below can easily be extended to check two or more properties.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, June 16, 2005 1:07 AM To: user@ant.apache.org Subject: AW: Subant - selecting projects to build Using a selector would be the finest, as you said. The problem is that all selectors check the given file. But your selector has to inspect a different one: - you want to select the module build.xml - you have to check the content of the module build.property Therefore you have to write your own selector. With 1.7 this is much more easier because you could script that. So the code would something like <subant ..> <fileset ...> <include name="*/build.xml"/> <scriptselector language="javascript"> dir = file.getParent(); nameWithoutSuffix = filename.substring(0, filename.lastIndexOf('.')); propName = nameWithoutSuffix + ".properties"; propFile = new java.io.File(dir, propName); propHasHost = ... self.setSelected(propHasHost); </scriptselector> </fileset> </subant> For the check for the text content you could reuse the contains selector, as you already had. Instantiate and check ... selector = new ContainsSelector(); selector.setText("deployhost=" + project.getProperty("host") ); propHasHost = selector.isSelected(dir, propName, propFile); ... Just my ideas as pseudo code ... If you´ll get it to work, let us know. Jan >-----Ursprüngliche Nachricht----- >Von: Dick, Brian E. [mailto:[EMAIL PROTECTED] >Gesendet: Mittwoch, 15. Juni 2005 18:03 >An: Ant Users List >Betreff: Subant - selecting projects to build > >I have my project directory structured similar to the last example in >the subant doc. I have a root directory with a common build file and >module directories with a simple build file that imports the common >build file. Currently, my project consists of 50+ modules. > >I deploy these modules across 10+ host machines. Each module resides on >only one host, but a host has many modules. I have a "deployhost" >property in the module build.properties file that specifies >the host for >deployment. When I want to deploy a particular module to its designated >host, I simply run "ant deploy" from the module directory and >the module >"knows" where to go. > >I implemented project-wide targets in the root build.xml file by >following the subant example. Each project-wide target iterates through >module directories and runs the appropriate target. I can deploy all >modules to their respective hosts by running "ant deploy" from the root >directory. > >Now, I want to do something a bit more complicated. I want to >deploy all >modules for a particular host. I have tried several combinations of >subant, fileset and selectors but I can't get what I want. I had to >resort to the <for> task from ant-contrib. Can anyone come up a better >solution than the following? > > <target name="deploy_by_host" description="Deploy projects by host"> > <for param="module"> > <fileset dir="modules"> > <include name="**/build.properties"/> > <contains text="deployhost=${host}"/> > </fileset> > > <sequential> > <property name="module.antfile" >location="@{module}/../build.xml"/> > <ant antfile="${module.dir}" target="deploy" >inheritAll="false"/> > <var name="module.antfile" unset="true"/> > </sequential> > </for> > </target> > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]