Question

I'm looking for events list of cases when packing war files. The main cause is to create a file with a build id of my system when the build is done.

I tried to look for it using google, but I didn't find any.

Was it helpful?

Solution 2

Solved by using this:

def webAppDir = "${basedir}" + "/web-app/"
def buildNumber = new SimpleDateFormat("yMMdd.HHmm").format(new Date())
new File(webAppDir + "buildNumber.properties").delete()
def file = new File(webAppDir + "buildNumber.properties")
file.append("app.buildNumber = " + buildNumber)

OTHER TIPS

Based on your comments it sounds like you want a custom Gant script that you can use. You can create your own scripts using the create-script command.

Assuming you use grails create-script MyCustomBuild

A very simple example of what your script may look like:

// MyCustomBuild.groovy
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsWar")

target(main: "Create a WAR and append to text file") {
    // build the WAR file
    war()

    // Append to the file
    // insert your logic here for creating your build number
    def buildNumber = new Date().getTime()
    def file = new File("somefile.txt")
    file.append("Build #: ${buildNumber}\n")
}

setDefaultTarget(main)

Once you create this script you can use it from the grails console or command line as such:

grails mycustombuild
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top