Archive

Posts Tagged ‘app.conf’

Custom Properties in NB Platform Application Config File (app.conf)

Since NetBeans V6.9 there’s a new property app.conf (project.properties) to configure a custom application configuration file. Geertjan wrote about that.

The default configuration file (from harness/etc/app.conf) looks like this (some lines are omitted):

# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/dev"

# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--branding ${branding.token} -J-Xms24m -J-Xmx64m"

Unfortunately, only the property branding.token is supported by the Ant distribution task! But I want include other well known properties like app.version to my custom configuration file to define default_userdir more flexible like

# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/${app.version}"

To achieve this, only a small patch in the build.xml is needed. I have to override the Ant target “build-launchers” (from harness/suite.xml):

<project name="MyApp" basedir=".">
   ...
   <target name="build-launchers" depends="suite.build-launchers">
      <replace file="${build.launcher.dir}/etc/${app.name}.conf" 
               token="$${app.version}" value="${app.version}"/>
   </target>
</project>

Now when I run the ZIP target, my own configuration file is used and the application version property is replaced by the value from the project.properties:

# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/1.1"
Categories: Java, NB Platform, NetBeans Tags: ,