In install4j, we can set the Overwrite policy for a file “If newer, otherwise ask”, or “Always ask”, etc..
I want to upgrade an application which has a .properties configuration file that end users can edit. In newer versions, some properties will be added, but we don’t want to update customized existing properties.
So I’d set the Overwrite policy to “never”, and create a custom action to merge the new properties in. I could use the “Append text to a file”, but I’d like to do it more dynamically, by comparing the old and the new file, and only append those properties whose keys do not exist in the old file.
So my questions:
- Can I detect if the action is called during an install or an upgrade?
- How can I get the content of the new file if it didn’t overwrite the old file?
Yes, you can use
in condition expressions or other scripts.
If a file is not installed, the content is not accessible. I would suggest the following: