/[gentoo-x86]/eclass/java-ant-2.eclass
Gentoo

Diff of /eclass/java-ant-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 Revision 1.22
1# eclass for ant based Java packages 1# eclass for ant based Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004-2005, Gentoo Foundation 4# Copyright (c) 2004-2005, Gentoo Foundation
5# Changes: 5# Changes:
6# May 2007:
7# Made bsfix make one pass for all things and add some glocal targets for
8# setting up the whole thing. Contributed by kiorky
9# (kiorky@cryptelium.net).
6# December 2006: 10# December 2006:
7# I pretty much rewrote the logic of the bsfix functions 11# I pretty much rewrote the logic of the bsfix functions
8# and xml-rewrite.py because they were so slow 12# and xml-rewrite.py because they were so slow
9# Petteri Räty (betelgeuse@gentoo.org) 13# Petteri Räty (betelgeuse@gentoo.org)
10# 14#
11# Licensed under the GNU General Public License, v2 15# Licensed under the GNU General Public License, v2
12# 16#
13# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.21 2007/04/26 23:32:12 caster Exp $ 17# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.22 2007/06/01 12:49:03 betelgeuse Exp $
14 18
15inherit java-utils-2 19inherit java-utils-2
16 20
17# This eclass provides functionality for Java packages which use 21# This eclass provides functionality for Java packages which use
18# ant to build. In particular, it will attempt to fix build.xml files, so that 22# ant to build. In particular, it will attempt to fix build.xml files, so that
206# 210#
207# Attempts to fix named build files. The following variables will affect its behavior 211# Attempts to fix named build files. The following variables will affect its behavior
208# as listed above: 212# as listed above:
209# JAVA_PKG_BSFIX_SOURCE_TAGS 213# JAVA_PKG_BSFIX_SOURCE_TAGS
210# JAVA_PKG_BSFIX_TARGET_TAGS 214# JAVA_PKG_BSFIX_TARGET_TAGS
215# JAVA_ANT_REWRITE_CLASSPATH
216# JAVA_ANT_JAVADOC_INPUT_DIRS: Where we can find java sources for javadoc
217# input. Can be a space separated list of
218# directories
219# JAVA_ANT_BSFIX_EXTRA_ARGS: You can use this to pass extra variables to the
220# rewriter if you know what you are doing.
211# 221#
222# If JAVA_ANT_JAVADOC_INPUT_DIRS is set, we will turn on the adding of a basic
223# javadoc target to the ant's build.xml with the javadoc xml-rewriter feature.
224# Then we will set EANT DOC TARGET to the added javadoc target
225# NOTE: the variable JAVA_ANT_JAVADOC_OUTPUT_DIR points where we will
226# generate the javadocs. This is a read-only variable, dont change it.
227
212# When changing this function, make sure that it works with paths with spaces in 228# When changing this function, make sure that it works with paths with spaces in
213# them. 229# them.
214# ------------------------------------------------------------------------------ 230# ------------------------------------------------------------------------------
215java-ant_bsfix_files() { 231java-ant_bsfix_files() {
216 debug-print-function ${FUNCNAME} $* 232 debug-print-function ${FUNCNAME} $*
260 if [[ "${using_new}" ]]; then 276 if [[ "${using_new}" ]]; then
261 # Play nice with paludis 277 # Play nice with paludis
262 if [[ $(type -t quiet_mode) = function ]] && quiet_mode; then 278 if [[ $(type -t quiet_mode) = function ]] && quiet_mode; then
263 local output=">/dev/null" 279 local output=">/dev/null"
264 fi 280 fi
281
282 # for javadoc target and all in one pass, we need the new rewriter.
283 local rewriter3="/usr/share/javatoolkit/xml-rewrite-3.py"
284 if [[ ! -f ${rewriter3} ]]; then
285 debug-print "Using second generation rewriter"
265 eval echo "Rewriting source attributes" ${output} 286 eval echo "Rewriting source attributes" ${output}
266 eval xml-rewrite-2.py ${files} \ 287 eval xml-rewrite-2.py ${files} \
267 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \ 288 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
268 -a source -v ${want_source} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}" 289 -a source -v ${want_source} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
269 290
270 eval echo "Rewriting target attributes" ${output} 291 eval echo "Rewriting target attributes" ${output}
271 eval xml-rewrite-2.py ${files} \ 292 eval xml-rewrite-2.py ${files} \
272 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ 293 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
273 -a target -v ${want_target} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}" 294 -a target -v ${want_target} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
274 295
275 eval echo "Rewriting nowarn attributes" ${output} 296 eval echo "Rewriting nowarn attributes" ${output}
276 eval xml-rewrite-2.py ${files} \ 297 eval xml-rewrite-2.py ${files} \
277 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ 298 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
278 -a nowarn -v yes ${output} || _bsfix_die "xml-rewrite2 failed: ${file}" 299 -a nowarn -v yes ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
300 else
301 debug-print "Using third generation rewriter"
302 eval echo "Rewriting attributes" ${output}
303 local bsfix_extra_args=""
304 # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES!
305 if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
306 bsfix_extra_args="${bsfix_extra_args} -g -e javac -e xjavac "
307 bsfix_extra_args="${bsfix_extra_args} -a classpath -v '\${gentoo.classpath}'"
308 fi
309 if [[ -n ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]]; then
310 if [[ -n ${JAVA_ANT_JAVADOC_OUTPUT_DIR} ]]; then
311 die "Do not define JAVA_ANT_JAVADOC_OUTPUT_DIR!"
312 fi
313 # Where will our generated javadoc go.
314 readonly JAVA_ANT_JAVADOC_OUTPUT_DIR=${WORKDIR}/gentoo_javadoc
315 mkdir -p "${JAVA_ANT_JAVADOC_OUTPUT_DIR}" || die
316
317 if hasq doc ${IUSE}; then
318 if use doc; then
319 if [[ -z ${EANT_DOC_TARGET} ]]; then
320 EANT_DOC_TARGET="gentoojavadoc"
321 else
322 die "You can't use javadoc adding and set EANT_DOC_TARGET too."
323 fi
324
325 for dir in ${JAVA_ANT_JAVADOC_INPUT_DIRS};do
326 if [[ ! -d ${dir} ]]; then
327 eerror "This dir: ${dir} doesnt' exists"
328 die "You must specify directories for javadoc input/output dirs."
329 fi
330 done
331 bsfix_extra_args="${bsfix_extra_args} --javadoc --source-directory "
332 # filter third/double spaces
333 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
334 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
335 bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_JAVADOC_INPUT_DIRS// / --source-directory }"
336 bsfix_extra_args="${bsfix_extra_args} --output-directory ${JAVA_ANT_JAVADOC_OUTPUT_DIR}"
337 fi
338 else
339 die "You need to have doc in IUSE when using JAVA_ANT_JAVADOC_INPUT_DIRS"
340 fi
341 fi
342
343 [[ -n ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \
344 && bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_BSFIX_EXTRA_ARGS}"
345
346 eval ${rewriter3} ${files} \
347 -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \
348 --source-attribute source --source-value ${want_source} \
349 --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \
350 --target-attribute target --target-value ${want_target} \
351 --target-attribute nowarn --target-value yes \
352 ${bsfix_extra_args} \
353 ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
354 fi
279 fi 355 fi
280 356
281 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 357 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
282 for file in "${@}"; do 358 for file in "${@}"; do
283 diff -NurbB "${file}.orig" "${file}" 359 diff -NurbB "${file}.orig" "${file}"

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.20