文件:buildnumber.gralde包含代码
task buildversionnumber << {
ant.propertyfile(file: "src/build.properties")
{
entry(key: 'builder.date', type:'date',value: new Date(),pattern:'YYYY/MM/dd HH:mm')
entry(key: 'build.number', value: '1',operation:'+',type:'int')
}
}
src\build.properties 文件里包含内容:
build.number=455
builder.date=2013/08/14 15\:22
builder.author=William Wang
运行:
gradle -b bnumber.gradle buildversionnumbertask buildversionnumber << {
ant.propertyfile(file: "src/build.properties")
{
entry(key: 'builder.date', type:'date',value: new Date(),pattern:'YYYY/MM/dd HH:mm')
entry(key: 'build.number', value: '1',operation:'+',type:'int')
}
}
src\build.properties 文件里包含内容:
build.number=455
builder.date=2013/08/14 15\:22
builder.author=William Wang
运行:
即可看到builder.date和build.number如期改变了。