doFirst not updating WAR file

In a gradle project, I’m trying to change properties file value before generating WAR in build.gradle as follows,

war {
doFirst {
def propertyFile = file “src/main/resources/properties/about/"
def props = new Properties()
propertyFile.withReader { props.load(it) }
props.setProperty(‘releaseDate’, new Date().format(“yyyy-MM-dd HH:mm:ss”))
propertyFile.withWriter {, null) }

But whenever I give build, it generates WAR with previous date time. Say, I’m giving first build at 11:30 and second build at 11:34. The second built WAR contains time as 11:30 instead of 11:34. My intention is to update date whenever WAR is built. Is this way right?