hdt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ad...@apache.org
Subject [7/8] git commit: Hadoop and dependency jars are all added from the hadoop bundle rather than the location
Date Sat, 13 Apr 2013 18:05:52 GMT
Hadoop and dependency jars are all added from the hadoop bundle rather
than the location

Project: http://git-wip-us.apache.org/repos/asf/incubator-hdt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hdt/commit/1c9333b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hdt/tree/1c9333b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hdt/diff/1c9333b0

Branch: refs/heads/master
Commit: 1c9333b0c67ad0ee530e8c10c9a1aa3bc73b7fb8
Parents: d15590c
Author: adamb <adamb@apache.org>
Authored: Sat Apr 13 12:24:15 2013 -0500
Committer: adamb <adamb@apache.org>
Committed: Sat Apr 13 12:24:15 2013 -0500

----------------------------------------------------------------------
 .../apache/hdt/core/natures/MapReduceNature.java   |   53 +++++++--------
 1 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/1c9333b0/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java
----------------------------------------------------------------------
diff --git a/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java b/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java
index ef9587e..b8999c8 100644
--- a/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java
+++ b/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java
@@ -20,6 +20,8 @@ package org.apache.hdt.core.natures;
 
 import java.io.File;
 import java.io.FileFilter;
+import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -29,12 +31,15 @@ import java.util.logging.Logger;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectNature;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
+import org.osgi.framework.Bundle;
 
 import org.apache.hdt.core.Activator;
 
@@ -62,37 +67,27 @@ public class MapReduceNature implements IProjectNature {
     String path =
         project.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID,
             "hadoop.runtime.path"));
+    
+    Bundle hadoopBundle = Platform.getBundle("org.apache.hadoop.eclipse");
+    URL jarLib = hadoopBundle.getEntry("lib/");
+    
+    File jarDir = null;
+    try {
+		jarDir = new File(FileLocator.resolve(jarLib).toURI());
+	} catch (URISyntaxException e1) {
+		// TODO Auto-generated catch block
+		e1.printStackTrace();
+	} catch (IOException e1) {
+		// TODO Auto-generated catch block
+		e1.printStackTrace();
+	}
+    
+    File[] jars = jarDir.listFiles(); 
 
-    File dir = new File(path);
     final ArrayList<File> coreJars = new ArrayList<File>();
-    dir.listFiles(new FileFilter() {
-      public boolean accept(File pathname) {
-        String fileName = pathname.getName();
-
-        // get the hadoop core jar without touching test or examples
-        // older version of hadoop don't use the word "core" -- eyhung
-        if ((fileName.indexOf("hadoop") != -1) && (fileName.endsWith("jar"))
-            && (fileName.indexOf("test") == -1)
-            && (fileName.indexOf("examples") == -1)) {
-          coreJars.add(pathname);
-        }
-
-        return false; // we don't care what this returns
-      }
-    });
-    File dir2 = new File(path + File.separatorChar + "lib");
-    if (dir2.exists() && dir2.isDirectory()) {
-      dir2.listFiles(new FileFilter() {
-        public boolean accept(File pathname) {
-          if ((!pathname.isDirectory())
-              && (pathname.getName().endsWith("jar"))) {
-            coreJars.add(pathname);
-          }
-
-          return false; // we don't care what this returns
-        }
-      });
-    }
+    for (File file : jars) {
+		coreJars.add(file);
+	}
 
     // Add Hadoop libraries onto classpath
     IJavaProject javaProject = JavaCore.create(getProject());


Mime
View raw message