Skip to main content


Showing posts from July, 2017

How-to Generate Build-Numbers for Gradle Projects

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 file

allprojects { updateVersionInApplicationProperties() } def updateVersionInApplicationProperties() { def configFile = new File('Webapp/src/main/resources/') if (!configFile.exists()) { configFile = new File('src/main/resources/') } println "Updating version to '" + getDate() + "' in ${configFile}" String configContent = configFile.getText('UTF-8') configContent = configContent.replaceAll(/info\.build\.version=.*/, "" + getDate()) configFile.write(configContent, 'UTF-8') } def getDate() { new Date().format('yy.MM.dd') }