File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Help Needed in editing the war file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Help Needed in editing the war file" Watch "Help Needed in editing the war file" New topic
Author

Help Needed in editing the war file

Keerthi Kumar
Ranch Hand

Joined: Apr 20, 2009
Posts: 105
Dear All,

I am trying to automate the build and deployment process in my project. Currently build.xml generates the war file and I have updated the script to copy the war file to the required destination in the linux environment. But before transferring the war file to the linux server, I need to explode the war file and edit few of the configuration files and pack them back to the war file. Hence request you all to help me or guide to update my ant script (build.xml) to achieve my above requirement.

Please do the needful.

Thanks in advance.


Cheers,
Keerthi Kumar N
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
This seems backwards. Why are you creating the war file before all its constituent parts are available?


Ping & DNS - my free Android networking tools app
Keerthi Kumar
Ranch Hand

Joined: Apr 20, 2009
Posts: 105
Hi,

The problem is, the generated war file is of from the default entries, which I am not supposed to edit it before the generation of the war file. I am supposed to edit the war file after the successful build.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
I would question that, as it doesn't seem to make sense. But regardless, a war file is just a zip file with a different extension, so you can use the unzip/unwar task to extract its contents, edit them to your heart's content, and finally war them back together.
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Hi keerthi,

The following steps for edit and update the war file content in linux

1. Just right click your war file.

2. Select 'open archive manager'

3. Then which file you want to edit, just open that file and edit the content.

4. Then system ask to update or cancel, when you close that archive manager dialog box.

I hope , its useful for u.


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
Keerthi Kumar
Ranch Hand

Joined: Apr 20, 2009
Posts: 105
Hi Eswar,

Thanks a lot for your reply. Could you please help me out to carry out the above steps through the ant build script!! I need to automate the build process. Hence I need to update my build.xml file to accomplish the above tasks specified by you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
After having read the documentation of the unwar/unzip Ant tasks, what, specifically, is unclear about how to do this?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Actually, I design all my webapps so that you don't have to edit the war file. The exact same byte-for-byte copy of the WAR serves for local testing, Beta testing, and production. I do this by defining the variable parts of the webapp as externally-injectable resources that can be retrieved via JNDI. The database location info comes that way naturally, since I always use server-pooled DataSources, but I also use external resource definitions to specify where file upload directories are, locations of server-specific property files, and so forth.

It makes the program design slightly more complex, but keeps the build simple. Just as importantly, it ensures that the wrong copy of a WAR doesn't get deployed and have Production updating a Test database or vice versa. Since there's only one copy, it's never the "wrong" one.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help Needed in editing the war file