Home > Java, NB Platform, NetBeans > Custom Properties in NB Platform Application Config File (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"
About these ads
Categories: Java, NB Platform, NetBeans Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: