Ant string functions?

前端 未结 2 387
礼貌的吻别
礼貌的吻别 2020-12-15 08:46

Does Ant have any way of doing string uppercase/lowercase/captialize/uncaptialize string manipulations? I looked at PropertyRegex but I don\'t believe the last two are poss

2条回答
  •  一向
    一向 (楼主)
    2020-12-15 09:41

    From this thread, use an Ant allLowerCase=${allLowerCase} allUpperCase=${allUpperCase}

    Output

    D:\ant-1.8.0RC1\bin>ant capitalize
    Buildfile: D:\ant-1.8.0RC1\bin\build.xml
    
    capitalize:
         [echo] allLowerCase=this is a normal line that doesn't say much
         [echo] allUpperCase=THIS IS A NORMAL LINE THAT DOESN'T SAY MUCH
    
    BUILD SUCCESSFUL
    

    Update for WarrenFaith's comment to separate the script into another target and pass a property from the called target back to the calling target

    Use antcallback from the ant-contrib jar

    
        
            
        
        a = ${allUpperCase}
    
    

    and capitalise task uses the passed in param1 thus

     
    
            
    

    Final output

       [echo] a = THIS IS A NORMAL LINE THAT DOESN'T SAY MUCH
    

提交回复
热议问题