THRIFT-363. java: Maven deploy

It finally works\!

Patch: Jake Farrell

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1085046 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/Makefile.am b/lib/java/Makefile.am
index cb1332e..c5c7521 100644
--- a/lib/java/Makefile.am
+++ b/lib/java/Makefile.am
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-EXTRA_DIST = build.xml ivy.xml src test
+EXTRA_DIST = build.xml src test
 
 export CLASSPATH
 
diff --git a/lib/java/build.xml b/lib/java/build.xml
index f0b09b4..096bfc7 100644
--- a/lib/java/build.xml
+++ b/lib/java/build.xml
@@ -22,85 +22,112 @@
   xmlns:artifact="antlib:org.apache.maven.artifact.ant">
 
   <description>Thrift Build File</description>
-
-  <property environment="env" />
-
-  <property name="gen" location="gen-java" />
-  <property name="genbean" location="gen-javabean" />
-  <property name="mvn.ant.task.version" value="2.1.0" />
-  
-  <property name="src" location="src" />
-  <property name="build" location="build" />
-  <property name="javadoc" location="${build}/javadoc" />
-  <property name="install.path" value="/usr/local/lib" />
-  <property name="src.test" location="test" />
-  <property name="build.test" location="${build}/test" />
-  <property name="test.thrift.home" location="../../test"/>
   <property name="thrift.root" location="../../"/>
-  <property name="jar.file" location="${basedir}/libthrift.jar" />  
-  <property name="test.jar.file" location="${basedir}/libthrift-test.jar" />
+  <property name="thrift.version" value="0.7.0"/>
+  <property name="thrift.groupid" value="org.apache.thrift"/>
+  <property name="thrift.artifactid" value="libthrift"/>
+	
+  <property name="mvn.ant.task.version" value="2.1.1"/>
+  <property name="ivy.version" value="2.2.0"/>
+ 	
+  <!-- Local install locations -->
+  <property name="install.path" value="/usr/local/lib"/>
+  <property name="install.javadoc.path" value="${install.path}"/>
 
-  <property file="${user.home}/.thrift-build.properties" />
-
-  <!-- ivy properties -->
-  <property name="ivy.version" value="2.0.0-rc2" />
-  <property name="ivy.dir" location="${build}/ivy" />
-  <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
-  <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
-  <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
-  <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
-  <property name="mvn_ant_task_url" value="http://www.reverse.net/pub/apache/maven/binaries/maven-ant-tasks-${mvn.ant.task.version}.jar" />
-  <property name="mvn.ant.task.jar" location="${ivy.dir}/maven-ant-tasks-${mvn.ant.task.version}.jar" />
-  <property name="sources.zip" location="${build}/libthrift-src.zip" />
-  <property name="pom.file" location="${build}/pom.xml" />
+  <!-- Dependency download location -->
+  <property name="mvn.repo" value="http://repo1.maven.org/maven2"/>
+  <property name="apache.repo" value="https://repository.apache.org/content/repositories/releases"/>	
   
