[EMAIL PROTECTED] wrote:
Hello,

Has the possibility of adding multiple conditions to the target 'if' and
'unless' attributes ever been considered? Are there any reasons why this
change would be a bad idea?

I have found Groovy (and to a lesser degree other scripting
languages) to be very useful for complex builds.
You can use Groovy from normal ant build files using the
<script> or external <groovy> tasks:

 http://groovy.codehaus.org/Groovy+Ant+Task

Or you can start from Groovy and use the ant builder syntax
to have full programming capabilities if you wish:

 http://groovy.codehaus.org/Ant+Scripting

As an example (not optimal) which combines both techniques:

 <groovy>
 def ant = new AntBuilder()
 def scanner = ant.fileScanner {
     fileset(dir:properties['basedir']) {
         include(name:"**/*.xml")
     }
 }
 def nameCheck = scanner.every{ file -> file.name.contains('build') }
 def totalSize = 0
 def fileCount = 0
 def maxSize = 0
 for(file in scanner){
     fileCount++
     if (file.length() > maxSize) maxSize = file.length()
     totalSize += file.length()
 }
 if (nameCheck || totalSize / fileCount > 50 ||
     maxSize > 100 || fileCount > 10) properties.put('shouldCompress', 'true')
 </groovy>

This sets up a property for subsequent use in an if or unless attribute
called 'shouldCompress' which is set based on the properties of xml
files in the directory in which the script is run. The property will
be set if every file in the selected fileset has the characters 'build'
in its name or if there are more than 10 files or if the average file
size is greater than 50 or if the maximum file size is more than 100.

This would be difficult trying to use alternative notations and
probably would be harder to understand. (Not that I am advocating
complex build logic just for the sake of it!)


Cheers, Paul.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to