You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2013/01/27 13:20:14 UTC

svn commit: r1439070 - in /uima/sandbox/uimafit/trunk: uimafit-maven-plugin/ uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/ uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ uimafit-maven-plugin/src/main/java/org/apac...

Author: rec
Date: Sun Jan 27 12:20:13 2013
New Revision: 1439070

URL: http://svn.apache.org/viewvc?rev=1439070&view=rev
Log:
[UIMA-2599] Fill description of component and parameters from JavaDoc 
- uimafit-maven-plugin: Workaround for MNG-5346 to fix build
- uimafit-maven-plugin: Added "enhance" mojo
- uimafit-maven-plugin: Refactoring to extract common code from "generate" and "enhance" mojo
- uimafit: moved some default values to Defaults.java. The Maven plugin can use this to check if a field has a default value or a customized value.

Added:
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java   (with props)
Modified:
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/pom.xml
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
    uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java

Modified: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/pom.xml?rev=1439070&r1=1439069&r2=1439070&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/pom.xml (original)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/pom.xml Sun Jan 27 12:20:13 2013
@@ -27,6 +27,7 @@
 	</parent>
 	<artifactId>uimafit-maven-plugin</artifactId>
 	<name>uimaFIT - Maven Plugin</name>
+	<packaging>maven-plugin</packaging>
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -34,6 +35,22 @@
 
 	<dependencies>
 		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.uima</groupId>
+			<artifactId>uimafit</artifactId>
+			<version>2.0.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.javassist</groupId>
+			<artifactId>javassist</artifactId>
+			<version>3.17.1-GA</version>
+		</dependency>
+
+		<!-- Dependencies on the Maven Plugin API and friends -->
+		<dependency>
 			<groupId>org.apache.maven</groupId>
 			<artifactId>maven-plugin-api</artifactId>
 			<version>3.0.4</version>
@@ -49,24 +66,42 @@
 			<version>2.0.10</version>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.maven.plugin-tools</groupId>
+			<artifactId>maven-plugin-annotations</artifactId>
+			<version>3.2</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
 			<groupId>org.sonatype.plexus</groupId>
 			<artifactId>plexus-build-api</artifactId>
 			<version>0.0.7</version>
 		</dependency>
+
+		<!-- Dependencies for accessing JavaDoc -->
 		<dependency>
-			<groupId>commons-io</groupId>
-			<artifactId>commons-io</artifactId>
+			<groupId>org.eclipse.jdt</groupId>
+			<artifactId>core</artifactId>
+			<version>3.2.0.666</version>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.uima</groupId>
-			<artifactId>uimafit</artifactId>
-			<version>2.0.0-SNAPSHOT</version>
+			<groupId>org.eclipse.core</groupId>
+			<artifactId>jobs</artifactId>
+			<version>3.3.0-v20070423</version>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.maven.plugin-tools</groupId>
-			<artifactId>maven-plugin-annotations</artifactId>
-			<version>3.2</version>
-			<scope>provided</scope>
+			<groupId>org.eclipse.core</groupId>
+			<artifactId>runtime</artifactId>
+			<version>3.3.100-v20070530</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.core</groupId>
+			<artifactId>resources</artifactId>
+			<version>3.3.0-v20070604</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.equinox</groupId>
+			<artifactId>common</artifactId>
+			<version>3.3.0-v20070426</version>
 		</dependency>
 	</dependencies>
 
@@ -76,8 +111,19 @@
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-plugin-plugin</artifactId>
 				<version>3.2</version>
+				<!-- BEGIN WORKAROUND http://jira.codehaus.org/browse/MNG-5346 -->
+				<configuration>
+					<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+				</configuration>
 				<executions>
 					<execution>
+						<id>mojo-descriptor</id>
+						<goals>
+							<goal>descriptor</goal>
+						</goals>
+					</execution>
+				<!-- END WORKAROUND http://jira.codehaus.org/browse/MNG-5346 -->
+					<execution>
 						<id>generated-helpmojo</id>
 						<goals>
 							<goal>helpmojo</goal>
@@ -88,7 +134,7 @@
 		</plugins>
 		<pluginManagement>
 			<plugins>
-				<!--This plugin's configuration is used to store Eclipse m2e settings 
+				<!--This plugin's configuration is used to store Eclipse m2e settings
 					only. It has no influence on the Maven build itself. -->
 				<plugin>
 					<groupId>org.eclipse.m2e</groupId>
