FELIX-1010 : Make use of qdox and annotations configurable, both are enabled by default.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@762453 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index c1fa0a7..2e6f3b4 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -81,6 +81,20 @@
private boolean generateAccessors;
/**
+ * This flag controls whether the javadoc source code will be scanned for
+ * tags.
+ * @parameter default-value="true"
+ */
+ protected boolean parseJavadoc;
+
+ /**
+ * This flag controls whether the annotations in the sources will be
+ * processed.
+ * @parameter default-value="true"
+ */
+ protected boolean processAnnotations;
+
+ /**
* The comma separated list of tokens to exclude when processing sources.
*
* @parameter alias="excludes"
@@ -111,13 +125,17 @@
public void execute() throws MojoExecutionException, MojoFailureException {
this.getLog().debug("Starting SCRDescriptorMojo....");
this.getLog().debug("..generating accessors: " + this.generateAccessors);
+ this.getLog().debug("..parsing javadocs: " + this.parseJavadoc);
+ this.getLog().debug("..processing annotations: " + this.processAnnotations);
boolean hasFailures = false;
JavaClassDescriptorManager jManager = new JavaClassDescriptorManager(this.getLog(),
this.project,
this.annotationTagProviders,
- this.sourceExcludes);
+ this.sourceExcludes,
+ this.parseJavadoc,
+ this.processAnnotations);
// iterate through all source classes and check for component tag
final JavaClassDescription[] javaSources = jManager.getSourceDescriptions();
Arrays.sort(javaSources, new JavaClassDescriptionInheritanceComparator());
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
index 1d060c6..f4e940f 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
@@ -74,19 +74,32 @@
*/
protected final AnnotationTagProviderManager annotationTagProviderManager;
+ /** Parse Javadocs? */
+ protected final boolean parseJavadocs;
+
+ /** Process Annotations? */
+ protected final boolean processAnnotations;
+
/**
* Construct a new manager.
* @param log
* @param project
* @param annotationTagProviders List of annotation tag providers
+ * @param excludeString The exclude information for sources
+ * @param parseJavadocs Should the javadocs be parsed?
+ * @param processAnnotations Should the annotations be processed?
* @throws MojoFailureException
* @throws MojoExecutionException
*/
public JavaClassDescriptorManager(final Log log,
final MavenProject project,
- final String[] annotationTagProviders,
- final String excludeString)
+ final String[] annotationTagProviders,
+ final String excludeString,
+ final boolean parseJavadocs,
+ final boolean processAnnotations)
throws MojoFailureException, MojoExecutionException {
+ this.processAnnotations = processAnnotations;
+ this.parseJavadocs = parseJavadocs;
this.log = log;
this.project = project;
this.annotationTagProviderManager = new AnnotationTagProviderManager(annotationTagProviders);
@@ -361,17 +374,7 @@
final JavaClassDescription[] descs = new JavaClassDescription[this.sources.length];
for(int i=0; i<this.sources.length; i++) {
final String className = this.sources[i].getClasses()[0].getFullyQualifiedName();
- try {
- // check for java annotation descriptions - fallback to QDox if none found
- Class clazz = this.classloader.loadClass(className);
- if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
- descs[i] = new AnnotationJavaClassDescription(clazz, this.sources[i], this);
- } else {
- descs[i] = new QDoxJavaClassDescription(clazz, this.sources[i], this);
- }
- } catch (ClassNotFoundException e) {
- throw new MojoExecutionException("Unable to load class " + className);
- }
+ descs[i] = this.getJavaClassDescription(className);
}
return descs;
}
@@ -393,10 +396,10 @@
try {
// check for java annotation descriptions - fallback to QDox if none found
Class clazz = this.classloader.loadClass(className);
- if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
+ if (this.processAnnotations && getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
this.log.debug("Found java annotation description for: " + className);
result = new AnnotationJavaClassDescription(clazz, this.sources[index], this);
- } else {
+ } else if ( this.parseJavadocs ) {
this.log.debug("Found qdox description for: " + className);
result = new QDoxJavaClassDescription(clazz, this.sources[index], this);
}