hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r732853 - in /hadoop/zookeeper/trunk: ./ src/contrib/ src/contrib/fatjar/ src/contrib/fatjar/conf/ src/contrib/fatjar/src/ src/contrib/fatjar/src/java/ src/contrib/fatjar/src/java/org/ src/contrib/fatjar/src/java/org/apache/ src/contrib/fat...
Date Thu, 08 Jan 2009 22:32:01 GMT
Author: mahadev
Date: Thu Jan  8 14:32:00 2009
New Revision: 732853

URL: http://svn.apache.org/viewvc?rev=732853&view=rev
Log:
ZOOKEEPER-135. Fat jar build target. (phunt and breed via mahadev)

Added:
    hadoop/zookeeper/trunk/src/contrib/fatjar/
    hadoop/zookeeper/trunk/src/contrib/fatjar/README.txt
    hadoop/zookeeper/trunk/src/contrib/fatjar/build.xml
    hadoop/zookeeper/trunk/src/contrib/fatjar/conf/
    hadoop/zookeeper/trunk/src/contrib/fatjar/conf/mainClasses
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/
    hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/build.xml
    hadoop/zookeeper/trunk/src/contrib/build-contrib.xml
    hadoop/zookeeper/trunk/src/contrib/zkfuse/build.xml

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=732853&r1=732852&r2=732853&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Thu Jan  8 14:32:00 2009
@@ -100,6 +100,8 @@
    ZOOKEEPER-258. docs incorrectly state max client timeout as 60 seconds
 (it's based on server ticktime). (phunt via mahadev)
 
+   ZOOKEEPER-135. Fat jar build target. (phunt and breed via mahadev)
+
 Release 3.0.0 - 2008-10-21
 
 Non-backward compatible changes:

Modified: hadoop/zookeeper/trunk/build.xml
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/build.xml?rev=732853&r1=732852&r2=732853&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/build.xml (original)
+++ hadoop/zookeeper/trunk/build.xml Thu Jan  8 14:32:00 2009
@@ -380,7 +380,7 @@
     <!-- ================================================================== -->
     <!--                                                                    -->
     <!-- ================================================================== -->
-    <target name="package" depends="release-jar, javadoc"
+    <target name="package" depends="release-jar, javadoc, compile-test"
             description="Build distribution">
       <mkdir dir="${dist.dir}"/>
       <mkdir dir="${dist.dir}/lib"/>

Modified: hadoop/zookeeper/trunk/src/contrib/build-contrib.xml
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/build-contrib.xml?rev=732853&r1=732852&r2=732853&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/build-contrib.xml (original)
+++ hadoop/zookeeper/trunk/src/contrib/build-contrib.xml Thu Jan  8 14:32:00 2009
@@ -24,46 +24,86 @@
   <property name="name" value="${ant.project.name}"/>
   <property name="root" value="${basedir}"/>
 
-  <property name="hadoop.root" location="${root}/../../../"/>
+  <property name="zk.root" location="${root}/../../../"/>
 
-  <property name="build.dir" location="${hadoop.root}/build/contrib/${name}"/>
+  <property name="src.dir"  location="${root}/src/java"/>
+  <property name="src.test" location="${root}/src/test"/>
+
+  <property name="build.dir" location="${zk.root}/build/contrib/${name}"/>
+  <property name="build.classes" location="${build.dir}/classes"/>
+  <property name="build.test" location="${build.dir}/test"/>
+
+  <property name="javac.deprecation" value="on"/>
+  <property name="javac.debug" value="on"/>
+
+  <property name="build.encoding" value="ISO-8859-1"/>
 
   <!-- to be overridden by sub-projects -->
   <target name="check-contrib"/>
   <target name="init-contrib"/>
 
+  <fileset id="lib.jars" dir="${root}" includes="lib/*.jar"/>
+
+  <path id="classpath">
+    <pathelement location="${build.classes}"/>
+    <fileset refid="lib.jars"/>
+    <pathelement location="${zk.root}/build/classes"/>
+    <fileset dir="${zk.root}/src/java/lib">
+      <include name="**/*.jar" />
+    </fileset>
+  </path>
+
   <!-- ====================================================== -->
   <!-- Stuff needed by all targets                            -->
   <!-- ====================================================== -->
   <target name="init" depends="check-contrib" unless="skip.contrib">
     <echo message="contrib: ${name}"/>
     <mkdir dir="${build.dir}"/>
+    <mkdir dir="${build.classes}"/>
+    <mkdir dir="${build.test}"/>
     <antcall target="init-contrib"/>
   </target>
 
   <!-- ====================================================== -->
   <!-- Compile a contrib's files                              -->
   <!-- ====================================================== -->
-  <target name="compile" depends="init">
-    <mkdir dir="${build.dir}"/>
-    <copy todir="${build.dir}">
-      <fileset dir="${basedir}">
-        <exclude name="**/VERSION"/>
-      </fileset>
-    </copy>
-    <exec executable="echo" output="${build.dir}/VERSION">
-      <arg line="${version}" />
-    </exec>
+  <target name="compile" depends="init" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+
+    <javac
+     encoding="${build.encoding}"
+     srcdir="${src.dir}"
+     includes="**/*.java"
+     destdir="${build.classes}"
+     debug="${javac.debug}"
+     deprecation="${javac.deprecation}">
+      <classpath refid="classpath"/>
+    </javac>
   </target>
 
+  <!-- ====================================================== -->
+  <!-- Make a contrib's jar                                   -->
+  <!-- ====================================================== -->
+  <target name="jar" depends="compile" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+    <jar
+      jarfile="${build.dir}/zookeeper-${version}-${name}.jar"
+      basedir="${build.classes}"      
+    />
+  </target>
 
   <!-- ====================================================== -->
   <!-- Package a contrib's files                              -->
   <!-- ====================================================== -->
-  <target name="package" depends="compile">
+  <target name="package" depends="jar" unless="skip.contrib"> 
+    <echo message="contrib: ${name}"/>
+
     <mkdir dir="${dist.dir}/contrib/${name}"/>
-    <copy todir="${dist.dir}/contrib/${name}">
-      <fileset dir="${build.dir}"/>
+    <copy todir="${dist.dir}/contrib/${name}" includeEmptyDirs="false"
+          flatten="true">
+      <fileset dir="${build.dir}">
+        <include name="zookeeper-${version}-${name}.jar" />
+      </fileset>
     </copy>
   </target>
 

Added: hadoop/zookeeper/trunk/src/contrib/fatjar/README.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/fatjar/README.txt?rev=732853&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/fatjar/README.txt (added)
+++ hadoop/zookeeper/trunk/src/contrib/fatjar/README.txt Thu Jan  8 14:32:00 2009
@@ -0,0 +1,2 @@
+This package contains build to create a fat zookeeper jar. You need to run ant to create
the fat jar.
+To run the fatjar you can use. java -jar zoookeeper-*fatjar.jar 

Added: hadoop/zookeeper/trunk/src/contrib/fatjar/build.xml
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/fatjar/build.xml?rev=732853&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/fatjar/build.xml (added)
+++ hadoop/zookeeper/trunk/src/contrib/fatjar/build.xml Thu Jan  8 14:32:00 2009
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+
+<!--
+   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.
+-->
+
+<project name="fatjar" default="jar">
+  <import file="../build-contrib.xml"/>
+
+  <available classname="org.apache.zookeeper.ZooKeeperMain"
+             classpathref="classpath"
+             property="mainIsCompiled"/>
+
+  <target name="checkMainCompiled" unless="mainIsCompiled">
+    <fail message="ZooKeeper main must first be compiled (toplevel build.xml)"/>
+  </target>
+
+  <target name="versionedjarname" if="version">
+    <property name="jarname"
+              value="${build.dir}/zookeeper-${version}-${name}.jar"/>
+  </target>
+
+  <target name="unversionedjarname" unless="version">
+    <property name="jarname"
+              value="${build.dir}/zookeeper-dev-${name}.jar"/>
+  </target>
+
+  <target name="setjarname" depends="versionedjarname, unversionedjarname"/>
+
+  <!-- Override jar target to specify main class -->
+  <target name="jar" depends="checkMainCompiled, setjarname, compile">
+    <echo message="contrib: ${name}"/>
+
+    <jar jarfile="${jarname}">
+      <manifest>
+        <attribute name="Main-Class" value="org.apache.zookeeper.util.FatJarMain" />
+        <attribute name="Built-By" value="${user.name}"/>
+        <attribute name="Built-At" value="${build.time}"/>
+        <attribute name="Built-On" value="${host.name}" />
+        <attribute name="Implementation-Title" value="org.apache.zookeeper"/>
+        <attribute name="Implementation-Version" value="${revision}"/>
+        <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
+      </manifest>
+      <fileset file="${zk.root}/LICENSE.txt" />
+      <fileset dir="${zk.root}/build/classes" excludes="**/.generated"/>
+      <fileset dir="${zk.root}/build/testclasses"/>
+      <zipgroupfileset dir="${zk.root}/src/java/lib" includes="*.jar" />
+      <fileset dir="${build.classes}"/>
+      <fileset file="${zk.root}/conf/log4j.properties" />
+      <fileset file="${basedir}/conf/mainClasses" />
+    </jar>
+  </target>
+
+  <target name="package" depends="jar, zookeeperbuildcontrib.package"
+          unless="skip.contrib">
+
+    <copy file="${basedir}/build.xml" todir="${dist.dir}/contrib/${name}"/>
+
+    <mkdir dir="${dist.dir}/contrib/${name}/conf"/>
+    <copy todir="${dist.dir}/contrib/${name}/conf">
+      <fileset dir="${basedir}/conf"/>
+    </copy>
+
+    <mkdir dir="${dist.dir}/contrib/${name}/src"/>
+    <copy todir="${dist.dir}/contrib/${name}/src">
+      <fileset dir="${basedir}/src"/>
+    </copy>
+  </target>
+
+</project>
+

Added: hadoop/zookeeper/trunk/src/contrib/fatjar/conf/mainClasses
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/fatjar/conf/mainClasses?rev=732853&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/fatjar/conf/mainClasses (added)
+++ hadoop/zookeeper/trunk/src/contrib/fatjar/conf/mainClasses Thu Jan  8 14:32:00 2009
@@ -0,0 +1,8 @@
+::Client Commands
+client:org.apache.zookeeper.ZooKeeperMain:Client shell to ZooKeeper
+::Server Commands
+server:org.apache.zookeeper.server.quorum.QuorumPeerMain:Start ZooKeeper server
+::Test Commands
+generateLoad:org.apache.zookeeper.test.GenerateLoad:A distributed load generator for testing
+quorumBench:org.apache.zookeeper.server.QuorumBenchmark:A benchmark of just the quorum protocol
+abBench:org.apache.zookeeper.server.quorum.AtomicBroadcastBenchmark:A benchmark of just the
atomic broadcast

Added: hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java?rev=732853&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
(added)
+++ hadoop/zookeeper/trunk/src/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
Thu Jan  8 14:32:00 2009
@@ -0,0 +1,126 @@
+/**
+ * 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.zookeeper.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * This is a generic Main class that is completely driven by the
+ * /mainClasses resource on the class path. This resource has the
+ * format:
+ * <pre>
+ * cmd:mainClass:Description
+ * </pre>
+ * Any lines starting with # will be skipped
+ *
+ */
+public class FatJarMain {
+    static class Cmd {
+        Cmd(String cmd, String clazz, String desc) {
+            this.cmd = cmd;
+            this.clazz = clazz;
+            this.desc = desc;
+        }
+        String cmd;
+        String clazz;
+        String desc;
+    }
+    static HashMap<String, Cmd> cmds = new HashMap<String, Cmd>();
+    static ArrayList<String> order = new ArrayList<String>();
+    
+    /**
+     * @param args the first parameter of args will be used as an
+     * index into the /mainClasses resource. The rest will be passed
+     * to the mainClass to run.
+     * @throws IOException 
+     * @throws ClassNotFoundException 
+     * @throws NoSuchMethodException 
+     * @throws SecurityException 
+     * @throws IllegalAccessException 
+     * @throws IllegalArgumentException 
+     */
+    public static void main(String[] args) throws IOException, ClassNotFoundException, SecurityException,
NoSuchMethodException, IllegalArgumentException, IllegalAccessException {
+        InputStream is = FatJarMain.class.getResourceAsStream("/mainClasses");
+        if (is == null) {
+            System.err.println("Couldn't find /mainClasses in classpath.");
+            System.exit(3);
+        }
+        BufferedReader br = new BufferedReader(new InputStreamReader(is));
+        String line;
+        while((line = br.readLine()) != null) {
+            String parts[] = line.split(":", 3);
+            if (parts.length != 3 || (parts[0].length() > 0 && parts[0].charAt(0)
== '#')) {
+                continue;
+            }
+            if (parts[0].length() > 0) {
+                cmds.put(parts[0], new Cmd(parts[0], parts[1], parts[2]));
+                // We use the order array to preserve the order of the commands
+                // for help. The hashmap will not preserver order. (It may be overkill.)
+                order.add(parts[0]);
+            } else {
+                // Just put the description in
+                order.add(parts[2]);
+            }
+        }
+        if (args.length == 0) {
+            doHelp();
+            return;
+        }
+        Cmd cmd = cmds.get(args[0]);
+        if (cmd == null) {
+            doHelp();
+            return;
+        }
+        Class<?> clazz = Class.forName(cmd.clazz);
+        Method main = clazz.getMethod("main", String[].class);
+        String newArgs[] = new String[args.length-1];
+        System.arraycopy(args, 1, newArgs, 0, newArgs.length);
+        try {
+            main.invoke(null, (Object)newArgs);
+        } catch(InvocationTargetException e) {
+            if (e.getCause() != null) {
+                e.getCause().printStackTrace();
+            } else {
+                e.printStackTrace();
+            }
+        }
+    }
+    
+    private static void doHelp() {
+        System.err.println("USAGE: FatJarMain cmd args");
+        System.err.println("Available cmds:");
+        for(String c: order) {
+            Cmd cmd = cmds.get(c);
+            if (cmd != null) {
+                System.err.println("  " + c + " " + cmd.desc);
+            } else {
+                System.err.println(c);
+            }
+        }
+        System.exit(2);
+    }
+
+}

Modified: hadoop/zookeeper/trunk/src/contrib/zkfuse/build.xml
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkfuse/build.xml?rev=732853&r1=732852&r2=732853&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/zkfuse/build.xml (original)
+++ hadoop/zookeeper/trunk/src/contrib/zkfuse/build.xml Thu Jan  8 14:32:00 2009
@@ -19,4 +19,34 @@
 
 <project name="zkfuse" default="compile">
   <import file="../build-contrib.xml"/>
+
+  <target name="init" depends="check-contrib" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+    <mkdir dir="${build.dir}"/>
+    <antcall target="init-contrib"/>
+  </target>
+
+  <target name="compile" depends="init" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+
+    <mkdir dir="${build.dir}"/>
+    <copy todir="${build.dir}">
+      <fileset dir="${basedir}">
+        <exclude name="**/VERSION"/>
+      </fileset>
+    </copy>
+    <exec executable="echo" output="${build.dir}/VERSION">
+      <arg line="${version}" />
+    </exec>
+  </target>
+
+  <target name="package" depends="compile" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+
+    <mkdir dir="${dist.dir}/contrib/${name}"/>
+    <copy todir="${dist.dir}/contrib/${name}">
+      <fileset dir="${build.dir}"/>
+    </copy>
+  </target>
+
 </project>



Mime
View raw message