ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: suggestion : Ant 1.8 full dist to include a 'scripting lang'
Date Thu, 21 Sep 2006 23:51:21 GMT
Kevin Jackson wrote:
> On 9/16/06, Jesse Glick <jesse.glick@sun.com> wrote:
>>[...]
> (I'd steer away from groovy before anyone suggests it ;))

Kevin, anything in particular you don't like about Groovy?

In my experience it is an excellent scripting language and
has excellent Ant support but as coauthor of the upcoming
Groovy in Action book I guess I am a little biased. :-)

Ant integration with Groovy crops up many times throughout
the book. Here is just one example (using Groovy in a
traditional build file - as distinct from using a Groovy
file as the build file - which would just involve leaving
off the outer tags in this example):

<groovy>
def scanner = ant.fileScanner {
    fileset(dir: properties['src.dir']) { 
        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.size() > maxSize) maxSize = file.size() 
    totalSize += file.size() 
} 
if (nameCheck || totalSize / fileCount > 50 ||
        maxSize > 100 || fileCount > 10)
    properties.shouldCompress = true
</groovy>

This just sets a property ready for a subsequent
'if' or 'unless' attribute based on some conditions
which would be rather hard to set up declaratively.


Cheers, Paul.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message