org.knopflerfish.ant.taskdefs.bundle
Class Bundle
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.apache.tools.ant.taskdefs.Zip
org.apache.tools.ant.taskdefs.Jar
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 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.
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.
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">
<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 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.WhenEmpty |
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 |
Methods inherited from class org.apache.tools.ant.taskdefs.Jar |
addConfiguredIndexJars, addConfiguredManifest, addConfiguredService, addMetainf, cleanUp, createEmptyZip, finalizeZipOutputStream, findJarName, getResourcesToAdd, grabFilesAndDirs, initZipOutputStream, reset, setFilesetmanifest, setIndex, setJarfile, setManifest, setManifestEncoding, setStrict, setWhenempty, setWhenmanifestonly, writeIndexLikeList, zipFile |
Methods inherited from class org.apache.tools.ant.taskdefs.Zip |
add, addFileset, addParentDirs, addResources, addResources, executeMain, getComment, getDestFile, getEncoding, getLevel, getNonFileSetResourcesToAdd, getResourcesToAdd, grabNonFileSetResources, grabResources, hasUpdatedFile, isAddingNewFiles, isCompress, isEmpty, isInUpdateMode, selectFileResources, setComment, setCompress, setDestFile, setDuplicate, setEncoding, setFile, setFilesonly, setKeepCompression, setLevel, setRoundUp, setUpdate, setZipfile, zipDir, 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 |
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 |
Bundle
public Bundle()
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