File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Add multiple files in WEB-INF of war Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Add multiple files in WEB-INF of war" Watch "Add multiple files in WEB-INF of war" New topic

Add multiple files in WEB-INF of war

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
My dev structure doesnt have a WEB-INF directory. How can i add multiple files other than web.xml to WEB-INF directory of the war?

I want to do this using the ant script.

Peter Johnson

Joined: May 14, 2008
Posts: 5812

Use the <copy> task?

Personally, I follow the Maven build pattern - I first gather the contents of the WAR in a single directory location, then I package up the whole directory. That way I have both a packaged WAR file and an "exploded" WAR directory.

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960

Second on Peter's suggestion.

I did learn a LONG time ago that it's best to make project directories either read-only or write-only, regardless of the build system you're using. I normally build an exploded WAR and feed that directly to Tomcat for debugging, then jar up the exploded WAR when I want to make a distribution module. In keeping with not having permanent files in an output directory, I copy them from a static file source directory (or directories) into the exploded WAR directory when I do a build, just as I compile to the exploded WAR's WEB-INF/classes directory.

Customer surveys are for companies who didn't pay proper attention to begin with.
Ali Qanavatian

Joined: Mar 29, 2011
Posts: 1

ant does not allow using <copy> in <war> block, you may use

in your ant file. and then just create a "WEB-INF" directory in "any-dir" directory, and put xml files there.
the directory structure would be like this:

that's how i did it.

who is this guy anyway?
Michael Henderson

Joined: Feb 22, 2011
Posts: 2
why not use the webinf element. This works for me.

subject: Add multiple files in WEB-INF of war
Similar Threads
creating a ear file around a war file
Servlet-Applet communication in a WAR
How to Generate a War file
reading filename in war archive
WAR file search order: classes, lib, root?