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/06/12 18:08:54 UTC

svn commit: r1685119 - in /uima/ruta/trunk: ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java

Author: pkluegl
Date: Fri Jun 12 16:08:53 2015
New Revision: 1685119

URL: http://svn.apache.org/r1685119
Log:
UIMA-4461
- use CONTAINER instead of variable for buildpath entry
- always override buildpath using the pom config

Modified:
    uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java
    uima/ruta/trunk/ruta-maven-plugin/src/main/java/org/apache/uima/ruta/maven/RutaGenerateDescriptorMojo.java

Modified: uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java?rev=1685119&r1=1685118&r2=1685119&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java (original)
+++ uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java Fri Jun 12 16:08:53 2015
@@ -31,7 +31,6 @@ import java.util.TreeSet;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.uima.ruta.engine.RutaEngine;
-import org.apache.uima.ruta.ide.RutaIdeCorePlugin;
 import org.apache.uima.ruta.ide.core.RutaNature;
 import org.eclipse.core.filesystem.URIUtil;
 import org.eclipse.core.resources.IFile;
@@ -48,11 +47,8 @@ import org.eclipse.core.runtime.Qualifie
 import org.eclipse.dltk.core.DLTKCore;
 import org.eclipse.dltk.core.IBuildpathAttribute;
 import org.eclipse.dltk.core.IBuildpathEntry;
-import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.IScriptFolder;
 import org.eclipse.dltk.core.IScriptProject;
 import org.eclipse.dltk.core.ModelException;
