/[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.27 Revision 1.28
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.27 2008/01/22 23:26:46 betelgeuse Exp $ 17# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.28 2008/01/27 03:37:49 betelgeuse 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
208 eerror "Please file a bug about this on bugs.gentoo.org" 208 eerror "Please file a bug about this on bugs.gentoo.org"
209 die "Could not find valid -source/-target values" 209 die "Could not find valid -source/-target values"
210 else 210 else
211 local files 211 local files
212 212
213 [[ -x "/usr/bin/xml-rewrite-2.py" ]] && local using_new="true"
214
215 for file in "${@}"; do 213 for file in "${@}"; do
216 debug-print "${FUNCNAME}: ${file}" 214 debug-print "${FUNCNAME}: ${file}"
217 215
218 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 216 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
219 cp "${file}" "${file}.orig" || die "failed to copy ${file}" 217 cp "${file}" "${file}.orig" || die "failed to copy ${file}"
222 if [[ ! -w "${file}" ]]; then 220 if [[ ! -w "${file}" ]]; then
223 chmod u+w "${file}" || die "chmod u+w ${file} failed" 221 chmod u+w "${file}" || die "chmod u+w ${file} failed"
224 fi 222 fi
225 223
226 files="${files} -f '${file}'" 224 files="${files} -f '${file}'"
225 done
227 226
228 if [[ -z "${using_new}" ]]; then 227 # Play nice with paludis
229 echo "Rewriting $file (using xml-rewrite.py)" 228 if [[ $(type -t quiet_mode) = function ]] && quiet_mode; then
230 # Doing this twice because otherwise the source attributes would 229 local output=">/dev/null"
231 # get added to target tags too and javadoc does not like target 230 fi
231
232 # for javadoc target and all in one pass, we need the new rewriter.
233 local rewriter3="/usr/share/javatoolkit/xml-rewrite-3.py"
234 if [[ ! -f ${rewriter3} ]]; then
235 debug-print "Using second generation rewriter"
236 eval echo "Rewriting source attributes" ${output}
232 xml-rewrite.py -f "${file}" \ 237 eval xml-rewrite-2.py ${files} \
233 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \ 238 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
234 -a source -v ${want_source} || _bsfix_die "xml-rewrite failed: ${file}" 239 -a source -v ${want_source} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
240
241 eval echo "Rewriting target attributes" ${output}
235 xml-rewrite.py -f "${file}" \ 242 eval xml-rewrite-2.py ${files} \
236 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ 243 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
237 -a target -v ${want_target} || _bsfix_die "xml-rewrite failed: ${file}" 244 -a target -v ${want_target} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
245
246 eval echo "Rewriting nowarn attributes" ${output}
247 eval xml-rewrite-2.py ${files} \
248 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
249 -a nowarn -v yes ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
250
251 if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
252 eval echo "Adding gentoo.classpath to javac tasks" ${output}
253 eval xml-rewrite-2.py ${files} \
254 -c -e javac -e xjavac -a classpath -v \
255 '\${gentoo.classpath}' \
256 || _bsfix_die "xml-rewrite2 failed"
238 fi 257 fi
239 done 258 else
240 259 debug-print "Using third generation rewriter"
241 if [[ "${using_new}" ]]; then 260 eval echo "Rewriting attributes" ${output}
242 # Play nice with paludis 261 local bsfix_extra_args=""
243 if [[ $(type -t quiet_mode) = function ]] && quiet_mode; then 262 # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES!
244 local output=">/dev/null" 263 if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
264 bsfix_extra_args="${bsfix_extra_args} -g -e javac -e xjavac "
265 bsfix_extra_args="${bsfix_extra_args} -a classpath -v '\${gentoo.classpath}'"
245 fi 266 fi
246 267 if [[ -n ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]]; then
247 # for javadoc target and all in one pass, we need the new rewriter. 268 if [[ -n ${JAVA_ANT_JAVADOC_OUTPUT_DIR} ]]; then
248 local rewriter3="/usr/share/javatoolkit/xml-rewrite-3.py" 269 die "Do not define JAVA_ANT_JAVADOC_OUTPUT_DIR!"
249 if [[ ! -f ${rewriter3} ]]; then
250 debug-print "Using second generation rewriter"
251 eval echo "Rewriting source attributes" ${output}
252 eval xml-rewrite-2.py ${files} \
253 -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
254 -a source -v ${want_source} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
255
256 eval echo "Rewriting target attributes" ${output}
257 eval xml-rewrite-2.py ${files} \
258 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
259 -a target -v ${want_target} ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
260
261 eval echo "Rewriting nowarn attributes" ${output}
262 eval xml-rewrite-2.py ${files} \
263 -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
264 -a nowarn -v yes ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
265
266 if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
267 eval echo "Adding gentoo.classpath to javac tasks" ${output}
268 eval xml-rewrite-2.py ${files} \
269 -c -e javac -e xjavac -a classpath -v \
270 '\${gentoo.classpath}' \
271 || _bsfix_die "xml-rewrite2 failed"
272 fi 270 fi
271 # Where will our generated javadoc go.
272 readonly JAVA_ANT_JAVADOC_OUTPUT_DIR=${WORKDIR}/gentoo_javadoc
273 mkdir -p "${JAVA_ANT_JAVADOC_OUTPUT_DIR}" || die
274
275 if hasq doc ${IUSE}; then
276 if use doc; then
277 if [[ -z ${EANT_DOC_TARGET} ]]; then
278 EANT_DOC_TARGET="gentoojavadoc"
279 else
280 die "You can't use javadoc adding and set EANT_DOC_TARGET too."
281 fi
282
283 for dir in ${JAVA_ANT_JAVADOC_INPUT_DIRS};do
284 if [[ ! -d ${dir} ]]; then
285 eerror "This dir: ${dir} doesnt' exists"
286 die "You must specify directories for javadoc input/output dirs."
287 fi
288 done
289 bsfix_extra_args="${bsfix_extra_args} --javadoc --source-directory "
290 # filter third/double spaces
291 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
292 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
293 bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_JAVADOC_INPUT_DIRS// / --source-directory }"
294 bsfix_extra_args="${bsfix_extra_args} --output-directory ${JAVA_ANT_JAVADOC_OUTPUT_DIR}"
295 fi
273 else 296 else
274 debug-print "Using third generation rewriter" 297 die "You need to have doc in IUSE when using JAVA_ANT_JAVADOC_INPUT_DIRS"
275 eval echo "Rewriting attributes" ${output}
276 local bsfix_extra_args=""
277 # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES!
278 if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then
279 bsfix_extra_args="${bsfix_extra_args} -g -e javac -e xjavac "
280 bsfix_extra_args="${bsfix_extra_args} -a classpath -v '\${gentoo.classpath}'"
281 fi 298 fi
282 if [[ -n ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]]; then
283 if [[ -n ${JAVA_ANT_JAVADOC_OUTPUT_DIR} ]]; then
284 die "Do not define JAVA_ANT_JAVADOC_OUTPUT_DIR!"
285 fi
286 # Where will our generated javadoc go.
287 readonly JAVA_ANT_JAVADOC_OUTPUT_DIR=${WORKDIR}/gentoo_javadoc
288 mkdir -p "${JAVA_ANT_JAVADOC_OUTPUT_DIR}" || die
289
290 if hasq doc ${IUSE}; then
291 if use doc; then
292 if [[ -z ${EANT_DOC_TARGET} ]]; then
293 EANT_DOC_TARGET="gentoojavadoc"
294 else
295 die "You can't use javadoc adding and set EANT_DOC_TARGET too."
296 fi
297
298 for dir in ${JAVA_ANT_JAVADOC_INPUT_DIRS};do
299 if [[ ! -d ${dir} ]]; then
300 eerror "This dir: ${dir} doesnt' exists"
301 die "You must specify directories for javadoc input/output dirs."
302 fi
303 done
304 bsfix_extra_args="${bsfix_extra_args} --javadoc --source-directory "
305 # filter third/double spaces
306 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
307 JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /}
308 bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_JAVADOC_INPUT_DIRS// / --source-directory }"
309 bsfix_extra_args="${bsfix_extra_args} --output-directory ${JAVA_ANT_JAVADOC_OUTPUT_DIR}"
310 fi
311 else
312 die "You need to have doc in IUSE when using JAVA_ANT_JAVADOC_INPUT_DIRS"
313 fi
314 fi
315
316 [[ -n ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \
317 && bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_BSFIX_EXTRA_ARGS}"
318
319 eval ${rewriter3} ${files} \
320 -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \
321 --source-attribute source --source-value ${want_source} \
322 --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \
323 --target-attribute target --target-value ${want_target} \
324 --target-attribute nowarn --target-value yes \
325 ${bsfix_extra_args} \
326 ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
327 fi 299 fi
300
301 [[ -n ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \
302 && bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_BSFIX_EXTRA_ARGS}"
303
304 eval ${rewriter3} ${files} \
305 -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \
306 --source-attribute source --source-value ${want_source} \
307 --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \
308 --target-attribute target --target-value ${want_target} \
309 --target-attribute nowarn --target-value yes \
310 ${bsfix_extra_args} \
311 ${output} || _bsfix_die "xml-rewrite2 failed: ${file}"
328 fi 312 fi
329 313
330 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 314 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
331 for file in "${@}"; do 315 for file in "${@}"; do
332 diff -NurbB "${file}.orig" "${file}" 316 diff -NurbB "${file}.orig" "${file}"
403# Run the right xml-rewrite binary with the given arguments 387# Run the right xml-rewrite binary with the given arguments
404# ------------------------------------------------------------------------------ 388# ------------------------------------------------------------------------------
405java-ant_xml-rewrite() { 389java-ant_xml-rewrite() {
406 local bindir="${ROOT}/usr/bin/" 390 local bindir="${ROOT}/usr/bin/"
407 local gen2="${bindir}/xml-rewrite-2.py" 391 local gen2="${bindir}/xml-rewrite-2.py"
408 local gen1="${bindir}/xml-rewrite.py" 392 # gen1 is deprecated
409 if [[ -x "${gen2}" ]]; then 393 if [[ -x "${gen2}" ]]; then
410 ${gen2} "${@}" || die "${gen2} failed" 394 ${gen2} "${@}" || die "${gen2} failed"
411 elif [[ -x "${gen1}" ]]; then
412 ${gen1} "${@}" || die "${gen1} failed"
413 else 395 else
414 eerror "No binary for rewriting found." 396 eerror "No binary for rewriting found."
415 eerror "Do you have dev-java/javatoolkit installed?" 397 eerror "Do you have dev-java/javatoolkit installed?"
416 die "xml-rewrite not found" 398 die "xml-rewrite not found"
417 fi 399 fi

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20