Reputation: 17874
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:
Upvotes: 1
Views: 586
Reputation: 48105
Can I detect if the action is called during an install or an upgrade?
Yes, you can use
context.isUpdateInstallation()
in condition expressions or other scripts.
How can I get the content of the new file if it didn't overwrite the old file?
If a file is not installed, the content is not accessible. I would suggest the following:
Upvotes: 1