Author: pkluegl
Date: Wed Mar  5 13:50:54 2014
New Revision: 1574486

URL: http://svn.apache.org/r1574486
Log:
no jira - improve datapath handling in builder

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

Modified: 
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java?rev=1574486&r1=1574485&r2=1574486&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java
 (original)
+++ 
uima/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java
 Wed Mar  5 13:50:54 2014
@@ -37,6 +37,7 @@ import org.apache.uima.ruta.ide.core.Rut
 import org.apache.uima.ruta.ide.parser.ast.RutaModuleDeclaration;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -82,6 +83,13 @@ public class RutaBuilder extends Abstrac
       IPath outputPath = getAbsolutePath(sourceModule);
       IPath[] generateResources = generateResources(moduleDeclaration, 
outputPath, container,
               sourceModule);
+
+      IProject proj = sourceModule.getScriptProject().getProject();
+      List<IFolder> allDescriptorFolders = 
RutaProjectUtils.getAllDescriptorFolders(proj);
+      for (IFolder iFolder : allDescriptorFolders) {
+        RutaProjectUtils.addProjectDataPath(proj, iFolder);
+      }
+      
       monitor.worked(2);
       String defaultDescriptorLocation = 
RutaProjectUtils.getDefaultDescriptorLocation();
       IFolder folder = 
container.getProject().getFolder(defaultDescriptorLocation);

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=1574486&r1=1574485&r2=1574486&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
 Wed Mar  5 13:50:54 2014
@@ -19,7 +19,6 @@
 
 package org.apache.uima.ruta.ide.core.builder;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -147,7 +146,7 @@ public class RutaProjectUtils {
     return result;
   }
 
-  private static Collection<IProject> getReferencedProjects(IProject proj,
+  public static Collection<IProject> getReferencedProjects(IProject proj,
           Collection<IProject> visited) throws CoreException {
     Collection<IProject> result = new HashSet<IProject>();
     IProject[] referencedProjects = proj.getReferencedProjects();
@@ -230,26 +229,32 @@ public class RutaProjectUtils {
 
   public static void addProjectDataPath(IProject project, IFolder folder) 
throws CoreException {
     String dataPath = project.getPersistentProperty((new QualifiedName("", 
CDE_DATA_PATH)));
+    String sep = System.getProperty("path.separator");
     if (dataPath == null) {
       dataPath = "";
     }
+    String[] split = dataPath.split(sep);
+    List<String> paths = Arrays.asList(split);
     String addon = folder.getLocation().toPortableString();
-    if (!StringUtils.isEmpty(dataPath)) {
-      dataPath += File.pathSeparator;
+    if(!paths.contains(addon)) {
+      if (!StringUtils.isEmpty(dataPath)) {
+        dataPath += sep;
+      }
+      dataPath += addon;
+      project.setPersistentProperty(new QualifiedName("", CDE_DATA_PATH), 
dataPath);
     }
-    dataPath += addon;
-    project.setPersistentProperty(new QualifiedName("", CDE_DATA_PATH), 
dataPath);
   }
 
   public static void removeProjectDataPath(IProject project, IFolder folder) 
throws CoreException {
     String dataPath = project.getPersistentProperty((new QualifiedName("", 
CDE_DATA_PATH)));
+    String sep = System.getProperty("path.separator");
     if (dataPath == null) {
       return;
     }
     String path = folder.getLocation().toPortableString();
     if (!StringUtils.isEmpty(dataPath)) {
       dataPath.replaceAll(path, "");
-      dataPath.replaceAll(File.pathSeparator + File.pathSeparator, "");
+      dataPath.replaceAll(sep + sep, "");
     }
     project.setPersistentProperty(new QualifiedName("", CDE_DATA_PATH), 
dataPath);
   }


Reply via email to