newton
Newton
 

Newton: Building Composites

This page describes how to build your own Newton composites.

Newton provides some Ant tasks that you should import into your project. To use these Ant tasks you will need a binary install of Newton, which you can either download or build from the Newton source.

Ant Configuration

The Newton Ant tasks require some external jars on Ant's library path.

These can be specified explicitly each time ant is invoked, using ant -lib, but it's generally more convenient to use the antrc file:

Unix

Set environment variable NEWTON_HOME to point to the top of the Newton binary installation:

export NEWTON_HOME=$HOME/newton-1.2.x

Add the following to $HOME/.antrc:

ANT_ARGS="-lib $NEWTON_HOME/sdk/ant/lib"

Windows

The setup is similar, but you need very specific use of double quotes if the NEWTON_HOME path contains spaces (e.g. C:\Documents and Settings\user).

Set HOME environment variable so ant.bat finds antrc_pre.bat:

set HOME=%HOMEDRIVE%%HOMEPATH%

Set environment variable NEWTON_HOME to point to the top of the Newton binary installation:

set NEWTON_HOME="%HOME%\newton-1.2.x"

Add the following to %HOME%\antrc_pre.bat:

set ANT_ARGS=-lib %NEWTON_HOME%\sdk\ant\lib
Note
If ant complains "Target 'and' does not exist in this project", then it is probably due to not using double quotes exactly as above - ant.bat is expanding %ANT_ARGS% and breaking on the 'and' in C:\Documents and Settings.

Composite build.xml

The following example shows how to build a component bundle named mycomposite that exports a single composite template:

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="mycomponent" basedir=".">
  <property environment="env"/>
  <property name="container.dir" location="${env.NEWTON_HOME}" />
  <!-- Note: container.dir must be set, as it is used in imported file -->
  <import file="${container.dir}/sdk/ant/component-utils.xml" />

  <target name="compile">
      <!-- compile your source here -->        
  </target>

  <target name="build" depends="compile" >
    <component.bundle name="mycomposite" version="1.0" templates="mytemplate.xml">
      <exportpackage name="com.company.application.component.api" version="1.0" />

      <fileset dir="${build.dir}/classes">
        <include name="com/company/application/component/**/*.class" />
      </fileset>

      <fileset dir="templates">
        <include name="mytemplate.xml" />
      </fileset>
    </component.bundle>
  </target>
</project>

See the existing component bundle Ant targets in the examples, for further details.