Excerpt | ||
---|---|---|
| ||
Using the Apache Felix SCR Ant Task to generate Declarative Services and Metatype Service descriptors during an Ant driven Build. |
...
The
...
The description on this page is based on unreleased software which must be built from the Apache Felix trunk. A release will be available shortly.
The SCR Ant Task is implemented in the org.apache.felix.scr.ant
library which must be registered as an Ant Task in the build file as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
<project ...> <taskdef resource="scrtask.properties" classpath="org.apache.felix.scr.ant-1.0.0.1-SNAPSHOT.jar" /> </project> |
Of course the value you set in the classpath
attribute depends on the actual location of the org.apache.felix.scr.ant
JAR file.
The SCR Ant Task is available for download from the Apache Felix Downloads page.
Notes:
- The name of the task is
scr
- The task requires that the source files have already been compiled
...
Attribute | Required | Default | Description |
---|---|---|---|
scrdir | Yes | – | The root directory of the implicitly defined fileset denoting the files to consider for annotation and/or JavaDoc tag processing. |
destdir | Yes | – | The name of the directory where the descriptor files are generated into. This is also used as the directory where the compiled classes from the |
classpath | No | – | The class path used to load classes from to analyse for the descriptor file generation. Generally this will be the same class path as the one used to compile the sources. |
classpathRef | No | – | A reference to a class path used to load classes from to analyse for the descriptor file generation. Generally this will be the same class path as the one used to compile the sources. |
finalName | No | | The name of the descriptor file to create. This file is always located inside the |
metaTypeName | No | | The name of the descriptor file to create. This file is always located inside the |
generateAccessors | No | | If this switch is turned on, the bind and unbind methods for unary references are automatically generated by the plugin. |
annotationTagProviders | No | – | List of fully qualified class names providing more Annotation Tag Providers. As of version 1.4.0 of the SCR Annotations library this configuration element is optional if the SCR Annotations library comes with a proper SPI setup (see Extending SCR Annotations) |
specVersion | No | Auto-Detected | The plugin will generate a descriptor for the Declarative Service version (either 1.0 or 1.1). If no value is specified, the plugin will detect the version and only use 1.1 if features from this version are used. |
The scr
task must be provided with the same class path as was used to compile the sources. The classes in the class path are used by the task to be able to load compiled classes (mostly for Java 5 annotation processing) and any base classes, which may be extended. The easiest way to share the class path is to define a class path property and refer to it with the classpathref
attribute of the scr
task.
Using JavaDoc Tags
JavaDoc tags are supported natively by the SCR Ant Task. No further configuration and/or libraries are needed.
Java 5 Annotations
To use Java 5 Annotations make sure the library defining the annotations is available on the class path for both the compilation in the javac
task and for generating the descriptor in the scr
task.
No further configuration is required as the SCR Ant Task automatically recognizes SCR Annotation definitions from libraries in the class path provided the annotations are provided in a JAR library with properly setup SPI configuration as documented in Extending SCR Annotations.
Example
The following is very simple example build file based on the Apache Sling JCR WebConsole bundle:
...