-  <!-- TODO: Get the appropriate tokens / URL for upload -->  
-  <property name="apache.snapshot.repository" value="https://repository.apache.org/content/repositories/snapshots" />
- 
+  <!-- Publish information-->
+  <property name="license" value="http://www.apache.org/licenses/LICENSE-2.0.txt"/>
+  <property name="maven-repository-url" value="https://repository.apache.org/service/local/staging/deploy/maven2"/>
+  <property name="maven-repository-id" value="apache.releases.https"/>	
+
+  <property environment="env"/>
+
+  <condition property="version" value="${thrift.version}">
+    <isset property="release"/>
+  </condition>
+  <property name="version" value="${thrift.version}-snapshot"/>	
+
+  <property name="final.name" value="${thrift.artifactid}-${version}"/>
+
+  <property name="gen" location="gen-java"/>
+  <property name="genbean" location="gen-javabean"/>
+
+  <property name="src" location="${basedir}/src"/>
+  <property name="build.dir" location="${basedir}/build"/>
+  <property name="build.lib.dir" location="${build.dir}/lib"/>
+  <property name="build.tools.dir" location="${build.dir}/tools"/>
+  <property name="src.test" location="test"/>
+  <property name="build.test.dir" location="${build.dir}/test"/>
+  <property name="test.thrift.home" location="${thrift.root}/test"/>
+
+  <property name="javadoc.dir" location="${build.dir}/javadoc"/>
+  
+  <property name="jar.file" location="${build.dir}/${final.name}.jar"/>
+  <property name="test.jar.file" location="${build.dir}/${final.name}-test.jar"/>
+  <property name="javadoc.jar.file" location="${build.dir}/${final.name}-javadoc.jar"/>
+  <property name="source.tar.gz" location="${build.dir}/${final.name}-src.tar.gz"/>
+
+  <!-- Junit properties -->
+  <property name="test.junit.output.format" value="plain"/>
+  <property name="test.timeout" value="2000000"/>
+  <property name="test.src.dir" location="${basedir}/test"/>
+  <property name="test.log.dir" value="${build.test.dir}/log"/>
+  <property name="test.port" value="9090"/>	
+
+  <!-- ivy properties -->	
+  <property name="ivy.repo.url" value="${mvn.repo}/org/apache/ivy/ivy/${ivy.version}/"/>
+  <property name="ivy.jar" value="${build.tools.dir}/ivy-${ivy.version}.jar"/>	
+
+  <!-- maven properties -->
+  <property name="mvn.ant.task.url" value="${mvn.repo}/org/apache/maven/maven-ant-tasks/${mvn.ant.task.version}"/>
+  <property name="mvn.ant.task.jar" location="${build.tools.dir}/maven-ant-tasks-${mvn.ant.task.version}.jar"/>
+  <property name="pom.xml" location="${build.dir}/${final.name}.pom"/>
+
+  <!-- custom override anything with a thrift-build.properties file in your home directory -->	
+  <property file="${user.home}/.thrift-build.properties"/>
+
   <path id="compile.classpath">
-    <path refid="ivy.compile.classpath" />
+    <fileset dir="${build.lib.dir}"> 
+      <include name="**/*.jar"/>
+    </fileset>
   </path>
 
   <path id="test.classpath">
-    <path refid="compile.classpath" />
-    <path refid="ivy.test.classpath" />
-    <pathelement path="${env.CLASSPATH}" />
-    <pathelement location="build/test" />
-    <pathelement location="${jar.file}" />
+    <path refid="compile.classpath"/>
+    <pathelement path="${env.CLASSPATH}"/>
+    <pathelement location="${build.test.dir}"/>
+    <pathelement location="${jar.file}"/>
+    <pathelement location="${test.jar.file}"/>
   </path>
 
-  <target name="init">
-    <tstamp />
-    <mkdir dir="${build}"/>
-    <mkdir dir="${build.test}" />
-    <!--
-    Allow Ivy to be disabled with "-Dnoivy=".
-    It is kind of a hack to pretend that we already found it,
-    but Ant doesn't provide an easy way of blocking dependencies
-    from executing or checking multiple conditions.
-    -->
-    <condition property="ivy.found"><isset property="noivy" /></condition>
-    <condition property="offline"><isset property="noivy" /></condition>
+  <!-- Tasks -->	
+  <target name="init" depends="setup.init,ivy.init,mvn.init" unless="init.finished">
+    <property name="init.finished" value="true"/>
   </target>
 
-  <target name="ivy-init-dirs">
-    <mkdir dir="${ivy.dir}" />
-    <mkdir dir="${ivy.lib.dir}" />
+  <target name="setup.init">
+    <tstamp/>
+    <mkdir dir="${build.dir}"/>
+    <mkdir dir="${build.lib.dir}"/>
+    <mkdir dir="${build.tools.dir}"/>
+    <mkdir dir="${build.test.dir}"/>
   </target>
 
-  <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
-    <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
+  <target name="ivy.download" depends="setup.init" unless="ivy.found">
+    <get src="${ivy.repo.url}/ivy-${ivy.version}.jar" dest="${ivy.jar}" usetimestamp="true"/>
   </target>
 
-  <target name="ivy-probe-antlib">
+  <target name="ivy.check" description="check if ivy is in the classpath">
     <condition property="ivy.found">
       <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
     </condition>
   </target>
 
-  <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
-    <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
-      loaderRef="ivyLoader">
+  <target name="ivy.init" depends="setup.init,ivy.check,ivy.download" unless="ivy.found">
+    <typedef uri="antlib:org.apache.ivy.ant" onerror="fail" loaderRef="ivyLoader">
       <classpath>
         <pathelement location="${ivy.jar}"/>
       </classpath>