-import org.eclipse.dltk.internal.core.ScriptProject;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -81,7 +77,7 @@ public class RutaProjectUtils {
     IScriptProject scriptProject = DLTKCore.create(project);
     IBuildpathEntry[] buildpathEntries = scriptProject.getRawBuildpath();
     for (IBuildpathEntry each : buildpathEntries) {
-      if (each.getEntryKind() == IBuildpathEntry.BPE_VARIABLE
+      if (each.getEntryKind() == IBuildpathEntry.BPE_CONTAINER
               && StringUtils.equals(each.getPath().toPortableString(), "RUTA_BUILD_VARS")) {
         IBuildpathAttribute[] attributes = each.getExtraAttributes();
         for (IBuildpathAttribute eachAttr : attributes) {
@@ -98,7 +94,7 @@ public class RutaProjectUtils {
     IScriptProject scriptProject = DLTKCore.create(project);
     IBuildpathEntry[] buildpathEntries = scriptProject.getRawBuildpath();
     for (IBuildpathEntry each : buildpathEntries) {
-      if (each.getEntryKind() == IBuildpathEntry.BPE_VARIABLE
+      if (each.getEntryKind() == IBuildpathEntry.BPE_CONTAINER
               && StringUtils.equals(each.getPath().toPortableString(), "RUTA_BUILD_VARS")) {
         IBuildpathAttribute[] attributes = each.getExtraAttributes();
         for (IBuildpathAttribute eachAttr : attributes) {

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=1685119&r1=1685118&r2=1685119&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 Fri Jun 12 16:08:53 2015
@@ -28,8 +28,6 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
@@ -245,7 +243,7 @@ public class RutaGenerateDescriptorMojo
       addRutaNature();
       addRutaBuildPath();
     }
-    
+
     if (filesToBuild.isEmpty()) {
       getLog().debug("UIMA Ruta Building: Skipped, since no changes were detected.");
       return;
@@ -466,99 +464,33 @@ public class RutaGenerateDescriptorMojo
     }
 
     File buildpathFile = new File(projectDir, ".buildpath");
-    if (buildpathFile.exists()) {
-      Xpp3Dom buildpathNode = null;
+    Xpp3Dom buildpathNode = new Xpp3Dom("buildpath");
+    for (String eachBP : buildPaths) {
+      String[] split = eachBP.split(":");
+      String type = "script";
+      String path = eachBP;
+      if (split.length == 2) {
+        type = split[0];
+        path = split[1];
+      }
+      addBuildPathEntry(buildpathNode, type, path);
+    }
+    Xpp3Dom buildpathentry = new Xpp3Dom("buildpathentry");
+    buildpathentry.setAttribute("kind", "con");
+    buildpathentry.setAttribute("path", "org.eclipse.dltk.launching.INTERPRETER_CONTAINER");
+    buildpathNode.addChild(buildpathentry);
+
+    addRutabuildVars(buildpathNode);
+
+    StringWriter sw = new StringWriter();
+    Xpp3DomWriter.write(sw, buildpathNode);
+    String string = sw.toString();
+    // Xpp3DomWriter creates empty string with file writer, check before writing to file
+    if (!StringUtils.isBlank(string)) {
       try {
-        buildpathNode = Xpp3DomBuilder.build(new FileReader(buildpathFile));
-      } catch (XmlPullParserException | IOException e) {
-        getLog().warn("Failed to access .buildpath file", e);
-      }
-
-      if (buildpathNode == null) {
-        return;
-      }
-
-      Collection<String> existingEntries = new HashSet<String>();
-      boolean foundInterpreter = false;
-      for (int i = 0; i < buildpathNode.getChildCount(); ++i) {
-        Xpp3Dom buildpathentry = buildpathNode.getChild(i);
-        if (buildpathentry != null
-                && StringUtils.equals(buildpathentry.getAttribute("kind"), "src")) {
-          existingEntries.add(buildpathentry.getAttribute("path"));
-        }
-        if (StringUtils.equals(buildpathentry.getAttribute("kind"), "con")
-                && StringUtils.equals(buildpathentry.getAttribute("path"),
-                        "org.eclipse.dltk.launching.INTERPRETER_CONTAINER")) {
-          foundInterpreter = true;
-        }
-        if (StringUtils.equals(buildpathentry.getAttribute("kind"), "var")
-                && StringUtils.equals(buildpathentry.getAttribute("path"), RUTA_BUILD_VARS)) {
-          buildpathNode.removeChild(i);
-        }
-      }
-      for (String eachBP : buildPaths) {
-        String[] split = eachBP.split(":");
-        String type = "script";
-        String path = eachBP;
-        if (split.length == 2) {
-          type = split[0];
-          path = split[1];
-        }
-        if (!existingEntries.contains(path)) {
-          addBuildPathEntry(buildpathNode, type, path);
-        }
-      }
-
-      addRutabuildVars(buildpathNode);
-
-      // if (!foundInterpreter) {
-      // Xpp3Dom buildpathentry = new Xpp3Dom("buildpathentry");
-      // buildpathentry.setAttribute("kind", "con");
-      // buildpathentry.setAttribute("path", "org.eclipse.dltk.launching.INTERPRETER_CONTAINER");
-      // buildpathNode.addChild(buildpathentry);
-      // }
-
-      StringWriter sw = new StringWriter();
-      Xpp3DomWriter.write(sw, buildpathNode);
-      String string = sw.toString();
-      // Xpp3DomWriter creates empty string with file writer, check before writing to file
-      if (!StringUtils.isBlank(string)) {
-        try {
-          FileUtils.fileWrite(buildpathFile, encoding, string);
-        } catch (IOException e) {
-          getLog().warn("Failed to write .buildpath file", e);
-        }
-      }
-
-    } else {
-      Xpp3Dom buildpathNode = new Xpp3Dom("buildpath");
-      for (String eachBP : buildPaths) {
-        String[] split = eachBP.split(":");
-        String type = "script";
-        String path = eachBP;
-        if (split.length == 2) {
-          type = split[0];
-          path = split[1];
-        }
-        addBuildPathEntry(buildpathNode, type, path);
-      }
-      Xpp3Dom buildpathentry = new Xpp3Dom("buildpathentry");
-      buildpathentry.setAttribute("kind", "con");
-      buildpathentry.setAttribute("path", "org.eclipse.dltk.launching.INTERPRETER_CONTAINER");
-      buildpathNode.addChild(buildpathentry);
-
-      addRutabuildVars(buildpathNode);
-
-      StringWriter sw = new StringWriter();
-      Xpp3DomWriter.write(sw, buildpathNode);
-      String string = sw.toString();
-      // Xpp3DomWriter creates empty string with file writer, check before writing to file
-      if (!StringUtils.isBlank(string)) {
-        try {
-          FileUtils.fileWrite(buildpathFile, encoding, string);
-        } catch (IOException e) {
-          getLog().warn("Failed to write .buildpath file", e);
-        }
+        FileUtils.fileWrite(buildpathFile, encoding, string);
+      } catch (IOException e) {
+        getLog().warn("Failed to write .buildpath file", e);
       }
     }
     buildContext.refresh(buildpathFile);
@@ -566,7 +498,7 @@ public class RutaGenerateDescriptorMojo
 
   private void addRutabuildVars(Xpp3Dom buildpathNode) {
     Xpp3Dom varEntry = new Xpp3Dom("buildpathentry");
-    varEntry.setAttribute("kind", "var");
+    varEntry.setAttribute("kind", "con");
     varEntry.setAttribute("path", RUTA_BUILD_VARS);
     Xpp3Dom attributes = new Xpp3Dom("attributes");
     varEntry.addChild(attributes);