Knopflerfish OSGi 5.2.0

org.knopflerfish.ant.taskdefs.bundle
Class Bundle

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by org.apache.tools.ant.taskdefs.Zip
                  extended by org.apache.tools.ant.taskdefs.Jar
                      extended by org.knopflerfish.ant.taskdefs.bundle.Bundle
All Implemented Interfaces:
java.lang.Cloneable, 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.

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 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

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 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.

importpackage

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

standardpackage

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.

Examples

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

   <standardpackage name="javax.imageio"/>

   <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/interfaces inherited from class org.apache.tools.ant.taskdefs.Jar
org.apache.tools.ant.taskdefs.Jar.FilesetManifestConfig, org.apache.tools.ant.taskdefs.Jar.StrictMode
 
Nested classes/interfaces 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.UnicodeExtraField, org.apache.tools.ant.taskdefs.Zip.WhenEmpty, org.apache.tools.ant.taskdefs.Zip.Zip64ModeAttribute
 
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
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, 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 addConfiguredStandardPackage(OSGiPackage osgiPackage)
           
 void addZipfileset(org.apache.tools.ant.types.ZipFileSet fileset)
           
 void addZipGroupFileset(org.apache.tools.ant.types.FileSet fileset)
           
protected  void analyze(org.apache.tools.ant.types.Resource res)
          Analyze a resource by checking its suffix and delegate to analyzeClass(Resource), analyzeJar(Resource), etc.
protected  void analyzeClass(org.apache.tools.ant.types.Resource res)
           
protected  void analyzeJar(org.apache.tools.ant.types.Resource res)
           
protected  void analyzePackageinfo(org.apache.tools.ant.types.Resource res)
           
 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, 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 org.apache.tools.ant.taskdefs.Zip
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 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
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 org.apache.tools.ant.ProjectComponent
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

Bundle

public Bundle()
Method Detail

analyze

protected void analyze(org.apache.tools.ant.types.Resource res)
                throws org.apache.tools.ant.BuildException
Analyze a resource by checking its suffix and delegate to analyzeClass(Resource), analyzeJar(Resource), etc.

Parameters:
res - The resource to be analyzed.
Throws:
org.apache.tools.ant.BuildException

analyzeJar

protected void analyzeJar(org.apache.tools.ant.types.Resource res)
                   throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

analyzeClass

protected void analyzeClass(org.apache.tools.ant.types.Resource res)
                     throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

analyzePackageinfo

protected void analyzePackageinfo(org.apache.tools.ant.types.Resource res)
                           throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

setActivator

public void setActivator(java.lang.String activator)

setPackageAnalysis

public void setPackageAnalysis(java.lang.String packageAnalysis)

addConfiguredStandardPackage

public void addConfiguredStandardPackage(OSGiPackage osgiPackage)

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()
Overrides:
execute in class org.apache.tools.ant.taskdefs.Zip

setBasedir

public void setBasedir(java.io.File baseDir)
Overrides:
setBasedir in class org.apache.tools.ant.taskdefs.Zip

addZipGroupFileset

public void addZipGroupFileset(org.apache.tools.ant.types.FileSet fileset)
Overrides:
addZipGroupFileset in class org.apache.tools.ant.taskdefs.Zip

addZipfileset

public void addZipfileset(org.apache.tools.ant.types.ZipFileSet fileset)
Overrides:
addZipfileset in class org.apache.tools.ant.taskdefs.Zip

Knopflerfish OSGi 5.2.0