@@ -111,110 +138,90 @@
           <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
         </not>
       </condition>
-      You need Apache Ivy 2.0 or later from http://ant.apache.org/
-      It could not be loaded from ${ivy_repo_url}
+      You need Apache Ivy 2.0 or later from ${ivy.repo.url}. It could not be loaded from ${ivy.jar}
     </fail>
   </target>
 
-  <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
-    <ivy:retrieve />
-    <ivy:cachepath pathid="ivy.compile.classpath" conf="compile" />
-    <ivy:cachepath pathid="ivy.test.classpath" conf="test" />
+  <target name="compile" depends="init">
+    <javac srcdir="${src}" destdir="${build.dir}" source="1.5" target="1.5" 
+      debug="true" classpathref="compile.classpath" includeantruntime="false"/>
   </target>
 
-  <target name="resolve-offline" depends="ivy-init-antlib" description="retrieve dependencies with ivy" if="noivy">
-    <path id="ivy.compile.classpath">
-      <fileset dir="${ivy.lib.dir}">
-        <include name="**/*.jar" />
-      </fileset>
-    </path>
-    <path id="ivy.test.classpath">
-    <!-- same as ivy.compile.classpath, but has to be defined -->
-    </path>
-  </target>
-
-  <target name="compile" depends="init,resolve,resolve-offline">
-    <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
-  </target>
-
-  <target name="javadoc" depends="init,resolve,resolve-offline">
-    <javadoc sourcepath="${src}"
-      destdir="${javadoc}"
-      version="true"
-      windowtitle="Thrift Java API"
-      doctitle="Thrift Java API"
+  <target name="javadoc" depends="init">
+    <javadoc sourcepath="${src}" destdir="${javadoc.dir}"
+      version="true" windowtitle="Thrift Java API" doctitle="Thrift Java API"
       classpathref="test.classpath">
     </javadoc>
+    <jar jarfile="${javadoc.jar.file}" basedir="${javadoc.dir}">
+      <manifest>
+        <attribute name="Implementation-Version" value="${version}"/>
+      </manifest>
+    </jar>
   </target>
 
   <target name="dist" depends="compile">
-    <mkdir dir="${build}/META-INF"/>
-    <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
-    <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
+    <mkdir dir="${build.dir}/META-INF"/>
+    <copy file="${thrift.root}/LICENSE" tofile="${build.dir}/META-INF/LICENSE.txt"/>
+    <copy file="${thrift.root}/NOTICE" tofile="${build.dir}/META-INF/NOTICE.txt"/>
     <jar jarfile="${jar.file}">
-      <fileset dir="${build}">
-        <include name="org/apache/thrift/**/*.class" />
-        <include name="META-INF/*.txt" />
+      <manifest>
+        <attribute name="Implementation-Version" value="${version}"/>
+      </manifest>
+      <fileset dir="${build.dir}">
+        <include name="org/apache/thrift/**/*.class"/>
+        <include name="META-INF/*.txt"/>
       </fileset>
       <fileset dir="src">
-        <include name="**/*.java" />
+        <include name="**/*.java"/>
       </fileset>
     </jar>
   </target>
 
+  <target name="pack.src">
+    <tar destfile="${source.tar.gz}" basedir="${src}" compression="gzip"/>
+  </target>
+
   <target name="install" depends="dist,javadoc">
     <copy todir="${install.path}">
-        <fileset dir="."><include name="*.jar" /></fileset>
+        <fileset dir="."><include name="*.jar"/></fileset>
     </copy>
     <copy todir="${install.javadoc.path}">
-      <fileset dir="${javadoc}">
-        <include name="**/*" />
+      <fileset dir="${javadoc.dir}">
+        <include name="**/*"/>
       </fileset>
     </copy>
   </target>
 
   <target name="clean">
-    <delete dir="${build}" />
+    <delete dir="${build.dir}"/>
     <delete dir="${gen}"/>
     <delete dir="${genbean}"/>
-    <delete dir="${javadoc}"/>
-    <delete file="${jar.file}" />
-    <delete file="${test.jar.file}" />
   </target>
 
   <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
