fix application installation

git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_staging@1984 123451ca-8445-de46-9d55-352943316053
diff --git a/pregelix/pregelix-api/pom.xml b/pregelix/pregelix-api/pom.xml
index a178578..1af5e9d 100644
--- a/pregelix/pregelix-api/pom.xml
+++ b/pregelix/pregelix-api/pom.xml
@@ -29,30 +29,6 @@
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-assembly-plugin</artifactId>
-				<version>2.2</version>
-				<configuration>
-					<outputDirectory>target</outputDirectory>
-					<descriptorRefs>
-						<descriptorRef>jar-with-dependencies</descriptorRef>
-					</descriptorRefs>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<version>2.6</version>
-				<configuration>
-					<systemProperties>
-						<property>
-							<name>prop.jarLocation</name>
-							<value>target/pregelix-example-${project.version}-jar-with-dependencies.jar</value>
-						</property>
-					</systemProperties>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-surefire-plugin</artifactId>
 				<version>2.7.2</version>
 				<configuration>
diff --git a/pregelix/pregelix-core/src/main/java/edu/uci/ics/pregelix/core/driver/Driver.java b/pregelix/pregelix-core/src/main/java/edu/uci/ics/pregelix/core/driver/Driver.java
index 7b03e10..c881561 100644
--- a/pregelix/pregelix-core/src/main/java/edu/uci/ics/pregelix/core/driver/Driver.java
+++ b/pregelix/pregelix-core/src/main/java/edu/uci/ics/pregelix/core/driver/Driver.java
@@ -4,10 +4,11 @@
 import java.io.FilenameFilter;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.ArrayList;
 import java.util.EnumSet;
+import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.UUID;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -90,13 +91,13 @@
             ClusterConfig.loadClusterConfig(ipAddress, port);
 
             URLClassLoader classLoader = (URLClassLoader) exampleClass.getClassLoader();
+            List<File> jars = new ArrayList<File>();
             URL[] urls = classLoader.getURLs();
-            String jarFile = "";
             for (URL url : urls)
                 if (url.toString().endsWith(".jar"))
-                    jarFile = url.getPath();
+                    jars.add(new File(url.getPath()));
 
-            installApplication(jarFile);
+            installApplication(jars);
             FileSystem dfs = FileSystem.get(job.getConfiguration());
             dfs.delete(FileOutputFormat.getOutputPath(job), true);
 
@@ -187,22 +188,9 @@
         hcc.waitForCompletion(jobId);
     }
 
-    public void installApplication(String jarFile) throws Exception {
-        System.out.println(jarFile);
-        applicationName = job.getJobName() + new UUID(System.currentTimeMillis(), System.nanoTime());
-        String home = System.getProperty(PREGELIX_HOME);
-        if (home == null)
-            home = "./";
-        String libDir = home + LIB;
-        File dir = new File(libDir);
-        if (!dir.isDirectory()) {
-            throw new HyracksException(libDir + " is not a directory!");
-        }
-        System.out.println(dir.getAbsolutePath());
-        File[] libJars = dir.listFiles(new FileFilter("jar"));
+    public void installApplication(List<File> jars) throws Exception {
         Set<String> allJars = new TreeSet<String>();
-        allJars.add(jarFile);
-        for (File jar : libJars) {
+        for (File jar : jars) {
             allJars.add(jar.getAbsolutePath());
         }
         File appZip = Utilities.getHyracksArchive(applicationName, allJars);
diff --git a/pregelix/pregelix-core/src/main/resources/scripts/pregelix b/pregelix/pregelix-core/src/main/resources/scripts/pregelix
index 3c704f0..01a0333 100644
--- a/pregelix/pregelix-core/src/main/resources/scripts/pregelix
+++ b/pregelix/pregelix-core/src/main/resources/scripts/pregelix
@@ -91,7 +91,7 @@
   REPO="$BASEDIR"/lib
 fi
 
-CLASSPATH=$CLASSPATH_PREFIX:"$HADOOP_HOME"/conf:"$BASEDIR"/etc:$(echo ${REPO}/*.jar | tr ' ' ':')
+CLASSPATH=$CLASSPATH_PREFIX:$1:"$HADOOP_HOME"/conf:"$BASEDIR"/etc:$(echo ${REPO}/*.jar | tr ' ' ':')
 
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin; then
diff --git a/pregelix/pregelix-example/pom.xml b/pregelix/pregelix-example/pom.xml
index 17caca2..f3a6541 100644
--- a/pregelix/pregelix-example/pom.xml
+++ b/pregelix/pregelix-example/pom.xml
@@ -23,28 +23,21 @@
 				</configuration>
 			</plugin>
 			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-assembly-plugin</artifactId>
-				<version>2.2</version>
 				<configuration>
-					<outputDirectory>target</outputDirectory>
 					<descriptorRefs>
 						<descriptorRef>jar-with-dependencies</descriptorRef>
 					</descriptorRefs>
 				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<version>2.6</version>
-				<configuration>
-					<systemProperties>
-						<property>
-							<name>prop.jarLocation</name>
-							<value>target/pregelix-example-${project.version}-jar-with-dependencies.jar</value>
-						</property>
-					</systemProperties>
-				</configuration>
+				<executions>
+					<execution>
+						<id>make-my-jar-with-dependencies</id>
+						<phase>package</phase>
+						<goals>
+							<goal>single</goal>
+						</goals>
+					</execution>
+				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>