Knopflerfish OSGi 5.2.0

Class Bundle

  extended by
      extended by
          extended by
              extended by
                  extended by
                      extended by org.knopflerfish.ant.taskdefs.bundle.Bundle
All Implemented Interfaces:

public class Bundle

An extension of the Jar task that builds an OSGi bundle. It can generate the Bundle-Activator, Bundle-ClassPath and Import-Package manifest headers based on the content specified in the task.


Attribute Description Required
file The bundle file to create. Yes
activator The bundle activator class name. If set to "none" no Bundle-Activator manifest header will be generated. If set to "auto" the bundle task will try to find an activator in the included class files. No, default is "auto"
packageanalysis Analyzes the class files of the bundle and the contents of the exportpackage and importpackage nested elements.
  • none – no analysis is performed.
  • warn – a warning will be displayed for each referenced package not found in the bundle or the importpackage nested elements.
  • auto – each referenced package not found in the bundle or the importpackage nested elements will be added to the Import-Package manifest header. Packages exported by the bundle will be added to the Import-Package manifest header with a version range following the OSGi versioning recommendation (if a package is incompatible with previous version then the major number of the version must be incremented). E.g., if the bundles exports version 1.0.2 the version range in the import will be "[1.0.2,2)".
No, default is "warn"

Nested elements


The nested classes element specifies a ZipFileSet. The prefix attribute will be added to the Bundle-ClassPath manifest header. The classes specified by the file set will be included in the class analysis.


The nested lib element specifies a ZipFileSet. The locations of all files in the file set will be added to the Bundle-ClassPath manifest header. All files of this file set must be either zip or jar files. The classes available in the zip or jar files will be included in the class analysis.


The nested exportpackage element specifies the name and version of a package to add to the Export-Package manifest header. If package analysis is not turned off, a warning will be issued if the specified package cannot be found in the bundle. When package analysis is turned on the version from the packageinfo-file in the directory of the package is read and used as the version of the exported package. In this case, if a version is specified in the exportpackage element that version is compared with the one from the packageinfo-file and if there is a mismatch a build error will be issued.


The nested importpackage element specifies the name and version of a package to add to the Import-Package manifest header.


The nested standardpackage element specifies the name or prefix of a package that should be excluded from the package analysis. It can be used to avoid importing packages that are available in the underlying runtime environment (i.e., via boot delegation).

Implicit file set

The implicit fileset is specified by the baseDir attribute of the bundle task and the nested include and exclude elements.

The implicit fileset of the bundle task will be included in the class analysis and in the Bundle-ClassPath manifest header if needed.


 <bundle activator="auto"

   <standardpackage name="javax.imageio"/>

   <exportpackage name="se.weilenmann.bundle.test" version="1.0"/>

     <attribute name="Bundle-Name" value="testbundle"/>
     <attribute name="Bundle-Version" value="1.0"/>
     <attribute name="Bundle-Vendor" value="Kaspar Weilenmann"/>

   <classes dir="out/classes">
     <include name="se/weilenmann/bundle/test/**"/>
   <classes dir="out/classes" prefix="util">
     <include name="se/weilenmann/util/**"/>
   <classes src="osgi/jars/log/log_api.jar" prefix="log_api">
     <include name="**/*.class"/>

   <lib dir="osgi/jars/cm" includes="cm_api.jar" prefix="osgi"/>
   <lib dir="lib/commons" includes="commons-logging.jar" prefix="commons"/>


Creates a bundle with the following manifest:

 Manifest-Version: 1.0
 Ant-Version: Apache Ant 1.6.2
 Created-By: 1.4.2_02-b03 (Sun Microsystems Inc.)
 Bundle-Name: testbundle
 Bundle-Version: 1.0
 Bundle-Vendor: Kaspar Weilenmann
 Bundle-Activator: se.weilenmann.bundle.test.Activator
 Bundle-ClassPath: .,util,log_api,osgi/cm_api.jar,commons/commons-loggi
 Import-Package: se.weilenmann.bundle.test;specification-version=1.0,or
 Export-Package: se.weilenmann.bundle.test;specification-version=1.0