-    <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
-    <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
-    <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
-    <copy todir="${build.test}">
-      <fileset dir="${src.test}" includes="log4j.properties" />
+    <javac debug="true" srcdir="${gen}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false"/>
+    <javac debug="true" srcdir="${genbean}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false"/>
+    <javac debug="true" srcdir="${src.test}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false"/>
+    <copy todir="${build.test.dir}">
+      <fileset dir="${src.test}" includes="log4j.properties"/>
     </copy>
-    <jar jarfile="${test.jar.file}" basedir="${build}/test"/>
+    <jar jarfile="${test.jar.file}" basedir="${build.test.dir}"/>
   </target>
 
-  <property name="build.test" location="${build.dir}/test"/>
-  <property name="test.junit.output.format" value="plain"/>
-  <property name="test.timeout" value="2000000"/>
-  <property name="test.src.dir" location="${basedir}/test"/>
-  <property name="test.log.dir" value="${build.test}/log"/>
-  <property name="test.port" value="9090" />
-
   <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
     <mkdir dir="${test.log.dir}"/>
-    <junit
-      printsummary="yes" showoutput="${test.output}" 
-      haltonfailure="no" fork="yes" maxmemory="512m"
-      errorProperty="tests.failed" failureProperty="tests.failed"
-      timeout="${test.timeout}"
+    <junit printsummary="true" showoutput="${test.output}" timeout="${test.timeout}" 
+      haltonfailure="no" errorProperty="tests.failed" failureProperty="tests.failed"
+      fork="true" forkmode="perTest" maxmemory="512m"
     >
-      <sysproperty key="build.test" value="${build.test}"/>
-      <sysproperty key="test.port" value="${test.port}" />
+      <sysproperty key="build.test" value="${build.test.dir}"/>
+      <sysproperty key="test.port" value="${test.port}"/>
       <sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
       <sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
       <sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
       <sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
       <classpath refid="test.classpath"/>
-      <formatter type="${test.junit.output.format}" />
+      <formatter type="${test.junit.output.format}"/>
       <batchtest todir="${test.log.dir}" unless="testcase">
         <fileset dir="${test.src.dir}">
           <include name="**/Test*.java"/>
@@ -224,17 +231,15 @@
         </fileset>
       </batchtest>
       <batchtest todir="${test.log.dir}" if="testcase">
-        <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
+        <fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
       </batchtest>
     </junit>
     <fail if="tests.failed">Tests failed!</fail>
   </target>
 
   <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
-    <java classname="org.apache.thrift.test.EqualityTest"
-      classpathref="test.classpath" failonerror="true" />
-    <java classname="org.apache.thrift.test.JavaBeansTest"
-      classpathref="test.classpath" failonerror="true" />
+    <java classname="org.apache.thrift.test.EqualityTest" classpathref="test.classpath" failonerror="true"/>
+    <java classname="org.apache.thrift.test.JavaBeansTest" classpathref="test.classpath" failonerror="true"/>
   </target>
 
   <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
@@ -242,72 +247,141 @@
   <target name="testclient" description="Run a test client" depends="compile-test">
     <java classname="org.apache.thrift.test.TestClient"
       classpathref="test.classpath" failonerror="true">
-      <arg line="${testargs}" />
+      <arg line="${testargs}"/>
     </java>
   </target>
 
   <target name="testserver" description="Run a test server" depends="compile-test">
     <java classname="org.apache.thrift.test.TestServer"
       classpathref="test.classpath" failonerror="true">
-      <arg line="${testargs}" />
+      <arg line="${testargs}"/>
     </java>
   </target>
 
   <target name="testnonblockingserver" description="Run a test nonblocking server" depends="compile-test">
     <java classname="org.apache.thrift.test.TestNonblockingServer"
       classpathref="test.classpath" failonerror="true">
-      <arg line="${testargs}" />
+      <arg line="${testargs}"/>
     </java>
   </target>
 
   <target name="generate">
+    <!-- Generate the thrift gen-java source -->
     <exec executable="../../compiler/cpp/thrift" failonerror="true">
-      <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
+      <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift"/>
     </exec>
     <exec executable="../../compiler/cpp/thrift" failonerror="true">
-      <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
+      <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift"/>
     </exec>
     <exec executable="../../compiler/cpp/thrift" failonerror="true">
