1 |
commit: d014d46e64b29ad5c8caf7461b78f8221b18a963 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Oct 16 13:54:15 2017 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Oct 16 13:54:15 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d014d46e |
7 |
|
8 |
eclass: sync java eclasses |
9 |
|
10 |
eclass/java-ant-2.eclass | 524 --------------------------------------- |
11 |
eclass/java-utils-2.eclass | 597 +++++++++++++++++++++++++++++---------------- |
12 |
2 files changed, 380 insertions(+), 741 deletions(-) |
13 |
|
14 |
diff --git a/eclass/java-ant-2.eclass b/eclass/java-ant-2.eclass |
15 |
deleted file mode 100644 |
16 |
index ddfbc3a29e..0000000000 |
17 |
--- a/eclass/java-ant-2.eclass |
18 |
+++ /dev/null |
19 |
@@ -1,524 +0,0 @@ |
20 |
-# eclass for ant based Java packages |
21 |
-# |
22 |
-# Copyright (c) 2004-2005, Thomas Matthijs <axxo@g.o> |
23 |
-# Copyright (c) 2004-2011, Gentoo Foundation |
24 |
-# Changes: |
25 |
-# May 2007: |
26 |
-# Made bsfix make one pass for all things and add some glocal targets for |
27 |
-# setting up the whole thing. Contributed by kiorky |
28 |
-# (kiorky@××××××××××.net). |
29 |
-# December 2006: |
30 |
-# I pretty much rewrote the logic of the bsfix functions |
31 |
-# and xml-rewrite.py because they were so slow |
32 |
-# Petteri Räty (betelgeuse@g.o) |
33 |
-# |
34 |
-# Licensed under the GNU General Public License, v2 |
35 |
-# |
36 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.58 2014/03/31 16:48:51 mgorny Exp $ |
37 |
- |
38 |
-# @ECLASS: java-ant-2.eclass |
39 |
-# @MAINTAINER: |
40 |
-# java@g.o |
41 |
-# @AUTHOR: |
42 |
-# kiorky (kiorky@××××××××××.net), Petteri Räty (betelgeuse@g.o) |
43 |
-# @BLURB: eclass for ant based Java packages |
44 |
-# @DESCRIPTION: |
45 |
-# Eclass for Ant-based Java packages. Provides support for both automatic and |
46 |
-# manual manipulation of build.xml files. Should be inherited after java-pkg-2 |
47 |
-# or java-pkg-opt-2 eclass. |
48 |
- |
49 |
-inherit java-utils-2 multilib |
50 |
- |
51 |
-# This eclass provides functionality for Java packages which use |
52 |
-# ant to build. In particular, it will attempt to fix build.xml files, so that |
53 |
-# they use the appropriate 'target' and 'source' attributes. |
54 |
- |
55 |
-# @ECLASS-VARIABLE: WANT_ANT_TASKS |
56 |
-# @DEFAULT_UNSET |
57 |
-# @DESCRIPTION: |
58 |
-# An $IFS separated list of ant tasks. |
59 |
-# Ebuild can specify this variable before inheriting java-ant-2 eclass to |
60 |
-# determine ANT_TASKS it needs. They will be automatically translated to |
61 |
-# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override |
62 |
-# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching. |
63 |
-# Ebuilds that need to depend conditionally on certain tasks and specify them |
64 |
-# differently for different eant calls can't use this simplified approach. |
65 |
-# You also cannot specify version or anything else than ant-*. |
66 |
-# |
67 |
-# @CODE |
68 |
-# WANT_ANT_TASKS="ant-junit ant-trax" |
69 |
-# @CODE |
70 |
- |
71 |
-#The implementation of dependencies is handled by java-utils-2.eclass |
72 |
-#WANT_ANT_TASKS |
73 |
- |
74 |
-# @ECLASS-VARIABLE: JAVA_ANT_DISABLE_ANT_CORE_DEP |
75 |
-# @DEFAULT_UNSET |
76 |
-# @DESCRIPTION: |
77 |
-# Setting this variable non-empty before inheriting java-ant-2 disables adding |
78 |
-# dev-java/ant-core into DEPEND. |
79 |
-if [[ -z "${JAVA_ANT_DISABLE_ANT_CORE_DEP}" ]]; then |
80 |
- JAVA_ANT_E_DEPEND="${JAVA_ANT_E_DEPEND} >=dev-java/ant-core-1.8.2" |
81 |
-fi |
82 |
- |
83 |
-# add ant tasks specified in WANT_ANT_TASKS to DEPEND |
84 |
-local ANT_TASKS_DEPEND; |
85 |
-ANT_TASKS_DEPEND="$(java-pkg_ant-tasks-depend)" |
86 |
-# check that java-pkg_ant-tasks-depend didn't fail |
87 |
-if [[ $? != 0 ]]; then |
88 |
- eerror "${ANT_TASKS_DEPEND}" |
89 |
- die "java-pkg_ant-tasks-depend() failed" |
90 |
-fi |
91 |
- |
92 |
-# We need some tools from javatoolkit. We also need portage 2.1 for phase hooks |
93 |
-# and ant dependencies constructed above. Python is there for |
94 |
-# java-ant_remove-taskdefs |
95 |
-JAVA_ANT_E_DEPEND="${JAVA_ANT_E_DEPEND} |
96 |
- ${ANT_TASKS_DEPEND} |
97 |
- ${JAVA_PKG_PORTAGE_DEP} |
98 |
- >=dev-java/javatoolkit-0.3.0-r2" |
99 |
- |
100 |
-# this eclass must be inherited after java-pkg-2 or java-pkg-opt-2 |
101 |
-# if it's java-pkg-opt-2, ant dependencies are pulled based on USE flag |
102 |
-if has java-pkg-opt-2 ${INHERITED}; then |
103 |
- JAVA_ANT_E_DEPEND="${JAVA_PKG_OPT_USE}? ( ${JAVA_ANT_E_DEPEND} )" |
104 |
-elif ! has java-pkg-2 ${INHERITED}; then |
105 |
- eerror "java-ant-2 eclass can only be inherited AFTER java-pkg-2 or java-pkg-opt-2" |
106 |
-fi |
107 |
- |
108 |
-DEPEND="${JAVA_ANT_E_DEPEND}" |
109 |
- |
110 |
-# @ECLASS-VARIABLE: JAVA_PKG_BSFIX |
111 |
-# @DESCRIPTION: |
112 |
-# Should we attempt to 'fix' ant build files to include the source/target |
113 |
-# attributes when calling javac? |
114 |
-JAVA_PKG_BSFIX=${JAVA_PKG_BSFIX:-"on"} |
115 |
- |
116 |
-# @ECLASS-VARIABLE: JAVA_PKG_BSFIX_ALL |
117 |
-# @DESCRIPTION: |
118 |
-# If we're fixing build files, should we try to fix all the ones we can find? |
119 |
-JAVA_PKG_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:-"yes"} |
120 |
- |
121 |
-# @ECLASS-VARIABLE: JAVA_PKG_BSFIX_NAME |
122 |
-# @DESCRIPTION: |
123 |
-# Filename of build files to fix/search for |
124 |
-JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:-"build.xml"} |
125 |
- |
126 |
-# @ECLASS-VARIABLE: JAVA_PKG_BSFIX_TARGET_TAGS |
127 |
-# @DESCRIPTION: |
128 |
-# Targets to fix the 'source' attribute in |
129 |
-JAVA_PKG_BSFIX_TARGET_TAGS=${JAVA_PKG_BSFIX_TARGET_TAGS:-"javac xjavac javac.preset"} |
130 |
- |
131 |
-# @ECLASS-VARIABLE: JAVA_PKG_BSFIX_SOURCE_TAGS |
132 |
-# @DESCRIPTION: |
133 |
-# Targets to fix the 'target' attribute in |
134 |
-JAVA_PKG_BSFIX_SOURCE_TAGS=${JAVA_PKG_BSFIX_SOURCE_TAGS:-"javadoc javac xjavac javac.preset"} |
135 |
- |
136 |
-# @ECLASS-VARIABLE: JAVA_ANT_CLASSPATH_TAGS |
137 |
-# @DESCRIPTION: |
138 |
-# Targets to add the classpath attribute to |
139 |
-JAVA_ANT_CLASSPATH_TAGS="javac xjavac" |
140 |
- |
141 |
-# @ECLASS-VARIABLE: JAVA_ANT_IGNORE_SYSTEM_CLASSES |
142 |
-# @DEFAULT_UNSET |
143 |
-# @DESCRIPTION: |
144 |
-# When set, <available> Ant tasks are rewritten to ignore Ant's runtime classpath. |
145 |
- |
146 |
-case "${EAPI:-0}" in |
147 |
- 0|1) : ;; |
148 |
- *) EXPORT_FUNCTIONS src_configure ;; |
149 |
-esac |
150 |
- |
151 |
-# @FUNCTION: java-ant-2_src_configure |
152 |
-# @DESCRIPTION: |
153 |
-# src_configure rewrites the build.xml files automatically, unless EAPI is undefined, 0 or 1. |
154 |
-java-ant-2_src_configure() { |
155 |
- # if java support is optional, don't perform this when the USE flag is off |
156 |
- if has java-pkg-opt-2 ${INHERITED}; then |
157 |
- use ${JAVA_PKG_OPT_USE} || return |
158 |
- fi |
159 |
- |
160 |
- # eant will call us unless called by Portage |
161 |
- [[ -e "${T}/java-ant-2_src_configure-run" ]] && return |
162 |
- |
163 |
- [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" ]] \ |
164 |
- && java-ant_ignore-system-classes "${S}/build.xml" |
165 |
- |
166 |
- java-ant_bsfix |
167 |
- touch "${T}/java-ant-2_src_configure-run" |
168 |
-} |
169 |
- |
170 |
-# @FUNCTION: java-ant_bsfix |
171 |
-# @INTERNAL |
172 |
-# @DESCRIPTION: |
173 |
-# Attempts to fix build files. |
174 |
-# |
175 |
-# @CODE |
176 |
-# Affected by variables: |
177 |
-# JAVA_PKG_BSFIX |
178 |
-# JAVA_PKG_BSFIX_ALL |
179 |
-# JAVA_PKG_BSFIX_NAME, |
180 |
-# @CODE |
181 |
-java-ant_bsfix() { |
182 |
- debug-print-function ${FUNCNAME} $* |
183 |
- |
184 |
- [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return |
185 |
- if ! java-pkg_needs-vm; then |
186 |
- echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM" |
187 |
- fi |
188 |
- |
189 |
- pushd "${S}" >/dev/null |
190 |
- |
191 |
- local find_args="" |
192 |
- [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1" |
193 |
- |
194 |
- find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } " |
195 |
- |
196 |
- # This voodoo is done for paths with spaces |
197 |
- local bsfix_these |
198 |
- while read line; do |
199 |
- [[ -z ${line} ]] && continue |
200 |
- bsfix_these="${bsfix_these} '${line}'" |
201 |
- done <<-EOF |
202 |
- $(find . ${find_args}) |
203 |
- EOF |
204 |
- |
205 |
- [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these} |
206 |
- |
207 |
- popd > /dev/null |
208 |
-} |
209 |
- |
210 |
-_bsfix_die() { |
211 |
- if has_version dev-python/pyxml; then |
212 |
- eerror "If the output above contains:" |
213 |
- eerror "ImportError:" |
214 |
- eerror "/usr/lib/python2.4/site-packages/_xmlplus/parsers/pyexpat.so:" |
215 |
- eerror "undefined symbol: PyUnicodeUCS2_DecodeUTF8" |
216 |
- eerror "Try re-emerging dev-python/pyxml" |
217 |
- die ${1} " Look at the eerror message above" |
218 |
- else |
219 |
- die ${1} |
220 |
- fi |
221 |
-} |
222 |
- |
223 |
-# @FUNCTION: java-ant_bsfix_files |
224 |
-# @USAGE: <path/to/first/build.xml> [path/to/second.build.xml ...] |
225 |
-# @DESCRIPTION: |
226 |
-# Attempts to fix named build files. |
227 |
-# |
228 |
-# @CODE |
229 |
-# Affected by variables: |
230 |
-# JAVA_PKG_BSFIX_SOURCE_TAGS |
231 |
-# JAVA_PKG_BSFIX_TARGET_TAGS |
232 |
-# JAVA_ANT_REWRITE_CLASSPATH |
233 |
-# JAVA_ANT_JAVADOC_INPUT_DIRS: Where we can find java sources for javadoc |
234 |
-# input. Can be a space separated list of |
235 |
-# directories |
236 |
-# JAVA_ANT_BSFIX_EXTRA_ARGS: You can use this to pass extra variables to the |
237 |
-# rewriter if you know what you are doing. |
238 |
-# @CODE |
239 |
-# |
240 |
-# If JAVA_ANT_JAVADOC_INPUT_DIRS is set, we will turn on the adding of a basic |
241 |
-# javadoc target to the ant's build.xml with the javadoc xml-rewriter feature. |
242 |
-# Then we will set EANT DOC TARGET to the added javadoc target |
243 |
-# NOTE: the variable JAVA_ANT_JAVADOC_OUTPUT_DIR points where we will |
244 |
-# generate the javadocs. This is a read-only variable, dont change it. |
245 |
- |
246 |
-# When changing this function, make sure that it works with paths with spaces in |
247 |
-# them. |
248 |
-java-ant_bsfix_files() { |
249 |
- debug-print-function ${FUNCNAME} $* |
250 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
251 |
- |
252 |
- [[ ${#} = 0 ]] && die "${FUNCNAME} called without arguments" |
253 |
- |
254 |
- local want_source="$(java-pkg_get-source)" |
255 |
- local want_target="$(java-pkg_get-target)" |
256 |
- |
257 |
- debug-print "${FUNCNAME}: target: ${want_target} source: ${want_source}" |
258 |
- |
259 |
- if [ -z "${want_source}" -o -z "${want_target}" ]; then |
260 |
- eerror "Could not find valid -source/-target values" |
261 |
- eerror "Please file a bug about this on bugs.gentoo.org" |
262 |
- die "Could not find valid -source/-target values" |
263 |
- else |
264 |
- local files |
265 |
- |
266 |
- for file in "${@}"; do |
267 |
- debug-print "${FUNCNAME}: ${file}" |
268 |
- |
269 |
- if [[ -n "${JAVA_PKG_DEBUG}" ]]; then |
270 |
- cp "${file}" "${file}.orig" || die "failed to copy ${file}" |
271 |
- fi |
272 |
- |
273 |
- if [[ ! -w "${file}" ]]; then |
274 |
- chmod u+w "${file}" || die "chmod u+w ${file} failed" |
275 |
- fi |
276 |
- |
277 |
- files="${files} -f '${file}'" |
278 |
- done |
279 |
- |
280 |
- # for javadoc target and all in one pass, we need the new rewriter. |
281 |
- local rewriter3="${EPREFIX}/usr/share/javatoolkit/xml-rewrite-3.py" |
282 |
- if [[ ! -f ${rewriter3} ]]; then |
283 |
- rewriter3="${EPREFIX}/usr/$(get_libdir)/javatoolkit/bin/xml-rewrite-3.py" |
284 |
- fi |
285 |
- |
286 |
- local rewriter4="${EPREFIX}/usr/$(get_libdir)/javatoolkit/bin/build-xml-rewrite" |
287 |
- |
288 |
- if [[ -x ${rewriter4} && ${JAVA_ANT_ENCODING} ]]; then |
289 |
- [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] && local gcp="-g" |
290 |
- [[ ${JAVA_ANT_ENCODING} ]] && local enc="-e ${JAVA_ANT_ENCODING}" |
291 |
- eval echo "cElementTree rewriter" |
292 |
- debug-print "${rewriter4} extra args: ${gcp} ${enc}" |
293 |
- ${rewriter4} ${gcp} ${enc} \ |
294 |
- -c "${JAVA_PKG_BSFIX_SOURCE_TAGS}" source ${want_source} \ |
295 |
- -c "${JAVA_PKG_BSFIX_TARGET_TAGS}" target ${want_target} \ |
296 |
- "${@}" || die "build-xml-rewrite failed" |
297 |
- elif [[ ! -f ${rewriter3} ]]; then |
298 |
- debug-print "Using second generation rewriter" |
299 |
- eval echo "Rewriting source attributes" |
300 |
- eval xml-rewrite-2.py ${files} \ |
301 |
- -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \ |
302 |
- -a source -v ${want_source} || _bsfix_die "xml-rewrite2 failed: ${file}" |
303 |
- |
304 |
- eval echo "Rewriting target attributes" |
305 |
- eval xml-rewrite-2.py ${files} \ |
306 |
- -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ |
307 |
- -a target -v ${want_target} || _bsfix_die "xml-rewrite2 failed: ${file}" |
308 |
- |
309 |
- eval echo "Rewriting nowarn attributes" |
310 |
- eval xml-rewrite-2.py ${files} \ |
311 |
- -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ |
312 |
- -a nowarn -v yes || _bsfix_die "xml-rewrite2 failed: ${file}" |
313 |
- |
314 |
- if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then |
315 |
- eval echo "Adding gentoo.classpath to javac tasks" |
316 |
- eval xml-rewrite-2.py ${files} \ |
317 |
- -c -e javac -e xjavac -a classpath -v \ |
318 |
- '\${gentoo.classpath}' \ |
319 |
- || _bsfix_die "xml-rewrite2 failed" |
320 |
- fi |
321 |
- else |
322 |
- debug-print "Using third generation rewriter" |
323 |
- eval echo "Rewriting attributes" |
324 |
- local bsfix_extra_args="" |
325 |
- # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES! |
326 |
- if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then |
327 |
- local cp_tags="${JAVA_ANT_CLASSPATH_TAGS// / -e }" |
328 |
- bsfix_extra_args="${bsfix_extra_args} -g -e ${cp_tags}" |
329 |
- bsfix_extra_args="${bsfix_extra_args} -a classpath -v '\${gentoo.classpath}'" |
330 |
- fi |
331 |
- if [[ -n ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]]; then |
332 |
- if [[ -n ${JAVA_ANT_JAVADOC_OUTPUT_DIR} ]]; then |
333 |
- die "Do not define JAVA_ANT_JAVADOC_OUTPUT_DIR!" |
334 |
- fi |
335 |
- # Where will our generated javadoc go. |
336 |
- readonly JAVA_ANT_JAVADOC_OUTPUT_DIR="${WORKDIR}/gentoo_javadoc" |
337 |
- mkdir -p "${JAVA_ANT_JAVADOC_OUTPUT_DIR}" || die |
338 |
- |
339 |
- if has doc ${IUSE}; then |
340 |
- if use doc; then |
341 |
- if [[ -z ${EANT_DOC_TARGET} ]]; then |
342 |
- EANT_DOC_TARGET="gentoojavadoc" |
343 |
- else |
344 |
- die "You can't use javadoc adding and set EANT_DOC_TARGET too." |
345 |
- fi |
346 |
- |
347 |
- for dir in ${JAVA_ANT_JAVADOC_INPUT_DIRS};do |
348 |
- if [[ ! -d ${dir} ]]; then |
349 |
- eerror "This dir: ${dir} doesnt' exists" |
350 |
- die "You must specify directories for javadoc input/output dirs." |
351 |
- fi |
352 |
- done |
353 |
- bsfix_extra_args="${bsfix_extra_args} --javadoc --source-directory " |
354 |
- # filter third/double spaces |
355 |
- JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /} |
356 |
- JAVA_ANT_JAVADOC_INPUT_DIRS=${JAVA_ANT_JAVADOC_INPUT_DIRS// /} |
357 |
- bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_JAVADOC_INPUT_DIRS// / --source-directory }" |
358 |
- bsfix_extra_args="${bsfix_extra_args} --output-directory ${JAVA_ANT_JAVADOC_OUTPUT_DIR}" |
359 |
- fi |
360 |
- else |
361 |
- die "You need to have doc in IUSE when using JAVA_ANT_JAVADOC_INPUT_DIRS" |
362 |
- fi |
363 |
- fi |
364 |
- |
365 |
- [[ -n ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \ |
366 |
- && bsfix_extra_args="${bsfix_extra_args} ${JAVA_ANT_BSFIX_EXTRA_ARGS}" |
367 |
- |
368 |
- debug-print "bsfix_extra_args: ${bsfix_extra_args}" |
369 |
- |
370 |
- eval ${rewriter3} ${files} \ |
371 |
- -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \ |
372 |
- --source-attribute source --source-value ${want_source} \ |
373 |
- --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \ |
374 |
- --target-attribute target --target-value ${want_target} \ |
375 |
- --target-attribute nowarn --target-value yes \ |
376 |
- ${bsfix_extra_args} \ |
377 |
- || _bsfix_die "xml-rewrite2 failed: ${file}" |
378 |
- fi |
379 |
- |
380 |
- if [[ -n "${JAVA_PKG_DEBUG}" ]]; then |
381 |
- for file in "${@}"; do |
382 |
- diff -NurbB "${file}.orig" "${file}" |
383 |
- done |
384 |
- fi |
385 |
- fi |
386 |
- return 0 # so that the 1 for diff doesn't get reported |
387 |
-} |
388 |
- |
389 |
- |
390 |
-# @FUNCTION: java-ant_bsfix_one |
391 |
-# @USAGE: <path/to/build.xml> |
392 |
-# @DESCRIPTION: |
393 |
-# Attempts to fix named build file. |
394 |
-# |
395 |
-# @CODE |
396 |
-# Affected by variables: |
397 |
-# JAVA_PKG_BSFIX_SOURCE_TAGS |
398 |
-# JAVA_PKG_BSFIX_TARGET_TAGS |
399 |
-# @CODE |
400 |
-java-ant_bsfix_one() { |
401 |
- debug-print-function ${FUNCNAME} $* |
402 |
- |
403 |
- if [ -z "${1}" ]; then |
404 |
- eerror "${FUNCNAME} needs one argument" |
405 |
- die "${FUNCNAME} needs one argument" |
406 |
- fi |
407 |
- |
408 |
- java-ant_bsfix_files "${1}" |
409 |
-} |
410 |
- |
411 |
-# @FUNCTION: java-ant_rewrite-classpath |
412 |
-# @USAGE: [path/to/build.xml] |
413 |
-# @DESCRIPTION: |
414 |
-# Adds 'classpath="${gentoo.classpath}"' to specified build file. |
415 |
-# |
416 |
-# Affected by: |
417 |
-# JAVA_ANT_CLASSPATH_TAGS |
418 |
-# |
419 |
-# Parameter defaults to build.xml when not specified |
420 |
-java-ant_rewrite-classpath() { |
421 |
- debug-print-function ${FUNCNAME} $* |
422 |
- |
423 |
- local file="${1}" |
424 |
- [[ -z "${1}" ]] && file=build.xml |
425 |
- [[ ${#} -gt 1 ]] && die "${FUNCNAME} currently can only rewrite one file." |
426 |
- |
427 |
- echo "Adding gentoo.classpath to ${file}" |
428 |
- debug-print "java-ant_rewrite-classpath: ${file}" |
429 |
- |
430 |
- cp "${file}" "${file}.orig" || die "failed to copy ${file}" |
431 |
- |
432 |
- chmod u+w "${file}" |
433 |
- |
434 |
- java-ant_xml-rewrite -f "${file}" --change \ |
435 |
- -e ${JAVA_ANT_CLASSPATH_TAGS// / -e } -a classpath -v '${gentoo.classpath}' |
436 |
- |
437 |
- if [[ -n "${JAVA_PKG_DEBUG}" ]]; then |
438 |
- diff -NurbB "${file}.orig" "${file}" |
439 |
- fi |
440 |
-} |
441 |
- |
442 |
-# @FUNCTION: java-ant_remove-taskdefs |
443 |
-# @USAGE: [--name NAME] [path/to/build.xml] |
444 |
-# @DESCRIPTION: |
445 |
-# Removes (named) taskdef elements from the build.xml file. |
446 |
-# When --name NAME is specified, only remove taskdef with name NAME. Otherwise, |
447 |
-# all taskdefs are removed. |
448 |
-# The file to rewrite defaults to build.xml when not specified. |
449 |
-java-ant_remove-taskdefs() { |
450 |
- debug-print-function ${FUNCNAME} $* |
451 |
- |
452 |
- die "${FUNCNAME} has been banned, see bug #479838." |
453 |
- |
454 |
- local task_name |
455 |
- if [[ "${1}" == --name ]]; then |
456 |
- task_name="${2}" |
457 |
- shift 2 |
458 |
- fi |
459 |
- local file="${1:-build.xml}" |
460 |
- echo "Removing taskdefs from ${file}" |
461 |
- python <<EOF |
462 |
-import sys |
463 |
-from xml.dom.minidom import parse |
464 |
-dom = parse("${file}") |
465 |
-for elem in dom.getElementsByTagName('taskdef'): |
466 |
- if (len("${task_name}") == 0 or elem.getAttribute("name") == "${task_name}"): |
467 |
- elem.parentNode.removeChild(elem) |
468 |
- elem.unlink() |
469 |
-f = open("${file}", "w") |
470 |
-dom.writexml(f) |
471 |
-f.close() |
472 |
-EOF |
473 |
- [[ $? != 0 ]] && die "Removing taskdefs failed" |
474 |
-} |
475 |
- |
476 |
-# @FUNCTION: java-ant_ignore-system-classes |
477 |
-# @USAGE: [path/to/build.xml] |
478 |
-# @DESCRIPTION: |
479 |
-# Makes the available task ignore classes in the system classpath |
480 |
-# Parameter defaults to build.xml when not specified |
481 |
-java-ant_ignore-system-classes() { |
482 |
- debug-print-function ${FUNCNAME} $* |
483 |
- local file=${1:-build.xml} |
484 |
- echo "Changing ignoresystemclasses to true for available tasks in ${file}" |
485 |
- java-ant_xml-rewrite -f "${file}" --change \ |
486 |
- -e available -a ignoresystemclasses -v "true" |
487 |
-} |
488 |
- |
489 |
-# @FUNCTION: java-ant_xml-rewrite |
490 |
-# @USAGE: <xml rewriter arguments> |
491 |
-# @DESCRIPTION: |
492 |
-# Run the right xml-rewrite binary with the given arguments |
493 |
-java-ant_xml-rewrite() { |
494 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
495 |
- local gen2="${EPREFIX}/usr/bin/xml-rewrite-2.py" |
496 |
- local gen2_1="${EPREFIX}/usr/$(get_libdir)/javatoolkit/bin/xml-rewrite-2.py" |
497 |
- # gen1 is deprecated |
498 |
- if [[ -x "${gen2}" ]]; then |
499 |
- ${gen2} "${@}" || die "${gen2} failed" |
500 |
- elif [[ -x "${gen2_1}" ]]; then |
501 |
- ${gen2_1} "${@}" || die "${gen2_1} failed" |
502 |
- else |
503 |
- eerror "No binary for rewriting found." |
504 |
- eerror "Do you have dev-java/javatoolkit installed?" |
505 |
- die "xml-rewrite not found" |
506 |
- fi |
507 |
-} |
508 |
- |
509 |
-# @FUNCTION: java-ant_rewrite-bootclasspath |
510 |
-# @USAGE: <version> [path/to/build.xml] [prepend] [append] |
511 |
-# @DESCRIPTION: |
512 |
-# Adds bootclasspath to javac-like tasks in build.xml filled with jars of a |
513 |
-# bootclasspath package of given version. |
514 |
-# |
515 |
-# @CODE |
516 |
-# Affected by: |
517 |
-# JAVA_PKG_BSFIX_TARGET_TAGS - the tags of javac tasks |
518 |
-# |
519 |
-# Parameters: |
520 |
-# $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath |
521 |
-# of the current JDK |
522 |
-# $2 - path to desired build.xml file, defaults to 'build.xml' |
523 |
-# $3 - (optional) what to prepend the bootclasspath with (to override) |
524 |
-# $4 - (optional) what to append to the bootclasspath |
525 |
-# @CODE |
526 |
-java-ant_rewrite-bootclasspath() { |
527 |
- local version="${1}" |
528 |
- local file="${2-build.xml}" |
529 |
- local extra_before="${3}" |
530 |
- local extra_after="${4}" |
531 |
- |
532 |
- local bcp="$(java-pkg_get-bootclasspath "${version}")" |
533 |
- |
534 |
- if [[ -n "${extra_before}" ]]; then |
535 |
- bcp="${extra_before}:${bcp}" |
536 |
- fi |
537 |
- if [[ -n "${extra_after}" ]]; then |
538 |
- bcp="${bcp}:${extra_after}" |
539 |
- fi |
540 |
- |
541 |
- java-ant_xml-rewrite -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ |
542 |
- -a bootclasspath -v "${bcp}" |
543 |
-} |
544 |
|
545 |
diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass |
546 |
index 55d7fa5849..1ec878b96c 100644 |
547 |
--- a/eclass/java-utils-2.eclass |
548 |
+++ b/eclass/java-utils-2.eclass |
549 |
@@ -1,12 +1,5 @@ |
550 |
-# Base eclass for Java packages |
551 |
-# |
552 |
-# Copyright (c) 2004-2005, Thomas Matthijs <axxo@g.o> |
553 |
-# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@g.o> |
554 |
-# Copyright (c) 2004-2011, Gentoo Foundation |
555 |
-# |
556 |
-# Licensed under the GNU General Public License, v2 |
557 |
-# |
558 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.156 2014/04/09 21:55:12 radhermit Exp $ |
559 |
+# Copyright 2004-2017 Gentoo Foundation |
560 |
+# Distributed under the terms of the GNU General Public License v2 |
561 |
|
562 |
# @ECLASS: java-utils-2.eclass |
563 |
# @MAINTAINER: |
564 |
@@ -21,7 +14,7 @@ |
565 |
# This eclass should not be inherited this directly from an ebuild. Instead, |
566 |
# you should inherit java-pkg-2 for Java packages or java-pkg-opt-2 for packages |
567 |
# that have optional Java support. In addition you can inherit java-ant-2 for |
568 |
-# Ant-based packages. |
569 |
+# Ant-based packages. |
570 |
inherit eutils versionator multilib |
571 |
|
572 |
IUSE="elibc_FreeBSD" |
573 |
@@ -29,6 +22,9 @@ IUSE="elibc_FreeBSD" |
574 |
# Make sure we use java-config-2 |
575 |
export WANT_JAVA_CONFIG="2" |
576 |
|
577 |
+# Prefix variables are only available for EAPI>=3 |
578 |
+has "${EAPI:-0}" 0 1 2 && ED="${D}" EPREFIX= EROOT="${ROOT}" |
579 |
+ |
580 |
# @VARIABLE: JAVA_PKG_PORTAGE_DEP |
581 |
# @INTERNAL |
582 |
# @DESCRIPTION: |
583 |
@@ -43,7 +39,7 @@ has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" |
584 |
# This is a convience variable to be used from the other java eclasses. This is |
585 |
# the version of java-config we want to use. Usually the latest stable version |
586 |
# so that ebuilds can use new features without depending on specific versions. |
587 |
-JAVA_PKG_E_DEPEND="!x86-winnt? ( >=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP} )" |
588 |
+JAVA_PKG_E_DEPEND="!x86-winnt? ( >=dev-java/java-config-2.2.0-r3 ${JAVA_PKG_PORTAGE_DEP} )" |
589 |
has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" |
590 |
|
591 |
# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH |
592 |
@@ -126,20 +122,43 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} |
593 |
# JAVA_PKG_WANT_TARGET=1.3 emerge bar |
594 |
# @CODE |
595 |
|
596 |
+# @ECLASS-VARIABLE: JAVA_PKG_DEBUG |
597 |
+# @DEFAULT_UNSET |
598 |
+# @DESCRIPTION: |
599 |
+# A variable to be set with "yes" or "y", or ANY string of length non equal to |
600 |
+# zero. When set, verbosity across java eclasses is increased and extra |
601 |
+# logging is displayed. |
602 |
+# @CODE |
603 |
+# JAVA_PKG_DEBUG="yes" |
604 |
+# @CODE |
605 |
+ |
606 |
+# @ECLASS-VARIABLE: JAVA_RM_FILES |
607 |
+# @DEFAULT_UNSET |
608 |
+# @DESCRIPTION: |
609 |
+# An array containing a list of files to remove. If defined, this array will be |
610 |
+# automatically handed over to java-pkg_rm_files for processing during the |
611 |
+# src_prepare phase. |
612 |
+# |
613 |
+# @CODE |
614 |
+# JAVA_RM_FILES=( |
615 |
+# path/to/File1.java |
616 |
+# DELETEME.txt |
617 |
+# ) |
618 |
+# @CODE |
619 |
+ |
620 |
# @VARIABLE: JAVA_PKG_COMPILER_DIR |
621 |
# @INTERNAL |
622 |
# @DESCRIPTION: |
623 |
# Directory where compiler settings are saved, without trailing slash. |
624 |
# You probably shouldn't touch this variable except local testing. |
625 |
-JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="${EPREFIX}"/usr/share/java-config-2/compiler} |
626 |
- |
627 |
+JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="${EPREFIX}/usr/share/java-config-2/compiler"} |
628 |
|
629 |
# @VARIABLE: JAVA_PKG_COMPILERS_CONF |
630 |
# @INTERNAL |
631 |
# @DESCRIPTION: |
632 |
# Path to file containing information about which compiler to use. |
633 |
# Can be overloaded, but it should be overloaded only for local testing. |
634 |
-JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="${EPREFIX}"/etc/java-config-2/build/compilers.conf} |
635 |
+JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="${EPREFIX}/etc/java-config-2/build/compilers.conf"} |
636 |
|
637 |
# @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER |
638 |
# @INTERNAL |
639 |
@@ -218,6 +237,73 @@ java-pkg_doexamples() { |
640 |
dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die |
641 |
} |
642 |
|
643 |
+# @FUNCTION: java-pkg_addres |
644 |
+# @USAGE: <jar> <dir> [<find arguments> ...] |
645 |
+# @DESCRIPTION: |
646 |
+# Adds resource files to an existing jar. |
647 |
+# It is important that the directory given is actually the root of the |
648 |
+# corresponding resource tree. The target directory as well as |
649 |
+# sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are |
650 |
+# automatically excluded. Symlinks are always followed. Additional |
651 |
+# arguments are passed through to find. |
652 |
+# |
653 |
+# @CODE |
654 |
+# java-pkg_addres ${PN}.jar resources ! -name "*.html" |
655 |
+# @CODE |
656 |
+# |
657 |
+# @param $1 - jar file |
658 |
+# @param $2 - resource tree directory |
659 |
+# @param $* - arguments to pass to find |
660 |
+java-pkg_addres() { |
661 |
+ debug-print-function ${FUNCNAME} $* |
662 |
+ |
663 |
+ [[ ${#} -lt 2 ]] && die "at least two arguments needed" |
664 |
+ |
665 |
+ local jar=$(realpath "$1" || die "realpath $1 failed") |
666 |
+ local dir="$2" |
667 |
+ shift 2 |
668 |
+ |
669 |
+ pushd "${dir}" > /dev/null || die "pushd ${dir} failed" |
670 |
+ find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -r0 jar uf "${jar}" || die "jar failed" |
671 |
+ popd > /dev/null || die "popd failed" |
672 |
+} |
673 |
+ |
674 |
+# @FUNCTION: java-pkg_rm_files |
675 |
+# @USAGE: java-pkg_rm_files File1.java File2.java ... |
676 |
+# @DESCRIPTION: |
677 |
+# Remove unneeded files in ${S}. |
678 |
+# |
679 |
+# Every now and then, you'll run into situations whereby a file needs removing, |
680 |
+# be it a unit test or a regular java class. |
681 |
+# |
682 |
+# You can use this function by either: |
683 |
+# - calling it yourself in src_prepare() and feeding java-pkg_rm_files with |
684 |
+# the list of files you wish to remove. |
685 |
+# - defining an array in the ebuild named JAVA_RM_FILES with the list of files |
686 |
+# you wish to remove. |
687 |
+# |
688 |
+# Both way work and it is left to the developer's preferences. If the |
689 |
+# JAVA_RM_FILES array is defined, it will be automatically handed over to |
690 |
+# java-pkg_rm_files during the src_prepare phase. |
691 |
+# |
692 |
+# See java-utils-2_src_prepare. |
693 |
+# |
694 |
+# @CODE |
695 |
+# java-pkg_rm_files File1.java File2.java |
696 |
+# @CODE |
697 |
+# |
698 |
+# @param $* - list of files to remove. |
699 |
+java-pkg_rm_files() { |
700 |
+ debug-print-function ${FUNCNAME} $* |
701 |
+ local IFS="\n" |
702 |
+ for filename in "$@"; do |
703 |
+ [[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting." |
704 |
+ einfo "Removing unneeded file ${filename}" |
705 |
+ rm -f "${S}/${filename}" || die "cannot remove ${filename}" |
706 |
+ eend $? |
707 |
+ done |
708 |
+} |
709 |
+ |
710 |
# @FUNCTION: java-pkg_dojar |
711 |
# @USAGE: <jar1> [<jar2> ...] |
712 |
# @DESCRIPTION: |
713 |
@@ -264,8 +350,10 @@ java-pkg_dojar() { |
714 |
#but first check class version when in strict mode. |
715 |
is-java-strict && java-pkg_verify-classes "${jar}" |
716 |
|
717 |
- INSDESTTREE="${JAVA_PKG_JARDEST}" \ |
718 |
- doins "${jar}" || die "failed to install ${jar}" |
719 |
+ ( |
720 |
+ insinto "${JAVA_PKG_JARDEST}" |
721 |
+ doins "${jar}" |
722 |
+ ) || die "failed to install ${jar}" |
723 |
java-pkg_append_ JAVA_PKG_CLASSPATH "${EPREFIX}/${JAVA_PKG_JARDEST}/${jar_basename}" |
724 |
debug-print "installed ${jar} to ${ED}${JAVA_PKG_JARDEST}" |
725 |
# make a symlink to the original jar if it's symlink |
726 |
@@ -280,19 +368,16 @@ java-pkg_dojar() { |
727 |
fi |
728 |
done |
729 |
|
730 |
- java-pkg_do_write_ |
731 |
-} |
732 |
+ # Extra logging if enabled. |
733 |
+ if [[ -n ${JAVA_PKG_DEBUG} ]]; then |
734 |
+ einfo "Verbose logging for \"${FUNCNAME}\" function" |
735 |
+ einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}" |
736 |
+ einfo "Jar file(s) created: ${@}" |
737 |
+ einfo "Complete command:" |
738 |
+ einfo "${FUNCNAME} ${@}" |
739 |
+ fi |
740 |
|
741 |
-# @FUNCTION: depend-java-query |
742 |
-# @INTERNAL |
743 |
-# @DESCRIPTION: |
744 |
-# Wrapper for the depend-java-query binary to enable passing USE in env. |
745 |
-# Using env variables keeps this eclass working with java-config versions that |
746 |
-# do not handle use flags. |
747 |
-depend-java-query() { |
748 |
- # Used to have a which call here but it caused endless loops for some people |
749 |
- # that had some weird bashrc voodoo for which. |
750 |
- USE="${USE}" "${EPREFIX}"/usr/bin/depend-java-query "${@}" |
751 |
+ java-pkg_do_write_ |
752 |
} |
753 |
|
754 |
# @FUNCTION: java-pkg_regjar |
755 |
@@ -412,9 +497,11 @@ java-pkg_doso() { |
756 |
if [[ -e "${lib}" ]] ; then |
757 |
# install if it isn't a symlink |
758 |
if [[ ! -L "${lib}" ]] ; then |
759 |
- INSDESTTREE="${JAVA_PKG_LIBDEST}" \ |
760 |
- INSOPTIONS="${LIBOPTIONS}" \ |
761 |
- doins "${lib}" || die "failed to install ${lib}" |
762 |
+ ( |
763 |
+ insinto "${JAVA_PKG_LIBDEST}" |
764 |
+ insopts -m0755 |
765 |
+ doins "${lib}" |
766 |
+ ) || die "failed to install ${lib}" |
767 |
java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" |
768 |
debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" |
769 |
# otherwise make a symlink to the symlink's origin |
770 |
@@ -502,13 +589,13 @@ java-pkg_sointo() { |
771 |
java-pkg_dohtml() { |
772 |
debug-print-function ${FUNCNAME} $* |
773 |
|
774 |
- [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" |
775 |
+ [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" |
776 |
|
777 |
- # from /usr/lib/portage/bin/dohtml -h |
778 |
- # -f Set list of allowed extensionless file names. |
779 |
- dohtml -f package-list "$@" |
780 |
+ # Do away with dohtml and rely on dodoc instead to do the deed. |
781 |
+ docinto html |
782 |
+ dodoc "$@" |
783 |
|
784 |
- # this probably shouldn't be here but it provides |
785 |
+ # This probably shouldn't be here but it provides |
786 |
# a reasonable way to catch # docs for all of the |
787 |
# old ebuilds. |
788 |
java-pkg_recordjavadoc |
789 |
@@ -570,7 +657,6 @@ java-pkg_dojavadoc() { |
790 |
fi |
791 |
|
792 |
# Actual installation |
793 |
- |
794 |
java-pkg_dohtml -r "${dir_to_install}" |
795 |
|
796 |
# Let's make a symlink to the directory we have everything else under |
797 |
@@ -580,6 +666,15 @@ java-pkg_dojavadoc() { |
798 |
debug-print "symlinking ${dest}/{api,${symlink}}" |
799 |
dosym ${dest}/{api,${symlink}} || die |
800 |
fi |
801 |
+ |
802 |
+ # Extra logging if enabled. |
803 |
+ if [[ -n ${JAVA_PKG_DEBUG} ]]; then |
804 |
+ einfo "Verbose logging for \"${FUNCNAME}\" function" |
805 |
+ einfo "Documentation destination: ${dest}" |
806 |
+ einfo "Directory to install: ${dir_to_install}" |
807 |
+ einfo "Complete command:" |
808 |
+ einfo "${FUNCNAME} ${@}" |
809 |
+ fi |
810 |
} |
811 |
|
812 |
# @FUNCTION: java-pkg_dosrc |
813 |
@@ -631,14 +726,27 @@ java-pkg_dosrc() { |
814 |
if [[ ${result} != 12 && ${result} != 0 ]]; then |
815 |
die "failed to zip ${dir_name}" |
816 |
fi |
817 |
- popd >/dev/null |
818 |
+ popd >/dev/null || die |
819 |
done |
820 |
|
821 |
# Install the zip |
822 |
- INSDESTTREE=${JAVA_PKG_SOURCESPATH} \ |
823 |
- doins ${zip_path} || die "Failed to install source" |
824 |
+ ( |
825 |
+ insinto "${JAVA_PKG_SOURCESPATH}" |
826 |
+ doins ${zip_path} |
827 |
+ ) || die "Failed to install source" |
828 |
|
829 |
JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}" |
830 |
+ |
831 |
+ # Extra logging if enabled. |
832 |
+ if [[ -n ${JAVA_PKG_DEBUG} ]]; then |
833 |
+ einfo "Verbose logging for \"${FUNCNAME}\" function" |
834 |
+ einfo "Zip filename created: ${zip_name}" |
835 |
+ einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}" |
836 |
+ einfo "Directories zipped: ${@}" |
837 |
+ einfo "Complete command:" |
838 |
+ einfo "${FUNCNAME} ${@}" |
839 |
+ fi |
840 |
+ |
841 |
java-pkg_do_write_ |
842 |
} |
843 |
|
844 |
@@ -725,7 +833,10 @@ java-pkg_dolauncher() { |
845 |
echo "source ${EPREFIX}/usr/share/java-config-2/launcher/launcher.bash" >> "${target}" |
846 |
|
847 |
if [[ -n "${target_dir}" ]]; then |
848 |
- DESTTREE="${target_dir}" dobin "${target}" |
849 |
+ ( |
850 |
+ into "${target_dir}" |
851 |
+ dobin "${target}" |
852 |
+ ) |
853 |
local ret=$? |
854 |
return ${ret} |
855 |
else |
856 |
@@ -764,9 +875,11 @@ java-pkg_dowar() { |
857 |
fi |
858 |
|
859 |
# Install those files like you mean it |
860 |
- INSOPTIONS="-m 0644" \ |
861 |
- INSDESTTREE=${JAVA_PKG_WARDEST} \ |
862 |
+ ( |
863 |
+ insopts -m0644 |
864 |
+ insinto "${JAVA_PKG_WARDEST}" |
865 |
doins ${warpath} |
866 |
+ ) |
867 |
done |
868 |
} |
869 |
|
870 |
@@ -921,7 +1034,7 @@ java-pkg_jar-from() { |
871 |
java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}" |
872 |
fi |
873 |
fi |
874 |
- # otherwise, if the current jar is the target jar, link it |
875 |
+ # otherwise, if the current jar is the target jar, link it |
876 |
elif [[ "${jar_name}" == "${target_jar}" ]] ; then |
877 |
[[ -f "${destjar}" ]] && rm "${destjar}" |
878 |
ln -snf "${jar}" "${destjar}" \ |
879 |
@@ -930,14 +1043,14 @@ java-pkg_jar-from() { |
880 |
if [[ -z "${build_only}" ]]; then |
881 |
java-pkg_record-jar_ "${target_pkg}" "${jar}" |
882 |
else |
883 |
- java-pkg_record-jar_ --build-only "${target_jar}" "${jar}" |
884 |
+ java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}" |
885 |
fi |
886 |
fi |
887 |
- popd > /dev/null |
888 |
+ popd > /dev/null || die |
889 |
return 0 |
890 |
fi |
891 |
done |
892 |
- popd > /dev/null |
893 |
+ popd > /dev/null || die |
894 |
# if no target was specified, we're ok |
895 |
if [[ -z "${target_jar}" ]] ; then |
896 |
return 0 |
897 |
@@ -1515,7 +1628,7 @@ java-pkg_get-target() { |
898 |
java-pkg_get-javac() { |
899 |
debug-print-function ${FUNCNAME} $* |
900 |
|
901 |
- |
902 |
+ java-pkg_init-compiler_ |
903 |
local compiler="${GENTOO_COMPILER}" |
904 |
|
905 |
local compiler_executable |
906 |
@@ -1534,18 +1647,15 @@ java-pkg_get-javac() { |
907 |
export JAVAC=${old_javac} |
908 |
|
909 |
if [[ -z ${compiler_executable} ]]; then |
910 |
- echo "JAVAC is empty or undefined in ${compiler_env}" |
911 |
- return 1 |
912 |
+ die "JAVAC is empty or undefined in ${compiler_env}" |
913 |
fi |
914 |
|
915 |
# check that it's executable |
916 |
if [[ ! -x ${compiler_executable} ]]; then |
917 |
- echo "${compiler_executable} doesn't exist, or isn't executable" |
918 |
- return 1 |
919 |
+ die "${compiler_executable} doesn't exist, or isn't executable" |
920 |
fi |
921 |
else |
922 |
- echo "Could not find environment file for ${compiler}" |
923 |
- return 1 |
924 |
+ die "Could not find environment file for ${compiler}" |
925 |
fi |
926 |
fi |
927 |
echo ${compiler_executable} |
928 |
@@ -1570,15 +1680,9 @@ java-pkg_javac-args() { |
929 |
debug-print "want target: ${want_target}" |
930 |
|
931 |
if [[ -z "${want_source}" || -z "${want_target}" ]]; then |
932 |
- debug-print "could not find valid -source/-target values for javac" |
933 |
- echo "Could not find valid -source/-target values for javac" |
934 |
- return 1 |
935 |
+ die "Could not find valid -source/-target values for javac" |
936 |
else |
937 |
- if java-pkg_is-vm-version-ge "1.4"; then |
938 |
- echo "${source_str} ${target_str}" |
939 |
- else |
940 |
- echo "${target_str}" |
941 |
- fi |
942 |
+ echo "${source_str} ${target_str}" |
943 |
fi |
944 |
} |
945 |
|
946 |
@@ -1715,8 +1819,8 @@ ejunit_() { |
947 |
if [[ "${junit}" == "junit-4" ]] ; then |
948 |
runner=org.junit.runner.JUnitCore |
949 |
fi |
950 |
- debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" |
951 |
- java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" |
952 |
+ debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}" |
953 |
+ java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" |
954 |
} |
955 |
|
956 |
# @FUNCTION: ejunit |
957 |
@@ -1769,18 +1873,28 @@ ejunit4() { |
958 |
# src_prepare Searches for bundled jars |
959 |
# Don't call directly, but via java-pkg-2_src_prepare! |
960 |
java-utils-2_src_prepare() { |
961 |
- [[ ${EBUILD_PHASE} == prepare ]] && |
962 |
- java-pkg_func-exists java_prepare && java_prepare |
963 |
+ case ${EAPI:-0} in |
964 |
+ [0-5]) |
965 |
+ java-pkg_func-exists java_prepare && java_prepare ;; |
966 |
+ *) |
967 |
+ java-pkg_func-exists java_prepare && |
968 |
+ eqawarn "java_prepare is no longer called, define src_prepare instead." |
969 |
+ eapply_user ;; |
970 |
+ esac |
971 |
+ |
972 |
+ # Check for files in JAVA_RM_FILES array. |
973 |
+ if [[ ${JAVA_RM_FILES[@]} ]]; then |
974 |
+ debug-print "$FUNCNAME: removing unneeded files" |
975 |
+ java-pkg_rm_files "${JAVA_RM_FILES[@]}" |
976 |
+ fi |
977 |
|
978 |
- # Remember that eant will call this unless called via Portage |
979 |
- if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then |
980 |
+ if is-java-strict; then |
981 |
echo "Searching for bundled jars:" |
982 |
java-pkg_find-normal-jars || echo "None found." |
983 |
echo "Searching for bundled classes (no output if none found):" |
984 |
find "${WORKDIR}" -name "*.class" |
985 |
echo "Search done." |
986 |
fi |
987 |
- touch "${T}/java-utils-2_src_prepare-run" |
988 |
} |
989 |
|
990 |
# @FUNCTION: java-utils-2_pkg_preinst |
991 |
@@ -1789,18 +1903,13 @@ java-utils-2_src_prepare() { |
992 |
# Don't call directly, but via java-pkg-2_pkg_preinst! |
993 |
java-utils-2_pkg_preinst() { |
994 |
if is-java-strict; then |
995 |
+ if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then |
996 |
+ return |
997 |
+ fi |
998 |
+ |
999 |
if has_version dev-java/java-dep-check; then |
1000 |
- [[ -e "${JAVA_PKG_ENV}" ]] || return |
1001 |
- local output=$(GENTOO_VM= java-dep-check --image "${ED}" "${JAVA_PKG_ENV}") |
1002 |
- if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then |
1003 |
- ewarn "Possibly unneeded dependencies found in package.env:" |
1004 |
- for dep in ${output}; do |
1005 |
- ewarn "\t${dep}" |
1006 |
- done |
1007 |
- fi |
1008 |
- if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then |
1009 |
- ewarn "${output}" |
1010 |
- fi |
1011 |
+ local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}") |
1012 |
+ [[ ${output} ]] && ewarn "${output}" |
1013 |
else |
1014 |
eerror "Install dev-java/java-dep-check for dependency checking" |
1015 |
fi |
1016 |
@@ -1813,7 +1922,7 @@ java-utils-2_pkg_preinst() { |
1017 |
# Ant wrapper function. Will use the appropriate compiler, based on user-defined |
1018 |
# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, |
1019 |
# variables: |
1020 |
-# |
1021 |
+# |
1022 |
# @CODE |
1023 |
# Variables: |
1024 |
# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the |
1025 |
@@ -1828,7 +1937,6 @@ eant() { |
1026 |
|
1027 |
if [[ ${EBUILD_PHASE} = compile ]]; then |
1028 |
java-ant-2_src_configure |
1029 |
- java-utils-2_src_prepare |
1030 |
fi |
1031 |
|
1032 |
if ! has java-ant-2 ${INHERITED}; then |
1033 |
@@ -1914,8 +2022,10 @@ eant() { |
1034 |
|
1035 |
if [[ ${EBUILD_PHASE} = "test" ]]; then |
1036 |
antflags="${antflags} -DJunit.present=true" |
1037 |
- [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" |
1038 |
getjarsarg="--with-dependencies" |
1039 |
+ |
1040 |
+ local re="\bant-junit4?([-:]\S+)?\b" |
1041 |
+ [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}" |
1042 |
else |
1043 |
antflags="${antflags} -Dmaven.test.skip=true" |
1044 |
fi |
1045 |
@@ -1923,17 +2033,15 @@ eant() { |
1046 |
local cp |
1047 |
|
1048 |
for atom in ${gcp}; do |
1049 |
- cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" |
1050 |
+ cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})" |
1051 |
done |
1052 |
|
1053 |
- [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)" |
1054 |
+ [[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)" |
1055 |
+ [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}" |
1056 |
|
1057 |
- if [[ ${cp} ]]; then |
1058 |
+ if [[ ${cp#:} ]]; then |
1059 |
# It seems ant does not like single quotes around ${cp} |
1060 |
- cp=${cp#:} |
1061 |
- [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \ |
1062 |
- cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}" |
1063 |
- antflags="${antflags} -Dgentoo.classpath=\"${cp}\"" |
1064 |
+ antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" |
1065 |
fi |
1066 |
|
1067 |
[[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" |
1068 |
@@ -1949,26 +2057,50 @@ eant() { |
1069 |
ejavac() { |
1070 |
debug-print-function ${FUNCNAME} $* |
1071 |
|
1072 |
- java-pkg_init-compiler_ |
1073 |
- |
1074 |
local compiler_executable |
1075 |
compiler_executable=$(java-pkg_get-javac) |
1076 |
- if [[ ${?} != 0 ]]; then |
1077 |
- eerror "There was a problem determining compiler: ${compiler_executable}" |
1078 |
- die "get-javac failed" |
1079 |
- fi |
1080 |
|
1081 |
local javac_args |
1082 |
javac_args="$(java-pkg_javac-args)" |
1083 |
- if [[ ${?} != 0 ]]; then |
1084 |
- eerror "There was a problem determining JAVACFLAGS: ${javac_args}" |
1085 |
- die "java-pkg_javac-args failed" |
1086 |
+ |
1087 |
+ if [[ -n ${JAVA_PKG_DEBUG} ]]; then |
1088 |
+ einfo "Verbose logging for \"${FUNCNAME}\" function" |
1089 |
+ einfo "Compiler executable: ${compiler_executable}" |
1090 |
+ einfo "Extra arguments: ${javac_args}" |
1091 |
+ einfo "Complete command:" |
1092 |
+ einfo "${compiler_executable} ${javac_args} ${@}" |
1093 |
fi |
1094 |
|
1095 |
- [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}" |
1096 |
+ ebegin "Compiling" |
1097 |
${compiler_executable} ${javac_args} "${@}" || die "ejavac failed" |
1098 |
} |
1099 |
|
1100 |
+# @FUNCTION: ejavadoc |
1101 |
+# @USAGE: <javadoc_arguments> |
1102 |
+# @DESCRIPTION: |
1103 |
+# javadoc wrapper function. Will set some flags based on the VM version |
1104 |
+# due to strict javadoc rules in 1.8. |
1105 |
+ejavadoc() { |
1106 |
+ debug-print-function ${FUNCNAME} $* |
1107 |
+ |
1108 |
+ local javadoc_args="" |
1109 |
+ |
1110 |
+ if java-pkg_is-vm-version-ge "1.8" ; then |
1111 |
+ javadoc_args="-Xdoclint:none" |
1112 |
+ fi |
1113 |
+ |
1114 |
+ if [[ -n ${JAVA_PKG_DEBUG} ]]; then |
1115 |
+ einfo "Verbose logging for \"${FUNCNAME}\" function" |
1116 |
+ einfo "Javadoc executable: javadoc" |
1117 |
+ einfo "Extra arguments: ${javadoc_args}" |
1118 |
+ einfo "Complete command:" |
1119 |
+ einfo "javadoc ${javadoc_args} ${@}" |
1120 |
+ fi |
1121 |
+ |
1122 |
+ ebegin "Generating JavaDoc" |
1123 |
+ javadoc ${javadoc_args} "${@}" || die "ejavadoc failed" |
1124 |
+} |
1125 |
+ |
1126 |
# @FUNCTION: java-pkg_filter-compiler |
1127 |
# @USAGE: <compiler(s)_to_filter> |
1128 |
# @DESCRIPTION: |
1129 |
@@ -2045,7 +2177,7 @@ java-pkg_init() { |
1130 |
} |
1131 |
|
1132 |
# People do all kinds of weird things. |
1133 |
- # http://forums.gentoo.org/viewtopic-p-3943166.html |
1134 |
+ # https://forums.gentoo.org/viewtopic-p-3943166.html |
1135 |
local silence="${SILENCE_JAVA_OPTIONS_WARNING}" |
1136 |
local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" |
1137 |
if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then |
1138 |
@@ -2065,10 +2197,6 @@ java-pkg_init() { |
1139 |
I_WANT_GLOBAL_JAVA_OPTIONS="true" |
1140 |
fi |
1141 |
|
1142 |
- if java-pkg_func-exists ant_src_unpack; then |
1143 |
- java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack" |
1144 |
- fi |
1145 |
- |
1146 |
java-pkg_switch-vm |
1147 |
# DON'T just prepend /bin to PATH ever in Prefix, it breaks more than can |
1148 |
# imagine |
1149 |
@@ -2148,7 +2276,7 @@ java-pkg_init-compiler_() { |
1150 |
|
1151 |
if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then |
1152 |
if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then |
1153 |
- einfo "Filtering ${compiler}" |
1154 |
+ einfo "Filtering ${compiler}" >&2 |
1155 |
continue |
1156 |
fi |
1157 |
fi |
1158 |
@@ -2168,14 +2296,11 @@ java-pkg_init-compiler_() { |
1159 |
continue |
1160 |
fi |
1161 |
|
1162 |
- # -source was introduced in 1.3, so only check 1.3 and on |
1163 |
- if version_is_at_least "${desired_soure}" "1.3"; then |
1164 |
- # Verify that the compiler supports source |
1165 |
- local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE}) |
1166 |
- if ! has ${desired_source} ${supported_source}; then |
1167 |
- ewarn "${compiler} does not support -source ${desired_source}, skipping" |
1168 |
- continue |
1169 |
- fi |
1170 |
+ # Verify that the compiler supports source |
1171 |
+ local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE}) |
1172 |
+ if ! has ${desired_source} ${supported_source}; then |
1173 |
+ ewarn "${compiler} does not support -source ${desired_source}, skipping" |
1174 |
+ continue |
1175 |
fi |
1176 |
|
1177 |
# if you get here, then the compiler should be good to go |
1178 |
@@ -2191,10 +2316,10 @@ java-pkg_init-compiler_() { |
1179 |
# If it hasn't been defined already, default to javac |
1180 |
if [[ -z ${GENTOO_COMPILER} ]]; then |
1181 |
if [[ -n ${compilers} ]]; then |
1182 |
- einfo "No suitable compiler found: defaulting to JDK default for compilation" |
1183 |
+ einfo "No suitable compiler found: defaulting to JDK default for compilation" >&2 |
1184 |
else |
1185 |
# probably don't need to notify users about the default. |
1186 |
- :;#einfo "Defaulting to javac for compilation" |
1187 |
+ :;#einfo "Defaulting to javac for compilation" >&2 |
1188 |
fi |
1189 |
if java-config -g GENTOO_COMPILER 2> /dev/null; then |
1190 |
export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER) |
1191 |
@@ -2202,7 +2327,7 @@ java-pkg_init-compiler_() { |
1192 |
export GENTOO_COMPILER=javac |
1193 |
fi |
1194 |
else |
1195 |
- einfo "Using ${GENTOO_COMPILER} for compilation" |
1196 |
+ einfo "Using ${GENTOO_COMPILER} for compilation" >&2 |
1197 |
fi |
1198 |
|
1199 |
} |
1200 |
@@ -2222,14 +2347,14 @@ java-pkg_init_paths_() { |
1201 |
JAVA_PKG_NAME="${PN}-${SLOT%/*}" |
1202 |
fi |
1203 |
|
1204 |
- JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" |
1205 |
+ JAVA_PKG_SHAREPATH="/usr/share/${JAVA_PKG_NAME}" |
1206 |
JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" |
1207 |
JAVA_PKG_ENV="${ED}${JAVA_PKG_SHAREPATH}/package.env" |
1208 |
- JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals" |
1209 |
- JAVA_PKG_VIRTUAL_PROVIDER="${ED}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}" |
1210 |
+ JAVA_PKG_VIRTUALS_PATH="/usr/share/java-config-2/virtuals" |
1211 |
+ JAVA_PKG_VIRTUAL_PROVIDER="${ED}${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}" |
1212 |
|
1213 |
[[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" |
1214 |
- [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" |
1215 |
+ [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="/usr/$(get_libdir)/${JAVA_PKG_NAME}" |
1216 |
[[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" |
1217 |
|
1218 |
# TODO maybe only print once? |
1219 |
@@ -2251,62 +2376,54 @@ java-pkg_do_write_() { |
1220 |
java-pkg_init_paths_ |
1221 |
# Create directory for package.env |
1222 |
dodir "${JAVA_PKG_SHAREPATH}" |
1223 |
- if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \ |
1224 |
- "${JAVA_PKG_DEPEND_FILE}" || -f \ |
1225 |
- "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then |
1226 |
- # Create package.env |
1227 |
- ( |
1228 |
- echo "DESCRIPTION=\"${DESCRIPTION}\"" |
1229 |
- echo "GENERATION=\"2\"" |
1230 |
- echo "SLOT=\"${SLOT}\"" |
1231 |
- echo "CATEGORY=\"${CATEGORY}\"" |
1232 |
- echo "PVR=\"${PVR}\"" |
1233 |
- |
1234 |
- [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" |
1235 |
- [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" |
1236 |
- [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" |
1237 |
- [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ |
1238 |
- && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\"" |
1239 |
- [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ |
1240 |
- && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\"" |
1241 |
- echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! |
1242 |
- [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \ |
1243 |
- && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\"" |
1244 |
- ) > "${JAVA_PKG_ENV}" |
1245 |
- |
1246 |
- # register target/source |
1247 |
- local target="$(java-pkg_get-target)" |
1248 |
- local source="$(java-pkg_get-source)" |
1249 |
- [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" |
1250 |
- [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" |
1251 |
- |
1252 |
- # register javadoc info |
1253 |
- [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \ |
1254 |
- >> ${JAVA_PKG_ENV} |
1255 |
- # register source archives |
1256 |
- [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \ |
1257 |
- >> ${JAVA_PKG_ENV} |
1258 |
- |
1259 |
- |
1260 |
- echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" |
1261 |
- [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" |
1262 |
- |
1263 |
- # extra env variables |
1264 |
- if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then |
1265 |
- cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die |
1266 |
- # nested echo to remove leading/trailing spaces |
1267 |
- echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \ |
1268 |
- >> "${JAVA_PKG_ENV}" || die |
1269 |
- fi |
1270 |
|
1271 |
- # Strip unnecessary leading and trailing colons |
1272 |
- # TODO try to cleanup if possible |
1273 |
- sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" |
1274 |
- else |
1275 |
- debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE" |
1276 |
- debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't" |
1277 |
- debug-print "write package.env." |
1278 |
- fi |
1279 |
+ # Create package.env |
1280 |
+ ( |
1281 |
+ echo "DESCRIPTION=\"${DESCRIPTION}\"" |
1282 |
+ echo "GENERATION=\"2\"" |
1283 |
+ echo "SLOT=\"${SLOT}\"" |
1284 |
+ echo "CATEGORY=\"${CATEGORY}\"" |
1285 |
+ echo "PVR=\"${PVR}\"" |
1286 |
+ |
1287 |
+ [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" |
1288 |
+ [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" |
1289 |
+ [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" |
1290 |
+ [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ |
1291 |
+ && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\"" |
1292 |
+ [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ |
1293 |
+ && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\"" |
1294 |
+ echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! |
1295 |
+ [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \ |
1296 |
+ && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\"" |
1297 |
+ ) > "${JAVA_PKG_ENV}" |
1298 |
+ |
1299 |
+ # register target/source |
1300 |
+ local target="$(java-pkg_get-target)" |
1301 |
+ local source="$(java-pkg_get-source)" |
1302 |
+ [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" |
1303 |
+ [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" |
1304 |
+ |
1305 |
+ # register javadoc info |
1306 |
+ [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \ |
1307 |
+ >> ${JAVA_PKG_ENV} |
1308 |
+ # register source archives |
1309 |
+ [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \ |
1310 |
+ >> ${JAVA_PKG_ENV} |
1311 |
+ |
1312 |
+ echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" |
1313 |
+ [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" |
1314 |
+ |
1315 |
+ # extra env variables |
1316 |
+ if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then |
1317 |
+ cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die |
1318 |
+ # nested echo to remove leading/trailing spaces |
1319 |
+ echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \ |
1320 |
+ >> "${JAVA_PKG_ENV}" || die |
1321 |
+ fi |
1322 |
+ |
1323 |
+ # Strip unnecessary leading and trailing colons |
1324 |
+ # TODO try to cleanup if possible |
1325 |
+ sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" |
1326 |
} |
1327 |
|
1328 |
# @FUNCTION: java-pkg_record-jar_ |
1329 |
@@ -2386,9 +2503,9 @@ java-pkg_append_() { |
1330 |
# @CODE |
1331 |
# @RETURN: path to $1's parent directory |
1332 |
java-pkg_expand_dir_() { |
1333 |
- pushd "$(dirname "${1}")" >/dev/null 2>&1 |
1334 |
+ pushd "$(dirname "${1}")" >/dev/null 2>&1 || die |
1335 |
pwd |
1336 |
- popd >/dev/null 2>&1 |
1337 |
+ popd >/dev/null 2>&1 || die |
1338 |
} |
1339 |
|
1340 |
# @FUNCTION: java-pkg_func-exists |
1341 |
@@ -2559,10 +2676,6 @@ java-pkg_switch-vm() { |
1342 |
export JAVA=$(java-config --java) |
1343 |
export JAVAC=$(java-config --javac) |
1344 |
JAVACFLAGS="$(java-pkg_javac-args)" |
1345 |
- if [[ ${?} != 0 ]]; then |
1346 |
- eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}" |
1347 |
- die "java-pkg_javac-args failed" |
1348 |
- fi |
1349 |
[[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" |
1350 |
export JAVACFLAGS |
1351 |
|
1352 |
@@ -2665,7 +2778,8 @@ java-pkg_verify-classes() { |
1353 |
# @INTERNAL |
1354 |
# @DESCRIPTION: |
1355 |
# Check that a package being used in jarfrom, getjars and getjar is contained |
1356 |
-# within DEPEND or RDEPEND. |
1357 |
+# within DEPEND or RDEPEND with the correct SLOT. See this mail for details: |
1358 |
+# https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e |
1359 |
# @CODE |
1360 |
# Parameters: |
1361 |
# $1 - empty - check both vars; "runtime" or "build" - check only |
1362 |
@@ -2679,43 +2793,56 @@ java-pkg_ensure-dep() { |
1363 |
local target_pkg="${2}" |
1364 |
local dev_error="" |
1365 |
|
1366 |
- # remove the version specification, which may include globbing (* and [123]) |
1367 |
- local stripped_pkg=$(echo "${target_pkg}" | sed \ |
1368 |
- 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//') |
1369 |
+ # Transform into a regular expression to look for a matching package |
1370 |
+ # and SLOT. SLOTs don't have to be numeric so foo-bar could either |
1371 |
+ # mean foo-bar:0 or foo:bar. So you want to get your head around the |
1372 |
+ # line below? |
1373 |
+ # |
1374 |
+ # * The target package first has any dots escaped, e.g. foo-1.2 |
1375 |
+ # becomes foo-1\.2. |
1376 |
+ # |
1377 |
+ # * sed then looks at the component following the last - or : |
1378 |
+ # character, or the whole string if there is no - or : |
1379 |
+ # character. It uses this to build a new regexp with two |
1380 |
+ # significant branches. |
1381 |
+ # |
1382 |
+ # * The first checks for the whole target package string, optionally |
1383 |
+ # followed by a version number, and then :0. |
1384 |
+ # |
1385 |
+ # * The second checks for the first part of the target package |
1386 |
+ # string, optionally followed by a version number, followed by the |
1387 |
+ # aforementioned component, treating that as a SLOT. |
1388 |
+ # |
1389 |
+ local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b |
1390 |
|
1391 |
debug-print "Matching against: ${stripped_pkg}" |
1392 |
|
1393 |
- if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then |
1394 |
- dev_error="The ebuild is attempting to use ${target_pkg} that is not" |
1395 |
- dev_error="${dev_error} declared in DEPEND." |
1396 |
- if is-java-strict; then |
1397 |
- eerror "${dev_error}" |
1398 |
- die "${dev_error}" |
1399 |
- elif [[ ${BASH_SUBSHELL} = 0 ]]; then |
1400 |
- eerror "${dev_error}" |
1401 |
- elog "Because you have this package installed the package will" |
1402 |
- elog "build without problems, but please report this to" |
1403 |
- elog "http://bugs.gentoo.org" |
1404 |
- fi |
1405 |
- fi |
1406 |
- |
1407 |
- if [[ ${limit_to} != build ]]; then |
1408 |
- if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then |
1409 |
- if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then |
1410 |
- dev_error="The ebuild is attempting to use ${target_pkg}," |
1411 |
- dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND" |
1412 |
- dev_error="${dev_error} or PDEPEND." |
1413 |
- if is-java-strict; then |
1414 |
- eerror "${dev_error}" |
1415 |
- die "${dev_error}" |
1416 |
- elif [[ ${BASH_SUBSHELL} = 0 ]]; then |
1417 |
- eerror "${dev_error}" |
1418 |
- elog "The package will build without problems, but may fail to run" |
1419 |
- elog "if you don't have ${target_pkg} installed, so please report" |
1420 |
- elog "this to http://bugs.gentoo.org" |
1421 |
- fi |
1422 |
- fi |
1423 |
- fi |
1424 |
+ # Uncomment the lines below once we've dealt with more of these |
1425 |
+ # otherwise we'll be tempted to turn JAVA_PKG_STRICT off while |
1426 |
+ # getting hit with a wave of bug reports. :( |
1427 |
+ |
1428 |
+ if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then |
1429 |
+ dev_error="The ebuild is attempting to use ${target_pkg}, which is not " |
1430 |
+ dev_error+="declared with a SLOT in DEPEND." |
1431 |
+# if is-java-strict; then |
1432 |
+# die "${dev_error}" |
1433 |
+# else |
1434 |
+ eqawarn "java-pkg_ensure-dep: ${dev_error}" |
1435 |
+# eerror "Because you have ${target_pkg} installed," |
1436 |
+# eerror "the package will build without problems, but please" |
1437 |
+# eerror "report this to https://bugs.gentoo.org." |
1438 |
+# fi |
1439 |
+ elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then |
1440 |
+ dev_error="The ebuild is attempting to use ${target_pkg}, which is not " |
1441 |
+ dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given." |
1442 |
+# if is-java-strict; then |
1443 |
+# die "${dev_error}" |
1444 |
+# else |
1445 |
+ eqawarn "java-pkg_ensure-dep: ${dev_error}" |
1446 |
+# eerror "The package will build without problems, but may fail to run" |
1447 |
+# eerror "if you don't have ${target_pkg} installed," |
1448 |
+# eerror "so please report this to https://bugs.gentoo.org." |
1449 |
+# fi |
1450 |
fi |
1451 |
} |
1452 |
|
1453 |
@@ -2762,3 +2889,39 @@ is-java-strict() { |
1454 |
[[ -n ${JAVA_PKG_STRICT} ]] |
1455 |
return $? |
1456 |
} |
1457 |
+ |
1458 |
+# @FUNCTION: java-pkg_clean |
1459 |
+# @DESCRIPTION: |
1460 |
+# Java package cleaner function. This will remove all *.class and *.jar |
1461 |
+# files, removing any bundled dependencies. |
1462 |
+java-pkg_clean() { |
1463 |
+ if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then |
1464 |
+ find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die |
1465 |
+ fi |
1466 |
+} |
1467 |
+ |
1468 |
+# @FUNCTION: java-pkg_gen-cp |
1469 |
+# @INTERNAL |
1470 |
+# @DESCRIPTION: |
1471 |
+# Java package generate classpath will create a classpath based on |
1472 |
+# special variable CP_DEPEND in the ebuild. |
1473 |
+# |
1474 |
+# @CODE |
1475 |
+# Parameters: |
1476 |
+# $1 - classpath variable either EANT_GENTOO_CLASSPATH or JAVA_GENTOO_CLASSPATH |
1477 |
+# @CODE |
1478 |
+java-pkg_gen-cp() { |
1479 |
+ debug-print-function ${FUNCNAME} "${@}" |
1480 |
+ |
1481 |
+ local atom |
1482 |
+ for atom in ${CP_DEPEND}; do |
1483 |
+ if [[ ${atom} =~ /(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)?(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+) ]]; then |
1484 |
+ atom=${BASH_REMATCH[2]:-${BASH_REMATCH[1]}} |
1485 |
+ [[ ${BASH_REMATCH[6]} != 0 ]] && atom+=-${BASH_REMATCH[6]} |
1486 |
+ local regex="(^|\s|,)${atom}($|\s|,)" |
1487 |
+ [[ ${!1} =~ ${regex} ]] || declare -g ${1}+=${!1:+,}${atom} |
1488 |
+ else |
1489 |
+ die "Invalid CP_DEPEND atom ${atom}, ensure a SLOT is included" |
1490 |
+ fi |
1491 |
+ done |
1492 |
+} |