File size: 9,477 Bytes
f4a7cbe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
<?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.
-->
<!-- Imported by contrib/*/build.xml files to share generic targets. -->
<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}/../../"/>
<property name="src.dir" location="${root}/src/main/java"/>
<property name="src.test" location="${root}/src/test"/>
<property name="lib.dir" location="${zk.root}/zookeeper-server/src/main/resources/lib"/>
<property name="build.dir" location="${zk.root}/zookeeper-contrib/zookeeper-contrib-${name}/target"/>
<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="utf8"/>
<property name="ivy.version" value="2.4.0"/>
<property name="ivy.url"
value="https://repo1.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"/>
<property name="ivysettings.xml" value="${zk.root}/zookeeper-contrib/ivysettings.xml"/>
<!-- to be overridden by sub-projects -->
<target name="check-contrib"/>
<target name="init-contrib"/>
<property name="lib.jars.includes" value="lib/*.jar" />
<property name="lib.jars.excludes" value="" />
<!-- prior to ant 1.7.1 fileset always fails if dir doesn't exist
so just point to bin directory and provide settings that exclude
everything - user can change as appropriate -->
<property name="additional.lib.dir" value="${zk.root}/bin" />
<property name="additional.lib.dir.includes" value="**/*.jar" />
<property name="additional.lib.dir.excludes" value="**/*.jar" />
<fileset id="lib.jars" dir="${root}">
<include name="${lib.jars.includes}" />
<exclude name="${lib.jars.excludes}" />
</fileset>
<path id="classpath">
<pathelement location="${build.classes}"/>
<!-- allow the user to override (e.g. if there are local versions) -->
<fileset dir="${additional.lib.dir}">
<include name="${additional.lib.dir.includes}" />
<exclude name="${additional.lib.dir.excludes}" />
</fileset>
<fileset refid="lib.jars"/>
<pathelement location="${zk.root}/build/classes"/>
<fileset dir="${ivy.lib}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${ivy.test.lib}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${zk.root}/zookeeper-server/src/main/resources/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${ant.home}/lib">
<include name="ant.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}"/>
<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">
<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="jar" unless="skip.contrib">
<echo message="contrib: ${name}"/>
<mkdir dir="${dist.dir}${package.share}/zookeeper-contrib/zookeeper-contrib-${name}"/>
<copy todir="${dist.dir}${package.share}/zookeeper-contrib/zookeeper-contrib-${name}" includeEmptyDirs="false"
flatten="true">
<fileset dir="${build.dir}">
<include name="zookeeper-${version}-${name}.jar" />
</fileset>
</copy>
</target>
<!-- ====================================================== -->
<!-- Package a contrib's files -->
<!-- ====================================================== -->
<target name="package-native" depends="jar" unless="skip.contrib">
<echo message="contrib: ${name}"/>
</target>
<!-- ================================================================== -->
<!-- Clean. Delete the build files, and their directories -->
<!-- ================================================================== -->
<target name="clean">
<echo message="contrib: ${name}"/>
<delete dir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- Utility features -->
<!-- ================================================================== -->
<target name="checkMainIsAvailable">
<available classname="org.apache.zookeeper.ZooKeeperMain"
property="mainIsCompiled">
<!-- we can't use id=classpath, because available fails if fileset directory
doesn't exist -->
<classpath>
<pathelement location="${zk.root}/zookeeper-server/target/classes"/>
</classpath>
</available>
</target>
<target name="checkMainCompiled" unless="mainIsCompiled" depends="checkMainIsAvailable">
<fail message="ZooKeeper main must first be compiled (toplevel build.xml)"/>
</target>
<target name="checkMainTestIsAvailable">
<available file="${zk.root}/zookeeper-server/target/test-classes/org/apache/zookeeper/test/ClientBase.class"
property="mainTestIsCompiled">
</available>
</target>
<target name="checkMainTestCompiled" unless="mainTestIsCompiled" depends="checkMainTestIsAvailable">
<fail message="ZooKeeper test must first be compiled (toplevel build.xml) using 'ant compile-test'"/>
</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"/>
<ivy:settings id="${ant.project.name}" file="${ivysettings.xml}"/>
</target>
<target name="ivy-retrieve" depends="init,ivy-init">
<ivy:retrieve settingsRef="${ant.project.name}" type="jar" conf="default"
pattern="${ivy.lib}/[artifact]-[revision].[ext]"/>
<ivy:retrieve settingsRef="${ant.project.name}" type="bundle" conf="default"
pattern="${ivy.lib}/[artifact]-[revision].[ext]"/>
</target>
<target name="ivy-retrieve-test" depends="init,ivy-init">
<ivy:retrieve settingsRef="${ant.project.name}" type="jar" conf="test"
pattern="${ivy.test.lib}/[artifact]-[revision].[ext]"/>
</target>
</project>
|