/[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.51 Revision 1.52
12# and xml-rewrite.py because they were so slow 12# and xml-rewrite.py because they were so slow
13# Petteri Räty (betelgeuse@gentoo.org) 13# Petteri Räty (betelgeuse@gentoo.org)
14# 14#
15# Licensed under the GNU General Public License, v2 15# Licensed under the GNU General Public License, v2
16# 16#
17# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.51 2011/07/08 11:35:01 ssuominen Exp $ 17# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.52 2011/10/21 11:05:01 caster Exp $
18 18
19inherit java-utils-2 19inherit java-utils-2
20 20
21# This eclass provides functionality for Java packages which use 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 22# ant to build. In particular, it will attempt to fix build.xml files, so that
429} 429}
430 430
431# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
432# @public java-ant_remove-taskdefs 432# @public java-ant_remove-taskdefs
433# 433#
434# Removes taskdef elements from the file 434# Removes (named) taskdef elements from the file.
435# Options:
436# --name NAME : only remove taskdef with name NAME.
435# @param $1 - the file to rewrite (defaults to build.xml) 437# @param $1 - the file to rewrite (defaults to build.xml)
436# ------------------------------------------------------------------------------ 438# ------------------------------------------------------------------------------
437java-ant_remove-taskdefs() { 439java-ant_remove-taskdefs() {
438 debug-print-function ${FUNCNAME} $* 440 debug-print-function ${FUNCNAME} $*
441 local task_name
442 if [[ "${1}" == --name ]]; then
443 task_name="${2}"
444 shift 2
445 fi
439 local file=${1:-build.xml} 446 local file="${1:-build.xml}"
440 echo "Removing taskdefs from ${file}" 447 echo "Removing taskdefs from ${file}"
441 python <<EOF 448 python <<EOF
442import sys 449import sys
443from xml.dom.minidom import parse 450from xml.dom.minidom import parse
444dom = parse("${file}") 451dom = parse("${file}")
445for elem in dom.getElementsByTagName('taskdef'): 452for elem in dom.getElementsByTagName('taskdef'):
453 if (len("${task_name}") == 0 or elem.getAttribute("name") == "${task_name}"):
446 elem.parentNode.removeChild(elem) 454 elem.parentNode.removeChild(elem)
447 elem.unlink() 455 elem.unlink()
448f = open("${file}", "w") 456f = open("${file}", "w")
449dom.writexml(f) 457dom.writexml(f)
450f.close() 458f.close()
451EOF 459EOF
452 [[ $? != 0 ]] && die "Removing taskdefs failed" 460 [[ $? != 0 ]] && die "Removing taskdefs failed"

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52

  ViewVC Help
Powered by ViewVC 1.1.20