You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2015/08/13 22:38:17 UTC

svn commit: r1695776 - in /uima/ruta/trunk/ruta-maven-plugin/src: main/java/org/apache/uima/ruta/maven/ test/java/org/apache/uima/ruta/maven/ test/resources/simple/ test/resources/simple/src/main/ruta/

Author: pkluegl
Date: Thu Aug 13 20:38:16 2015
New Revision: 1695776

URL: http://svn.apache.org/r1695776
Log:
UIMA-4513
* finished simple test

Modified:
    uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java
    uima/ruta/trunk/ruta-maven-plugin/src/test/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojoTest.java
    uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/pom.xml
    uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/src/main/ruta/Simple.ruta

Modified: uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java?rev=1695776&r1=1695775&r2=1695776&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java (original)
+++ uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java Thu Aug 13 20:38:16 2015
@@ -245,17 +245,17 @@ public class RutaGenerateDescriptorMojo
       files = FileUtils.getFilesFromExtension(project.getBuild().getOutputDirectory(),
               new String[] { "ruta" });
     }
-    
+
     if (addRutaNature) {
       addRutaNature();
       addRutaBuildPath();
     }
-    
+
     if (files == null) {
       getLog().debug("UIMA Ruta Building: Skipped, since no script files were selected.");
       return;
     }
-    
+
     List<File> filesToBuild = new ArrayList<File>();
     for (String each : files) {
       File file = new File(each);
@@ -266,8 +266,6 @@ public class RutaGenerateDescriptorMojo
       }
     }
 
-    
-
     if (filesToBuild.isEmpty()) {
       getLog().debug("UIMA Ruta Building: Skipped, since no changes were detected.");
       return;
@@ -428,20 +426,22 @@ public class RutaGenerateDescriptorMojo
       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;
+    Set<Artifact> artifacts = (Set<Artifact>) aProject.getDependencyArtifacts();
+    if (artifacts != null) {
+      for (Artifact dep : artifacts) {
+        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);
         }
-        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[] {}),

Modified: uima/ruta/trunk/ruta-maven-plugin/src/test/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojoTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-maven-plugin/src/test/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojoTest.java?rev=1695776&r1=1695775&r2=1695776&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-maven-plugin/src/test/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojoTest.java (original)
+++ uima/ruta/trunk/ruta-maven-plugin/src/test/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojoTest.java Thu Aug 13 20:38:16 2015
@@ -31,6 +31,10 @@ import org.apache.maven.project.ProjectB
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.text.AnnotationIndex;
 import org.apache.uima.util.XMLInputSource;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -38,18 +42,28 @@ public class RutaGenerateDescriptorMojoT
 
   public void testSimple() throws Exception {
     MavenProject project = build("simple");
- // check that the Java files have been generated
-    File descDirectory = new File(project.getBasedir(), "target/generated-sources/ruta/descriptor");
     
+    File descDirectory = new File(project.getBasedir(), "target/generated-sources/ruta/descriptor");
     File aeFile = new File(descDirectory, "SimpleEngine.xml");
     Assert.assertTrue(aeFile.exists());
     File tsFile = new File(descDirectory, "SimpleTypeSystem.xml");
     Assert.assertTrue(tsFile.exists());
+    project.getCompileSourceRoots().contains(descDirectory.getAbsolutePath());
     
     AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(aeFile));
     AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aed);
     
-    project.getCompileSourceRoots().contains(descDirectory.getAbsolutePath());
+    CAS cas = ae.newCAS();
+    cas.setDocumentText("This is a test.");
+    ae.process(cas);
+    
+    Type type = cas.getTypeSystem().getType("Simple.MyType");
+    AnnotationIndex<AnnotationFS> ai = cas.getAnnotationIndex(type);
+    assertEquals(1, ai.size());
+    assertEquals("is", ai.iterator().next().getCoveredText());
+    
+    cas.release();
+    
   }
 
 

Modified: uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/pom.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/pom.xml?rev=1695776&r1=1695775&r2=1695776&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/pom.xml (original)
+++ uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/pom.xml Thu Aug 13 20:38:16 2015
@@ -27,8 +27,23 @@
       <plugin>
         <groupId>org.apache.uima</groupId>
         <artifactId>ruta-maven-plugin</artifactId>
-        <version>${project.version}</version>
-
+        <configuration>
+          <typeSystemOutputDirectory>${project.build.directory}/generated-sources/ruta/descriptor</typeSystemOutputDirectory>
+          <analysisEngineOutputDirectory>${project.build.directory}/generated-sources/ruta/descriptor</analysisEngineOutputDirectory>
+          <scriptPaths>
+            <scriptPath>${project.build.directory}/classes</scriptPath>
+          </scriptPaths>
+          <descriptorPaths>
+            <descriptorPath>${project.build.directory}/generated-sources/ruta/descriptor</descriptorPath>
+          </descriptorPaths>
+          <analysisEngineSuffix>Engine</analysisEngineSuffix>
+          <typeSystemSuffix>TypeSystem</typeSystemSuffix>
+          <encoding>UTF-8</encoding>
+          <importByName>false</importByName>
+          <resolveImports>false</resolveImports>
+          <maxBuildRetries>-1</maxBuildRetries>
+          <addRutaNature>false</addRutaNature>
+        </configuration>
         <executions>
           <execution>
             <id>descriptors</id>
@@ -36,26 +51,6 @@
             <goals>
               <goal>generate</goal>
             </goals>
-              <configuration>
-              <typeSystemOutputDirectory>${project.build.directory}/generated-sources/ruta/descriptor</typeSystemOutputDirectory>
-              <analysisEngineOutputDirectory>${project.build.directory}/generated-sources/ruta/descriptor</analysisEngineOutputDirectory>
-              <scriptPaths>
-                <scriptPath>${basedir}/src/main/ruta/</scriptPath>
-              </scriptPaths>
-              <descriptorPaths>
-                <descriptorPath>${project.build.directory}/generated-sources/ruta/descriptor</descriptorPath>
-              </descriptorPaths>
-              <resourcePaths>
-                <resourcePath>${basedir}/src/main/resources/</resourcePath>
-                <resourcePath>${project.build.directory}/generated-sources/ruta/resources/</resourcePath>
-              </resourcePaths>
-              <analysisEngineSuffix>Engine</analysisEngineSuffix>
-              <typeSystemSuffix>TypeSystem</typeSystemSuffix>
-              <encoding>UTF-8</encoding>
-              <importByName>false</importByName>
-              <resolveImports>false</resolveImports>
-              <maxBuildRetries>-1</maxBuildRetries>
-            </configuration>
           </execution>
         </executions>
       </plugin>

Modified: uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/src/main/ruta/Simple.ruta
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/src/main/ruta/Simple.ruta?rev=1695776&r1=1695775&r2=1695776&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/src/main/ruta/Simple.ruta (original)
+++ uima/ruta/trunk/ruta-maven-plugin/src/test/resources/simple/src/main/ruta/Simple.ruta Thu Aug 13 20:38:16 2015
@@ -1,2 +1,2 @@
 DECLARE MyType;
-CW SW{-> MYType};
+CW SW{-> MyType};