|
Knopflerfish OSGi 3.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.ProjectComponent org.apache.tools.ant.Task org.knopflerfish.ant.taskdefs.bundle.BundleInfoTask
public class BundleInfoTask
Task that analyzes a set of java sources or class files, and lists all imported and defined packages. Also tries to find any class implementing org.osgi.framework.BundleActivator.
Java class files are analyzed using the ASM library.
Note: Scanning only applies
to the listed files - a complete closure of all referenced classes is
not done.
Java source code is analyzed using very simple line-based scanning of
files.
Note: Source code analysis does not attempt to find any
BundleActivator
All classes in jar files are analysed.
Attribute | Description | Required |
imports | Name of property that will receive a comma-separated list
of all used packages.
If set to empty string, no property will be set. Note: Some default packages are always added. These defaults can be set using the defaultimports parameter. |
No. Default value is "" |
exports | Name of property that will receive a comma-separated
list of all defined packages.
If set to empty string, no property will be set. |
No. Default value is "" |
activator |
Name of property that will receive name of class which implements
org.osgi.framework.BundleActivator
If set to empty string, no property will be set. If set to non-empty, and multiple activators are found, or an activator not equal to any previous content in the named property is found - a warning will be logged. |
No. Default value is "" |
stdimports |
Comma-separated list of package name prefixes for referenced
packages that shall not be included in the Import-Package
manifest attribute.
Example of packages to list in this attribute are
|
No. Default value is "java." |
defaultimports | Comma-separated list of packages that will be unconditionally added to the derived set of packages that the bundle needs to import. |
No. Default value is "" |
extraimports | Comma-separated list of package names that must be present in the import list even though they are not explicitly referenced from the bundles code. E.g., packages from which all classes are loaded using reflection. |
No. Default value is "" |
importsOnly | If set to true then do not update Export-Package manifest header. | No. Default value is "false". |
implicitImports |
Flag for adding all exported packages to the import list.
If set to "true", the task will add all packages mentioned in
the property named by |
No. Default value is "true" |
serviceComponent |
The value of the Service-Component manifest header.
If set to non-empty, leave the value of the activator property untouched and do not complain if there are no class that implements BundleActivator in the bundle. |
No. Default value is "" |
fragmentHost |
The value of the Fragment-Host manifest header.
If set to non-empty (i.e., this is a fragment bundle), leave the value of the activator property untouched and do not complain if there are no class that implements BundleActivator in the bundle. |
No. Default value is "" |
manifestVersion |
The value of the Bundle-ManifestVersion manifest header.
If set to "2" and the uses attribute is also true then a "uses" directive is computed and added to each package in the Export-Package header generated by this task. |
No. Default value is "1" (pre OSGi R4 bundle). |
uses |
If set to true then add / update uses
directive in the value of the Export-Package manifest header.
Note that uses-directives are not added for pre OSGi R4 bundle. That is for bundle with manifestVersion less than "2". |
No. Default value is "true". |
checkMinimumEE |
Flag for testing for the Minum Execution Environment
If set to "true", the task will check if all used classes is in the set of the Minimum Execution Environment. |
No. Default value is "false" |
checkSMFEE |
Flag for testing for the SMF Execution Environment
If set to "true", the task will check if all used classes is in the set of the SMF profile Execution Environment. |
No. Default value is "false" |
checkFoundationEE |
Flag for testing for the Foundation Execution Environment
If set to "true", the task will check if all used classes is in the set of the OSGi Foundation Execution Environment. |
No. Default value is "false" |
failOnExports | If an error is detected in the given export package header and this attibute is set to true then a build failure is trigger. |
No. Default value is "true" |
failOnImports | If an error is detected in the given import package header and this attibute is set to true then a build failure is trigger. |
No. Default value is "true" |
failOnActivator | If an error is detected in the given bundle activator header and this attibute is set to true then a build failure is trigger. |
No. Default value is "true" |
All files must be specified as a fileset. Unsupported file types are ignored.
This example assumes all implemention classes are in the package test.impl.*
<bundleinfo activator = "bmfa.Bundle-Activator" imports = "impl.import.package"> <fileset dir="classes" includes="test/impl/*"/> </bundleinfo> <echo message="imports = ${impl.import.package}"/> <echo message="activator = ${bmfa.Bundle-Activator}"/>
This example assumes all API classes are in the package test.*
<bundleinfo exports = "api.export.package" imports = "api.import.package"> <fileset dir="classes" includes="test/*"/> </bundleinfo> <echo message="imports = ${api.import.package}"/> <echo message="exports = ${api.export.package}"/>
Field Summary |
---|
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 | |
---|---|
BundleInfoTask()
|
Method Summary | |
---|---|
void |
addFileset(org.apache.tools.ant.types.FileSet set)
|
protected void |
analyze(java.io.File file)
Analyze a file by checking its suffix and delegate to analyzeClass, analyzeJava etc |
protected void |
analyzeClass(java.io.File file)
|
protected void |
analyzeJar(java.io.File file)
|
protected void |
analyzeJava(java.io.File file)
Analyze java source file by reading line by line and looking for keywords such as "import", "package". |
protected java.lang.String |
buildExportPackagesValue(java.util.Set exportPackages)
Return the value of the Export-Package based on the analyzis. |
void |
execute()
|
protected boolean |
isImported(java.lang.String className)
|
protected boolean |
isStdImport(java.lang.String name)
Check if package is included in the prefix list of packages that does not need to be in the Import-Package list. |
void |
setActivator(java.lang.String propName)
Set property receiving any BundleActivator class. |
void |
setCheckFoundationEE(java.lang.String s)
|
void |
setCheckMinimumEE(java.lang.String s)
|
void |
setCheckSMFEE(java.lang.String s)
|
void |
setDefaultImports(java.lang.String packageList)
Set default import set. |
void |
setExports(java.lang.String propName)
Set property receiving list of exported packages. |
void |
setExtraImports(java.lang.String packageList)
Set the extra imports set. |
void |
setFailOnActivator(boolean b)
|
void |
setFailOnExports(boolean b)
|
void |
setFailOnImports(boolean b)
|
void |
setFragmentHost(java.lang.String fragmentHost)
Set value of the Fragment-Host manifest header. |
void |
setImplicitImports(java.lang.String s)
|
void |
setImports(java.lang.String s)
Set property receiving list of imported packages. |
void |
setImportsOnly(boolean importsOnly)
If set to true then do not update Export-Package manifest header. |
void |
setMain(java.lang.String propName)
Set property receiving any Main class. |
void |
setManifestVersion(java.lang.String manifestVersion)
Set value of the Bundle-ManifestVersion manifest header. |
void |
setPrintClasses(java.lang.String s)
|
void |
setServiceComponent(java.lang.String serviceComponent)
Set name value of the Service-Component manifest header. |
void |
setStdImports(java.lang.String packageList)
Set set of packages always imported. |
void |
setUses(boolean uses)
Shall uses directives be added to the Export-Package header or not. |
protected static java.lang.String |
toString(java.util.Set set,
java.lang.String separator)
Convert Set elements to a string. |
protected java.lang.String |
validateExportPackagesValue(java.lang.String oldExportsVal)
Validate a given Export-Package header value. |
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, setProject |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BundleInfoTask()
Method Detail |
---|
public void setImports(java.lang.String s)
public void setPrintClasses(java.lang.String s)
public void setCheckFoundationEE(java.lang.String s)
public void setCheckMinimumEE(java.lang.String s)
public void setCheckSMFEE(java.lang.String s)
public void setFailOnExports(boolean b)
public void setFailOnImports(boolean b)
public void setFailOnActivator(boolean b)
public void setImplicitImports(java.lang.String s)
public void setDefaultImports(java.lang.String packageList)
packageList
- Comma-separated list of package names.public void setExtraImports(java.lang.String packageList)
packageList
- Comma-separated list of package names.public void setExports(java.lang.String propName)
public void setActivator(java.lang.String propName)
public void setServiceComponent(java.lang.String serviceComponent)
public void setFragmentHost(java.lang.String fragmentHost)
public void setManifestVersion(java.lang.String manifestVersion)
public void setUses(boolean uses)
public void setMain(java.lang.String propName)
Not yet implemented.
public void setStdImports(java.lang.String packageList)
packageList
- Comma-separated list of package names.public void addFileset(org.apache.tools.ant.types.FileSet set)
public void setImportsOnly(boolean importsOnly)
public void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
protected java.lang.String buildExportPackagesValue(java.util.Set exportPackages)
exportPackages
- The set of provided packages to export.protected java.lang.String validateExportPackagesValue(java.lang.String oldExportsVal)
oldExportsVal
- the Export-Package value to validate and update.protected void analyze(java.io.File file) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected boolean isImported(java.lang.String className)
protected boolean isStdImport(java.lang.String name)
protected void analyzeJar(java.io.File file) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected void analyzeClass(java.io.File file) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
protected void analyzeJava(java.io.File file) throws org.apache.tools.ant.BuildException
Note: This code does not attempt to find any class implementing BundleActivator
org.apache.tools.ant.BuildException
protected static java.lang.String toString(java.util.Set set, java.lang.String separator)
separator
- String to use as sperator between elements.
|
Knopflerfish OSGi 3.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |