Build 1 war from two separate web applications using ANT

孤街浪徒 提交于 2019-12-24 08:56:43

问题


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


回答1:


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)




回答2:


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:

  1. Have project 1 all by itself in eclipse
  2. Have project 2 all by itself in eclipse
  3. Have common stuff like the super web.xml (that you make by hand) in a third project 3
  4. 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?




回答3:


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.



来源:https://stackoverflow.com/questions/2936391/build-1-war-from-two-separate-web-applications-using-ant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!