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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.55 - (hide annotations) (download)
Fri Sep 14 05:04:50 2012 UTC (19 months, 1 week ago) by ferringb
Branch: MAIN
Changes since 1.54: +11 -16 lines
Drop quiet mode.

1) paludis never had a quiet_mode, portage did.
2) portage manages it's output as is via controlling what it relays to term from
logs.

Meaning, this isn't useful/necessary, plus it didn't properly protect itself from
external bleeding of output content into that func for when quiet_mode wasn't a
function.

1 nichoj 1.1 # eclass for ant based Java packages
2     #
3     # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4 fauli 1.53 # Copyright (c) 2004-2011, Gentoo Foundation
5 betelgeuse 1.10 # Changes:
6 betelgeuse 1.22 # 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).
10 betelgeuse 1.10 # December 2006:
11     # I pretty much rewrote the logic of the bsfix functions
12     # and xml-rewrite.py because they were so slow
13     # Petteri R├Ąty (betelgeuse@gentoo.org)
14 nichoj 1.1 #
15     # Licensed under the GNU General Public License, v2
16     #
17 ferringb 1.55 # $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.54 2012/06/02 19:16:31 zmedico Exp $
18 nichoj 1.1
19 zmedico 1.54 inherit java-utils-2 multilib
20 nichoj 1.1
21     # This eclass provides functionality for Java packages which use
22     # ant to build. In particular, it will attempt to fix build.xml files, so that
23     # they use the appropriate 'target' and 'source' attributes.
24    
25 caster 1.14 # -----------------------------------------------------------------------------
26     # @variable-preinherit WANT_ANT_TASKS
27     # @variable-default ""
28     #
29     # Please see the description in java-utils-2.eclass.
30     #WANT_ANT_TASKS
31    
32 caster 1.17 # -----------------------------------------------------------------------------
33     # @variable-preinherit JAVA_ANT_DISABLE_ANT_CORE_DEP
34     # @variable-default unset for java-pkg-2, true for java-pkg-opt-2
35     #
36     # Setting this variable non-empty before inheriting java-ant-2 disables adding
37     # dev-java/ant-core into DEPEND.
38 betelgeuse 1.15
39 caster 1.17 # construct ant-speficic DEPEND
40 caster 1.25 # add ant-core into DEPEND, unless disabled
41 caster 1.17 if [[ -z "${JAVA_ANT_DISABLE_ANT_CORE_DEP}" ]]; then
42     JAVA_ANT_E_DEPEND="${JAVA_ANT_E_DEPEND} >=dev-java/ant-core-1.7.0"
43     fi
44 betelgeuse 1.15
45 caster 1.14 # add ant tasks specified in WANT_ANT_TASKS to DEPEND
46     local ANT_TASKS_DEPEND;
47     ANT_TASKS_DEPEND="$(java-pkg_ant-tasks-depend)"
48     # check that java-pkg_ant-tasks-depend didn't fail
49     if [[ $? != 0 ]]; then
50     eerror "${ANT_TASKS_DEPEND}"
51     die "java-pkg_ant-tasks-depend() failed"
52     fi
53 betelgeuse 1.43
54     # We need some tools from javatoolkit. We also need portage 2.1 for phase hooks
55 betelgeuse 1.50 # and ant dependencies constructed above. Python is there for
56     # java-ant_remove-taskdefs
57 betelgeuse 1.43 JAVA_ANT_E_DEPEND="${JAVA_ANT_E_DEPEND}
58 fauli 1.53 ${ANT_TASKS_DEPEND}
59     ${JAVA_PKG_PORTAGE_DEP}
60     >=dev-java/javatoolkit-0.3.0-r2
61     >=dev-lang/python-2.4"
62 caster 1.17
63     # this eclass must be inherited after java-pkg-2 or java-pkg-opt-2
64     # if it's java-pkg-opt-2, ant dependencies are pulled based on USE flag
65 ssuominen 1.51 if has java-pkg-opt-2 ${INHERITED}; then
66 caster 1.17 JAVA_ANT_E_DEPEND="${JAVA_PKG_OPT_USE}? ( ${JAVA_ANT_E_DEPEND} )"
67 ssuominen 1.51 elif ! has java-pkg-2 ${INHERITED}; then
68 caster 1.17 eerror "java-ant-2 eclass can only be inherited AFTER java-pkg-2 or java-pkg-opt-2"
69     fi
70    
71 betelgeuse 1.43 DEPEND="${JAVA_ANT_E_DEPEND}"
72 nichoj 1.1
73     # ------------------------------------------------------------------------------
74 nichoj 1.7 # @global JAVA_PKG_BSFIX
75 nichoj 1.1 #
76     # Should we attempt to 'fix' ant build files to include the source/target
77     # attributes when calling javac?
78     #
79     # default: on
80     # ------------------------------------------------------------------------------
81 nichoj 1.7 JAVA_PKG_BSFIX=${JAVA_PKG_BSFIX:-"on"}
82 nichoj 1.1
83     # ------------------------------------------------------------------------------
84 nichoj 1.7 # @global JAVA_PKG_BSFIX_ALL
85 nichoj 1.1 #
86     # If we're fixing build files, should we try to fix all the ones we can find?
87     #
88     # default: yes
89     # ------------------------------------------------------------------------------
90 nichoj 1.7 JAVA_PKG_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:-"yes"}
91 nichoj 1.1
92     # ------------------------------------------------------------------------------
93 nichoj 1.5 # @global JAVA_PKG_BSFIX_NAME
94 nichoj 1.1 #
95     # Filename of build files to fix/search for
96     #
97     # default: build.xml
98     # ------------------------------------------------------------------------------
99 nichoj 1.7 JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:-"build.xml"}
100 nichoj 1.1
101     # ------------------------------------------------------------------------------
102 nichoj 1.7 # @global JAVA_PKG_BSFIX_TARGETS_TAGS
103 nichoj 1.1 #
104     # Targets to fix the 'source' attribute in
105     #
106     # default: javac xjavac javac.preset
107     # ------------------------------------------------------------------------------
108 nichoj 1.7 JAVA_PKG_BSFIX_TARGET_TAGS=${JAVA_PKG_BSFIX_TARGET_TAGS:-"javac xjavac javac.preset"}
109 nichoj 1.1
110     # ------------------------------------------------------------------------------
111 nichoj 1.7 # @global JAVA_PKG_BSFIX_SOURCE_TAGS
112 nichoj 1.1 #
113     # Targets to fix the 'target' attribute in
114     #
115     # default: javacdoc javac xjavac javac.preset
116     # ------------------------------------------------------------------------------
117 nichoj 1.7 JAVA_PKG_BSFIX_SOURCE_TAGS=${JAVA_PKG_BSFIX_SOURCE_TAGS:-"javadoc javac xjavac javac.preset"}
118 nichoj 1.1
119     # ------------------------------------------------------------------------------
120 betelgeuse 1.30 # @global JAVA_ANT_CLASSPATH_TAGS
121     #
122     # Targets to add the classpath attribute to
123     #
124     # default: javac xjavac
125     # ------------------------------------------------------------------------------
126     JAVA_ANT_CLASSPATH_TAGS="javac xjavac"
127    
128     # ------------------------------------------------------------------------------
129 betelgeuse 1.23 # @global JAVA_ANT_IGNORE_SYSTEM_CLASSES
130 nichoj 1.1 #
131 betelgeuse 1.23 # Rewrites available tasks to ignore ant classpath.
132 nichoj 1.1 #
133 betelgeuse 1.23 # default: off
134 nichoj 1.1 # ------------------------------------------------------------------------------
135    
136 caster 1.47 case "${EAPI:-0}" in
137     0|1) : ;;
138     *) EXPORT_FUNCTIONS src_configure ;;
139     esac
140 betelgeuse 1.40
141     # ------------------------------------------------------------------------------
142     # @eclass-src_configure
143     #
144     # src_configure rewrites the build.xml files
145     # ------------------------------------------------------------------------------
146     java-ant-2_src_configure() {
147 caster 1.49 # if java support is optional, don't perform this when the USE flag is off
148 ssuominen 1.51 if has java-pkg-opt-2 ${INHERITED}; then
149 caster 1.49 use ${JAVA_PKG_OPT_USE} || return
150     fi
151    
152 betelgeuse 1.40 # eant will call us unless called by Portage
153     [[ -e "${T}/java-ant-2_src_configure-run" ]] && return
154    
155     [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" ]] \
156     && java-ant_ignore-system-classes "${S}/build.xml"
157    
158     java-ant_bsfix
159     touch "${T}/java-ant-2_src_configure-run"
160 maekke 1.44 }
161 betelgeuse 1.40
162 nichoj 1.1 # ------------------------------------------------------------------------------
163     # @private java-ant_bsfix
164     #
165     # Attempts to fix build files. The following variables will affect its behavior
166     # as listed above:
167     # JAVA_PKG_BSFIX
168     # JAVA_PKG_BSFIX_ALL
169     # JAVA_PKG_BSFIX_NAME,
170     # ------------------------------------------------------------------------------
171     java-ant_bsfix() {
172     debug-print-function ${FUNCNAME} $*
173    
174 nelchael 1.4 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return
175     if ! java-pkg_needs-vm; then
176 nichoj 1.1 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
177     fi
178    
179 betelgeuse 1.10 pushd "${S}" >/dev/null
180 nelchael 1.4
181 nichoj 1.7 local find_args=""
182     [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1"
183 swegener 1.8
184 nichoj 1.7 find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
185 nichoj 1.1
186 betelgeuse 1.10 # This voodoo is done for paths with spaces
187     local bsfix_these
188 nichoj 1.1 while read line; do
189     [[ -z ${line} ]] && continue
190 betelgeuse 1.10 bsfix_these="${bsfix_these} '${line}'"
191 swegener 1.8 done <<-EOF
192 flameeyes 1.3 $(find . ${find_args})
193 nichoj 1.1 EOF
194    
195 betelgeuse 1.10 [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these}
196    
197     popd > /dev/null
198 nelchael 1.4 }
199    
200 betelgeuse 1.11 _bsfix_die() {
201     if has_version dev-python/pyxml; then
202     eerror "If the output above contains:"
203     eerror "ImportError:"
204     eerror "/usr/lib/python2.4/site-packages/_xmlplus/parsers/pyexpat.so:"
205     eerror "undefined symbol: PyUnicodeUCS2_DecodeUTF8"
206     eerror "Try re-emerging dev-python/pyxml"
207     die ${1} " Look at the eerror message above"
208     else
209     die ${1}
210     fi
211     }
212    
213 nelchael 1.4 # ------------------------------------------------------------------------------
214 betelgeuse 1.10 # @public java-ant_bsfix_files
215 nelchael 1.4 #
216 betelgeuse 1.10 # Attempts to fix named build files. The following variables will affect its behavior
217 nelchael 1.4 # as listed above:
218     # JAVA_PKG_BSFIX_SOURCE_TAGS
219     # JAVA_PKG_BSFIX_TARGET_TAGS
220 betelgeuse 1.22 # JAVA_ANT_REWRITE_CLASSPATH
221     # JAVA_ANT_JAVADOC_INPUT_DIRS: Where we can find java sources for javadoc
222     # input. Can be a space separated list of
223     # directories
224     # JAVA_ANT_BSFIX_EXTRA_ARGS: You can use this to pass extra variables to the
225     # rewriter if you know what you are doing.
226     #
227     # If JAVA_ANT_JAVADOC_INPUT_DIRS is set, we will turn on the adding of a basic
228     # javadoc target to the ant's build.xml with the javadoc xml-rewriter feature.
229     # Then we will set EANT DOC TARGET to the added javadoc target
230     # NOTE: the variable JAVA_ANT_JAVADOC_OUTPUT_DIR points where we will
231     # generate the javadocs. This is a read-only variable, dont change it.
232    
233 betelgeuse 1.10 # When changing this function, make sure that it works with paths with spaces in
234     # them.
235 nelchael 1.4 # ------------------------------------------------------------------------------
236 betelgeuse 1.10 java-ant_bsfix_files() {
237 nelchael 1.4 debug-print-function ${FUNCNAME} $*
238    
239 betelgeuse 1.10 [[ ${#} = 0 ]] && die "${FUNCNAME} called without arguments"
240 nelchael 1.4
241 nichoj 1.1 local want_source="$(java-pkg_get-source)"
242     local want_target="$(java-pkg_get-target)"
243    
244 betelgeuse 1.10 debug-print "${FUNCNAME}: target: ${want_target} source: ${want_source}"
245 nichoj 1.1
246     if [ -z "${want_source}" -o -z "${want_target}" ]; then
247     eerror "Could not find valid -source/-target values"
248     eerror "Please file a bug about this on bugs.gentoo.org"
249     die "Could not find valid -source/-target values"
250     else
251 betelgeuse 1.10 local files
252 nelchael 1.4
253 betelgeuse 1.10 for file in "${@}"; do
254     debug-print "${FUNCNAME}: ${file}"
255 nelchael 1.4
256 betelgeuse 1.10 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
257     cp "${file}" "${file}.orig" || die "failed to copy ${file}"
258     fi
259    
260     if [[ ! -w "${file}" ]]; then
261     chmod u+w "${file}" || die "chmod u+w ${file} failed"
262     fi
263    
264     files="${files} -f '${file}'"
265     done
266    
267 betelgeuse 1.28 # for javadoc target and all in one pass, we need the new rewriter.
268     local rewriter3="/usr/share/javatoolkit/xml-rewrite-3.py"
269 ali_bush 1.33 if [[ ! -f ${rewriter3} ]]; then
270     rewriter3="/usr/$(get_libdir)/javatoolkit/bin/xml-rewrite-3.py"
271     fi
272    
273 betelgeuse 1.36 local rewriter4="/usr/$(get_libdir)/javatoolkit/bin/build-xml-rewrite"
274    
275     if [[ -x ${rewriter4} && ${JAVA_ANT_ENCODING} ]]; then
276     [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] && local gcp="-g"
277     [[ ${JAVA_ANT_ENCODING} ]] && local enc="-e ${JAVA_ANT_ENCODING}"
278 ferringb 1.55 eval echo "cElementTree rewriter"
279 betelgeuse 1.36 debug-print "${rewriter4} extra args: ${gcp} ${enc}"
280     ${rewriter4} ${gcp} ${enc} \
281     -c "${JAVA_PKG_BSFIX_SOURCE_TAGS}" source ${want_source} \
282     -c "${JAVA_PKG_BSFIX_TARGET_TAGS}" target ${want_target} \
283     "${@}" || die "build-xml-rewrite failed"
284     elif [[ ! -f ${rewriter3} ]]; then
285 betelgeuse 1.28 debug-print "Using second generation rewriter"
286 ferringb 1.55 eval echo "Rewriting source attributes"
287 ali_bush 1.32 eval xml-rewrite-2.py ${files} \
288 betelgeuse 1.28 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
289 ferringb 1.55 -a source -v ${want_source} || _bsfix_die "xml-rewrite2 failed: ${file}"
290 betelgeuse 1.28
291 ferringb 1.55 eval echo "Rewriting target attributes"
292 ali_bush 1.32 eval xml-rewrite-2.py ${files} \
293 betelgeuse 1.28 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
294 ferringb 1.55 -a target -v ${want_target} || _bsfix_die "xml-rewrite2 failed: ${file}"
295 betelgeuse 1.28
296 ferringb 1.55 eval echo "Rewriting nowarn attributes"
297 ali_bush 1.32 eval xml-rewrite-2.py ${files} \
298 betelgeuse 1.28 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
299 ferringb 1.55 -a nowarn -v yes || _bsfix_die "xml-rewrite2 failed: ${file}"
300 betelgeuse 1.22
301 betelgeuse 1.28 if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
302 ferringb 1.55 eval echo "Adding gentoo.classpath to javac tasks"
303 ali_bush 1.32 eval xml-rewrite-2.py ${files} \
304 betelgeuse 1.28 -c -e javac -e xjavac -a classpath -v \
305 ali_bush 1.32 '\${gentoo.classpath}' \
306     || _bsfix_die "xml-rewrite2 failed"
307 betelgeuse 1.28 fi
308     else
309     debug-print "Using third generation rewriter"
310 ferringb 1.55 eval echo "Rewriting attributes"
311 betelgeuse 1.28 local bsfix_extra_args=""
312     # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES!
313     if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
314 betelgeuse 1.45 local cp_tags="${JAVA_ANT_CLASSPATH_TAGS// / -e }"
315     bsfix_extra_args="${bsfix_extra_args} -g -e ${cp_tags}"
316 betelgeuse 1.28 bsfix_extra_args="${bsfix_extra_args} -a classpath -v '\${gentoo.classpath}'"
317     fi
318     if [[ -n ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]]; then
319     if [[ -n ${JAVA_ANT_JAVADOC_OUTPUT_DIR} ]]; then
320     die "Do not define JAVA_ANT_JAVADOC_OUTPUT_DIR!"
321     fi
322     # Where will our generated javadoc go.
323 betelgeuse 1.29 readonly JAVA_ANT_JAVADOC_OUTPUT_DIR="${WORKDIR}/gentoo_javadoc"
324 betelgeuse 1.28 mkdir -p "${JAVA_ANT_JAVADOC_OUTPUT_DIR}" || die
325    
326 ssuominen 1.51 if has doc ${IUSE}; then
327 betelgeuse 1.28 if use doc; then
328     if [[ -z ${EANT_DOC_TARGET} ]]; then
329     EANT_DOC_TARGET="gentoojavadoc"
330     else
331     die "You can't use javadoc adding and set EANT_DOC_TARGET too."
332     fi
333 betelgeuse 1.22
334 betelgeuse 1.28 for dir in ${JAVA_ANT_JAVADOC_INPUT_DIRS};do
335     if [[ ! -d ${dir} ]]; then
336     eerror "This dir: ${dir} doesnt' exists"
337     die "You must specify directories for javadoc input/output dirs."
338 betelgeuse 1.22 fi
339 betelgeuse 1.28 done
340     bsfix_extra_args="${bsfix_extra_args} --javadoc --source-directory "
341     # filter third/double spaces
342     JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
343     JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
344     bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_JAVADOC_INPUT_DIRS// / --source-directory }"
345     bsfix_extra_args="${bsfix_extra_args} --output-directory ${JAVA_ANT_JAVADOC_OUTPUT_DIR}"
346 betelgeuse 1.22 fi
347 betelgeuse 1.28 else
348     die "You need to have doc in IUSE when using JAVA_ANT_JAVADOC_INPUT_DIRS"
349 betelgeuse 1.22 fi
350 betelgeuse 1.28 fi
351 betelgeuse 1.22
352 betelgeuse 1.28 [[ -n ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \
353     && bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_BSFIX_EXTRA_ARGS}"
354 betelgeuse 1.22
355 betelgeuse 1.45 debug-print "bsfix_extra_args: ${bsfix_extra_args}"
356    
357 betelgeuse 1.28 eval ${rewriter3} ${files} \
358     -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \
359     --source-attribute source --source-value ${want_source} \
360     --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \
361     --target-attribute target --target-value ${want_target} \
362     --target-attribute nowarn --target-value yes \
363     ${bsfix_extra_args} \
364 ferringb 1.55 || _bsfix_die "xml-rewrite2 failed: ${file}"
365 betelgeuse 1.10 fi
366 nelchael 1.4
367     if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
368 betelgeuse 1.10 for file in "${@}"; do
369     diff -NurbB "${file}.orig" "${file}"
370     done
371 nelchael 1.4 fi
372 nichoj 1.1 fi
373 betelgeuse 1.24 return 0 # so that the 1 for diff doesn't get reported
374 nichoj 1.1 }
375 nelchael 1.6
376 betelgeuse 1.10
377     # ------------------------------------------------------------------------------
378     # @public java-ant_bsfix_one
379     #
380     # Attempts to fix named build file. The following variables will affect its behavior
381     # as listed above:
382     # JAVA_PKG_BSFIX_SOURCE_TAGS
383     # JAVA_PKG_BSFIX_TARGET_TAGS
384     # ------------------------------------------------------------------------------
385     java-ant_bsfix_one() {
386     debug-print-function ${FUNCNAME} $*
387    
388     if [ -z "${1}" ]; then
389     eerror "${FUNCNAME} needs one argument"
390     die "${FUNCNAME} needs one argument"
391     fi
392    
393     java-ant_bsfix_files "${1}"
394     }
395    
396 nelchael 1.6 # ------------------------------------------------------------------------------
397     # @public java-ant_rewrite-classpath
398     #
399     # Adds 'classpath="${gentoo.classpath}"' to specified build file.
400 betelgeuse 1.30 # Affected by:
401     # JAVA_ANT_CLASSPATH_TAGS
402 betelgeuse 1.12 # @param $1 - the file to rewrite (defaults to build.xml)
403 nelchael 1.6 # ------------------------------------------------------------------------------
404     java-ant_rewrite-classpath() {
405     debug-print-function ${FUNCNAME} $*
406    
407 betelgeuse 1.12 local file="${1}"
408     [[ -z "${1}" ]] && file=build.xml
409 betelgeuse 1.24 [[ ${#} -gt 1 ]] && die "${FUNCNAME} currently can only rewrite one file."
410 nelchael 1.6
411     echo "Adding gentoo.classpath to ${file}"
412     debug-print "java-ant_rewrite-classpath: ${file}"
413    
414     cp "${file}" "${file}.orig" || die "failed to copy ${file}"
415    
416     chmod u+w "${file}"
417    
418 betelgeuse 1.30 java-ant_xml-rewrite -f "${file}" --change \
419     -e ${JAVA_ANT_CLASSPATH_TAGS// / -e } -a classpath -v '${gentoo.classpath}'
420 nelchael 1.6
421     if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
422     diff -NurbB "${file}.orig" "${file}"
423     fi
424     }
425 betelgeuse 1.12
426     # ------------------------------------------------------------------------------
427 betelgeuse 1.50 # @public java-ant_remove-taskdefs
428     #
429 caster 1.52 # Removes (named) taskdef elements from the file.
430     # Options:
431     # --name NAME : only remove taskdef with name NAME.
432 betelgeuse 1.50 # @param $1 - the file to rewrite (defaults to build.xml)
433     # ------------------------------------------------------------------------------
434     java-ant_remove-taskdefs() {
435     debug-print-function ${FUNCNAME} $*
436 caster 1.52 local task_name
437     if [[ "${1}" == --name ]]; then
438     task_name="${2}"
439     shift 2
440     fi
441     local file="${1:-build.xml}"
442 betelgeuse 1.50 echo "Removing taskdefs from ${file}"
443     python <<EOF
444     import sys
445     from xml.dom.minidom import parse
446     dom = parse("${file}")
447     for elem in dom.getElementsByTagName('taskdef'):
448 fauli 1.53 if (len("${task_name}") == 0 or elem.getAttribute("name") == "${task_name}"):
449     elem.parentNode.removeChild(elem)
450     elem.unlink()
451 betelgeuse 1.50 f = open("${file}", "w")
452     dom.writexml(f)
453     f.close()
454     EOF
455     [[ $? != 0 ]] && die "Removing taskdefs failed"
456     }
457    
458     # ------------------------------------------------------------------------------
459 betelgeuse 1.12 # @public java-ant_ignore-system-classes
460     #
461     # Makes the available task ignore classes in the system classpath
462     # @param $1 - the file to rewrite (defaults to build.xml)
463     # ------------------------------------------------------------------------------
464     java-ant_ignore-system-classes() {
465     debug-print-function ${FUNCNAME} $*
466 betelgeuse 1.36 local file=${1:-build.xml}
467     echo "Changing ignoresystemclasses to true for available tasks in ${file}"
468 betelgeuse 1.12 java-ant_xml-rewrite -f "${file}" --change \
469     -e available -a ignoresystemclasses -v "true"
470     }
471    
472     # ------------------------------------------------------------------------------
473     # @public java-ant_xml-rewrite
474     # Run the right xml-rewrite binary with the given arguments
475     # ------------------------------------------------------------------------------
476     java-ant_xml-rewrite() {
477 ali_bush 1.32 local gen2="/usr/bin/xml-rewrite-2.py"
478 ali_bush 1.33 local gen2_1="/usr/$(get_libdir)/javatoolkit/bin/xml-rewrite-2.py"
479 ali_bush 1.31 # gen1 is deprecated
480 betelgeuse 1.12 if [[ -x "${gen2}" ]]; then
481 ali_bush 1.32 ${gen2} "${@}" || die "${gen2} failed"
482 ali_bush 1.34 elif [[ -x "${gen2_1}" ]]; then
483 ali_bush 1.35 ${gen2_1} "${@}" || die "${gen2_1} failed"
484 betelgeuse 1.12 else
485     eerror "No binary for rewriting found."
486     eerror "Do you have dev-java/javatoolkit installed?"
487     die "xml-rewrite not found"
488     fi
489     }
490 caster 1.46
491     # ------------------------------------------------------------------------------
492     # @public java-ant_rewrite-bootclasspath
493     #
494     # Adds bootclasspath to javac-like tasks in build.xml filled with jars of a
495     # bootclasspath package of given version.
496     #
497     # Affected by:
498     # JAVA_PKG_BSFIX_TARGET_TAGS - the tags of javac tasks
499     #
500     # @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
501     # of the current JDK
502     # @param $2 - path to desired build.xml file, defaults to 'build.xml'
503     # @param $3 - (optional) what to prepend the bootclasspath with (to override)
504     # @param $4 - (optional) what to append to the bootclasspath
505     # ------------------------------------------------------------------------------
506    
507     java-ant_rewrite-bootclasspath() {
508     local version="${1}"
509     local file="${2-build.xml}"
510     local extra_before="${3}"
511     local extra_after="${4}"
512    
513 caster 1.48 local bcp="$(java-pkg_get-bootclasspath "${version}")"
514    
515 caster 1.46 if [[ -n "${extra_before}" ]]; then
516     bcp="${extra_before}:${bcp}"
517     fi
518     if [[ -n "${extra_after}" ]]; then
519     bcp="${bcp}:${extra_after}"
520     fi
521    
522     java-ant_xml-rewrite -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
523     -a bootclasspath -v "${bcp}"
524     }

  ViewVC Help
Powered by ViewVC 1.1.20