/[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.58 - (hide annotations) (download)
Mon Mar 31 16:48:51 2014 UTC (4 months, 3 weeks ago) by mgorny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.57: +5 -3 lines
Ban the java-ant_remove-taskdefs() function and remove Python dependency, bug #479838.

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

  ViewVC Help
Powered by ViewVC 1.1.20