You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/04/06 20:50:07 UTC

svn commit: r762453 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: SCRDescriptorMojo.java tags/JavaClassDescriptorManager.java

Author: cziegeler
Date: Mon Apr  6 18:50:06 2009
New Revision: 762453

URL: http://svn.apache.org/viewvc?rev=762453&view=rev
Log:
FELIX-1010 : Make use of qdox and annotations configurable, both are enabled by default.

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=762453&r1=762452&r2=762453&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java Mon Apr  6 18:50:06 2009
@@ -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());

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=762453&r1=762452&r2=762453&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java Mon Apr  6 18:50:06 2009
@@ -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);
                         }