39878

Build 1 war from two separate web applications using ANT

Question:

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

Answer1:

If you want to package multiple web applications together, the standard format for that is an EAR file. <a href="http://en.wikipedia.org/wiki/EAR_(file_format)" rel="nofollow">http://en.wikipedia.org/wiki/EAR_(file_format)</a>

Answer2:

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:

<ol><li>Have project 1 all by itself in eclipse </li> <li>Have project 2 all by itself in eclipse</li> <li>Have common stuff like the super web.xml (that you make by hand) in a third project 3 </li> <li>Have ant pull the right stuff from all over and make a war.</li> </ol>

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?

Answer3:

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.

Recommend

  • communicate between wars and jar inside ear
  • Access Antlib Resources From Within Apache Ant Macros
  • What is an Artifact?
  • Unable to get Emma Coverage for Android [duplicate]
  • What to use (best/good practice) for the secret key in HMAC solution?
  • How to sync a PHP project using RSync and NetBeans?
  • K Shortest Path Python Not Working
  • What does the “?” mean in the following statement
  • How do you compute the XOR Remainder used in CRC?
  • eC (Ecere) how to not worry about private data fields of a class
  • How do I know what reference to include to import a specific .NET namespace?
  • Error Installing Windows 10 development tools for Visual Studio 2015 RC on Windows 8.1
  • Hibernate - Cannot connect to DB
  • Ant: fileset “dir” attribute with a runtime expanded full path
  • why fullscreen functionality is not working in chrome?
  • How can I make a 100% stacked chart with nvd3?
  • why does .next() give me 'undefined'
  • Launch powershell script from UWP app with FullTrustProcessLauncher class
  • jinja2 template not found and internal server error
  • iOS 6 dateFromString returns wrong date
  • What's the name of this finding square root algorithm?
  • Create a link to a web page that runs a Javascript function on the page
  • iOS Cordova first plugin - plugin.xml to inject a feature
  • Compress a file with GZipStream while maintaining its meta-data
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • How can I include If-None-Match header in HttpRequestMessage
  • Parse a date string in a specific locale (not timezone!)
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • ImageMagick, replace semi-transparent white with opaque white
  • Cannot connect to cassandra from Spark
  • Display issues when we change from one jquery mobile page to another in firefox
  • Cross-Platform Protobuf Serialization
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • Do I've to free mysql result after storing it?
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • How to get icons for entities from eclipse?
  • Turn off referential integrity in Derby? is it possible?
  • Is it possible to post an object from jquery to bottle.py?
  • JaxB to read class hierarchy
  • Python/Django TangoWithDjango Models and Databases