Custom target parameters. Using closures or grobal def.

By neokrates, written on June 2, 2010

gant   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 68 views
Rate it
Ad
Poll
  • Estimate your experience level with Virtualization technology?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

There seems to be some kind of problem with giving custom arguments to GAnt target.
There where an el way, closure like way and now there is a mention about single parameter which must be a map or so.
Anyways, here are two alternative ways to solve the problem.

👉 Use closures with parameters:

def sayMyName = { name ->
    println "Your name is $name "
}
 
target ( default: ''  ) {
    sayMyName ('Dimitri')
}

 

⚠ Remark. Closures are no targets, they are treated differently. There are interaction issues between closures and ant target. I see it as a risk factor.

👉 Define global variables:

def name = ''
target ( sayMyName : 'Will say the name' ) {
  println "Your name is $name "
}
 
 
target ( default: ''  ) {
  name = 'Dimitri'
  sayMyName ()
}
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: 0 (from 0 votes)
0 votes 'YES'  0 votes 'NO'
TAGS
No tags for this post.
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply