Merge pull request #163 from apache/bugfix/UIMA-6396-uimaFIT-maven-plugin-mixes-up-test-and-compile-scopes

[UIMA-6396] uimaFIT maven plugin mixes up test and compile scopes
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactory.java
index e3b2d99..263d85d 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactory.java
@@ -120,15 +120,17 @@
             XMLInputSource xmlInputType1 = new XMLInputSource(location);
             tsdList.add(getXMLParser().parseTypeSystemDescription(xmlInputType1));
             LogFactory.getLog(TypeSystemDescription.class)
-            .debug("Detected type system at [" + location + "]");
+              .debug("Detected type system at [" + location + "]");
           } catch (IOException e) {
             throw new ResourceInitializationException(e);
           } catch (InvalidXMLException e) {
             LogFactory.getLog(TypeSystemDescription.class)
-            .warn("[" + location + "] is not a type file. Ignoring.", e);
+              .warn("[" + location + "] is not a type file. Ignoring.", e);
           }
         }
 
+        LogFactory.getLog(TypeSystemDescription.class)
+          .trace("Merging type systems and resolving imports...");
         ResourceManager resMgr = ResourceManagerFactory.newResourceManager();
         tsd = mergeTypeSystems(tsdList, resMgr);
         typeDescriptorByClassloader.put(cl, tsd);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
index b62dc86..7ac142c 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
@@ -20,6 +20,7 @@
 
 import java.net.MalformedURLException;
 
+import org.apache.commons.logging.LogFactory;
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.UimaContext;
 import org.apache.uima.UimaContextAdmin;
@@ -75,6 +76,8 @@
           // handle switching across more than one classloader.
           // This can be done since UIMA 2.9.0 and starts being handled in uimaFIT 2.3.0
           // See https://issues.apache.org/jira/browse/UIMA-5056
+          LogFactory.getLog(ResourceManagerFactory.class)
+            .trace("Using resource manager from active UIMA context");
           return ((UimaContextAdmin) activeContext).getResourceManager();
         }
 
@@ -83,10 +86,13 @@
         // This was the default behavior until uimaFIT 2.2.0.
         ResourceManager resMgr;
         if (Thread.currentThread().getContextClassLoader() != null) {
-          // If the context classloader is set, then we want the resource manager to fallb
-          // back to it. However, it may not reliably do that that unless we explictly pass
+          // If the context classloader is set, then we want the resource manager to fall
+          // back to it. However, it may not reliably do that that unless we explicitly pass
           // null here. See. UIMA-6239.
+          LogFactory.getLog(ResourceManagerFactory.class)
+            .trace("Detected thread context classloader: preparing resource manager to use it");
           resMgr = new ResourceManager_impl(null);
+          resMgr.setExtensionClassPath(ClassLoaderUtils.findClassloader(), "", true);
         }
         else {
           resMgr = UIMAFramework.newDefaultResourceManager();
@@ -102,6 +108,9 @@
                 (maj == 2 && (min < 10 || (min == 10 && rev < 3))) || // version < 2.10.3
                 (maj == 3 && ((min == 0 && rev < 1)));                // version < 3.0.1
         if (uimaCoreIgnoresContextClassloader) {
+          LogFactory.getLog(ResourceManagerFactory.class)
+            .trace("Detected UIMA version " + maj + "." + min + "." + rev + 
+                    " which ignores the thread context classloader, setting it explicitly");
           resMgr.setExtensionClassPath(ClassLoaderUtils.findClassloader(), "", true);
         }
 
diff --git a/uimafit-maven-plugin/pom.xml b/uimafit-maven-plugin/pom.xml
index 07e7bb6..3e3a0af 100644
--- a/uimafit-maven-plugin/pom.xml
+++ b/uimafit-maven-plugin/pom.xml
@@ -131,7 +131,7 @@
           <settingsFile>src/it/settings.xml</settingsFile>
           <goals>
             <goal>clean</goal>
-            <goal>test-compile</goal>
+            <goal>package</goal>
           </goals>
         </configuration>
         <executions>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/pom.xml
new file mode 100644
index 0000000..c8ab8e4
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.uima.fit.maven.it</groupId>
+    <artifactId>default</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>compile-artifact</artifactId>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt
new file mode 100644
index 0000000..1f3212d
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt
@@ -0,0 +1 @@
+classpath*:org/apache/uima/fit/type/compileartifact/types.xml
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/org/apache/uima/fit/type/compileartifact/types.xml b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/org/apache/uima/fit/type/compileartifact/types.xml
new file mode 100644
index 0000000..68daef7
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/compile-artifact/src/main/resources/org/apache/uima/fit/type/compileartifact/types.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+  <name>Compile Types</name>
+  <description></description>
+  <version>1.0</version>
+  <vendor/>
+  <types>
+    <typeDescription>
+      <name>org.apache.uima.fit.type.CompileType</name>
+      <description/>
+      <supertypeName>uima.tcas.Annotation</supertypeName>
+    </typeDescription>
+  </types>
+</typeSystemDescription>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/pom.xml
new file mode 100644
index 0000000..4b6a93f
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.uima.fit.maven.it</groupId>
+    <artifactId>default</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>main-artifact-plus-test-scope</artifactId>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.uima.fit.maven.it</groupId>
+      <artifactId>compile-artifact</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.uima.fit.maven.it</groupId>
+      <artifactId>test-artifact</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.uima</groupId>
+      <artifactId>uimafit-core</artifactId>
+      <version>@pom.version@</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.uima</groupId>
+        <artifactId>uimafit-maven-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <componentVendor>Apache UIMA</componentVendor>
+          <componentCopyright>Copyright by the respective authors.</componentCopyright>
+        </configuration>
+        <executions>
+          <execution>
+            <id>default</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>enhance</goal>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <includeScope>test</includeScope>
+              <addTypeSystemDescriptions>EMBEDDED</addTypeSystemDescriptions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/src/main/java/TestAnnotator.java b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/src/main/java/TestAnnotator.java
new file mode 100644
index 0000000..65c612f
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact-plus-test-scope/src/main/java/TestAnnotator.java
@@ -0,0 +1,33 @@
+/*
+ * 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.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
+import org.apache.uima.jcas.JCas;
+
+/**
+ * Test annotator.
+ */
+public class TestAnnotator extends JCasAnnotator_ImplBase {
+
+  @Override
+  public void process(JCas aJCas) throws AnalysisEngineProcessException {
+    // Nothing to do
+  }
+}
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/pom.xml
new file mode 100644
index 0000000..a245507
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.uima.fit.maven.it</groupId>
+    <artifactId>default</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>main-artifact</artifactId>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.uima.fit.maven.it</groupId>
+      <artifactId>compile-artifact</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.uima.fit.maven.it</groupId>
+      <artifactId>test-artifact</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.uima</groupId>
+      <artifactId>uimafit-core</artifactId>
+      <version>@pom.version@</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.uima</groupId>
+        <artifactId>uimafit-maven-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <componentVendor>Apache UIMA</componentVendor>
+          <componentCopyright>Copyright by the respective authors.</componentCopyright>
+        </configuration>
+        <executions>
+          <execution>
+            <id>default</id>
+            <phase>process-classes</phase>
+            <goals>
+              <goal>enhance</goal>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <addTypeSystemDescriptions>EMBEDDED</addTypeSystemDescriptions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/src/main/java/TestAnnotator.java b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/src/main/java/TestAnnotator.java
new file mode 100644
index 0000000..65c612f
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/main-artifact/src/main/java/TestAnnotator.java
@@ -0,0 +1,33 @@
+/*
+ * 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.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
+import org.apache.uima.jcas.JCas;
+
+/**
+ * Test annotator.
+ */
+public class TestAnnotator extends JCasAnnotator_ImplBase {
+
+  @Override
+  public void process(JCas aJCas) throws AnalysisEngineProcessException {
+    // Nothing to do
+  }
+}
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/pom.xml
new file mode 100644
index 0000000..6da2856
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>org.apache.uima.fit.maven.it</groupId>
+	<artifactId>default</artifactId>
+	<version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+	<properties>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+  
+  <modules>
+    <module>test-artifact</module>
+    <module>test-artifact2</module>
+    <module>compile-artifact</module>
+    <module>main-artifact</module>
+    <module>main-artifact-plus-test-scope</module>
+  </modules>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact-plus-test-scope/TestAnnotator.xml b/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact-plus-test-scope/TestAnnotator.xml
new file mode 100644
index 0000000..bd3a6b6
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact-plus-test-scope/TestAnnotator.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+        
+    <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+        
+    <primitive>true</primitive>
+        
+    <annotatorImplementationName>TestAnnotator</annotatorImplementationName>
+        
+    <analysisEngineMetaData>
+                
+        <name>TestAnnotator</name>
+                
+        <description>Test annotator.</description>
+                
+        <version>1.0-SNAPSHOT</version>
+                
+        <vendor>Apache UIMA</vendor>
+                
+        <copyright>Copyright by the respective authors.</copyright>
+                
+        <configurationParameters/>
+                
+        <configurationParameterSettings/>
+                
+        <typeSystemDescription>
+                        
+            <types>
+                                
+                <typeDescription>
+                                        
+                    <name>org.apache.uima.fit.type.CompileType</name>
+                                        
+                    <description/>
+                                        
+                    <supertypeName>uima.tcas.Annotation</supertypeName>
+                                    
+                </typeDescription>
+                                
+                <typeDescription>
+                                        
+                    <name>org.apache.uima.fit.type.TestType</name>
+                                        
+                    <description/>
+                                        
+                    <supertypeName>uima.tcas.Annotation</supertypeName>
+                                    
+                </typeDescription>
+                                
+                <typeDescription>
+                                        
+                    <name>org.apache.uima.fit.type.TestType2</name>
+                                        
+                    <description/>
+                                        
+                    <supertypeName>uima.tcas.Annotation</supertypeName>
+                                    
+                </typeDescription>
+                            
+            </types>
+                    
+        </typeSystemDescription>
+                
+        <typePriorities/>
+                
+        <fsIndexCollection/>
+                
+        <capabilities/>
+                
+        <operationalProperties>
+                        
+            <modifiesCas>true</modifiesCas>
+                        
+            <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+                        
+            <outputsNewCASes>false</outputsNewCASes>
+                    
+        </operationalProperties>
+            
+    </analysisEngineMetaData>
+    
+</analysisEngineDescription>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact/TestAnnotator.xml b/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact/TestAnnotator.xml
new file mode 100644
index 0000000..3fadbc9
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/reference/main-artifact/TestAnnotator.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+        
+    <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+        
+    <primitive>true</primitive>
+        
+    <annotatorImplementationName>TestAnnotator</annotatorImplementationName>
+        
+    <analysisEngineMetaData>
+                
+        <name>TestAnnotator</name>
+                
+        <description>Test annotator.</description>
+                
+        <version>1.0-SNAPSHOT</version>
+                
+        <vendor>Apache UIMA</vendor>
+                
+        <copyright>Copyright by the respective authors.</copyright>
+                
+        <configurationParameters/>
+                
+        <configurationParameterSettings/>
+                
+        <typeSystemDescription>
+                        
+            <types>
+                                
+                <typeDescription>
+                                        
+                    <name>org.apache.uima.fit.type.CompileType</name>
+                                        
+                    <description/>
+                                        
+                    <supertypeName>uima.tcas.Annotation</supertypeName>
+                                    
+                </typeDescription>
+                            
+            </types>
+                    
+        </typeSystemDescription>
+                
+        <typePriorities/>
+                
+        <fsIndexCollection/>
+                
+        <capabilities/>
+                
+        <operationalProperties>
+                        
+            <modifiesCas>true</modifiesCas>
+                        
+            <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+                        
+            <outputsNewCASes>false</outputsNewCASes>
+                    
+        </operationalProperties>
+            
+    </analysisEngineMetaData>
+    
+</analysisEngineDescription>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/pom.xml
new file mode 100644
index 0000000..01b5c36
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.uima.fit.maven.it</groupId>
+    <artifactId>default</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>test-artifact</artifactId>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.uima.fit.maven.it</groupId>
+      <artifactId>test-artifact2</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt
new file mode 100644
index 0000000..61797b7
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/META-INF/org.apache.uima.fit/types.txt
@@ -0,0 +1 @@
+classpath*:org/apache/uima/fit/type/testartifact/types.xml
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/org/apache/uima/fit/type/testartifact/types.xml b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/org/apache/uima/fit/type/testartifact/types.xml
new file mode 100644
index 0000000..8da2663
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact/src/main/resources/org/apache/uima/fit/type/testartifact/types.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+  <name>Test Types</name>
+  <description />
+  <version>1.0</version>
+  <vendor />
+  <imports>
+    <import name="org.apache.uima.fit.type.testartifact2.types" />
+  </imports>
+  <types>
+    <typeDescription>
+      <name>org.apache.uima.fit.type.TestType</name>
+      <description />
+      <supertypeName>uima.tcas.Annotation</supertypeName>
+    </typeDescription>
+  </types>
+</typeSystemDescription>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/pom.xml b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/pom.xml
new file mode 100644
index 0000000..e29688f
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.uima.fit.maven.it</groupId>
+    <artifactId>default</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>test-artifact2</artifactId>
+</project>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/META-INF/org.apache.uima.fit/types.txt b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/META-INF/org.apache.uima.fit/types.txt
new file mode 100644
index 0000000..0879c21
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/META-INF/org.apache.uima.fit/types.txt
@@ -0,0 +1 @@
+classpath*:org/apache/uima/fit/type/testartifact2/types.xml
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/org/apache/uima/fit/type/testartifact2/types.xml b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/org/apache/uima/fit/type/testartifact2/types.xml
new file mode 100644
index 0000000..e98ac10
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/test-artifact2/src/main/resources/org/apache/uima/fit/type/testartifact2/types.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+  <name>Test Types 2</name>
+  <description></description>
+  <version>1.0</version>
+  <vendor/>
+  <types>
+    <typeDescription>
+      <name>org.apache.uima.fit.type.TestType2</name>
+      <description/>
+      <supertypeName>uima.tcas.Annotation</supertypeName>
+    </typeDescription>
+  </types>
+</typeSystemDescription>
diff --git a/uimafit-maven-plugin/src/it/compile-test-scope/verify.bsh b/uimafit-maven-plugin/src/it/compile-test-scope/verify.bsh
new file mode 100644
index 0000000..df87f6e
--- /dev/null
+++ b/uimafit-maven-plugin/src/it/compile-test-scope/verify.bsh
@@ -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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.apache.commons.io.*;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+
+try
+{
+  String reference = IOUtils.toString(new File(basedir, 
+    "reference/main-artifact/TestAnnotator.xml").toURI().toURL());
+  String actual = IOUtils.toString(new File(basedir, 
+    "main-artifact/target/classes/TestAnnotator.xml").toURI().toURL());
+
+  // In a local build, I get indented XML but on the Apache Jenkins I get non-indented XML. This
+  // settings tells XMLUnit to ignore this difference in whitespace - rec 2013-02-16
+  XMLUnit.setIgnoreWhitespace(true);
+  Diff diff = XMLUnit.compareXML(reference, actual);
+
+  if (!diff.identical()) {
+        System.out.println("Actual descriptor does not match expected descriptor: " + diff);
+        return false;
+  }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+try
+{
+  String reference = IOUtils.toString(new File(basedir, 
+    "reference/main-artifact-plus-test-scope/TestAnnotator.xml").toURI().toURL());
+  String actual = IOUtils.toString(new File(basedir, 
+    "main-artifact-plus-test-scope/target/classes/TestAnnotator.xml").toURI().toURL());
+
+  // In a local build, I get indented XML but on the Apache Jenkins I get non-indented XML. This
+  // settings tells XMLUnit to ignore this difference in whitespace - rec 2013-02-16
+  XMLUnit.setIgnoreWhitespace(true);
+  Diff diff = XMLUnit.compareXML(reference, actual);
+
+  if (!diff.identical()) {
+        System.out.println("Actual descriptor does not match expected descriptor: " + diff);
+        return false;
+  }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;
diff --git a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java
index 8a4acaa..df2bbc8 100644
--- a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java
+++ b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java
@@ -18,6 +18,10 @@
  */
 package org.apache.uima.fit.maven;
 
+import static org.apache.commons.lang.exception.ExceptionUtils.getRootCauseMessage;
+import static org.apache.maven.plugins.annotations.LifecyclePhase.PROCESS_CLASSES;
+import static org.apache.maven.plugins.annotations.ResolutionScope.TEST;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -31,20 +35,6 @@
 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.MemberValue;
-import javassist.bytecode.annotation.StringMemberValue;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.LineIterator;
 import org.apache.commons.lang.StringUtils;
@@ -53,10 +43,8 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 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.descriptor.ResourceMetaData;
 import org.apache.uima.fit.factory.ConfigurationParameterFactory;
@@ -71,10 +59,23 @@
 import com.google.common.collect.Multimap;
 import com.thoughtworks.qdox.model.JavaSource;
 
+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.MemberValue;
+import javassist.bytecode.annotation.StringMemberValue;
+
 /**
  * Enhance UIMA components with automatically generated uimaFIT annotations.
  */
-@Mojo(name = "enhance", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresDependencyCollection = ResolutionScope.COMPILE)
+@Mojo(name = "enhance", defaultPhase = PROCESS_CLASSES, requiresDependencyResolution = TEST, requiresDependencyCollection = TEST)
 public class EnhanceMojo extends AbstractMojo {
   @Component
   private MavenProject project;
@@ -165,6 +166,13 @@
   private String[] externalResourceNameConstantPrefixes = { "KEY_", "RES_" };
 
   /**
+   * Scope threshold to include. The default is "compile" (which implies compile, provided and
+   * system dependencies). Can also be changed to "test" (which implies all dependencies).
+   */
+  @Parameter(defaultValue = "compile", required = true)
+  private String includeScope;
+
+  /**
    * Start of a line containing a class name in the missing meta data report file
    */
   private static final String MARK_CLASS = "Class:";
@@ -174,12 +182,13 @@
    */
   private static final String MARK_NO_MISSING_META_DATA = "No missing meta data was found.";
 
+  
+  @Override
   public void execute() throws MojoExecutionException, MojoFailureException {
     // Get the compiled classes from this project
     String[] files = FileUtils.getFilesFromExtension(project.getBuild().getOutputDirectory(),
             new String[] { "class" });
-
-    componentLoader = Util.getClassloader(project, getLog());
+    componentLoader = Util.getClassloader(project, getLog(), includeScope);
 
     // Set up class pool with all the project dependencies and the project classes themselves
     ClassPool classPool = new ClassPool(true);
@@ -242,7 +251,7 @@
         ctClazz = classPool.get(clazzName);
       } catch (NotFoundException e) {
         throw new MojoExecutionException("Class [" + clazzName + "] not found in class pool: "
-                + ExceptionUtils.getRootCauseMessage(e), e);
+                + getRootCauseMessage(e), e);
       }
 
       // Get the source file
@@ -280,10 +289,10 @@
         }
       } catch (IOException e) {
         throw new MojoExecutionException("Enhanced class [" + clazzName + "] cannot be written: "
-                + ExceptionUtils.getRootCauseMessage(e), e);
+                + getRootCauseMessage(e), e);
       } catch (CannotCompileException e) {
         throw new MojoExecutionException("Enhanced class [" + clazzName + "] cannot be compiled: "
-                + ExceptionUtils.getRootCauseMessage(e), e);
+                + getRootCauseMessage(e), e);
       }
     }
     
diff --git a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
index 2e85b4b..edf1bb0 100644
--- a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
+++ b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
@@ -18,6 +18,11 @@
  */
 package org.apache.uima.fit.maven;
 
+import static org.apache.maven.plugins.annotations.LifecyclePhase.PROCESS_CLASSES;
+import static org.apache.maven.plugins.annotations.ResolutionScope.TEST;
+import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
+import static org.apache.uima.fit.factory.CollectionReaderFactory.createReaderDescription;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -29,15 +34,11 @@
 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.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.collection.CollectionReaderDescription;
-import org.apache.uima.fit.factory.AnalysisEngineFactory;
-import org.apache.uima.fit.factory.CollectionReaderFactory;
 import org.apache.uima.fit.factory.TypeSystemDescriptionFactory;
 import org.apache.uima.fit.maven.util.Util;
 import org.apache.uima.resource.ResourceCreationSpecifier;
@@ -52,7 +53,7 @@
 /**
  * Generate descriptor files for uimaFIT-based UIMA components.
  */
-@Mojo(name = "generate", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresDependencyCollection = ResolutionScope.COMPILE)
+@Mojo(name = "generate", defaultPhase = PROCESS_CLASSES, requiresDependencyResolution = TEST, requiresDependencyCollection = TEST)
 public class GenerateDescriptorsMojo extends AbstractMojo {
   @Component
   private MavenProject project;
@@ -97,6 +98,13 @@
   @Parameter(defaultValue = "NONE")
   private TypeSystemSerialization addTypeSystemDescriptions;
 
+  /**
+   * Scope threshold to include. The default is "compile" (which implies compile, provided and
+   * system dependencies). Can also be changed to "test" (which implies all dependencies).
+   */
+  @Parameter(defaultValue = "compile", required = true)
+  private String includeScope;
+
   @Override
   public void execute() throws MojoExecutionException {
     // add the generated sources to the build
@@ -109,7 +117,7 @@
     String[] files = FileUtils.getFilesFromExtension(project.getBuild().getOutputDirectory(),
             new String[] { "class" });
 
-    componentLoader = Util.getClassloader(project, getLog());
+    componentLoader = Util.getClassloader(project, getLog(), includeScope);
 
     // List of components that is later written to META-INF/org.apache.uima.fit/components.txt
     StringBuilder componentsManifest = new StringBuilder();
@@ -136,13 +144,12 @@
         ProcessingResourceMetaData metadata = null;
         switch (Util.getType(componentLoader, clazz)) {
           case ANALYSIS_ENGINE:
-            AnalysisEngineDescription aeDesc = AnalysisEngineFactory.createEngineDescription(clazz);
+            AnalysisEngineDescription aeDesc = createEngineDescription(clazz);
             metadata = aeDesc.getAnalysisEngineMetaData();
             desc = aeDesc;
             break;
           case COLLECTION_READER:
-            CollectionReaderDescription crDesc = CollectionReaderFactory
-                    .createReaderDescription(clazz);
+            CollectionReaderDescription crDesc = createReaderDescription(clazz);
             metadata = crDesc.getCollectionReaderMetaData();
             desc = crDesc;
           default:
diff --git a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java
index 195817c..3de6192 100644
--- a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java
+++ b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java
@@ -30,6 +30,7 @@
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
@@ -123,7 +124,7 @@
    * Create a class loader which covers the classes compiled in the current project and all
    * dependencies.
    */
-  public static URLClassLoader getClassloader(MavenProject aProject, Log aLog)
+  public static URLClassLoader getClassloader(MavenProject aProject, Log aLog, String aIncludeScopeThreshold)
           throws MojoExecutionException {
     List<URL> urls = new ArrayList<URL>();
     try {
@@ -139,13 +140,26 @@
       throw new MojoExecutionException("Unable to resolve dependencies: "
               + ExceptionUtils.getRootCauseMessage(e), e);
     }
-
-    for (Artifact dep : (Set<Artifact>) aProject.getDependencyArtifacts()) {
+    
+    ScopeArtifactFilter filter = new ScopeArtifactFilter(aIncludeScopeThreshold);
+    
+    for (Artifact dep : (Set<Artifact>) aProject.getArtifacts()) {
       try {
+        if (!filter.include(dep)) {
+          aLog.debug("Not generating classpath entry for out-of-scope artifact: " + dep.getGroupId()
+                  + ":" + dep.getArtifactId() + ":" + dep.getVersion() + " (" + dep.getScope()
+                  + ")");
+          continue;
+        }
+        
         if (dep.getFile() == null) {
+          aLog.debug("Not generating classpath entry for unresolved artifact: " + dep.getGroupId()
+                  + ":" + dep.getArtifactId() + ":" + dep.getVersion()+ " (" + dep.getScope()
+                  + ")");
           // 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());