Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include extra files when building a war?

Tags:

grails

I am trying to add a dir (garils-app/store) to my war like this on my BuildConfig.groovy.

grails.war.resources = {stagingDir,args->
    copy(file: "grails-app/store/**", toFile: "${stagingDir}/store")
}

But when I try to build the war file I am getting this error:


| Error WAR packaging error: Warning: Could not find file /home/codehx/git/appName/grails-app/store/** to copy.

It looks like grails is not considering the ** as wild cards, am I having any error? Or if it is not possible how can I recursively copy the content of store dir to my war file.

like image 307
dsharew Avatar asked Mar 26 '15 07:03

dsharew


People also ask

Can a war file contain another war file?

Typically, war files don't contain war files. They can contain jar files; that's what the directory WEB-INF/lib is for.

How do you create war file?

To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file. Go inside the project directory of your project (outside the WEB-INF), then write the following command: jar -cvf projectname.


1 Answers

Given that the grails.war.resources is an AntBuilder you can use any proper AntBuilder expressions to include additional resources. In older versions of AntBuilder the ** notation did work, but in later versions of AntBuilder the preferred method is:

grails.war.resources = { stagingDir, args ->
    copy(todir: "${stagingDir}/store") {
        fileset(dir: "grails-app/store")
    }
}
like image 85
Joshua Moore Avatar answered Oct 08 '22 20:10

Joshua Moore