/[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.9 Revision 1.10
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:
6# December 2006:
7# I pretty much rewrote the logic of the bsfix functions
8# and xml-rewrite.py because they were so slow
9# Petteri R├Ąty (betelgeuse@gentoo.org)
5# 10#
6# Licensed under the GNU General Public License, v2 11# Licensed under the GNU General Public License, v2
7# 12#
8# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.9 2006/12/03 13:05:06 betelgeuse Exp $ 13# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.10 2006/12/27 18:46:01 betelgeuse Exp $
9 14
10inherit java-utils-2 15inherit java-utils-2
11 16
12# This eclass provides functionality for Java packages which use 17# This eclass provides functionality for Java packages which use
13# ant to build. In particular, it will attempt to fix build.xml files, so that 18# ant to build. In particular, it will attempt to fix build.xml files, so that
103 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return 108 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return
104 if ! java-pkg_needs-vm; then 109 if ! java-pkg_needs-vm; then
105 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM" 110 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
106 fi 111 fi
107 112
108 cd "${S}" 113 pushd "${S}" >/dev/null
109 114
110 local find_args="" 115 local find_args=""
111 [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1" 116 [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1"
112 117
113 find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } " 118 find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
114 119
115 local i=0 120 # This voodoo is done for paths with spaces
116 local -a bsfix_these 121 local bsfix_these
117 while read line; do 122 while read line; do
118 [[ -z ${line} ]] && continue 123 [[ -z ${line} ]] && continue
119 bsfix_these[${i}]="${line}" 124 bsfix_these="${bsfix_these} '${line}'"
120 let i+=1
121 done <<-EOF 125 done <<-EOF
122 $(find . ${find_args}) 126 $(find . ${find_args})
123 EOF 127 EOF
124 128
125 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do 129 [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these}
126 local file="${bsfix_these[${i}]}"
127 java-ant_bsfix_one "${file}"
128 done
129}
130 130
131 popd > /dev/null
132}
133
131# ------------------------------------------------------------------------------ 134# ------------------------------------------------------------------------------
132# @public java-ant_bsfix_one 135# @public java-ant_bsfix_files
133# 136#
134# Attempts to fix named build file. The following variables will affect its behavior 137# Attempts to fix named build files. The following variables will affect its behavior
135# as listed above: 138# as listed above:
136# JAVA_PKG_BSFIX_SOURCE_TAGS 139# JAVA_PKG_BSFIX_SOURCE_TAGS
137# JAVA_PKG_BSFIX_TARGET_TAGS 140# JAVA_PKG_BSFIX_TARGET_TAGS
141#
142# When changing this function, make sure that it works with paths with spaces in
143# them.
138# ------------------------------------------------------------------------------ 144# ------------------------------------------------------------------------------
139java-ant_bsfix_one() { 145java-ant_bsfix_files() {
140 debug-print-function ${FUNCNAME} $* 146 debug-print-function ${FUNCNAME} $*
141 147
142 if [ -z "${1}" ]; then 148 [[ ${#} = 0 ]] && die "${FUNCNAME} called without arguments"
143 eerror "java-ant_bsfix_one needs one argument"
144 die "java-ant_bsfix_one needs one argument"
145 fi
146 149
147 local want_source="$(java-pkg_get-source)" 150 local want_source="$(java-pkg_get-source)"
148 local want_target="$(java-pkg_get-target)" 151 local want_target="$(java-pkg_get-target)"
149 152
150 debug-print "bsfix_one: target: ${want_target} source: ${want_source}" 153 debug-print "${FUNCNAME}: target: ${want_target} source: ${want_source}"
151 154
152 if [ -z "${want_source}" -o -z "${want_target}" ]; then 155 if [ -z "${want_source}" -o -z "${want_target}" ]; then
153 eerror "Could not find valid -source/-target values" 156 eerror "Could not find valid -source/-target values"
154 eerror "Please file a bug about this on bugs.gentoo.org" 157 eerror "Please file a bug about this on bugs.gentoo.org"
155 die "Could not find valid -source/-target values" 158 die "Could not find valid -source/-target values"
156 else 159 else
157 local file="${1}" 160 local files
158 echo "Rewriting ${file}"
159 debug-print "bsfix: ${file}"
160 161
162 [[ -x "/usr/bin/xml-rewrite-2.py" ]] && local using_new="true"
163
164 for file in "${@}"; do
165 debug-print "${FUNCNAME}: ${file}"
166
167 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
161 cp "${file}" "${file}.orig" || die "failed to copy ${file}" 168 cp "${file}" "${file}.orig" || die "failed to copy ${file}"
169 fi
162 170
163 chmod u+w "${file}" 171 if [[ ! -w "${file}" ]]; then
172 chmod u+w "${file}" || die "chmod u+w ${file} failed"
173 fi
164 174
175 files="${files} -f '${file}'"
176
177 if [[ -z "${using_new}" ]]; then
178 vecho "Rewriting $file (using xml-rewrite.py)"
179 # Doing this twice because otherwise the source attributes would
180 # get added to target tags too and javadoc does not like target
165 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}" 181 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
166 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}" 182 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
183 fi
184 done
185
186 if [[ "${using_new}" ]]; then
187 quiet_mode && local output=">/dev/null"
188 vecho "Rewriting source attributes"
189 eval xml-rewrite-2.py ${files} \
190 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
191 -a source -v ${want_source} ${output} || die "xml-rewrite2 failed: ${file}"
192
193 vecho "Rewriting target attributes"
194 eval xml-rewrite-2.py ${files} \
195 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
196 -a target -v ${want_target} ${output} || die "xml-rewrite2 failed: ${file}"
197 fi
167 198
168 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 199 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
200 for file in "${@}"; do
169 diff -NurbB "${file}.orig" "${file}" 201 diff -NurbB "${file}.orig" "${file}"
202 done
170 fi 203 fi
171 fi 204 fi
205}
206
207
208# ------------------------------------------------------------------------------
209# @public java-ant_bsfix_one
210#
211# Attempts to fix named build file. The following variables will affect its behavior
212# as listed above:
213# JAVA_PKG_BSFIX_SOURCE_TAGS
214# JAVA_PKG_BSFIX_TARGET_TAGS
215# ------------------------------------------------------------------------------
216java-ant_bsfix_one() {
217 debug-print-function ${FUNCNAME} $*
218
219 if [ -z "${1}" ]; then
220 eerror "${FUNCNAME} needs one argument"
221 die "${FUNCNAME} needs one argument"
222 fi
223
224 java-ant_bsfix_files "${1}"
172} 225}
173 226
174# ------------------------------------------------------------------------------ 227# ------------------------------------------------------------------------------
175# @public java-ant_rewrite-classpath 228# @public java-ant_rewrite-classpath
176# 229#

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20