I82*_*uch 5 java ant netbeans netbeans-6.9
全部,
我有一个 NetBeans 平台项目(不仅仅是我在 NetBeans 中编写的项目,而是使用NetBeans 提供的富客户端框架的项目)。我可以通过命令运行该项目ant run。现在,我想传递一个参数,该参数将ant通过该方法进行访问System.getProperty。
我知道我需要使用一个<sysproperty>节点来将键/值对实际注入到运行时环境中,但我一生都无法弄清楚如何让它与 NetBeans 为您创建的复杂构建树一起工作(构建.xml 依赖于 build-impl.xml,而 build-impl.xml 又依赖于 ${harness.dir}/suite.xml,而 ${harness.dir}/suite.xml 又依赖于 ${harness.dir}/run.xml)
我发现的最简单的例子是
<target name="run" depends="compile">
<java classname="prop"
fork="true">
<sysproperty key="test.property"
value="blue"
/>
</java>
</target>
Run Code Online (Sandbox Code Playgroud)
但问题是我的 xml 文件都没有<java>这样易于访问的节点。我想我已经设法跟踪执行流程到实际调用某些内容的地方(在${harness.dir}/run.xml)
<target name="run" depends="-prepare-as-app,-prepare-as-platform">
<touch file="${cluster}/.lastModified"/> <!-- #138427 -->
<property name="run.args" value=""/>
<property name="run.args.ide" value=""/>
<property name="run.args.extra" value=""/>
<condition property="run.args.mac" value="-J-Xdock:name=${app.name}" else="">
<os family="mac"/>
</condition>
<exec osfamily="windows" executable="${run.exe}" failonerror="no" resultproperty="result.prop">
<arg value="--jdkhome"/>
<arg file="${run.jdkhome}"/>
<arg line="${run.args.common}"/>
<arg line="${run.args.prepared}"/>
<arg line="${run.args}"/>
<arg line="${run.args.ide}"/>
<arg line="${run.args.extra}"/>
</exec>
<exec osfamily="unix" dir="." executable="sh"
failonerror="no" resultproperty="result.prop">
<arg value="${run.sh}"/>
<arg value="--jdkhome"/>
<arg file="${run.jdkhome}"/>
<arg line="${run.args.common}"/>
<arg line="${run.args.prepared}"/>
<arg line="${run.args}"/>
<arg line="${run.args.ide}"/>
<arg line="${run.args.extra}"/>
<arg line="${run.args.mac}"/>
</exec>
<fail>
The application is already running within the test user directory.
You must shut it down before trying to run it again.
<condition>
<and>
<isset property="result.prop" />
<or>
<!-- unknown option exit code as returned from IDE by org.netbeans.api.sendopts.CommandLine -->
<equals arg1="${result.prop}" arg2="50346" />
<!-- unknown option exit code as returned from platform app by org.netbeans.CLIHandler -->
<equals arg1="${result.prop}" arg2="2" />
</or>
</and>
</condition>
</fail>
</target>
Run Code Online (Sandbox Code Playgroud)
如您所见,没有<java>可以在其下放置自定义系统属性的节点。此外,必须使用harness xml 文件来注入仅影响我的一个项目而不是所有项目的属性,这似乎是一件非常错误的事情。那么,确保传递给 ant run 的命令行属性最终出现在 NetBeans 平台项目中的正确方法是什么?
小智 0
在您的 RCP 应用程序的发行版中有一个文件夹等,在该文件夹中是文件yourapp.conf我认为您正在寻找答案。例如,来自我的一个 NB RCP 应用程序:
# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/dev"
default_mac_userdir="${HOME}/Library/Application Support/${APPNAME}/dev"
# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--laf Metal --branding xmled -J-Xms24m -J-Xmx64m"
# for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea
# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
#jdkhome="/path/to/jdk"
# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#extra_clusters=
Run Code Online (Sandbox Code Playgroud)