Procházet zdrojové kódy

ZOOKEEPER-534. The test target in contib/bookkeeper does not depend on jar target. (phunt via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@891486 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar před 15 roky
rodič
revize
ee25880945

+ 3 - 0
CHANGES.txt

@@ -179,6 +179,9 @@ BUGFIXES:
   ZOOKEEPER-627. zkpython arbitrarily restricts the size of a 'get' to 512
   bytes (henry robinson via mahadev)
 
+  ZOOKEEPER-534. The test target in contib/bookkeeper does not depend on jar
+  target. (phunt via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)

+ 7 - 3
src/contrib/bookkeeper/build.xml

@@ -37,8 +37,10 @@
               value="${build.dir}/zookeeper-${version}-${name}.jar"/>
   </target>
 
+  <target name="init" depends="checkMainCompiled, zookeeperbuildcontrib.init"/>
+
   <!-- Override jar target to specify main class -->
-  <target name="jar" depends="checkMainCompiled, setjarname, compile">
+  <target name="jar" depends="setjarname, compile">
     <echo message="contrib: ${name}"/>
 
     <jar jarfile="${jarname}">
@@ -56,9 +58,11 @@
     </jar>
   </target>
 
-	<target name="test" depends="compile-test,test-init,test-category,junit.run" />
+  <target name="compile" depends="ivy-retrieve,zookeeperbuildcontrib.compile"/>
+
+  <target name="test" depends="compile-test,test-init,test-category,junit.run" />
 
-	<target name="compile-test" depends="compile">
+	<target name="compile-test" depends="ivy-retrieve-test,compile">
   		<property name="target.jdk" value="${ant.java.version}" />	
 		<property name="src.test.local" location="${basedir}/test" />
 		<mkdir dir="${build.test}"/>

+ 40 - 0
src/contrib/bookkeeper/ivy.xml

@@ -0,0 +1,40 @@
+<!--
+   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.
+-->
+
+<ivy-module version="2.0"
+            xmlns:e="http://ant.apache.org/ivy/extra">
+
+  <info organisation="org.apache.zookeeper"
+        module="${name}" revision="${version}">
+    <license name="Apache 2.0"/>
+    <ivyauthor name="Apache Hadoop" url="http://hadoop.apache.org"/>
+    <description>BookKeeper</description>
+  </info>
+
+  <configurations defaultconfmapping="default">
+    <conf name="default"/>
+    <conf name="test"/>
+  </configurations>
+
+  <dependencies>
+    <!-- transitive false turns off dependency checking, log4j deps seem borked -->
+    <dependency org="log4j" name="log4j" rev="1.2.15" transitive="false"/>
+
+    <dependency org="junit" name="junit" rev="4.7" conf="test->default"/>
+  </dependencies>
+
+</ivy-module>

+ 54 - 4
src/contrib/build-contrib.xml

@@ -19,9 +19,10 @@
 
 <!-- Imported by contrib/*/build.xml files to share generic targets. -->
 
-<project name="zookeeperbuildcontrib">
+<project name="zookeeperbuildcontrib" xmlns:ivy="antlib:org.apache.ivy.ant">
 
   <property name="name" value="${ant.project.name}"/>
+  <property name="version" value="dev"/>
   <property name="root" value="${basedir}"/>
 
   <property name="zk.root" location="${root}/../../../"/>
@@ -29,6 +30,8 @@
   <property name="src.dir"  location="${root}/src/java"/>
   <property name="src.test" location="${root}/src/test"/>
 
+  <property name="lib.dir"  location="${zk.root}/src/java/lib"/>
+
   <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"/>
@@ -38,6 +41,13 @@
 
   <property name="build.encoding" value="ISO-8859-1"/>
 
+  <property name="ivy.version" value="2.1.0-rc2"/>
+  <property name="ivy.url"
+            value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
+  <property name="ivy.home" value="${user.home}/.ant" />
+  <property name="ivy.lib" value="${build.dir}/lib"/>
+  <property name="ivy.test.lib" value="${build.test}/lib"/>
+
   <!-- to be overridden by sub-projects -->
   <target name="check-contrib"/>
   <target name="init-contrib"/>
@@ -48,15 +58,18 @@
     <pathelement location="${build.classes}"/>
     <fileset refid="lib.jars"/>
     <pathelement location="${zk.root}/build/classes"/>
-    <fileset dir="${zk.root}/build/lib">
+    <fileset dir="${ivy.lib}">
       <include name="**/*.jar" />
     </fileset>
-    <fileset dir="${zk.root}/build/test/lib">
+    <fileset dir="${ivy.test.lib}">
       <include name="**/*.jar" />
     </fileset>
     <fileset dir="${zk.root}/src/java/lib">
       <include name="**/*.jar" />
     </fileset>
+    <fileset dir="${ant.home}/lib">
+      <include name="ant.jar" />
+    </fileset>
   </path>
 
   <!-- ====================================================== -->
@@ -67,13 +80,21 @@
     <mkdir dir="${build.dir}"/>
     <mkdir dir="${build.classes}"/>
     <mkdir dir="${build.test}"/>
+
+    <mkdir dir="${ivy.lib}"/>
+    <mkdir dir="${ivy.test.lib}"/>
+    <condition property="ivy.jar.exists">
+      <available file="${lib.dir}/ivy-${ivy.version}.jar"/>
+    </condition>
+
     <antcall target="init-contrib"/>
   </target>
 
   <!-- ====================================================== -->
   <!-- Compile a contrib's files                              -->
   <!-- ====================================================== -->
-  <target name="compile" depends="init" unless="skip.contrib">
+  <target name="compile" depends="init"
+          unless="skip.contrib">
     <echo message="contrib: ${name}"/>
 
     <javac
@@ -141,4 +162,33 @@
     <fail message="ZooKeeper main must first be compiled (toplevel build.xml)"/>
   </target>
 
+
+  <!-- ====================================================== -->
+  <!-- Ivy                                                    -->
+  <!-- ====================================================== -->
+  <target name="ivy-download" unless="ivy.jar.exists" depends="init">
+    <delete dir="${lib.dir}"
+            includes="ivy-*.jar" excludes="ivy-${ivy.version}.jar"/>
+    <get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
+         dest="${lib.dir}/ivy-${ivy.version}.jar" usetimestamp="true"/>
+  </target>
+
+  <target name="ivy-init" depends="ivy-download" unless="ivy.initialized">
+    <taskdef resource="org/apache/ivy/ant/antlib.xml"
+             uri="antlib:org.apache.ivy.ant" classpathref="classpath"/>
+    <!-- ensure that ivy taskdef is only run once, otw ant will error -->
+    <property name="ivy.initialized" value="true"/>
+  </target>
+
+  <target name="ivy-retrieve" depends="init,ivy-init">
+    <ivy:retrieve type="jar" conf="default"
+                  pattern="${ivy.lib}/[artifact]-[revision].[ext]"/>
+  </target>
+
+  <target name="ivy-retrieve-test" depends="init,ivy-init">
+    <ivy:retrieve type="jar" conf="test"
+                  pattern="${ivy.test.lib}/[artifact]-[revision].[ext]"/>
+  </target>
+
+
 </project>

+ 3 - 1
src/contrib/rest/build.xml

@@ -41,10 +41,12 @@
               value="${build.dir}/zookeeper-${version}-${name}.jar"/>
   </target>
 
+  <target name="compile" depends="ivy-retrieve,zookeeperbuildcontrib.compile"/>
+
   <target name="test"
           depends="compile-test,test-init,test-category,test-start,junit.run,test-stop" />
 
-	<target name="compile-test" depends="compile">
+	<target name="compile-test" depends="ivy-retrieve-test,compile">
   		<property name="target.jdk" value="${ant.java.version}" />	
 		<property name="src.test.local" location="${basedir}/src/test" />
 		<mkdir dir="${build.test}"/>

+ 40 - 0
src/contrib/rest/ivy.xml

@@ -0,0 +1,40 @@
+<!--
+   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.
+-->
+
+<ivy-module version="2.0"
+            xmlns:e="http://ant.apache.org/ivy/extra">
+
+  <info organisation="org.apache.zookeeper"
+        module="${name}" revision="${version}">
+    <license name="Apache 2.0"/>
+    <ivyauthor name="Apache Hadoop" url="http://hadoop.apache.org"/>
+    <description>ZooKeeper-REST</description>
+  </info>
+
+  <configurations defaultconfmapping="default">
+    <conf name="default"/>
+    <conf name="test"/>
+  </configurations>
+
+  <dependencies>
+    <!-- transitive false turns off dependency checking, log4j deps seem borked -->
+    <dependency org="log4j" name="log4j" rev="1.2.15" transitive="false"/>
+
+    <dependency org="junit" name="junit" rev="4.7" conf="test->default"/>
+  </dependencies>
+
+</ivy-module>