Adding a Top-level Package

Adding a top-level package that you will compile as a separate operation and that a user will run separately doesn't happen very often.

There are several steps in making new top-level package that you can compile and run using package-specific Ant targets.

  • Add patternsets and paths for common, compile-time, and run-time classpaths to build-compile.xml
  • Add a compile target to build-compile.xml
  • Add the compile target to the next higher-level compile target in build-compile.xml
  • Add an Ant property for the jar or war file's name to build-compile.xml
  • Add a jar target to build-compile.xml
  • Add the new jar target as a dependency of the 'jars' target in build-compile.xml

Adding Patternsets and Classpaths to build-compile.xml

Each top-level package typically has three patternsets and two classpaths defined in build-compile.xml:

  • xxx.common.files - Files common to both compile-time and run-time.
  • xxx.compile.files - The common files plus files that are needed when compiling the package but not necessary when running it.
  • xxx.compile.classpath - xxx.compile.files expressed as a classpath.
  • - The common files plus files that are needed when running the package but not necessary when compiling it.
  • - expressed as a classpath.


<!-- Classpath used to compile the Bulk Loader -->
<patternset id="bulkLoader.common.files">
    <include name="${}.jar"/>
    <include name="omar-common.jar"/>
    <include name="commons-logging.jar"/>
    <include name="ant.jar"/>

<patternset id="bulkLoader.compile.files">
    <patternset refid="jaxr.client.compile.files"/>
    <patternset refid="bulkLoader.common.files"/>
<path id="bulkLoader.compile.classpath">
    <fileset dir="${build.lib}">
        <patternset refid="bulkLoader.compile.files"/>

<patternset id="">
    <patternset refid=""/>
    <patternset refid="bulkLoader.common.files"/>
<path id="">
    <fileset dir="${build.lib}">
        <patternset refid=""/>

Adding a Compile Target to build-compile.xml

Running this target compiles the package after all the target's dependencies have been satisfied.


<target name="compile.bulkLoader" depends="jar.ebxml.provider" description="Compile the bulk loader">
    <javac fork="true" memoryMaximumSize="100m" debug="${compile.debug}" deprecation="${compile.deprecation}" destdir="${build.lib}/classes" optimize="${compile.optimize}" srcdir="${}">        
        <classpath refid="bulkLoader.compile.classpath"/>
        <include name="org/freebxml/omar/client/bulkLoader/**"/>

Adding the Compile Target to the Next Higher-Level Compile Target in build-compile.xml

The next higher-level ".compile" target is probably compile.client, compile.common, or compile.server. If your package does not fit in any of those three categories, then it should probably be a dependency of compile.all.


<target name="compile.client"
        depends="compile.ebxml.provider, compile.browser, compile.client.thin,
                 compile.bulkLoader, compile.ebxml.provider.tests"/>

Adding an Ant Property for the Jar or War File's Name

You should add this to the similar properties defined in build-compile.xml.


<!-- Properties for *ar names -->
<property name="" value="registry-browser"/>
<property name="" value="bulk-loader"/>
<property name="" value="jaxr-ebxml-admin"/>
<property name="" value="jaxr-ebxml"/>
<property name="" value="jaxr-ebxml-test"/>

Adding a Jar Target

The created jar file should include a manifest that:

  • Identifies the package and attributes it to the project.
  • Specifies the package's main class as the jar's main class.
  • Specifies all other required jars in this jar's classpath.


<target name="jar.bulkLoader" depends="compile.bulkLoader"
        description="create jar file containing only the Bulk Loader">
    <!-- Remove path prefixes from list of files and build a list for Class-Path -->
    <pathconvert property="bulkLoader.manifest.classpath"
                 dirsep="/" pathsep=" "
        <map from="${build.lib}${file.separator}"

    <manifest file="${build.lib}/bulk-loader.manifest"
        <attribute name="Main-Class" 
        <attribute name="Class-Path" 
        <attribute name="Build-Time" 
        <section name="com/sun/xml/registry/client/bulkLoader">
            <attribute name="Specification-Title"
                       value="Bulk Loader"/>
            <attribute name="Specification-Version"
            <attribute name="Specification-Vendor"
            <attribute name="Implementation-Title"
                       value="Bulk Loader"/>
            <attribute name="Implementation-Version"
            <attribute name="Implementation-Vendor"
            <attribute name="Implementation-URL"
    <copy todir="${build.lib}/classes" file="conf/"/>
    <copy todir="${build.lib}/classes/META-INF"

    <jar manifest="${build.lib}/bulk-loader.manifest"
        <metainf dir="${build.lib}/classes/META-INF">
            <include name="mime.types"/>
        <include name="org/freebxml/omar/client/bulkLoader/**"/>
        <include name=""/>
        <include name=""/>


Adding the New Jar Target to 'jars' Target

Once you do this, the new jar target will be compiled along with the other jars whenever the 'jars' target is run.

  • Identifies the package and attributes it to the project.
  • Specifies the package's main class as the jar's main class.
  • Specifies all other required jars in this jar's classpath.


<target name="jars"
        depends="jar.ebxml.provider, jar.browser, jar.adminTool, jar.bulkLoader, jar.ebxml.provider.tests"
        description="Build jar files"/>