initial commit of core plugin, that has the mr nature
diff --git a/org.apache.hdt.core/.classpath b/org.apache.hdt.core/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/org.apache.hdt.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.apache.hdt.core/.gitignore b/org.apache.hdt.core/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/org.apache.hdt.core/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/org.apache.hdt.core/.project b/org.apache.hdt.core/.project
new file mode 100644
index 0000000..bb03cc0
--- /dev/null
+++ b/org.apache.hdt.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.hdt.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.apache.hdt.core/.settings/org.eclipse.jdt.core.prefs b/org.apache.hdt.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/org.apache.hdt.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.apache.hdt.core/META-INF/MANIFEST.MF b/org.apache.hdt.core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..de9d579
--- /dev/null
+++ b/org.apache.hdt.core/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Hadoop Development Tools Core
+Bundle-SymbolicName: org.apache.hdt.core;singleton:=true
+Bundle-Version: 0.0.0
+Bundle-Activator: org.apache.hdt.core.Activator
+Bundle-Vendor: Apache Software Foundation
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
diff --git a/org.apache.hdt.core/build.properties b/org.apache.hdt.core/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/org.apache.hdt.core/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/org.apache.hdt.core/plugin.xml b/org.apache.hdt.core/plugin.xml
new file mode 100644
index 0000000..fbed8c5
--- /dev/null
+++ b/org.apache.hdt.core/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="org.apache.hdt.mrnature"
+ name="MapReduce Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.apache.hdt.core.natures.MapReduceNature">
+ </run>
+ </runtime>
+ </extension>
+
+</plugin>
diff --git a/org.apache.hdt.core/src/org/apache/hdt/core/Activator.java b/org.apache.hdt.core/src/org/apache/hdt/core/Activator.java
new file mode 100644
index 0000000..624d949
--- /dev/null
+++ b/org.apache.hdt.core/src/org/apache/hdt/core/Activator.java
@@ -0,0 +1,31 @@
+package org.apache.hdt.core;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+ public static final String PLUGIN_ID = "org.apache.hdt.core";
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
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
new file mode 100644
index 0000000..7b10d25
--- /dev/null
+++ b/org.apache.hdt.core/src/org/apache/hdt/core/natures/MapReduceNature.java
@@ -0,0 +1,151 @@
+/**
+ * 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.
+ */
+
+package org.apache.hdt.core.natures;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+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.apache.hdt.core.Activator;
+
+/**
+ * Class to configure and deconfigure an Eclipse project with the MapReduce
+ * project nature.
+ */
+
+public class MapReduceNature implements IProjectNature {
+
+ public static final String ID = "org.apache.hadoop.eclipse.Nature";
+
+ private IProject project;
+
+ static Logger log = Logger.getLogger(MapReduceNature.class.getName());
+
+ /**
+ * Configures an Eclipse project as a Map/Reduce project by adding the
+ * Hadoop libraries to a project's classpath.
+ */
+ /*
+ * TODO Versioning connector needed here
+ */
+ public void configure() throws CoreException {
+ String path =
+ project.getPersistentProperty(new QualifiedName(Activator.PLUGIN_ID,
+ "hadoop.runtime.path"));
+
+ 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
+ }
+ });
+ }
+
+ // Add Hadoop libraries onto classpath
+ IJavaProject javaProject = JavaCore.create(getProject());
+ // Bundle bundle = Activator.getDefault().getBundle();
+ try {
+ IClasspathEntry[] currentCp = javaProject.getRawClasspath();
+ IClasspathEntry[] newCp =
+ new IClasspathEntry[currentCp.length + coreJars.size()];
+ System.arraycopy(currentCp, 0, newCp, 0, currentCp.length);
+
+ final Iterator<File> i = coreJars.iterator();
+ int count = 0;
+ while (i.hasNext()) {
+ // for (int i = 0; i < s_coreJarNames.length; i++) {
+
+ final File f = (File) i.next();
+ // URL url = FileLocator.toFileURL(FileLocator.find(bundle, new
+ // Path("lib/" + s_coreJarNames[i]), null));
+ URL url = f.toURI().toURL();
+ log.finer("hadoop library url.getPath() = " + url.getPath());
+
+ newCp[newCp.length - 1 - count] =
+ JavaCore.newLibraryEntry(new Path(url.getPath()), null, null);
+ count++;
+ }
+
+ javaProject.setRawClasspath(newCp, new NullProgressMonitor());
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "IOException generated in "
+ + this.getClass().getCanonicalName(), e);
+ }
+ }
+
+ /**
+ * Deconfigure a project from MapReduce status. Currently unimplemented.
+ */
+ public void deconfigure() throws CoreException {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Returns the project to which this project nature applies.
+ */
+ public IProject getProject() {
+ return this.project;
+ }
+
+ /**
+ * Sets the project to which this nature applies. Used when instantiating
+ * this project nature runtime.
+ */
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}