-      <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
+      <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift"/>
     </exec>
     <exec executable="../../compiler/cpp/thrift" failonerror="true">
-      <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
+      <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift"/>
     </exec>
   </target>
 
-  <target name="mvn.init">
-    <get src="${mvn_ant_task_url}" dest="${mvn.ant.task.jar}" usetimestamp="true" /> 
-    <path id="maven-ant-tasks.classpath" path="${mvn.ant.task.jar}" />
-  <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
-                        uri="antlib:org.apache.maven.artifact.ant"
-          classpathref="maven-ant-tasks.classpath" />
+  <target name="mvn.ant.tasks.download" depends="setup.init" unless="mvn.ant.tasks.found">
+    <get src="${mvn.ant.task.url}/maven-ant-tasks-${mvn.ant.task.version}.jar" dest="${mvn.ant.task.jar}" usetimestamp="true"/>
   </target>
 
-  <target name="pack.src">
-    <zip destfile="${sources.zip}" basedir="${src}" />
+  <target name="mvn.ant.tasks.check">
+    <condition property="mvn.ant.tasks.found">
+      <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
+    </condition>
+  </target>	
+
+  <target name="mvn.init" depends="mvn.ant.tasks.download" unless="mvn.finished">
+    <!-- Download mvn ant tasks, download dependencies, and setup pom file -->
+    <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${mvn.ant.task.jar}"/>
+
+    <!-- remote repositories used to download dependencies from -->
+    <artifact:remoteRepository id="central" url="${mvn.repo}"/>
+    <artifact:remoteRepository id="apache" url="${apache.repo}"/>
+
+    <!-- Pom file information -->
+    <artifact:pom id="pom" 
+      groupId="${thrift.groupid}" 
+      artifactId="${thrift.artifactid}"
+      version="${version}" 
+      url="http://thrift.apache.org"
+      name="Apache Thrift"
+      description="Thrift is a software framework for scalable cross-language services development."
+      packaging="pom"
+    >
+      <remoteRepository refid="central"/>
+      <remoteRepository refid="apache"/>
+      <license name="The Apache Software License, Version 2.0" url="${license}"/>
+      <scm connection="scm:svn:http://svn.apache.org/repos/asf/thrift/trunk/" 
+        developerConnection="scm:svn:http://svn.apache.org/repos/asf/thrift/trunk/"
+        url="http://svn.apache.org/viewcvs.cgi/thrift"
+      />
+      <!-- Thrift Developers -->
+      <developer id="mcslee" name="Mark Slee"/>
+      <developer id="dreiss" name="David Reiss"/>
+      <developer id="aditya" name="Aditya Agarwal"/>
+      <developer id="marck" name="Marc Kwiatkowski"/>
+      <developer id="jwang" name="James Wang"/>
+      <developer id="cpiro" name="Chris Piro"/>
+      <developer id="bmaurer" name="Ben Maurer"/>
+      <developer id="kclark" name="Kevin Clark"/>
+      <developer id="jake" name="Jake Luciani"/>
+      <developer id="bryanduxbury" name="Bryan Duxbury"/>
+      <developer id="esteve" name="Esteve Fernandez"/>
+      <developer id="todd" name="Todd Lipcon"/>
+      <developer id="geechorama" name="Andrew McGeachie"/>
+      <developer id="molinaro" name="Anthony Molinaro"/>
+      <developer id="roger" name="Roger Meier"/>
+
+      <!-- Thrift dependencies list -->
+      <dependency groupId="org.slf4j" artifactId="slf4j-api" version="1.5.8"/>
+      <dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.5.8"/>
+      <dependency groupId="commons-lang" artifactId="commons-lang" version="2.5"/>
+      <dependency groupId="junit" artifactId="junit" version="4.4"/>
+      <dependency groupId="javax.servlet" artifactId="servlet-api" version="2.5"/>
+      <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
+    </artifact:pom>
+
+    <!-- Generate the pom file -->
+    <artifact:writepom pomRefId="pom" file="${pom.xml}"/>
+
+    <!-- Download the dependencies -->
+    <artifact:dependencies filesetId="build-dependency-jars" pomRefId="pom"/>
+
+    <!-- Copy the dependencies to the build/lib dir -->
+    <copy todir="${build.dir}/lib">
+      <fileset refid="build-dependency-jars"/>
+      <mapper type="flatten"/>
+    </copy>
+
+    <property name="mvn.finished" value="true"/>
   </target>
 
