Last active
July 3, 2023 11:38
-
-
Save kknd22/9234822 to your computer and use it in GitHub Desktop.
grails custom build hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* create Events.Groovy under directory <grails-project>/scripts | |
**/ | |
eventCreateWarStart = {warName, stagingDir -> | |
//def wd = grailsSettings.projectWorkDir | |
println "###eventCreateWarStart [${stagingDir}]" | |
def today = System.currentTimeMillis() | |
def spt_js_dir= "spt_${today}" | |
File appJsFile = new File("${stagingDir}/js/app.js") | |
def newFileText = appJsFile.text.replaceAll("appFolder: \'js\',", "appFolder: 'js/${spt_js_dir}',") | |
appJsFile.write(newFileText) | |
File homeIndexGspFile = new File("${stagingDir}/WEB-INF/grails-app/views/home/index.gsp") | |
def newGspText = homeIndexGspFile.text.replaceAll("js/spt/app.js", "js/${spt_js_dir}/app.js") | |
homeIndexGspFile.write(newGspText) | |
new File("${stagingDir}/js/spt").renameTo(new File("${stagingDir}/js/${spt_js_dir}")) | |
println "### custom js foler [${spt_js_dir}] is done" | |
} | |
eventCreateWarEnd = {warName, stagingDir -> | |
new File("${stagingDir}").renameTo(new File("${stagingDir}2")) | |
println "### staging dir preserved: ${stagingDir}2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment