/[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.5 Revision 1.9
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# 5#
6# Licensed under the GNU General Public License, v2 6# Licensed under the GNU General Public License, v2
7# 7#
8# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.9 2006/12/03 13:05:06 betelgeuse Exp $
8 9
9inherit java-utils-2 10inherit java-utils-2
10 11
11# This eclass provides functionality for Java packages which use 12# This eclass provides functionality for Java packages which use
12# ant to build. In particular, it will attempt to fix build.xml files, so that 13# ant to build. In particular, it will attempt to fix build.xml files, so that
14 15
15# We need some tools from javatoolkit. We also need portage 2.1 for phase hooks 16# We need some tools from javatoolkit. We also need portage 2.1 for phase hooks
16DEPEND=">=dev-java/javatoolkit-0.1.5 ${JAVA_PKG_PORTAGE_DEP}" 17DEPEND=">=dev-java/javatoolkit-0.1.5 ${JAVA_PKG_PORTAGE_DEP}"
17 18
18# ------------------------------------------------------------------------------ 19# ------------------------------------------------------------------------------
19# @global JAVA_ANT_BSFIX 20# @global JAVA_PKG_BSFIX
20# 21#
21# Should we attempt to 'fix' ant build files to include the source/target 22# Should we attempt to 'fix' ant build files to include the source/target
22# attributes when calling javac? 23# attributes when calling javac?
23# 24#
24# default: on 25# default: on
25# ------------------------------------------------------------------------------ 26# ------------------------------------------------------------------------------
26JAVA_ANT_BSFIX=${JAVA_PKG_BSFIX:="on"} 27JAVA_PKG_BSFIX=${JAVA_PKG_BSFIX:-"on"}
27 28
28# ------------------------------------------------------------------------------ 29# ------------------------------------------------------------------------------
29# @global JAVA_ANT_BSFIX_ALL 30# @global JAVA_PKG_BSFIX_ALL
30# 31#
31# If we're fixing build files, should we try to fix all the ones we can find? 32# If we're fixing build files, should we try to fix all the ones we can find?
32# 33#
33# default: yes 34# default: yes
34# ------------------------------------------------------------------------------ 35# ------------------------------------------------------------------------------
35JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"} 36JAVA_PKG_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:-"yes"}
36 37
37# ------------------------------------------------------------------------------ 38# ------------------------------------------------------------------------------
38# @global JAVA_PKG_BSFIX_NAME 39# @global JAVA_PKG_BSFIX_NAME
39# 40#
40# Filename of build files to fix/search for 41# Filename of build files to fix/search for
41# 42#
42# default: build.xml 43# default: build.xml
43# ------------------------------------------------------------------------------ 44# ------------------------------------------------------------------------------
44JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"} 45JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:-"build.xml"}
45 46
46# ------------------------------------------------------------------------------ 47# ------------------------------------------------------------------------------
47# @global JAVA_ANT_BSFIX_TARGETS_TAGS 48# @global JAVA_PKG_BSFIX_TARGETS_TAGS
48# 49#
49# Targets to fix the 'source' attribute in 50# Targets to fix the 'source' attribute in
50# 51#
51# default: javac xjavac javac.preset 52# default: javac xjavac javac.preset
52# ------------------------------------------------------------------------------ 53# ------------------------------------------------------------------------------
53JAVA_ANT_BSFIX_TARGET_TAGS=${JAVA_PKG_BSFIX_TARGET_TAGS:="javac xjavac javac.preset"} 54JAVA_PKG_BSFIX_TARGET_TAGS=${JAVA_PKG_BSFIX_TARGET_TAGS:-"javac xjavac javac.preset"}
54 55
55# ------------------------------------------------------------------------------ 56# ------------------------------------------------------------------------------
56# @global JAVA_ANT_BSFIX_SOURCE_TAGS 57# @global JAVA_PKG_BSFIX_SOURCE_TAGS
57# 58#
58# Targets to fix the 'target' attribute in 59# Targets to fix the 'target' attribute in
59# 60#
60# default: javacdoc javac xjavac javac.preset 61# default: javacdoc javac xjavac javac.preset
61# ------------------------------------------------------------------------------ 62# ------------------------------------------------------------------------------
62JAVA_ANT_BSFIX_SOURCE_TAGS=${JAVA_PKG_BSFIX_SOURCE_TAGS:="javadoc javac xjavac javac.preset"} 63JAVA_PKG_BSFIX_SOURCE_TAGS=${JAVA_PKG_BSFIX_SOURCE_TAGS:-"javadoc javac xjavac javac.preset"}
63 64
64# ------------------------------------------------------------------------------ 65# ------------------------------------------------------------------------------
65# @public java-ant_src_unpack 66# @public java-ant_src_unpack
66# 67#
67# Unpacks the source, and attempts to fix build files. 68# Unpacks the source, and attempts to fix build files.
104 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM" 105 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
105 fi 106 fi
106 107
107 cd "${S}" 108 cd "${S}"
108 109
109 local find_args="-type f" 110 local find_args=""
110 if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then 111 [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1"
112
111 find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }" 113 find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
112 else
113 find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
114 fi
115 114
116 local i=0 115 local i=0
117 local -a bsfix_these 116 local -a bsfix_these
118 while read line; do 117 while read line; do
119 [[ -z ${line} ]] && continue 118 [[ -z ${line} ]] && continue
120 bsfix_these[${i}]="${line}" 119 bsfix_these[${i}]="${line}"
121 let i+=1 120 let i+=1
122 done <<-EOF 121 done <<-EOF
123 $(find . ${find_args}) 122 $(find . ${find_args})
124 EOF 123 EOF
125 124
126 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do 125 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do
127 local file="${bsfix_these[${i}]}" 126 local file="${bsfix_these[${i}]}"
169 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 168 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
170 diff -NurbB "${file}.orig" "${file}" 169 diff -NurbB "${file}.orig" "${file}"
171 fi 170 fi
172 fi 171 fi
173} 172}
173
174# ------------------------------------------------------------------------------
175# @public java-ant_rewrite-classpath
176#
177# Adds 'classpath="${gentoo.classpath}"' to specified build file.
178# ------------------------------------------------------------------------------
179java-ant_rewrite-classpath() {
180 debug-print-function ${FUNCNAME} $*
181
182 if [ -z "${1}" ]; then
183 eerror "java-ant_rewrite-classpath needs one argument"
184 die "java-ant_rewrite-classpath needs one argument"
185 fi
186
187 local file="${1}"
188 echo "Adding gentoo.classpath to ${file}"
189 debug-print "java-ant_rewrite-classpath: ${file}"
190
191 cp "${file}" "${file}.orig" || die "failed to copy ${file}"
192
193 chmod u+w "${file}"
194
195 xml-rewrite.py -f "${file}" --change -e javac -e xjavac -a classpath -v '${gentoo.classpath}' || die "xml-rewrite failed: ${file}"
196
197 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
198 diff -NurbB "${file}.orig" "${file}"
199 fi
200}

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

  ViewVC Help
Powered by ViewVC 1.1.20