forked from phunt/avro-rpc-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
158 lines (130 loc) · 5.58 KB
/
build.xml
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
<?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>