org.knopflerfish.ant.taskdefs.bundle
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.
| 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.
|
No, default is "warn" |
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).
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"
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
org.apache.tools.ant.taskdefs.Jar.FilesetManifestConfig, org.apache.tools.ant.taskdefs.Jar.StrictModeorg.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| Constructor and Description |
|---|
Bundle() |
| Modifier and Type | Method and Description |
|---|---|
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) |
addConfiguredIndexJars, addConfiguredManifest, addConfiguredService, addMetainf, cleanUp, createEmptyZip, finalizeZipOutputStream, findJarName, getResourcesToAdd, grabFilesAndDirs, initZipOutputStream, reset, setFilesetmanifest, setFlattenAttributes, setIndex, setIndexMetaInf, setJarfile, setManifest, setManifestEncoding, setMergeClassPathAttributes, setStrict, setWhenempty, setWhenmanifestonly, writeIndexLikeList, zipFileadd, 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, zipFileadd, 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, XsetItemsbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeprotected void analyze(org.apache.tools.ant.types.Resource res)
throws org.apache.tools.ant.BuildException
analyzeClass(Resource), analyzeJar(Resource), etc.res - The resource to be analyzed.org.apache.tools.ant.BuildExceptionprotected void analyzeJar(org.apache.tools.ant.types.Resource res)
throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionprotected void analyzeClass(org.apache.tools.ant.types.Resource res)
throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionprotected void analyzePackageinfo(org.apache.tools.ant.types.Resource res)
throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionpublic 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(org.apache.tools.ant.types.ZipFileSet fileset)
public void addClasses(org.apache.tools.ant.types.ZipFileSet fileset)
public void execute()
execute in class org.apache.tools.ant.taskdefs.Zippublic void setBasedir(java.io.File baseDir)
setBasedir in class org.apache.tools.ant.taskdefs.Zippublic void addZipGroupFileset(org.apache.tools.ant.types.FileSet fileset)
addZipGroupFileset in class org.apache.tools.ant.taskdefs.Zippublic void addZipfileset(org.apache.tools.ant.types.ZipFileSet fileset)
addZipfileset in class org.apache.tools.ant.taskdefs.Zip