Shell command to update pom file from a variable

后端 未结 6 1463
[愿得一人]
[愿得一人] 2021-01-06 17:24

Previously I used below command to take the version in pom.xml and increment it from one. Before increment snapshot version is, 0.0.1

#!/bin/bas         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 18:11

    Yes you can use sed to modify the version in pom.xml file. Simply add, at the end of your given bash script, those two lines:

    LN=$(grep -n "" pom.xml | head -1 | awk -F ":" '{print $1}')
    sed -i "$LN s/$version/$incrementVer/" pom.xml
    

    Explanation:

    • The first line recover the line number of the project version (in LN var)
    • The second modify in place (-i parameter of sed) the pom file with new version value.

提交回复
热议问题