Ant: How do I set a properties from a comma-separated list passed in on command line?

前端 未结 2 1760
北荒
北荒 2021-01-11 14:44

I\'m using Ant 1.8.1. If I passed in an argument on the command line ...

-DenableProperties=abc,def,ghi,jkl

How do I set individual proper

2条回答
  •  一整个雨季
    2021-01-11 15:18

    How to decide when an item of your property $enableproperties is to be set to false or true ?
    Some criteria missin..
    From my understanding of your question you might try something like that, my solution is based on Ant plugin Flaka

    starting with ant -f demo.xml -Denableproperties=abc#t,def#t,ghi,jkl#t,mno
    means all items in the list that should be set to true in your script have to be propertyname#t
    others will be set to false

    
    
        
          #{split(p, '#')[0]} := #{split(p, '#')[1] == 't' ? 'true' : 'false'}
        
    
        
    $${abc} = ${abc}
    $${def} = ${def}
    $${ghi} = ${ghi}
    $${jkl} = ${jkl}
    $${mno} = ${mno}
        
    
    
    

    output

     [echo] ${abc} = true
     [echo] ${def} = true
     [echo] ${ghi} = false
     [echo] ${jkl} = true
     [echo] ${mno} = false
    

    Disclosure = i'm participating as committer in the Flaka project

提交回复
热议问题