Is there any way to generate a guid in ANT?

前端 未结 2 583
醉酒成梦
醉酒成梦 2021-02-07 11:09

I have an ant script to manage out build process. For WiX I need to produce a new guid when we produce a new version of the installer. Anyone have any idea how to do this in ANT

2条回答
  •  日久生厌
    2021-02-07 11:26

    If you are using (or would like to use) groovy this will work nicely.

    
    
        
            
                //generate uuid and place it in ants properties map
                def myguid1 = UUID.randomUUID()
                properties['guid1'] =  myguid1
                println "uuid " + properties['guid1']
            
            
            
        
    
    

    Output

    Buildfile: C:\dev\anttest\build.xml
    main:
          [groovy] uuid d9b4a35e-4a75-454c-9f15-16b4b83bc6d0
          [echo] uuid d9b4a35e-4a75-454c-9f15-16b4b83bc6d0
    BUILD SUCCESSFUL
    

    Using groovy 2.1.5 and ant 1.8

提交回复
热议问题