/[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.1 Revision 1.5
10 10
11# This eclass provides functionality for Java packages which use 11# 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 12# ant to build. In particular, it will attempt to fix build.xml files, so that
13# they use the appropriate 'target' and 'source' attributes. 13# they use the appropriate 'target' and 'source' attributes.
14 14
15# Only exports src_unpack 15# We need some tools from javatoolkit. We also need portage 2.1 for phase hooks
16EXPORT_FUNCTIONS src_unpack
17
18# We need some tools from java-toolkit
19DEPEND=">=dev-java/javatoolkit-0.1.5" 16DEPEND=">=dev-java/javatoolkit-0.1.5 ${JAVA_PKG_PORTAGE_DEP}"
20 17
21# ------------------------------------------------------------------------------ 18# ------------------------------------------------------------------------------
22# @global JAVA_ANT_BSFIX 19# @global JAVA_ANT_BSFIX
23# 20#
24# Should we attempt to 'fix' ant build files to include the source/target 21# Should we attempt to 'fix' ant build files to include the source/target
36# default: yes 33# default: yes
37# ------------------------------------------------------------------------------ 34# ------------------------------------------------------------------------------
38JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"} 35JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"}
39 36
40# ------------------------------------------------------------------------------ 37# ------------------------------------------------------------------------------
41# @global JAVA_ANT_BSFIX_NAME 38# @global JAVA_PKG_BSFIX_NAME
42# 39#
43# Filename of build files to fix/search for 40# Filename of build files to fix/search for
44# 41#
45# default: build.xml 42# default: build.xml
46# ------------------------------------------------------------------------------ 43# ------------------------------------------------------------------------------
47JAVA_ANT_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"} 44JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"}
48 45
49# ------------------------------------------------------------------------------ 46# ------------------------------------------------------------------------------
50# @global JAVA_ANT_BSFIX_TARGETS_TAGS 47# @global JAVA_ANT_BSFIX_TARGETS_TAGS
51# 48#
52# Targets to fix the 'source' attribute in 49# Targets to fix the 'source' attribute in
67# ------------------------------------------------------------------------------ 64# ------------------------------------------------------------------------------
68# @public java-ant_src_unpack 65# @public java-ant_src_unpack
69# 66#
70# Unpacks the source, and attempts to fix build files. 67# Unpacks the source, and attempts to fix build files.
71# ------------------------------------------------------------------------------ 68# ------------------------------------------------------------------------------
72java-ant-2_src_unpack() { 69post_src_unpack() {
70 if java-pkg_func-exists ant_src_unpack; then
71 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
73 ant_src_unpack 72 ant_src_unpack
73 fi
74 java-ant_bsfix 74 java-ant_bsfix
75} 75}
76 76
77# ------------------------------------------------------------------------------ 77# ------------------------------------------------------------------------------
78# @private ant_src_unpack 78# @private ant_src_unpack
79# 79#
80# Helper function which does the actual unpacking 80# Helper function which does the actual unpacking
81# ------------------------------------------------------------------------------ 81# ------------------------------------------------------------------------------
82# TODO maybe use base.eclass for some patching love? 82# TODO maybe use base.eclass for some patching love?
83ant_src_unpack() { 83#ant_src_unpack() {
84 debug-print-function ${FUNCNAME} $* 84# debug-print-function ${FUNCNAME} $*
85 if [[ -n "${A}" ]]; then 85# if [[ -n "${A}" ]]; then
86 unpack ${A} 86# unpack ${A}
87 fi 87# fi
88} 88#}
89 89
90# ------------------------------------------------------------------------------ 90# ------------------------------------------------------------------------------
91# @private java-ant_bsfix 91# @private java-ant_bsfix
92# 92#
93# Attempts to fix build files. The following variables will affect its behavior 93# Attempts to fix build files. The following variables will affect its behavior
94# as listed above: 94# as listed above:
95# JAVA_PKG_BSFIX 95# JAVA_PKG_BSFIX
96# JAVA_PKG_BSFIX_ALL 96# JAVA_PKG_BSFIX_ALL
97# JAVA_PKG_BSFIX_NAME, 97# JAVA_PKG_BSFIX_NAME,
98# JAVA_PKG_BSFIX_SOURCE_TAGS
99# JAVA_PKG_BSFIX_TARGET_TAGS)
100# ------------------------------------------------------------------------------ 98# ------------------------------------------------------------------------------
101java-ant_bsfix() { 99java-ant_bsfix() {
102 debug-print-function ${FUNCNAME} $* 100 debug-print-function ${FUNCNAME} $*
103 101
104 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return 102 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return
105 if ! java-pkg_needs-vm; then 103 if ! java-pkg_needs-vm; then
106 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM" 104 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
107 fi 105 fi
108 106
109 cd "${S}" 107 cd "${S}"
110 108
111 local find_args="-type f" 109 local find_args="-type f"
112 if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then 110 if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then
113 find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }" 111 find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }"
114 else 112 else
115 find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } " 113 find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
120 while read line; do 118 while read line; do
121 [[ -z ${line} ]] && continue 119 [[ -z ${line} ]] && continue
122 bsfix_these[${i}]="${line}" 120 bsfix_these[${i}]="${line}"
123 let i+=1 121 let i+=1
124 done <<-EOF 122 done <<-EOF
125 $(find ${find_args}) 123 $(find . ${find_args})
126 EOF 124 EOF
125
126 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do
127 local file="${bsfix_these[${i}]}"
128 java-ant_bsfix_one "${file}"
129 done
130}
131
132# ------------------------------------------------------------------------------
133# @public java-ant_bsfix_one
134#
135# Attempts to fix named build file. The following variables will affect its behavior
136# as listed above:
137# JAVA_PKG_BSFIX_SOURCE_TAGS
138# JAVA_PKG_BSFIX_TARGET_TAGS
139# ------------------------------------------------------------------------------
140java-ant_bsfix_one() {
141 debug-print-function ${FUNCNAME} $*
142
143 if [ -z "${1}" ]; then
144 eerror "java-ant_bsfix_one needs one argument"
145 die "java-ant_bsfix_one needs one argument"
146 fi
127 147
128 local want_source="$(java-pkg_get-source)" 148 local want_source="$(java-pkg_get-source)"
129 local want_target="$(java-pkg_get-target)" 149 local want_target="$(java-pkg_get-target)"
130 150
131 debug-print "bsfix: target: ${want_target} source: ${want_source}" 151 debug-print "bsfix_one: target: ${want_target} source: ${want_source}"
132 152
133 if [ -z "${want_source}" -o -z "${want_target}" ]; then 153 if [ -z "${want_source}" -o -z "${want_target}" ]; then
134 eerror "Could not find valid -source/-target values" 154 eerror "Could not find valid -source/-target values"
135 eerror "Please file a bug about this on bugs.gentoo.org" 155 eerror "Please file a bug about this on bugs.gentoo.org"
136 die "Could not find valid -source/-target values" 156 die "Could not find valid -source/-target values"
137 else 157 else
138 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do 158 local file="${1}"
139 local file="${bsfix_these[${i}]}"
140 echo "Rewriting ${file}" 159 echo "Rewriting ${file}"
141 debug-print "bsfix: ${file}" 160 debug-print "bsfix: ${file}"
142 161
143 cp "${file}" "${file}.orig" || die "failed to copy ${file}" 162 cp "${file}" "${file}.orig" || die "failed to copy ${file}"
144 163
145 chmod u+w "${file}" 164 chmod u+w "${file}"
146 165
147 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_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
148 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}" 167 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
149 168
150 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 169 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
151 diff -NurbB "${file}.orig" "${file}" 170 diff -NurbB "${file}.orig" "${file}"
152 fi 171 fi
153 done
154 fi 172 fi
155} 173}

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

  ViewVC Help
Powered by ViewVC 1.1.20