@@ -117,5 +163,4 @@
 			</plugins>
 		</pluginManagement>
 	</build>
-	<packaging>maven-plugin</packaging>
 </project>
\ No newline at end of file

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.LoaderClassPath;
+import javassist.NotFoundException;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.annotation.Annotation;
+import javassist.bytecode.annotation.StringMemberValue;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.uima.fit.factory.ConfigurationParameterFactory;
+import org.apache.uima.fit.maven.javadoc.JavadocTextExtractor;
+import org.apache.uima.fit.maven.javadoc.ParameterDescriptionExtractor;
+import org.apache.uima.fit.maven.util.Util;
+import org.apache.uima.fit.util.ReflectionUtil;
+import org.apache.uima.resource.metadata.ConfigurationParameter;
+import org.codehaus.plexus.util.FileUtils;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+/**
+ * Enhance UIMA components with automatically generated uimaFIT annotations.
+ */
+@Mojo(name = "enhance", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresDependencyCollection = ResolutionScope.COMPILE)
+public class EnhanceMojo extends AbstractMojo {
+  @Component
+  private MavenProject project;
+
+  @Component
+  private BuildContext buildContext;
+
+  private ClassLoader componentLoader;
+
+  /**
+   * Override version in generated descriptors.
+   * 
+   * @see #componentVersion
+   */
+  @Parameter(defaultValue="true", required=true)
+  private boolean overrideComponentVersion;
+
+  /**
+   * Version to use in generated descriptors.
+   */
+  @Parameter(defaultValue="${project.version}", required=false)
+  private String componentVersion;
+
+  /**
+   * Override vendor in generated descriptors.
+   * 
+   * @see #componentVendor
+   */
+  @Parameter(defaultValue="true", required=true)
+  private boolean overrideComponentVendor;
+
+  /**
+   * Vendor to use in generated descriptors.
+   */
+  @Parameter(defaultValue="${project.organization.name}", required=false)
+  private String componentVendor;
+
+  /**
+   * Source file encoding.
+   */
+  @Parameter(defaultValue="${project.build.sourceEncoding}", required=true)
+  private String encoding;
+
+  public void execute() throws MojoExecutionException {   
+    // Get the compiled classes from this project
+    String[] files = FileUtils.getFilesFromExtension(project.getBuild().getOutputDirectory(),
+            new String[] { "class" });
+
+    componentLoader = Util.getClassloader(project, getLog());
+    
+    // Set up class pool with all the project dependencies and the project classes themselves
+    ClassPool classPool = new ClassPool(true);
+    classPool.appendClassPath(new LoaderClassPath(componentLoader));
+
+    for (String file : files) {
+      String clazzName = Util.getClassName(project, file);
+      
+      // Check if this is a UIMA component
+      Class clazz;
+      try {
+        clazz = componentLoader.loadClass(clazzName);
+        if (!Util.isComponent(componentLoader, clazz)) {
+          continue;
+        }
+      }
+      catch (ClassNotFoundException e) {
+        getLog().warn("Cannot analyze class [" + clazzName + "]", e);
+        continue;
+      } 
+      
+      // Get the Javassist class
+      CtClass ctClazz;
+      try {
+        ctClazz = classPool.get(clazzName);
+//        if (ctClazz.isFrozen()) {
+//          getLog().info("Ignoring frozen class [" + clazzName + "]");
+//          continue;
+//        }
+      }
+      catch(NotFoundException e) {
+        throw new MojoExecutionException("Class [" + clazzName + "] not found in class pool: " + 
+                ExceptionUtils.getRootCauseMessage(e), e);
+      }
+      ClassFile classFile = ctClazz.getClassFile();
+      ConstPool constPool = classFile.getConstPool();
+      
+      // Get the source file
+      String sourceFile = getSourceFile(clazzName);
+      
+      // Get the parameter name constants
+      Map<String, Field> nameFields = getParameterConstants(clazz);
+      
+      // Try to extract parameter descriptions from JavaDoc in source file
+      if (sourceFile != null) {
+        getLog().info("Enhancing class [" + clazzName + "]");
+        
+        // Parse source file so we can extract the JavaDoc
+        CompilationUnit ast = parseSource(sourceFile);
+        
+        // Fetch configuration parameters from the @ConfigurationParameter annotations in the
+        // compiled class
+        
+        for (Field field : ReflectionUtil.getFields(clazz)) {
+          // Is this a configuration parameter?
+          if (!ConfigurationParameterFactory.isConfigurationParameterField(field)) {
+            continue;
+          }
+
+//          // Extract configuration parameter information from the uimaFIT annotation
+//          // We only want to override if the description is not set yet.
+          ConfigurationParameter p = ConfigurationParameterFactory.createPrimitiveParameter(field);
+//          if (StringUtils.isNotBlank(p.getDescription())) {
+//            continue;
+//          }
+          
+          // Extract JavaDoc for this parameter from the source file
+          String pdesc = getParameterDocumentation(ast, field, nameFields.get(p.getName()));
+          if (pdesc == null) {
+            getLog().warn("No description found for parameter [" + p.getName() + "]");
+            continue;
+          }
+          
+          // Update the "description" field of the annotation
+          try {
+            CtField ctField = ctClazz.getField(field.getName());
+            AnnotationsAttribute annoAttr = (AnnotationsAttribute) ctField.getFieldInfo()
+                    .getAttribute(AnnotationsAttribute.visibleTag);
+            
+            // Locate and update annotation
+            if (annoAttr != null) {
+              Annotation[] annotations = annoAttr.getAnnotations();
+              for (Annotation a : annotations) {
+                if (a.getTypeName().equals("org.apache.uima.fit.descriptor.ConfigurationParameter")
+                        || a.getTypeName().equals("org.uimafit.descriptor.ConfigurationParameter")) {
+                  if (a.getMemberValue("description") == null) {
+                    a.addMemberValue("description", new StringMemberValue(pdesc, constPool));
+                    getLog().info("Enhanced description of parameter [" + p.getName() + "]");
+                    // Replace updated annotation
+                    annoAttr.addAnnotation(a);
+                  } else {
+                    getLog().info(
+                            "Not enhancing parameter [" + p.getName()
+                                    + "] which already has a description");
+
+                  }
+                }
+              }
+            }
+            
+            // Replace annotations
+            ctField.getFieldInfo().addAttribute(annoAttr);
+          } catch (NotFoundException e) {
+            throw new MojoExecutionException("Field [" + field.getName()
+                    + "] not found in byte code: " + ExceptionUtils.getRootCauseMessage(e), e);
+          }
+        }
+      } else {
+        getLog().warn("No source file found for class [" + clazzName + "]");
+      }
+      
+      try {
+        ctClazz.writeFile(project.getBuild().getOutputDirectory());
+      }
+      catch (IOException e) {
+        throw new MojoExecutionException("Enhanced class [" + clazzName + "] cannot be written: " + 
+                ExceptionUtils.getRootCauseMessage(e), e);
+        
+      } catch (CannotCompileException e) {
+        throw new MojoExecutionException("Enhanced class [" + clazzName + "] cannot be compiled: " + 
+                ExceptionUtils.getRootCauseMessage(e), e);
+      }
+    }
+  }
+  
+  /**
+   * Get a map of parameter name to parameter name constant field, e.g. ("value",
+   * Field("PARAM_VALUE")).
+   */
+  private Map<String, Field> getParameterConstants(Class aClazz)
+  {
+    Map<String, Field> result = new HashMap<String, Field>();
+    for (Field f : aClazz.getFields()) {
+      if (!f.getName().startsWith("PARAM_")) {
+        continue;
+      }
+      try {
+        String parameterName = (String) f.get(null);
+        result.put(parameterName, f);
+      }
+      catch (IllegalAccessException e) {
+        getLog().warn(
+                "Unable to access parameter name constant field [" + f.getName() + "]: "
+                        + ExceptionUtils.getRootCauseMessage(e), e);
+      }
+    }
+    return result;
+  }
+  
+  private CompilationUnit parseSource(String aSourceFile) throws MojoExecutionException
+  {
+    try {
+      return Util.parseSource(aSourceFile, encoding);
+    }
+    catch (IOException e) {
+      throw new MojoExecutionException("Unable to parse source file [" + aSourceFile + "]: "
+              + ExceptionUtils.getRootCauseMessage(e), e);
+    }
+  }
+
+  /**
+   * Get the source file for the given class.
+   * 
+   * @return The path to the source file or {@code null} if no source file was found.
+   */
+  private String getSourceFile(String aClassName)
+  {
+    String sourceName = aClassName.replace('.', '/') + ".java";
+    
+    for (String root : (List<String>) project.getCompileSourceRoots())
+    {
+      File f = new File(root, sourceName);
+      if (f.exists()) {
+        return f.getPath();
+      }
+    }
+    return null;
+  }
+  
+  private String getParameterDocumentation(CompilationUnit aAst, Field aParameter,
+          Field aParameterNameConstant) {
+    
+    // Generate JavaDoc related annotations
+    ParameterDescriptionExtractor visitor = new ParameterDescriptionExtractor(aParameter.getName(),
+            (aParameterNameConstant != null) ? aParameterNameConstant.getName() : null);
+    aAst.accept(visitor);
+
+    if (visitor.getJavadoc() != null) {
+      JavadocTextExtractor textExtractor = new JavadocTextExtractor();
+      visitor.getJavadoc().accept(textExtractor);
+      // getLog().info(
+      // "Description found for parameter [" + aParameter + "]: " + textExtractor.getText());
+      return textExtractor.getText();
+    } else {
+      return null;
+    }
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java?rev=1439070&r1=1439069&r2=1439070&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java Sun Jan 27 12:20:13 2013
@@ -22,16 +22,8 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
@@ -42,6 +34,8 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.project.MavenProject;
 import org.apache.uima.fit.factory.AnalysisEngineFactory;
 import org.apache.uima.fit.factory.CollectionReaderFactory;
+import org.apache.uima.fit.maven.util.Util;
+import org.apache.uima.resource.ResourceCreationSpecifier;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.resource.ResourceSpecifier;
 import org.codehaus.plexus.util.FileUtils;
@@ -60,14 +54,16 @@ public class GenerateDescriptorsMojo ext
 
   @Component
   private BuildContext buildContext;
-  
+
+  private ClassLoader componentLoader;
+
+  /**
+   * Path where the generated resources are written.
+   */
   @Parameter(defaultValue="${project.build.directory}/generated-sources/uimafit", required=true)
   private File outputDirectory;
   
-  private ClassLoader componentLoader;
-
   public void execute() throws MojoExecutionException {
-    
     // add the generated sources to the build
     if (!outputDirectory.exists()) {
       outputDirectory.mkdirs();
@@ -75,52 +71,20 @@ public class GenerateDescriptorsMojo ext
     }
     project.addCompileSourceRoot(outputDirectory.getPath());
     
+    // Get the compiled classes from this project
     String[] files = FileUtils.getFilesFromExtension(project.getBuild().getOutputDirectory(),
             new String[] { "class" });
 
-    // Create a class loader which covers the classes compiled in the current project and all
-    // dependencies.
-    List<URL> urls = new ArrayList<URL>();
-    try {
-      for (Object object : project.getCompileClasspathElements()) {
-        String path = (String) object;
-        getLog().debug("Classpath entry: " + object);
-        urls.add(new File(path).toURI().toURL());
-      }
-    } catch (IOException e) {
-      throw new MojoExecutionException("Unable to assemble classpath: "
-              + ExceptionUtils.getRootCauseMessage(e), e);
-    } catch (DependencyResolutionRequiredException e) {
-      throw new MojoExecutionException("Unable to resolve dependencies: "
-              + ExceptionUtils.getRootCauseMessage(e), e);
-    }
-    
-    for (Artifact dep : (Set<Artifact>) project.getDependencyArtifacts()) {
-      try {
-        if (dep.getFile() == null) {
-          // Unresolved file because it is in the wrong scope (e.g. test?)
-          continue;
-        }
-        getLog().debug(
-                "Classpath entry: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":"
-                        + dep.getVersion() + " -> " + dep.getFile());
-        urls.add(dep.getFile().toURI().toURL());
-      } catch (Exception e) {
-        throw new MojoExecutionException("Unable get dependency artifact location for "
-                + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion()
-                + ExceptionUtils.getRootCauseMessage(e), e);
-      }
-    }
-    componentLoader = new URLClassLoader(urls.toArray(new URL[] {}), getClass().getClassLoader());
+    componentLoader = Util.getClassloader(project, getLog());
 
     for (String file : files) {
       String base = file.substring(0, file.length() - 6);
       String clazzPath = base.substring(project.getBuild().getOutputDirectory().length() + 1);
       String clazzName = clazzPath.replace("/", ".");
       try {
-        Class clazz = getClass(clazzName);
-        ResourceSpecifier desc = null;
-        switch (getType(clazz)) {
+        Class clazz = componentLoader.loadClass(clazzName);
+        ResourceCreationSpecifier desc = null;
+        switch (Util.getType(componentLoader, clazz)) {
           case ANALYSIS_ENGINE:
             desc = AnalysisEngineFactory.createPrimitiveDescription(clazz);
             break;
@@ -164,35 +128,4 @@ public class GenerateDescriptorsMojo ext
       IOUtils.closeQuietly(os);
     }
   }
-
-  /**
-   * Load class using the component classloader.
-   * 
-   * @throws ClassNotFoundException
-   */
-  private Class getClass(String aClassName) throws ClassNotFoundException {
-    return componentLoader.loadClass(aClassName);
-  }
-
-  /**
-   * Determine what kind of class it is.
-   * 
-   * @throws ClassNotFoundException
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  private ComponentType getType(Class aClass) throws ClassNotFoundException {
-    Class iCR = getClass("org.apache.uima.collection.CollectionReader");
-    Class iAE = getClass("org.apache.uima.analysis_component.AnalysisComponent");
-    if (iCR.isAssignableFrom(aClass)) {
-      return ComponentType.COLLECTION_READER;
-    } else if (iAE.isAssignableFrom(aClass)) {
-      return ComponentType.ANALYSIS_ENGINE;
-    } else {
-      return ComponentType.NONE;
-    }
-  }
-
-  private enum ComponentType {
-    COLLECTION_READER, ANALYSIS_ENGINE, NONE;
-  }
 }

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven.javadoc;
+
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+
+/**
+ * Find JavaDoc for a given uimaFIT parameter.
+ */
+public class ComponentDescriptionExtractor extends ASTVisitor {
+  private String parameterName;
+
+  private Javadoc javadoc;
+
+  public ComponentDescriptionExtractor(String aParameterName) {
+    parameterName = aParameterName;
+  }
+
+  public Javadoc getJavadoc() {
+    return javadoc;
+  }
+
+  @Override
+  public boolean visit(FieldDeclaration aNode) {
+    if ((!aNode.fragments().isEmpty())
+            && (aNode.fragments().get(0) instanceof VariableDeclarationFragment)) {
+      VariableDeclarationFragment f = (VariableDeclarationFragment) aNode.fragments().get(0);
+      if (f.getName().getIdentifier().startsWith("PARAM_")
+              && (f.getInitializer() instanceof StringLiteral)) {
+        String name = f.getName().getIdentifier();
+        String value = ((StringLiteral) f.getInitializer()).getLiteralValue();
+        if (parameterName.equals(value)) {
+          javadoc = aNode.getJavadoc();
+        }
+      }
+    }
+    return false;
+  }
+}
\ No newline at end of file

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ComponentDescriptionExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven.javadoc;
+
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.TextElement;
+
+/**
+ * Extract text from a JavaDoc comment.
+ */
+public class JavadocTextExtractor extends ASTVisitor {
+  private StringBuilder text = new StringBuilder();
+
+  @Override
+  public boolean visit(TextElement aNode) {
+    // In multi-line JavaDoc, each line is parsed as a separate node. We have to insert something
+    // (a line break or space) to prevent gluing words together.
+    if (text.length() > 0 && text.charAt(text.length()-1) != ' ') {
+      text.append(' ');
+    }
+    text.append(aNode.getText());
+    return true;
+  }
+
+  @Override
+  public boolean visit(Javadoc aNode) {
+    return true;
+  }
+  
+  public String getText() {
+    return text.toString();
+  }
+}
\ No newline at end of file

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/JavadocTextExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven.javadoc;
+
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+
+/**
+ * Find JavaDoc for a given uimaFIT parameter. Javadoc on a parameter name constant is preferred
+ * over JavaDoc on the parameter field itself.
+ */
+public class ParameterDescriptionExtractor extends ASTVisitor {
+  private String parameter;
+  
+  private String parameterNameConstant;
+
+  private Javadoc nameConstantJavadoc;
+
+  private Javadoc parameterJavadoc;
+
+  /**
+   * New extractor.
+   * 
+   * @param aParameter name of the parameter field.
+   * @param aParameterNameConstant name of the parameter name constant field.
+   */
+  public ParameterDescriptionExtractor(String aParameter, String aParameterNameConstant) {
+    parameter = aParameter;
+    parameterNameConstant = aParameterNameConstant;
+  }
+
+  public Javadoc getJavadoc() {
+    if (parameterNameConstant != null && nameConstantJavadoc != null) {
+      return nameConstantJavadoc;
+    }
+    else {
+      return parameterJavadoc;
+    }
+  }
+  
+  public Javadoc getParameterJavadoc() {
+    return parameterJavadoc;
+  }
+  
+  public Javadoc getNameConstantJavadoc() {
+    return nameConstantJavadoc;
+  }
+
+  @Override
+  public boolean visit(FieldDeclaration aNode) {
+    if ((!aNode.fragments().isEmpty())
+            && (aNode.fragments().get(0) instanceof VariableDeclarationFragment)) {
+      VariableDeclarationFragment f = (VariableDeclarationFragment) aNode.fragments().get(0);
+
+      String fieldName = f.getName().getIdentifier();
+      
+      // CASE 1: JavaDoc is located on parameter name constant
+      if (parameterNameConstant != null && parameterNameConstant.equals(fieldName)) {
+        nameConstantJavadoc = aNode.getJavadoc();
+      }
+      
+      // CASE 2: JavaDoc is located on the parameter field itself
+      if (parameter.equals(fieldName)) {
+        parameterJavadoc = aNode.getJavadoc();
+      }
+    }
+    return false;
+  }
+}
\ No newline at end of file

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/javadoc/ParameterDescriptionExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven.util;
+public enum ComponentType {
+  COLLECTION_READER, ANALYSIS_ENGINE, NONE;
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/ComponentType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+
+public final class Util {
+
+  private Util() {
+    // No instances
+  }
+
+  public static CompilationUnit parseSource(String aSourceFile, String aEncoding)
+          throws IOException {
+    ASTParser parser = ASTParser.newParser(AST.JLS3);
+    parser.setSource(org.apache.commons.io.FileUtils.readFileToString(new File(aSourceFile),
+            aEncoding).toCharArray());
+    Map options = JavaCore.getOptions();
+    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
+    parser.setCompilerOptions(options);
+    return (CompilationUnit) parser.createAST(null);
+  }
+
+  /**
+   * Get the class name for a class file.
+   */
+  public static String getClassName(MavenProject aProject, String aFile) {
+    String base = aFile.substring(0, aFile.length() - 6);
+    String clazzPath = base.substring(aProject.getBuild().getOutputDirectory().length() + 1);
+    return clazzPath.replace("/", ".");
+  }
+
+  /**
+   * Create a class loader which covers the classes compiled in the current project and all
+   * dependencies.
+   * 
+   * @throws MojoExecutionException
+   */
+  public static URLClassLoader getClassloader(MavenProject aProject, Log aLog)
+          throws MojoExecutionException {
+    List<URL> urls = new ArrayList<URL>();
+    try {
+      for (Object object : aProject.getCompileClasspathElements()) {
+        String path = (String) object;
+        aLog.debug("Classpath entry: " + object);
+        urls.add(new File(path).toURI().toURL());
+      }
+    } catch (IOException e) {
+      throw new MojoExecutionException("Unable to assemble classpath: "
+              + ExceptionUtils.getRootCauseMessage(e), e);
+    } catch (DependencyResolutionRequiredException e) {
+      throw new MojoExecutionException("Unable to resolve dependencies: "
+              + ExceptionUtils.getRootCauseMessage(e), e);
+    }
+
+    for (Artifact dep : (Set<Artifact>) aProject.getDependencyArtifacts()) {
+      try {
+        if (dep.getFile() == null) {
+          // Unresolved file because it is in the wrong scope (e.g. test?)
+          continue;
+        }
+        aLog.debug("Classpath entry: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":"
+                + dep.getVersion() + " -> " + dep.getFile());
+        urls.add(dep.getFile().toURI().toURL());
+      } catch (Exception e) {
+        throw new MojoExecutionException("Unable get dependency artifact location for "
+                + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion()
+                + ExceptionUtils.getRootCauseMessage(e), e);
+      }
+    }
+    return new URLClassLoader(urls.toArray(new URL[] {}), Util.class.getClassLoader());
+  }
+
+  public static boolean isComponent(ClassLoader aClassLoader, Class aClass)
+          throws ClassNotFoundException {
+    return getType(aClassLoader, aClass) != ComponentType.NONE;
+  }
+
+  /**
+   * Determine what kind of class it is.
+   * 
+   * @param aClassLoader
+   *          the class loader by which the component was loaded.
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public static ComponentType getType(ClassLoader aClassLoader, Class aClass)
+          throws ClassNotFoundException {
+    Class iCR = aClassLoader.loadClass("org.apache.uima.collection.CollectionReader");
+    Class iAE = aClassLoader.loadClass("org.apache.uima.analysis_component.AnalysisComponent");
+    if (iCR.isAssignableFrom(aClass)) {
+      return ComponentType.COLLECTION_READER;
+    } else if (iAE.isAssignableFrom(aClass)) {
+      return ComponentType.ANALYSIS_ENGINE;
+    } else {
+      return ComponentType.NONE;
+    }
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml?rev=1439070&r1=1439069&r2=1439070&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml (original)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml Sun Jan 27 12:20:13 2013
@@ -3,6 +3,7 @@
     <pluginExecution>
       <pluginExecutionFilter>
         <goals>
+          <goal>enhance</goal>
           <goal>generate</goal>
         </goals>
       </pluginExecutionFilter>

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven;
+
+import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+
+import org.apache.uima.fit.maven.javadoc.JavadocTextExtractor;
+import org.apache.uima.fit.maven.javadoc.ParameterDescriptionExtractor;
+import org.junit.Test;
+
+public class JavadocTextExtractorTest {
+
+  @Test
+  public void testDocOnName() throws Exception {
+    String doc = getJavadoc("value1", "PARAM_VALUE_1");
+    assertEquals("Documentation for value 1", doc);
+  }
+  
+  @Test
+  public void testDocOnParameterWithName() throws Exception {
+    String doc = getJavadoc("value2", "PARAM_VALUE_2");
+    assertEquals("Documentation for value 2", doc);
+  }
+
+  @Test
+  public void testDocOnParameterWithoutName() throws Exception {
+    String doc = getJavadoc("value3", "PARAM_VALUE_3");
+    assertEquals("Documentation for value 3", doc);
+  }
+
+  @Test
+  public void testWithoutDoc() throws Exception {
+    String doc = getJavadoc("value4", "PARAM_VALUE_4");
+    assertEquals(null, doc);
+  }
+
+  @Test
+  public void testDocOnParameterWithNonLiteralName() throws Exception {
+    String doc = getJavadoc("value5", "PARAM_VALUE_5");
+    assertEquals("Documentation for value 5", doc);
+  }
+
+  private String getJavadoc(String aParameter, String aNameConstanct) throws IOException {
+    ParameterDescriptionExtractor paramEx = ParameterDescriptionExtractorTest.getExtractor(
+            aParameter, aNameConstanct);
+
+    if (paramEx.getJavadoc() == null) {
+      return null;
+    }
+    else {
+      JavadocTextExtractor textEx = new JavadocTextExtractor();
+      paramEx.getJavadoc().accept(textEx);
+      return textEx.getText();
+    }
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/JavadocTextExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.maven;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import org.apache.uima.fit.maven.javadoc.ParameterDescriptionExtractor;
+import org.apache.uima.fit.maven.util.Util;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.junit.Test;
+
+public class ParameterDescriptionExtractorTest {
+
+  @Test
+  public void testDocOnName() throws Exception {
+    ParameterDescriptionExtractor visitor = getExtractor("value1", "PARAM_VALUE_1");
+
+    assertNotNull(visitor.getJavadoc());
+    assertNull(visitor.getParameterJavadoc());
+    assertNotNull(visitor.getNameConstantJavadoc());
+  }
+
+  @Test
+  public void testDocOnParameterWithName() throws Exception {
+    ParameterDescriptionExtractor visitor = getExtractor("value2", "PARAM_VALUE_2");
+
+    assertNotNull(visitor.getJavadoc());
+    assertNotNull(visitor.getParameterJavadoc());
+    assertNull(visitor.getNameConstantJavadoc());
+
+  }
+
+  @Test
+  public void testDocOnParameterWithoutName() throws Exception {
+    ParameterDescriptionExtractor visitor = getExtractor("value3", "PARAM_VALUE_3");
+
+    assertNotNull(visitor.getJavadoc());
+    assertNotNull(visitor.getParameterJavadoc());
+    assertNull(visitor.getNameConstantJavadoc());
+  }
+
+  @Test
+  public void testWithoutDoc() throws Exception {
+    ParameterDescriptionExtractor visitor = getExtractor("value4", "PARAM_VALUE_4");
+
+    assertNull(visitor.getJavadoc());
+    assertNull(visitor.getParameterJavadoc());
+    assertNull(visitor.getNameConstantJavadoc());
+  }
+
+  @Test
+  public void testDocOnParameterWithNonLiteralName() throws Exception {
+    ParameterDescriptionExtractor visitor = getExtractor("value5", "PARAM_VALUE_5");
+
+    assertNotNull(visitor.getJavadoc());
+    assertNull(visitor.getParameterJavadoc());
+    assertNotNull(visitor.getNameConstantJavadoc());
+  }
+
+  public static ParameterDescriptionExtractor getExtractor(String aParameter, String aNameConstant)
+          throws IOException {
+    // Create the Java parser and parse the source code into an abstract syntax tree
+    CompilationUnit result = Util.parseSource("src/test/resources/TestComponent.java", "UTF-8");
+
+    // Generate JavaDoc related annotations
+    ParameterDescriptionExtractor visitor = new ParameterDescriptionExtractor(aParameter,
+            aNameConstant);
+    result.accept(visitor);
+
+    return visitor;
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/java/org/apache/uima/fit/maven/ParameterDescriptionExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
+
+/**
+ * A test component.
+ */
+public class TestComponent {
+  /**
+   * Documentation for value 1
+   */
+  public static final String PARAM_VALUE_1 = "value1";
+  @ConfigurationParameter(name = PARAM_VALUE_1)
+  private String value1;
+
+  public static final String PARAM_VALUE_2 = "value2";
+  /**
+   * Documentation for value 2
+   */
+  @ConfigurationParameter(name = PARAM_VALUE_2)
+  private String value2;
+
+  /**
+   * Documentation for value 3
+   */
+  @ConfigurationParameter
+  private String value3;
+
+  @ConfigurationParameter
+  private String value4;
+
+  public static final String PARAM_DEFAULT_NAME_5 = "value5";
+  /**
+   * Documentation for value 5
+   */
+  public static final String PARAM_VALUE_5 = PARAM_DEFAULT_NAME_5;
+  @ConfigurationParameter(name = PARAM_VALUE_5)
+  private String value5;
+
+  public TestComponent() {
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit-maven-plugin/src/test/resources/TestComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java?rev=1439070&r1=1439069&r2=1439070&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java Sun Jan 27 12:20:13 2013
@@ -75,7 +75,7 @@ public final class AnalysisEngineFactory
   private AnalysisEngineFactory() {
     // This class is not meant to be instantiated
   }
-
+  
   /**
    * Get an AnalysisEngine from the name (Java-style, dotted) of an XML descriptor file, and a set
    * of configuration parameters.
@@ -299,8 +299,8 @@ public final class AnalysisEngineFactory
     if (componentClass.getPackage() != null) {
       meta.setVendor(componentClass.getPackage().getName());
     }
-    meta.setDescription("Descriptor automatically generated by uimaFIT");
-    meta.setVersion("unknown");
+    meta.setDescription(Defaults.DEFAULT_DESCRIPTION);
+    meta.setVersion(Defaults.DEFAULT_VERSION);
 
     ConfigurationData reflectedConfigurationData = createConfigurationData(componentClass);
     ResourceCreationSpecifierFactory.setConfigurationParameters(desc,

Added: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java?rev=1439070&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java Sun Jan 27 12:20:13 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.fit.factory;
+
+/**
+ * Common constants. 
+ */
+public final class Defaults {  
+  /**
+   * Used when the version of a component is unknown.
+   */
+  public static final String DEFAULT_VERSION = "unknown";
+  
+  /**
+   * Used when the description of a component is unknown.
+   */
+  public static final String DEFAULT_DESCRIPTION = "Descriptor automatically generated by uimaFIT";
+
+  private Defaults() {
+    // No instances
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/Defaults.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java?rev=1439070&r1=1439069&r2=1439070&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java Sun Jan 27 12:20:13 2013
@@ -103,8 +103,8 @@ public final class FlowControllerFactory
     ResourceMetaData meta = desc.getMetaData();
     meta.setName(flowControllerClass.getName());
     meta.setVendor(flowControllerClass.getPackage().toString());
-    meta.setDescription("Descriptor automatically generated by uimaFIT");
-    meta.setVersion("unknown");
+    meta.setDescription(Defaults.DEFAULT_DESCRIPTION);
+    meta.setVersion(Defaults.DEFAULT_VERSION);
 
     // Extract external resource dependencies
     Collection<ExternalResourceDependency> deps = ExternalResourceInitializer