Knopflerfish OSGi 1.3.3

org.knopflerfish.ant.taskdefs.bundle
Class Bundle

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.tools.ant.taskdefs.MatchingTask
              extended byorg.apache.tools.ant.taskdefs.Zip
                  extended byorg.apache.tools.ant.taskdefs.Jar
                      extended byorg.knopflerfish.ant.taskdefs.bundle.Bundle
All Implemented Interfaces:
org.apache.tools.ant.types.selectors.SelectorContainer

public class Bundle
extends org.apache.tools.ant.taskdefs.Jar

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.

Note: This task depends on the Apache Jakarta BCEL library, not included in the Ant distribution.

Parameters

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 the version as specified in the exportpackage nested element.
No, default is "warn"

Nested elements

classes

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.

lib

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.

exportpackage

The nested exportpackage element specifies the name and specification 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.

importpackage

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

Implicit fileset

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.

Examples

 <bundle activator="auto"
         packageanalysis="auto"
         file="out/${ant.project.name}.jar">

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

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

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

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

 </bundle>
 

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
 ng.jar
 Import-Package: se.weilenmann.bundle.test;specification-version=1.0,or
 g.osgi.framework
 Export-Package: se.weilenmann.bundle.test;specification-version=1.0
 

Author:
Kaspar Weilenmann

Nested Class Summary
 
Nested classes inherited from class org.apache.tools.ant.taskdefs.Jar
org.apache.tools.ant.taskdefs.Jar.FilesetManifestConfig
 
Nested classes inherited from class org.apache.tools.ant.taskdefs.Zip
org.apache.tools.ant.taskdefs.Zip.ArchiveState, org.apache.tools.ant.taskdefs.Zip.Duplicate, org.apache.tools.ant.taskdefs.Zip.WhenEmpty
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.taskdefs.Zip
addedDirs, archiveType, doubleFilePass, duplicate, emptyBehavior, entries, skipWriting, zipFile
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Bundle()
           
 
Method Summary
 void addClasses(org.apache.tools.ant.types.ZipFileSet fileset)
           
 void addConfiguredExportPackage(OSGiPackage osgiPackage)
           
 void addConfiguredImportPackage(OSGiPackage osgiPackage)
           
 void addConfiguredLib(org.apache.tools.ant.types.ZipFileSet fileset)
           
 void addZipfileset(org.apache.tools.ant.types.ZipFileSet fileset)
           
 void addZipGroupFileset(org.apache.tools.ant.types.FileSet fileset)
           
 void execute()
           
 void setActivator(java.lang.String activator)
           
 void setBasedir(java.io.File baseDir)
           
 void setPackageAnalysis(java.lang.String packageAnalysis)
           
 
Methods inherited from class org.apache.tools.ant.taskdefs.Jar
addConfiguredIndexJars, addConfiguredManifest, addMetainf, cleanUp, createEmptyZip, finalizeZipOutputStream, findJarName, getResourcesToAdd, grabFilesAndDirs, initZipOutputStream, reset, setFilesetmanifest, setIndex, setJarfile, setManifest, setManifestEncoding, setWhenempty, writeIndexLikeList, zipFile
 
Methods inherited from class org.apache.tools.ant.taskdefs.Zip
addFileset, addParentDirs, addResources, executeMain, getDestFile, getEncoding, grabResources, isAddingNewFiles, isCompress, isEmpty, isInUpdateMode, selectFileResources, setCompress, setDestFile, setDuplicate, setEncoding, setFile, setFilesonly, setKeepCompression, setRoundUp, setUpdate, setZipfile, zipDir, zipFile
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
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 org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bundle

public Bundle()
Method Detail

setActivator

public void setActivator(java.lang.String activator)

setPackageAnalysis

public void setPackageAnalysis(java.lang.String packageAnalysis)

addConfiguredImportPackage

public void addConfiguredImportPackage(OSGiPackage osgiPackage)

addConfiguredExportPackage

public void addConfiguredExportPackage(OSGiPackage osgiPackage)

addConfiguredLib

public void addConfiguredLib(org.apache.tools.ant.types.ZipFileSet fileset)

addClasses

public void addClasses(org.apache.tools.ant.types.ZipFileSet fileset)

execute

public void execute()

setBasedir

public void setBasedir(java.io.File baseDir)

addZipGroupFileset

public void addZipGroupFileset(org.apache.tools.ant.types.FileSet fileset)

addZipfileset

public void addZipfileset(org.apache.tools.ant.types.ZipFileSet fileset)

Knopflerfish OSGi 1.3.3