Ant if else condition?

后端 未结 5 1272
傲寒
傲寒 2020-12-13 13:03

Is there an if/else condition that I can use for an Ant task?

This is what i have written so far:



        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 13:26

    
        
    
        
        Value Buld is now  ${PARAM_BUILD_TYPE} is set
            
                
            
    
           Value Buld is now  ${PARAM_BUILD_TYPE} is set
           Value Buld is now  ${build.type} is set
        
    
    

    In my Case DPARAM_BUILD_TYPE=Debug if it is supplied than, I need to build for for Debug otherwise i need to go for building Release build. I write like above condition it worked and i have tested as below it is working fine for me.

    And property ${build.type} we can pass this to other target or macrodef for processing which i am doing in my other ant macrodef.

    D:\>ant -DPARAM_BUILD_TYPE=Debug
    Buildfile: D:\build.xml
    clean:
         [echo] Value Buld is now  Debug is set
         [echo] Value Buld is now  Debug is set
         [echo] Value Buld is now  Debug is set
    main:
    BUILD SUCCESSFUL
    Total time: 0 seconds
    D:\>ant
    Buildfile: D:\build.xml
    clean:
         [echo] Value Buld is now  ${PARAM_BUILD_TYPE} is set
         [echo] Value Buld is now  ${PARAM_BUILD_TYPE} is set
         [echo] Value Buld is now  Release is set
    main:
    BUILD SUCCESSFUL
    Total time: 0 seconds
    

    It work for me to implement condition so posted hope it will helpful.

提交回复
热议问题