Build 1 war from two separate web applications using ANT
Is it possible, by using ANT开发者_开发知识库, to create 1 war-file out of two separate eclipse java web application projects? Besides from just copying the right files to the right places i would have to be able two create one single web.xml. Also some other files that exists in both projects should be united into one file.
Thanks
Pich
If you want to package multiple web applications together, the standard format for that is an EAR file. http://en.wikipedia.org/wiki/EAR_(file_format)
Ant doesn't care about eclipse. It can grab stuff from anywhere.
But taking 2 separate web.xml and combining into 1 file.. not sure you can automatically do that. Too many variables with how that would happen.
What you COULD do is:
- Have project 1 all by itself in eclipse
- Have project 2 all by itself in eclipse
- Have common stuff like the super web.xml (that you make by hand) in a third project 3
- Have ant pull the right stuff from all over and make a war.
Sounds like a lot of work though. Why do you have 2 separate web.xml if they are going to the same war? Why not just make 1 big project?
It is easy if there are no duplicate files. Then just unzip them on top of each other, and zip them back to a new WAR file.
If there are duplicates you need to determine what information goes in the resulting file. For merging web.xml files, the easiest is most likely by using an XML capable transformation tool. The typical choice is XSLT, and there is an XSLT engine available in Java 1.4 and newer.
The question is, however, if this can be fully automated or you need to have the authors of either WAR files know about the other (write snippets, etc). Please provide more details.
精彩评论