Link to home
Start Free TrialLog in
Avatar of enthuguy
enthuguyFlag for Australia

asked on

automate find and replace inside jar on linux platform

Hi Experts

Would like to get your advise on what is the best way to automate replacing files inside jar files on Linux platform.

scenario:
1. We will have a directory "fixes" with all the code fix files. E.g xml, .class, .properties
2. We will have another directory with jar files one or more files (where all the fixes will go in)
3. Need your help in writing a script.
      a. Each jar should be unjar/unzip to a tmp directory
      b. Go through each code fix file one by one inside "fixes" directory
      c. Search inside unjar tmp location and replace.
      d. Take next code fix file, search again inside the same unjar tmp location and replace. Basically to find/replace all code fix files.
      e. Once all done. jar the file and clear tmp
      f. Now unjar next jar file and repeat from a to e.


Interesting part is
1. single code fix could be in multiple jar files
2. multiple code fix could be in single jar as well.


will try to upload sample files
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, on reflection, you should be using a version control system. Git would render all the above unecessary. A build file in the project would simply generate archives from the latest commit