0
|
1 <?xml version="1.0"?>
|
|
2 <!--
|
|
3 Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4 contributor license agreements. See the NOTICE file distributed with
|
|
5 this work for additional information regarding copyright ownership.
|
|
6 The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7 (the "License"); you may not use this file except in compliance with
|
|
8 the License. You may obtain a copy of the License at
|
|
9
|
|
10 http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
|
12 Unless required by applicable law or agreed to in writing, software
|
|
13 distributed under the License is distributed on an "AS IS" BASIS,
|
|
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15 See the License for the specific language governing permissions and
|
|
16 limitations under the License.
|
|
17 -->
|
|
18 <!-- Imported by plugin build.xml files to define default targets. -->
|
|
19 <project xmlns:ivy="antlib:org.apache.ivy.ant">
|
|
20
|
|
21 <property name="name" value="${ant.project.name}"/>
|
|
22 <property name="root" value="${basedir}"/>
|
|
23
|
|
24 <!-- load plugin-specific properties first -->
|
|
25 <property file="${user.home}/${name}.build.properties" />
|
|
26 <property file="${root}/build.properties" />
|
|
27
|
|
28 <property name="nutch.root" location="${root}/../../../"/>
|
|
29
|
|
30 <property name="src.dir" location="${root}/src/java"/>
|
|
31 <property name="src.test" location="${root}/src/test"/>
|
|
32
|
|
33 <available file="${src.test}" type="dir" property="test.available"/>
|
|
34
|
|
35 <property name="conf.dir" location="${nutch.root}/conf"/>
|
|
36
|
|
37 <property name="build.dir" location="${nutch.root}/build/${name}"/>
|
|
38 <property name="build.classes" location="${build.dir}/classes"/>
|
|
39 <property name="build.test" location="${build.dir}/test"/>
|
|
40
|
|
41 <property name="deploy.dir" location="${nutch.root}/build/plugins/${name}"/>
|
|
42
|
|
43 <!-- load nutch defaults last so that they can be overridden above -->
|
|
44 <property file="${nutch.root}/default.properties" />
|
|
45
|
|
46 <ivy:settings id="ivy.instance" file="${nutch.root}/ivy/ivysettings.xml" />
|
|
47
|
|
48 <path id="plugin.deps"/>
|
|
49
|
|
50 <fileset id="lib.jars" dir="${root}" includes="lib/*.jar"/>
|
|
51
|
|
52 <!-- the normal classpath -->
|
|
53 <path id="classpath">
|
|
54 <pathelement location="${build.classes}"/>
|
|
55 <fileset refid="lib.jars"/>
|
|
56 <pathelement location="${nutch.root}/build/classes"/>
|
|
57 <fileset dir="${nutch.root}/build/lib">
|
|
58 <include name="*.jar" />
|
|
59 </fileset>
|
|
60 <path refid="plugin.deps"/>
|
|
61 <fileset dir="${deploy.dir}">
|
|
62 <include name="*.jar" />
|
|
63 </fileset>
|
|
64 </path>
|
|
65
|
|
66 <!-- the unit test classpath -->
|
|
67 <path id="test.classpath">
|
|
68 <pathelement location="${build.test}" />
|
|
69 <pathelement location="${nutch.root}/build/test/classes"/>
|
|
70 <pathelement location="${nutch.root}/src/test"/>
|
|
71 <pathelement location="${conf.dir}"/>
|
|
72 <pathelement location="${nutch.root}/build"/>
|
|
73 <path refid="classpath"/>
|
|
74 </path>
|
|
75
|
|
76 <!-- ====================================================== -->
|
|
77 <!-- Stuff needed by all targets -->
|
|
78 <!-- ====================================================== -->
|
|
79 <target name="init">
|
|
80 <mkdir dir="${build.dir}"/>
|
|
81 <mkdir dir="${build.classes}"/>
|
|
82 <mkdir dir="${build.test}"/>
|
|
83 <mkdir dir="${deploy.dir}"/>
|
|
84
|
|
85 <antcall target="init-plugin"/>
|
|
86 </target>
|
|
87
|
|
88 <!-- to be overridden by sub-projects -->
|
|
89 <target name="init-plugin"/>
|
|
90
|
|
91 <!--
|
|
92 ! Used to build plugin compilation dependencies
|
|
93 ! (to be overridden by plugins)
|
|
94 !-->
|
|
95 <target name="deps-jar"/>
|
|
96
|
|
97 <!--
|
|
98 ! Used to deploy plugin runtime dependencies
|
|
99 ! (to be overridden by plugins)
|
|
100 !-->
|
|
101 <target name="deps-test"/>
|
|
102
|
|
103 <!-- ====================================================== -->
|
|
104 <!-- Compile the Java files -->
|
|
105 <!-- ====================================================== -->
|
|
106 <target name="compile" depends="init,deps-jar, resolve-default">
|
|
107 <echo message="Compiling plugin: ${name}"/>
|
|
108 <javac
|
|
109 encoding="${build.encoding}"
|
|
110 srcdir="${src.dir}"
|
|
111 includes="**/*.java"
|
|
112 destdir="${build.classes}"
|
|
113 debug="${javac.debug}"
|
|
114 optimize="${javac.optimize}"
|
|
115 target="${javac.version}"
|
|
116 source="${javac.version}"
|
|
117 deprecation="${javac.deprecation}">
|
|
118 <classpath refid="classpath"/>
|
|
119 </javac>
|
|
120 </target>
|
|
121
|
|
122 <target name="compile-core">
|
|
123 <ant target="compile-core" inheritall="false" dir="${nutch.root}"/>
|
|
124 <ant target="compile"/>
|
|
125 </target>
|
|
126
|
|
127 <!-- ================================================================== -->
|
|
128 <!-- Make plugin .jar -->
|
|
129 <!-- ================================================================== -->
|
|
130 <!-- -->
|
|
131 <!-- ================================================================== -->
|
|
132 <target name="jar" depends="compile">
|
|
133 <jar
|
|
134 jarfile="${build.dir}/${name}.jar"
|
|
135 basedir="${build.classes}"
|
|
136 />
|
|
137 </target>
|
|
138
|
|
139 <target name="jar-core" depends="compile-core">
|
|
140 <jar
|
|
141 jarfile="${build.dir}/${name}.jar"
|
|
142 basedir="${build.classes}"
|
|
143 />
|
|
144 </target>
|
|
145
|
|
146 <!-- ================================================================== -->
|
|
147 <!-- Deploy plugin to ${deploy.dir} -->
|
|
148 <!-- ================================================================== -->
|
|
149 <!-- -->
|
|
150 <!-- ================================================================== -->
|
|
151 <target name="deploy" depends="jar, deps-test">
|
|
152 <mkdir dir="${deploy.dir}"/>
|
|
153 <copy file="plugin.xml" todir="${deploy.dir}"
|
|
154 preservelastmodified="true"/>
|
|
155 <available property="lib-available"
|
|
156 file="${build.dir}/${name}.jar"/>
|
|
157 <antcall target="copy-generated-lib"/>
|
|
158 <copy todir="${deploy.dir}" flatten="true">
|
|
159 <fileset refid="lib.jars"/>
|
|
160 </copy>
|
|
161 </target>
|
|
162
|
|
163 <target name="copy-generated-lib" if="lib-available">
|
|
164 <copy file="${build.dir}/${name}.jar" todir="${deploy.dir}" failonerror="false"/>
|
|
165 </target>
|
|
166
|
|
167 <!-- ================================================================== -->
|
|
168 <!-- Compile test code -->
|
|
169 <!-- ================================================================== -->
|
|
170 <target name="compile-test" depends="compile" if="test.available">
|
|
171 <javac
|
|
172 encoding="${build.encoding}"
|
|
173 srcdir="${src.test}"
|
|
174 includes="**/*.java"
|
|
175 destdir="${build.test}"
|
|
176 debug="${javac.debug}"
|
|
177 optimize="${javac.optimize}"
|
|
178 target="${javac.version}"
|
|
179 source="${javac.version}"
|
|
180 deprecation="${javac.deprecation}">
|
|
181 <classpath refid="test.classpath"/>
|
|
182 </javac>
|
|
183 </target>
|
|
184
|
|
185 <!-- ================================================================== -->
|
|
186 <!-- Run unit tests -->
|
|
187 <!-- ================================================================== -->
|
|
188 <target name="test" depends="compile-test, deploy" if="test.available">
|
|
189 <echo message="Testing plugin: ${name}"/>
|
|
190
|
|
191 <junit printsummary="yes" haltonfailure="no" fork="yes"
|
|
192 errorProperty="tests.failed" failureProperty="tests.failed">
|
|
193 <sysproperty key="test.data" value="${build.test}/data"/>
|
|
194 <sysproperty key="test.input" value="${root}/data"/>
|
|
195 <sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
|
|
196 <classpath refid="test.classpath"/>
|
|
197 <formatter type="plain" />
|
|
198 <batchtest todir="${build.test}" unless="testcase">
|
|
199 <fileset dir="${src.test}"
|
|
200 includes="**/Test*.java" excludes="**/${test.exclude}.java" />
|
|
201 </batchtest>
|
|
202 <batchtest todir="${build.test}" if="testcase">
|
|
203 <fileset dir="${src.test}" includes="**/${testcase}.java"/>
|
|
204 </batchtest>
|
|
205 </junit>
|
|
206
|
|
207 <fail if="tests.failed">Tests failed!</fail>
|
|
208
|
|
209 </target>
|
|
210
|
|
211 <!-- target: resolve ================================================= -->
|
|
212 <target name="resolve-default" depends="clean-lib" description="resolve and retrieve dependencies with ivy">
|
|
213 <ivy:resolve file="ivy.xml" conf="default" log="download-only"/>
|
|
214 <ivy:retrieve pattern="${deploy.dir}/[artifact]-[revision].[ext]" symlink="false" log="quiet"/>
|
|
215 </target>
|
|
216
|
|
217 <target name="resolve-test" depends="clean-lib" description="resolve and retrieve dependencies with ivy">
|
|
218 <ivy:resolve file="ivy.xml" conf="test" log="download-only"/>
|
|
219 <ivy:retrieve pattern="${deploy.dir}/[artifact]-[revision].[ext]" symlink="false" log="quiet"/>
|
|
220 </target>
|
|
221
|
|
222 <!-- ================================================================== -->
|
|
223 <!-- Clean. Delete the build files, and their directories -->
|
|
224 <!-- ================================================================== -->
|
|
225 <!-- target: clean =================================================== -->
|
|
226 <target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
|
|
227
|
|
228 <!-- target: clean-lib =============================================== -->
|
|
229 <target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
|
|
230 <delete includeemptydirs="true" dir="${build.lib.dir}"/>
|
|
231 </target>
|
|
232
|
|
233 <!-- target: clean-build ============================================= -->
|
|
234 <target name="clean-build" description="--> clean the project built files">
|
|
235 <delete includeemptydirs="true" dir="${build.dir}"/>
|
|
236 <delete includeemptydirs="true" dir="${deploy.dir}"/>
|
|
237 </target>
|
|
238
|
|
239 </project>
|