Retrieve value from text file and replace a string constant in another file with that value using ant script

后端 未结 2 939
暖寄归人
暖寄归人 2020-12-22 05:40

I have a file called versionInfo.txt. This file among other things has the following text: \"Implementation-Version: 7.5.0.1\".

I need to retrieve the version value

2条回答
  •  生来不讨喜
    2020-12-22 06:17

    Create a properties file like this and name it build.properties

    version.label=7.5.0.1
    

    Then in your build.xml file

    
    
        
    
            
    
            
    
         
    
    
    

    So your file structure should look like

    myproject
        build.properties
        build.xml
        myClass.java
    

    Then you can execute your ANT build by changing to the "myproject" directory and executing

    ant replace-labels
    

    The replace tag will look for the string "@version-info@" in your myClass.java file and replace it with the value "7.5.0.1"

提交回复
热议问题