Ant, NetBeans Platform Project - How to pass command line arguments and access through System.getProperties?

Everything,

I have a NetBeans platform project (not just a project that I wrote in NetBeans, but using the rich client environment provided by NetBeans ). I can start the project using the ant run command. Now I want to pass an argument that will work through ant to be accessible using the System.getProperty method.

I understand that I need to use the <sysproperty> node to actually enter the key / value pair into the runtime, but for life I can’t figure out how to make this work with the minimized assembly that NetBeans creates for you (build.xml depends on build -impl.xml, which in turn depends on $ {harness.dir} /suite.xml, which, in turn, depends on $ {harness.dir} /run.xml)

A simple example I found

 <target name="run" depends="compile"> <java classname="prop" fork="true"> <sysproperty key="test.property" value="blue" /> </java> </target> 

but the problem is that none of my xml files has an easily accessible <java> node. I think I managed to trace the thread of execution in which something is actually being called (in ${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> 

As you can see, there is no under <java> node, under which I can put my own sysproperty. Also, it seems very wrong to do this to spoof the xml bundle files in order to implement a property that affects only one of my projects and not all of them. So, what is the right way to ensure that the command-line property that I pass to ant to execute ends in a NetBeans platform project?

+4
source share
1 answer

Your RCP application distribution has a folder , etc. , and in this folder is the yourapp.conf file. I think there is an answer you are looking for. For example, from one of my NB RCP applications:

 # ${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= 
0
source

Source: https://habr.com/ru/post/1338940/


All Articles