Building Components With Apache ANT

November 4, 2008

I have always wanted a quick way to build components without firing up ComponentWizard. I'm not talking about the actual construction of the component like adding resources. I'm talking about the assembly of the component zip file. Combing through the intradoc user group and other online forums can yield a little discussion about Apache ANT being used to construct component zip files. However, I did not find an easy reference to an actual ant file for such purpose.

So once we have this ability to create component zips what else can we do with it? Most projects do not consist of a single component. The components are also not completed in a linear fashion. Generally components that are completed will typically have adjustments being made throughout the project. Using a tool like ant we can orchestrate the build of multiple components at once. This orchestration can even include tasks such as placing built components in shared folders or uploading them to an FTP location.

As for using the Component Wizard to lay out the component architecture you might want to add the build file as a component extra. Then the installation of the component at a target location brings the build file along for the ride.

Here's an example build file:

<project name="CompName" default="dist" basedir=".">
 <property name="build.home" value="${basedir}/classes"/>
 <property name="src.home" value="${basedir}/src"/>
 <property name="compile.debug" value="true"/>
 <property name="compile.deprecation" value="true"/>
 <property name="component.root" value="component/${}/"/>

 <path id="compile.classpath">
  <pathelement location="${basedir}/../../shared/classes/"/>
  <pathelement location="${basedir}/../../shared/classes/jspserver.jar"/>

 <target name="clean">
  <delete dir="${build.home}"/>
  <mkdir dir="${build.home}"/>

 <target name="compile" depends="clean">
  <javac srcdir="${src.home}" destdir="${build.home}" debug="${compile.debug}" deprecation="${compile.deprecation}">
   <classpath refid="compile.classpath"/>

 <target name="dist" depends="compile" description="Package as a Fusion ECM Component">
  <delete file="${basedir}/${}.zip"/>
   <format property="component.timestamp" pattern="yyyy_MM_dd_hh_mm_ss_aa"/>

  <zip destfile="${basedir}/${component.timestamp}_${}.zip">
   <zipfileset dir="${src.home}" prefix="${component.root}src"/>
   <zipfileset dir="${build.home}" prefix="${component.root}classes"/>
   <zipfileset dir="${basedir}/resources" excludes="**/lockwait.dat" prefix="${component.root}resources"/>
   <zipfileset dir="${basedir}" includes="${}.hda" fullpath="${component.root}${}.hda"/>
   <zipfileset dir="${basedir}" includes="build.xml" fullpath="${component.root}build.xml"/>
   <zipfileset dir="${basedir}" includes="readme.txt" fullpath="${component.root}readme.txt"/>
   <zipfileset dir="${basedir}" includes="manifest.hda" fullpath="manifest.hda"/>
© 2020 Jason Stortz (version 20200607-210013)