I am new to Grunt build. Here my requirement is, create WEB-INF/lib directory and copy Jar files into it while doing war task using Grunt build.
Below is the sample of my war.js:
module.exports = {
/*
* Build a WAR (web archive) without Maven or the JVM installed.
*/
target: {
options: {
war_dist_folder: 'deploy',
/* Folder to generate the WAR into */
war_name: 'mySampleApp',
/* The name fo the WAR file (.war will be the extension) */
webxml_webapp_version: '2.5',
war_extras: [{
filename: 'WEB-INF/weblogic.xml',
data: '<?xml version = "1.0" encoding = "US-ASCII"?> \n\n\
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n\n\
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" \n\n\
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"> \n\n\
<context-root>my-sample-app</context-root> \n\n\
<session-descriptor> \n\n\
<timeout-secs>1800</timeout-secs> \n\n\
<cookie-name>JSESSIONID</cookie-name> \n\n\
<cookie-path>/my-sample-app</cookie-path> \n\n\
<url-rewriting-enabled>false</url-rewriting-enabled> \n\n\
</session-descriptor> \n\n\
</weblogic-web-app>'
}],
/* the war_extras are extra files to be generated, needed since grunt-war doesn't create a weblogic.xml */
webxml_welcome: 'index.html',
/* to point web.xml to the default page */
webxml_webapp_extras: ['<login-config />\n',
'<session-config>\n \n\
<session-timeout>\n 30\n </session-timeout>\n\n\
</session-config>\n',
'<servlet>\n \n\
<servlet-name>\n MyServlet\n </servlet-name>\n\n\
<servlet-class>com.sample.servlet.MyServlet</servlet-class>\n\n\
</servlet>\n',
'<servlet-mapping>\n\
<servlet-name>MyServlet</servlet-name>\n\
<url-pattern>/maySampleApp</url-pattern> \n\
</servlet-mapping>'
]
},
files: [{
expand: true,
cwd: 'release',
/* find the source files for the WAR in the /release folder */
src: ['**'],
dest: ''
}]
}
};
Please provide me instructions to create WEB-INF/lib directory and copying the jar files into it.
Have You tried something "easy" as (files
takes an "array" argument ...this particular options field is not really documented at grunt-war):
// ...,
files: [{
expand: true,
// better ...no cwd, "copy single file tree" @see [2]
src: ['release/*'],
dest: ''
}, // a second "files" object! (and my particular answer)
{
// expand: false, assuming/hoping for a flat *.jar structure (all in one folder)
// cwd: '', NO cwd ...
/* GET all files with "lib/*.jar" "matcher" */
src: ['lib/*.jar'],
/* ... and "destinate" into "WEB-INF/lib" */
dest: 'WEB-INF/lib'
}
] // ...
?
No warranty, no tests, just a gutshot! :)
When your "lib" folder structure is too fancy, you have to go with epxand
and cwd
, see:
[1], [2], @RobC 's comment.
And when all of this fails with the grunt-war plugin, I'd try to copy (the jars) into "release/WEB-INF/lib", before war
is executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With