Creating an OSGi application using Apache Ant

You can use the Apache Ant (Ant) command-line tool to package bundles together into an OSGi application.

Before you begin

This topic assumes that you understand how to use the Ant build tooling, and that you have already created the bundles and the application manifest file that you want to package together as an OSGi application.

For a detailed overview of creating an OSGi application, and instructions on how to do this using Rational® Application Developer or similar tooling, see Creating an OSGi application.

About this task

The code example in this topic shows the syntax for using the Ant zip task to package a set of bundles and an application manifest (APPLICATION.MF) file into an enterprise bundle archive (.eba) file.

Example

<zip destfile="${output.dir}/myExample.eba" basedir="${basedir}">
    <filename name="META-INF/APPLICATION.MF"/>
    <fileset dir="${basedir}">
        <include name="*.jar"/>
    </fileset>
</zip>

This example packages the META-INF/APPLICATION.MFfile into the EBA file, and also includes all files ending in .jar (that is, the bundles).

${output.dir} and ${basedir} refer to the following Ant properties:
  • output.dir is user-defined, and specifies the output directory for your build.
  • basedir is predefined, and specifies the directory that contains the Ant build.xml file.

What to do next

You can use the administrative console or wsadmin commands to deploy and start an OSGi application in WebSphere® Application Server. See Deploying an OSGi application as a business-level application.