/[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.57 - (hide annotations) (download)
Sat Oct 5 13:40:57 2013 UTC (13 months, 3 weeks ago) by caster
Branch: MAIN
Changes since 1.56: +104 -108 lines
Convert comments for eclass manpages. Heavily based on work from ercpe, bug #476946.

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

  ViewVC Help
Powered by ViewVC 1.1.20