-  <target name="generate.pom" depends="init,resolve" description="Generate a Maven POM file for libthrift">
-    <ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${pom.file}" >
-      <mapping conf="default" scope="compile" />
-      <mapping conf="runtime" scope="runtime" />
-    </ivy:makepom>
-  </target>
+  <macrodef name="signAndDeploy">
+    <!-- Sign and deploy jars to apache repo -->
+    <attribute name="file"/>
+    <attribute name="classifier" default=""/>
+    <attribute name="packaging" default="jar"/>
+    <sequential>
+      <artifact:mvn fork="true">
+        <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file"/>
+        <arg value="-DrepositoryId=${maven-repository-id}"/>
+        <arg value="-Durl=${maven-repository-url}"/>
+        <arg value="-DpomFile=${pom.xml}"/>
+        <arg value="-Dfile=@{file}"/>
+        <arg value="-Dclassifier=@{classifier}"/>
+        <arg value="-Dpackaging=@{packaging}"/>
+        <arg value="-Pgpg"/>
+      </artifact:mvn>
+    </sequential>
+  </macrodef>
 
-  <target name="publish" depends="test,dist,mvn.init,generate.pom,pack.src">
-    <artifact:pom id="pom" file="${pom.file}" />
-
-    <artifact:install file="${jar.file}">
-      <pom refid="pom"/>
-      <attach file="${sources.zip}" classifier="source" />
-    </artifact:install>
-
-    <artifact:remoteRepository id="remote.repository" url="${apache.snapshot.repository}" />
-
-    <artifact:deploy file="${jar.file}">
-      <remoteRepository refid="remote.repository" />
-      <pom refid="pom"/>
-      <attach file="${sources.zip}" classifier="source" />
-    </artifact:deploy>
+  <target name="publish" depends="clean,init,test,dist,javadoc,pack.src">
+    <!-- Compile, package, test and then send release to apache maven repo -->
+    <!-- run with: ant -Drelease=true publish-->
+    <signAndDeploy file="${pom.xml}" packaging="pom" classifier=""/>
+    <signAndDeploy file="${jar.file}" packaging="jar" classifier=""/>
+    <signAndDeploy file="${javadoc.jar.file}" packaging="jar" classifier="javadoc"/>
+    <signAndDeploy file="${source.tar.gz}" packaging="src" classifier="tar.gz"/>
   </target>
 </project>
diff --git a/lib/java/ivy.xml b/lib/java/ivy.xml
deleted file mode 100644
index 1ba933d..0000000
--- a/lib/java/ivy.xml
+++ /dev/null
@@ -1,38 +0,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.
--->
-<ivy-module version="1.0">
-    <info organisation="org.apache.thrift" module="libthrift" revision="0.7.0-dev" >
-      <license name="Apache License 2.0" url="http://www.apache.org/licenses/LICENSE-2.0" />
-      <ivyauthor name="Thrift Developers" url="dev@thrift.apache.org" />
-      <repository name="apache repository" url="http://thrift.apache.org" />
-      <description homepage="http://thrift.apache.org">
-      Java bindings for the Apache Thrift RPC system
-      </description>
-    </info>
-    <configurations defaultconfmapping="compile">
-      <conf name="compile" />
-      <conf name="test" extends="compile" visibility="private" />
-    </configurations>
-    <dependencies>
-       <dependency org="org.slf4j" name="slf4j-api" rev="1.5.8" conf="* -> *,!sources,!javadoc"/>
-       <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.8" conf="test -> *,!sources,!javadoc"/>
-       <dependency org="commons-lang" name="commons-lang" rev="2.5" conf="* -> *,!sources,!javadoc"/>
-       <dependency org="junit" name="junit" rev="4.4" conf="test -> *,!sources,!javadoc"/>
-       <dependency org="javax.servlet" name="servlet-api" rev="2.5" conf="* -> *,!sources,!javadoc"/>
-       <dependency org="org.apache.httpcomponents" name="httpclient" rev="4.0.1" conf="* -> *,!sources,!javadoc"/>
-    </dependencies>
-</ivy-module>