Kaspar Weilenmann

Nested Class Summary
Nested classes/interfaces inherited from class,
Nested classes/interfaces inherited from class,,,,
Field Summary
Fields inherited from class
addedDirs, archiveType, doubleFilePass, duplicate, emptyBehavior, entries, skipWriting, zipFile
Fields inherited from class
Fields inherited from class
target, taskName, taskType, wrapper
Fields inherited from class
description, location, project
Constructor Summary
Method Summary
 void addClasses( fileset)
 void addConfiguredExportPackage(OSGiPackage osgiPackage)
 void addConfiguredImportPackage(OSGiPackage osgiPackage)
 void addConfiguredLib( fileset)
 void addConfiguredStandardPackage(OSGiPackage osgiPackage)
 void addZipfileset( fileset)
 void addZipGroupFileset( fileset)
protected  void analyze( res)
          Analyze a resource by checking its suffix and delegate to analyzeClass(Resource), analyzeJar(Resource), etc.
protected  void analyzeClass( res)
protected  void analyzeJar( res)
protected  void analyzePackageinfo( res)
 void execute()
 void setActivator(java.lang.String activator)
 void setBasedir( baseDir)
 void setPackageAnalysis(java.lang.String packageAnalysis)
Methods inherited from class
addConfiguredIndexJars, addConfiguredManifest, addConfiguredService, addMetainf, cleanUp, createEmptyZip, finalizeZipOutputStream, findJarName, getResourcesToAdd, grabFilesAndDirs, initZipOutputStream, reset, setFilesetmanifest, setFlattenAttributes, setIndex, setIndexMetaInf, setJarfile, setManifest, setManifestEncoding, setMergeClassPathAttributes, setStrict, setWhenempty, setWhenmanifestonly, writeIndexLikeList, zipFile
Methods inherited from class
add, addFileset, addParentDirs, addResources, addResources, executeMain, getComment, getCreateUnicodeExtraFields, getCurrentExtraFields, getDestFile, getEncoding, getFallBackToUTF8, getLevel, getNonFileSetResourcesToAdd, getPreserve0Permissions, getResourcesToAdd, getUseLanguageEnodingFlag, getZip64Mode, grabNonFileSetResources, grabResources, hasUpdatedFile, isAddingNewFiles, isCompress, isEmpty, isFirstPass, isInUpdateMode, logWhenWriting, selectDirectoryResources, selectFileResources, selectResources, setComment, setCompress, setCreateUnicodeExtraFields, setCurrentExtraFields, setDestFile, setDuplicate, setEncoding, setFallBackToUTF8, setFile, setFilesonly, setKeepCompression, setLevel, setPreserve0Permissions, setRoundUp, setUpdate, setUseLanguageEncodingFlag, setZip64Mode, setZipfile, zipDir, zipDir, zipDir, zipFile, zipFile
Methods inherited from class
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
Methods inherited from class
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
Methods inherited from class
clone, getDescription, getLocation, getProject, setDescription, setLocation
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Bundle()
Method Detail


protected void analyze( res)
Analyze a resource by checking its suffix and delegate to analyzeClass(Resource), analyzeJar(Resource), etc.

res - The resource to be analyzed.


protected void analyzeJar( res)


protected void analyzeClass( res)


protected void analyzePackageinfo( res)


public void setActivator(java.lang.String activator)


public void setPackageAnalysis(java.lang.String packageAnalysis)


public void addConfiguredStandardPackage(OSGiPackage osgiPackage)


public void addConfiguredImportPackage(OSGiPackage osgiPackage)


public void addConfiguredExportPackage(OSGiPackage osgiPackage)


public void addConfiguredLib( fileset)


public void addClasses( fileset)


public void execute()
execute in class


public void setBasedir( baseDir)
setBasedir in class


public void addZipGroupFileset( fileset)
addZipGroupFileset in class


public void addZipfileset( fileset)
addZipfileset in class

Knopflerfish OSGi 5.2.0