Custom target parameters. Using closures or grobal def.

By neokrates, written on June 2, 2010

gant   snippet

Rate it
  • 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
Ad
Poll
  • Your skill as shell programmer is?

    • No skill (35%, 7 Votes)
    • FreeTime coder (acceptable) (25%, 5 Votes)
    • Developer (good) (15%, 3 Votes)
    • Novice (15%, 3 Votes)
    • Admin (very good) (10%, 2 Votes)
    • Guru (perfect) (0%, 0 Votes)

    Total Voters: 20

    Vote

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext
Most popular search terms:

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 ()
}
 
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
    nope :(
SOCIAL
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BlinkList
  • Blogosphere News
  • E-mail this story to a friend!
  • Furl
  • LinkArena
  • Live
  • MisterWong
  • Print this article!
  • StumbleUpon
  • Technorati
  • Webnews.de
  • YahooMyWeb

Leave a Reply