diff --git ant/ivy.xml ant/ivy.xml
index 0fe0a23..52c202d 100644
--- ant/ivy.xml
+++ ant/ivy.xml
@@ -27,6 +27,7 @@
+
diff --git ant/src/org/apache/hadoop/hive/ant/ShortenClassPath.java ant/src/org/apache/hadoop/hive/ant/ShortenClassPath.java
new file mode 100644
index 0000000..db93f5f
--- /dev/null
+++ ant/src/org/apache/hadoop/hive/ant/ShortenClassPath.java
@@ -0,0 +1,123 @@
+/*
+ * 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.hadoop.hive.ant;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.StringTokenizer;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * This task shortens the original class path by removing all the duplicate entries, coping
+ * all the files (JARs) into a temporary folder, removing the entries of these files from CLASSPATH
+ * or PATH, and adding this folder into CLASSPATH or PATH
+ */
+public class ShortenClassPath extends Task {
+ private String tmpJarFolderPath = null;
+ private String inputPath = null;
+ private String outputPath = null;
+
+ /**
+ * This method removes all the duplicate entries, copies all the files (JARs) into a temporary folder, removes
+ * the entries of these files from CLASSPATH or PATH, and adds this folder into CLASSPATH or PATH
+ */
+ public void execute() {
+ HashSet includedElements = new HashSet();
+ if (tmpJarFolderPath == null | inputPath == null | outputPath == null) {
+ System.err.print("Did not find proper class path configuration");
+ System.exit(0);
+ }
+
+ File tmpJarFolder = null;
+ try {
+ tmpJarFolder = new File(tmpJarFolderPath);
+ if (!tmpJarFolder.exists()) {
+ tmpJarFolder.mkdir();
+ }
+ } catch (Exception e) {
+ System.err.print("Failed to generate a folder to hold temporary jars");
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+ StringTokenizer sp = new StringTokenizer(inputPath, ";");
+ StringBuilder resultElements = new StringBuilder();
+ while (sp.hasMoreTokens()) {
+ String pathElement = sp.nextToken();
+ if (pathElement != null && !pathElement.isEmpty()) {
+ File p = new File(pathElement);
+ if (p.exists()) {
+ String setItem = pathElement.toLowerCase();
+ if (p.isFile()) {
+ setItem = p.getName().toLowerCase();
+ }
+ if (!includedElements.contains(setItem)) {
+ includedElements.add(setItem);
+ if (p.isFile()) {
+ try {
+ if (tmpJarFolder != null) {
+ FileUtils.copyFileToDirectory(p,
+ tmpJarFolder);
+ }
+ } catch (Exception e) {
+ System.err.println("Failed to copy a jar to the folder that holds temporary jars");
+ e.printStackTrace();
+ System.exit(0);
+ }
+ } else {
+ resultElements.append(pathElement + ";");
+ }
+ }
+ }
+ }
+ }
+ resultElements.append(tmpJarFolderPath + "\\*");
+
+ Project project = getProject();
+ project.setProperty(outputPath, resultElements.toString());
+ }
+
+ public void setTmpJarFolderPath(String tmpJarFolderPath) {
+ this.tmpJarFolderPath = tmpJarFolderPath;
+ }
+
+ public void setInputPath(String inputPath) {
+ this.inputPath = inputPath;
+ }
+
+ public void setOutputPath(String outputPath) {
+ this.outputPath = outputPath;
+ }
+
+ public String getOutputPath() {
+ return outputPath;
+ }
+
+ public String getInputPath() {
+ return inputPath;
+ }
+
+ public String getTmpJarFolderPath() {
+ return tmpJarFolderPath;
+ }
+
+}
\ No newline at end of file
diff --git build-common.xml build-common.xml
index 96e8046..a6516c2 100644
--- build-common.xml
+++ build-common.xml
@@ -53,6 +53,7 @@
+
@@ -109,6 +110,18 @@
+
+
+
+
+
+
+
+
+
@@ -401,7 +414,6 @@
-
@@ -416,9 +428,12 @@
+
+
+