java – IzPack替换文本文件中的变量
发布时间:2020-12-15 08:37:19 所属栏目:Java 来源:网络整理
导读:我试图找出如何在文本文件中使用IzPack替换变量.看起来它应该是一件简单的事情,但我找不到使用现有文档执行此操作的具体示例. 有任何想法吗? 提前致谢. 解决方法 在 01es’ answer上构建这是一个示例,您可以让用户使用 UserInputPanel选择应用程序数据的路
我试图找出如何在文本文件中使用IzPack替换变量.看起来它应该是一件简单的事情,但我找不到使用现有文档执行此操作的具体示例.
有任何想法吗? 提前致谢. 解决方法
在
01es’ answer上构建这是一个示例,您可以让用户使用
UserInputPanel选择应用程序数据的路径,然后将该路径写入安装目录中的配置文件,供应用程序读取.
包含要替换的变量的示例config.xml: <?xml version="1.0" encoding="UTF-8"?> <Entries> <Entry> <Key>appDataDir</Key> <!-- IzPack will substitute this --> <Value>$appDataDir</Value> </Entry> </Entries> userInputSpec.xml: <userInput> <panel id="panel1"> <field type="dir" variable="appDataDir"> <spec size="20" set="$USER_HOMEAppDataRoaming$APP_NAME" mustExist="false" create ="true"/> <os family="windows"/> </field> </panel> </userInput> installer.xml: <?xml version="1.0" encoding="UTF-8"?><installation version="1.0"> <info> <appname>Your app</appname> <appversion>0.0.1</appversion> <!-- Try to run as the administrator on Windows to be able to install under "C:Program Files" --> <run-privileged condition="izpack.windowsinstall" /> </info> <locale> <langpack iso3="eng" /> </locale> <resources> <res id="userInputSpec.xml" src="userInputSpec.xml" parse="yes" type="xml" /> </resources> <panels> <panel classname="UserInputPanel" id="panel1" /> <panel classname="InstallPanel" /> <panel classname="FinishPanel" /> </panels> <packs> <pack name="Core" id="core.package" required="yes"> <description>The base files that need to be part of the app</description> <!-- The runnable application should be in this directory --> <fileset dir="YourAppDir" targetdir="$INSTALL_PATH/YourAppDir"> <include name="**" /> </fileset> <!-- This file contains placeholder variables starting with $that Izpack substitutes with values that the user enters during installation in the UserInputPanel --> <parsable targetfile="$INSTALL_PATH/YourAppDir/config.xml" /> </pack> </packs> </installation> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |