Add the below stuff to your build.gradle file. Everytime build or any other task is executed the below code will generate date based build-no and insert into the application.properties file
allprojects { updateVersionInApplicationProperties() } def updateVersionInApplicationProperties() { def configFile = new File('Webapp/src/main/resources/application-build.properties') if (!configFile.exists()) { configFile = new File('src/main/resources/application-build.properties') } println "Updating version to '" + getDate() + "' in ${configFile}" String configContent = configFile.getText('UTF-8') configContent = configContent.replaceAll(/info\.build\.version=.*/, "info.build.version=" + getDate()) configFile.write(configContent, 'UTF-8') } def getDate() { new Date().format('yy.MM.dd') }
Comments