Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Any/Ivy build support

  • Loading branch information...
commit 8644060ff67799924301e1be55606d86d8d383fa 1 parent 9c04fb4
@phunt authored
Showing with 209 additions and 1 deletion.
  1. +13 −1 README.textile
  2. +158 −0 build.xml
  3. +38 −0 ivy.xml
View
14 README.textile
@@ -4,7 +4,7 @@ h1. Avro RPC Quick Start
h2. Summary
-This is a template/blueprint project intended as a Quick Start introduction to Avro. You'll learn how to define a protocol, generate and compile your code, and run a working "Hello World" type example.
+This is a template/blueprint project intended as a Quick Start introduction to Avro. You'll learn how to define a protocol, generate and compile your code, and run a working "Hello World" type example. This project supports building with either Maven or Ant/Ivy, choose one.
h2. Requirements
@@ -16,12 +16,24 @@ h2. Overview of the files
h2. Compiling the sample
+Maven:
<code>
mvn compile
</code>
+Ant/Ivy:
+<code>
+ant compile
+</code>
+
h2. Running the sample
+Maven:
<code>
mvn -e exec:java -Dexec.mainClass=example.Main -Dexec.args='avro_user pat Hello_World'
</code>
+
+Ant/Ivy:
+<code>
+ant exec:java
+</code>
View
158 build.xml
@@ -0,0 +1,158 @@
+<?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="avro-rpc-quickstart" default="compile" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <property name="name" value="avro-rpc-quickstart" />
+
+ <property environment="env"/>
+
+ <property name="version" value="1.1.0" />
+ <property name="final.name" value="${name}-${version}"/>
+
+ <property name="src.dir" value="${basedir}/src/main/java" />
+ <property name="avro.schema.dir" value="${basedir}/src/main/avro" />
+
+ <property name="lib.dir" value="${basedir}/lib" />
+
+ <property name="build.dir" value="${basedir}/target" />
+ <property name="generated.dir" value="${build.dir}/generated-sources" />
+ <property name="avro.generated.dir" value="${build.dir}/generated-sources/avro" />
+ <property name="build.classes" value="${build.dir}/classes"/>
+
+ <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"/>
+
+ <!-- the normal classpath -->
+ <path id="java.classpath">
+ <pathelement location="${build.classes}"/>
+ <fileset dir="${lib.dir}">
+ <include name="**/*.jar" />
+ </fileset>
+ <fileset dir="${ant.home}/lib">
+ <include name="ant.jar" />
+ </fileset>
+ <fileset dir="${ivy.lib}">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <!-- ====================================================== -->
+ <!-- Generate and compile the Java files -->
+ <!-- ====================================================== -->
+ <target name="init">
+ <mkdir dir="${lib.dir}" />
+
+ <mkdir dir="${build.dir}" />
+ <mkdir dir="${generated.dir}" />
+ <mkdir dir="${avro.generated.dir}" />
+ <mkdir dir="${build.classes}" />
+
+ <mkdir dir="${ivy.lib}"/>
+ <condition property="ivy.jar.exists">
+ <available file="${lib.dir}/ivy-${ivy.version}.jar"/>
+ </condition>
+
+ <tstamp>
+ <format property="build.time" pattern="MM/dd/yyyy HH:mm zz" timezone="GMT"/>
+ <format property="year" pattern="yyyy" timezone="GMT"/>
+ </tstamp>
+ </target>
+
+ <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="java.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="generate" depends="ivy-retrieve">
+ <taskdef name="protocol"
+ classname="org.apache.avro.specific.ProtocolTask">
+ <classpath refid="java.classpath" />
+ </taskdef>
+ <taskdef name="schema" classname="org.apache.avro.specific.SchemaTask">
+ <classpath refid="java.classpath" />
+ </taskdef>
+ <taskdef name="paranamer"
+ classname="com.thoughtworks.paranamer.ant.ParanamerGeneratorTask">
+ <classpath refid="java.classpath" />
+ </taskdef>
+
+ <protocol destdir="${avro.generated.dir}">
+ <fileset dir="${avro.schema.dir}">
+ <include name="**/*.avpr" />
+ </fileset>
+ </protocol>
+
+ <schema destdir="${avro.generated.dir}">
+ <fileset dir="${avro.schema.dir}">
+ <include name="**/*.avsc" />
+ </fileset>
+ </schema>
+ </target>
+
+ <target name="compile-generated" depends="ivy-retrieve">
+ <javac srcdir="${avro.generated.dir}" destdir="${build.classes}">
+ <classpath refid="java.classpath"/>
+ </javac>
+
+ <paranamer sourceDirectory="${avro.generated.dir}"
+ outputDirectory="${build.classes}"/>
+ </target>
+
+ <target name="compile-app" depends="ivy-retrieve">
+ <javac srcdir="${src.dir}" destdir="${build.classes}">
+ <classpath refid="java.classpath"/>
+ </javac>
+ </target>
+
+ <target name="exec:java" depends="compile">
+ <java classname="example.Main">
+ <arg value="avro_users"/>
+ <arg value="pat"/>
+ <arg value="Hello_World"/>
+ <classpath refid="java.classpath"/>
+ </java>
+ </target>
+
+ <target name="compile" depends="generate,compile-generated,compile-app"/>
+
+ <!-- ====================================================== -->
+ <!-- Clean. Delete the build files, and their directories -->
+ <!-- ====================================================== -->
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+</project>
View
38 ivy.xml
@@ -0,0 +1,38 @@
+<!--
+ 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.avro"
+ module="${name}" revision="${version}">
+ <license name="Apache 2.0"/>
+ <ivyauthor name="Apache Hadoop" url="http://hadoop.apache.org"/>
+ <description>Avro RPC Quick Start</description>
+ </info>
+
+ <configurations defaultconfmapping="default">
+ <conf name="default"/>
+ <conf name="test"/>
+ </configurations>
+
+ <dependencies>
+ <dependency org="org.apache.hadoop" name="avro" rev="1.1.0"/>
+
+ <dependency org="junit" name="junit" rev="4.7" conf="test->default"/>
+ </dependencies>
+
+</ivy-module>
Please sign in to comment.
Something went wrong with that request. Please try again.