0

我们有一个 Java 小程序项目,我们使用 Ant 生成包装器 HTML,它看起来有点像这样:

<target name="build-applet" description="Build web applet" depends="set-build-properties, set-properties">  
    <antcall target="clean" />
    <antcall target="clean-applet" />
    <antcall target="set-version" />
    <antcall target="compile" />
    <antcall target="jar" />
    <antcall target="applet" />
</target>

<target name="applet">      
    <replace file="${applet.dir}/${applet.html.file}">          
        <replacefilter token="@jar.file@" value="${applet.jar.file}"/>
        <replacefilter token="@assets.file@" value="${applet.assets.file}"/>
        <replacefilter token="@codebase@" value="${applet.codebase}"/>
</target>

请注意,${applet.codebase}它必须是从例如 mysite.com/game 加载小程序的 URL。它在属性文件中设置。

现在我希望能够将这个小程序构建到两个不同的位置,这是实时/测试设置的一部分。例如,一个在 mysite.com/game 上访问,另一个在 mysite.com/test 上访问。我几乎可以正常工作,除了${applet.codebase}因为这在每种情况下都需要有所不同。我以为我可以${applet.codebase}${applet.codebase_test}但我不知道该怎么做。也许有一种方法可以将标志从 传递到applet目标build-applet,并添加两个顶级目标build-applet-livebuild-applet-test并且只需build-applet使用参数调用。

4

1 回答 1

1

为什么不简单ant -Dapplet.codebase=whatever build.xml,意味着将 ${applet_codebase} 设置为 userproperty(= 通过 -Dkey=value 设置的那些属性)?

于 2013-10-23T22:29:59.913 回答