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.
Each top-level package typically has three patternsets and two classpaths defined in build-compile.xml:
<!-- Classpath used to compile the Bulk Loader -->
<patternset id="bulkLoader.common.files">
<include name="${jaxr.provider.name}.jar"/>
<include name="omar-common.jar"/>
<include name="commons-logging.jar"/>
<include name="ant.jar"/>
</patternset>
<patternset id="bulkLoader.compile.files">
<patternset refid="jaxr.client.compile.files"/>
<patternset refid="bulkLoader.common.files"/>
</patternset>
<path id="bulkLoader.compile.classpath">
<fileset dir="${build.lib}">
<patternset refid="bulkLoader.compile.files"/>
</fileset>
</path>
<patternset id="bulkLoader.run.files">
<patternset refid="jaxr.provider.run.files"/>
<patternset refid="bulkLoader.common.files"/>
</patternset>
<path id="bulkLoader.run.classpath">
<fileset dir="${build.lib}">
<patternset refid="bulkLoader.run.files"/>
</fileset>
</path>
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="${src.java}">
<classpath refid="bulkLoader.compile.classpath"/>
<include name="org/freebxml/omar/client/bulkLoader/**"/>
</javac>
</target>
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"/>
You should add this to the similar properties defined in build-compile.xml.
<!-- Properties for *ar names --> <property name="browser.name" value="registry-browser"/> <property name="bulkLoader.name" value="bulk-loader"/> <property name="jaxr.admin.name" value="jaxr-ebxml-admin"/> <property name="jaxr.provider.name" value="jaxr-ebxml"/> <property name="jaxr.test.name" value="jaxr-ebxml-test"/>
The created jar file should include a manifest that:
<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"
setonempty="false"
dirsep="/" pathsep=" "
refid="bulkLoader.run.classpath">
<map from="${build.lib}${file.separator}"
to=""/>
</pathconvert>
<manifest file="${build.lib}/bulk-loader.manifest"
mode="replace">
<attribute name="Main-Class"
value="org.freebxml.omar.client.bulkLoader.BulkLoaderTool"/>
<attribute name="Class-Path"
value="${bulkLoader.manifest.classpath}"/>
<attribute name="Build-Time"
value="${DSTAMP}${TSTAMP}"/>
<section name="com/sun/xml/registry/client/bulkLoader">
<attribute name="Specification-Title"
value="Bulk Loader"/>
<attribute name="Specification-Version"
value="${dist.version}"/>
<attribute name="Specification-Vendor"
value="freebxml"/>
<attribute name="Implementation-Title"
value="Bulk Loader"/>
<attribute name="Implementation-Version"
value="${dist.version}"/>
<attribute name="Implementation-Vendor"
value="freebxml"/>
<attribute name="Implementation-URL"
value="http://ebxmlrr.sourceforge.net/"/>
</section>
</manifest>
<copy todir="${build.lib}/classes" file="conf/log4j.properties"/>
<copy todir="${build.lib}/classes/META-INF"
file="conf/mime.types"/>
<jar manifest="${build.lib}/bulk-loader.manifest"
jarfile="${build.lib}/${bulkLoader.name}.jar"
basedir="${build.lib}/classes">
<metainf dir="${build.lib}/classes/META-INF">
<include name="mime.types"/>
</metainf>
<include name="org/freebxml/omar/client/bulkLoader/**"/>
<include name="commons-logging.properties"/>
<include name="log4j.properties"/>
</jar>
</target>
Once you do this, the new jar target will be compiled along with the other jars whenever the 'jars' target is run.
<target name="jars"
depends="jar.ebxml.provider, jar.browser, jar.adminTool, jar.bulkLoader, jar.ebxml.provider.tests"
description="Build jar files"/>