tscheuerman
Posts: 43
Joined: Thu Feb 11, 2016 11:39 pm

Deploying a .war file to Tomcat that needs to be modified before being deployed

I need to deploy a .war file to Tomcat but before I do, I need to configure some of the files in the .war file. Because of this need, I can not simply copy the .war file to the Tomcat \webapps folder. Here is what I would like to do:

1. Determine the destination installation path for the web application. This will be the Tomcat installation location followed by "\webapps". The user will provide this information.

2. Create a temporary folder that I can temporarily copy the .war file to. I am assuming that I can create a temporary folder via PowerShell.

3. Copy the .war file into the temporary folder.

I am not sure how I get the .war file from Advanced Installer to the temporary folder as I do not want Advanced Installer to actually install the .war file; I will do that programmatically (See Step #7 below).

4. Using PowerShell, unzip the .war file into the temporary folder.

5. As I mentioned, I need to configure some of the files contained in the .war file. Using the extract files in the temporary folder, perform the necessary file updates/manipulation to support the web application. I'm assuming I can do the necessary file manipulation using PowerShell.

6. Using PowerShell, compress all files and folders in the temporary folder back into a .war file; excluding the original .war file from Step #3 above.

7. Using PowerShell, copy the new .war file to the destination installation path. Tomcat will see the new .war file and attempt to deploy the web application.

Any suggestions or examples on how I might do this would be appreciated.

Thanks in advance!
Todd Scheuerman
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Deploying a .war file to Tomcat that needs to be modified before being deployed

Hello Todd,

Most likely, you will need to use the "temporary files" support we offer.

Otherwise, you might not be able to work with the file even with a custom action as the file is not yet extracted on the machine (it is extracted on the machine during the "Add resources" action group, on the "deferred" stage).

Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.

Besides this, you can use the PowerShell custom actions as you mentioned.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”