/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.22 Revision 1.104
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2005, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.104 2008/03/03 17:55:21 betelgeuse Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
23# 23#
24# ----------------------------------------------------------------------------- 24# -----------------------------------------------------------------------------
25 25
26inherit eutils versionator multilib 26inherit eutils versionator multilib
27 27
28IUSE="elibc_FreeBSD"
29
28# ----------------------------------------------------------------------------- 30# -----------------------------------------------------------------------------
29# @section-begin variables 31# @section-begin variables
30# @section-title Variables 32# @section-title Variables
31# 33#
32# Summary of variables which control the behavior of building Java packges. 34# Summary of variables which control the behavior of building Java packges.
33# ----------------------------------------------------------------------------- 35# -----------------------------------------------------------------------------
34 36
35# Make sure we use java-config-2 37# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 38export WANT_JAVA_CONFIG="2"
37 39
38# TODO document 40# -----------------------------------------------------------------------------
41# @variable-external WANT_ANT_TASKS
42# @variable-default ""
43#
44# An $IFS separated list of ant tasks.
45# Ebuild can specify this variable before inheriting java-ant-2 eclass to
46# determine ANT_TASKS it needs. They will be automatically translated to
47# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
48# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
49# Ebuilds that need to depend conditionally on certain tasks and specify them
50# differently for different eant calls can't use this simplified approach.
51# You also cannot specify version or anything else than ant-*.
52#
53# @example WANT_ANT_TASKS="ant-junit ant-trax"
54#
55# @seealso JAVA_PKG_FORCE_ANT_TASKS
56# -----------------------------------------------------------------------------
57#WANT_ANT_TASKS
58
59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env
64# saving.
65# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
40 67
41# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
43# 70#
44# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
45# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
46# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
47# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
49 77
50# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
52# @variable-default yes 80# @variable-default yes
53# 81#
127# @note This should only be used internally or for testing. 155# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 156# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 157# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 158# -----------------------------------------------------------------------------
131 159
160# -----------------------------------------------------------------------------
161# @variable-external JAVA_PKG_FORCE_ANT_TASKS
162#
163# An $IFS separated list of ant tasks. Can be set in environment before calling
164# emerge/ebuild to override variables set in ebuild, mainly for testing before
165# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
166# eant() call, not the dependencies specified in WANT_ANT_TASKS.
167#
168# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
169# ebuild foo.ebuild compile
170#
171# @seealso WANT_ANT_TASKS
172# -----------------------------------------------------------------------------
173
132# TODO document me 174# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 175JAVA_PKG_QA_VIOLATIONS=0
134 176
135# ----------------------------------------------------------------------------- 177# -----------------------------------------------------------------------------
136# @section-end variables 178# @section-end variables
143# 185#
144# These are used to install Java-related things, such as jars, Javadocs, JNI 186# These are used to install Java-related things, such as jars, Javadocs, JNI
145# libraries, etc. 187# libraries, etc.
146# ----------------------------------------------------------------------------- 188# -----------------------------------------------------------------------------
147 189
190# -----------------------------------------------------------------------------
191# @ebuild-function java-pkg_doexamples
192#
193# Installs given arguments to /usr/share/doc/${PF}/examples
194# If you give it only one parameter and it is a directory it will install
195# everything in that directory to the examples directory.
196#
197# @example
198# java-pkg_doexamples demo
199# java-pkg_doexamples demo/* examples/*
200#
201# @param --subdir - If the examples need a certain directory structure
202# @param $* - list of files to install
203# ------------------------------------------------------------------------------
204java-pkg_doexamples() {
205 debug-print-function ${FUNCNAME} $*
206
207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
208
209 java-pkg_check-phase install
210
211 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2}
214 dodir ${dest}
215 shift 2
216 fi
217
218 if [[ ${#} = 1 && -d ${1} ]]; then
219 ( # dont want to pollute calling env
220 insinto "${dest}"
221 doins -r ${1}/*
222 ) || die "Installing examples failed"
223 else
224 ( # dont want to pollute calling env
225 insinto "${dest}"
226 doins -r "$@"
227 ) || die "Installing examples failed"
228 fi
229}
148 230
149# ----------------------------------------------------------------------------- 231# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 232# @ebuild-function java-pkg_dojar
151# 233#
152# Installs any number of jars. 234# Installs any number of jars.
171 # Create JARDEST if it doesn't exist 253 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 254 dodir ${JAVA_PKG_JARDEST}
173 255
174 local jar 256 local jar
175 # for each jar 257 # for each jar
176 for jar in "$@"; do 258 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 259 local jar_basename=$(basename "${jar}")
178 260
179 java-pkg_check-versioned-jar ${jar_basename} 261 java-pkg_check-versioned-jar ${jar_basename}
180 262
181 # check if it exists 263 # check if it exists
182 if [[ -e "${jar}" ]] ; then 264 if [[ -e "${jar}" ]] ; then
265 # Don't overwrite if jar has already been installed with the same
266 # name
267 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
268 if [[ -e "${dest}" ]]; then
269 ewarn "Overwriting ${dest}"
270 fi
271
183 # install it into JARDEST if it's a non-symlink 272 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 273 if [[ ! -L "${jar}" ]] ; then
274 #but first check class version when in strict mode.
275 is-java-strict && java-pkg_verify-classes "${jar}"
276
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 277 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 278 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 279 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
188 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 280 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
189 # make a symlink to the original jar if it's symlink 281 # make a symlink to the original jar if it's symlink
199 done 291 done
200 292
201 java-pkg_do_write_ 293 java-pkg_do_write_
202} 294}
203 295
296# ------------------------------------------------------------------------------
297# @internal-function depend-java-query
298#
299# Wrapper for the depend-java-query binary to enable passing USE in env.
300# Using env variables keeps this eclass working with java-config versions that
301# do not handle use flags.
302# ------------------------------------------------------------------------------
204 303
304depend-java-query() {
305 # Used to have a which call here but it caused endless loops for some people
306 # that had some weird bashrc voodoo for which.
307 USE="${USE}" /usr/bin/depend-java-query "${@}"
308}
205 309
206# ------------------------------------------------------------------------------ 310# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 311# @ebuild-function java-pkg_regjar
208# 312#
209# Records an already installed jar in the package.env 313# Records an already installed jar in the package.env
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 344 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 345
242 java-pkg_init_paths_ 346 java-pkg_init_paths_
243 347
244 local jar jar_dir jar_file 348 local jar jar_dir jar_file
245 for jar in "$@"; do 349 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 350 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 351 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
352 [[ -d "${jar}" || -d "${D}${jar}" ]] \
353 && die "Called ${FUNCNAME} on a directory $*"
354
355 #check that class version correct when in strict mode
356 is-java-strict && java-pkg_verify-classes "${jar}"
357
248 # nelchael: we should strip ${D} in this case too, here's why: 358 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 359 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 360 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 361 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 362 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 363 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 364 else
365 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.'
369 fi
257 die "${jar} does not exist" 370 die "${jar} does not exist"
258 fi 371 fi
259 done 372 done
260 373
261 java-pkg_do_write_ 374 java-pkg_do_write_
262} 375}
263
264 376
265# ------------------------------------------------------------------------------ 377# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 378# @ebuild-function java-pkg_newjar
267# 379#
268# Installs a jar with a new name 380# Installs a jar with a new name
279 local original_jar="${1}" 391 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 392 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 393 local new_jar_dest="${T}/${new_jar}"
282 394
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 395 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 396 [[ ! -f ${original_jar} ]] \
397 && die "${original_jar} does not exist or is not a file!"
285 398
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 399 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 400 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 401 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 402 java-pkg_dojar "${new_jar_dest}"
290} 403}
291 404
292
293# ------------------------------------------------------------------------------ 405# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 406# @ebuild-function java-pkg_addcp
295# 407#
296# Add something to the package's classpath. For jars, you should use dojar, 408# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 409# newjar, or regjar. This is typically used to add directories to the classpath.
301# ------------------------------------------------------------------------------ 413# ------------------------------------------------------------------------------
302java-pkg_addcp() { 414java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 415 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 416 java-pkg_do_write_
305} 417}
306
307 418
308# ------------------------------------------------------------------------------ 419# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 420# @ebuild-function java-pkg_doso
310# 421#
311# Installs any number of JNI libraries 422# Installs any number of JNI libraries
340 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
341 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
342 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
343 else 454 else
344 # TODO use dosym 455 # TODO use dosym
456 ln -s "$(readlink "${lib}")" \
345 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
346 debug-print "${lib} is a symlink, linking accordanly" 458 debug-print "${lib} is a symlink, linking accordanly"
347 fi 459 fi
348 # otherwise die 460 # otherwise die
349 else 461 else
350 die "${lib} does not exist" 462 die "${lib} does not exist"
428# ------------------------------------------------------------------------------ 540# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 541java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 542 debug-print-function ${FUNCNAME} $*
431 543
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 544 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 545
546 # from /usr/lib/portage/bin/dohtml -h
547 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 548 dohtml -f package-list "$@"
549
435 # this probably shouldn't be here but it provides 550 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 551 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 552 # old ebuilds.
438 java-pkg_recordjavadoc 553 java-pkg_recordjavadoc
439} 554}
440 555
441# TODO document 556# ------------------------------------------------------------------------------
557# @ebuild-function java-pkg_dojavadoc
558#
559# Installs javadoc documentation. This should be controlled by the doc use flag.
560#
561# @param $1: optional --symlink creates to symlink like this for html
562# documentation bundles.
563# @param $2: - The javadoc root directory.
564#
565# @example:
566# java-pkg_dojavadoc docs/api
567# java-pkg_dojavadoc --symlink apidocs docs/api
568#
569# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 570java-pkg_dojavadoc() {
571 debug-print-function ${FUNCNAME} $*
572
573 # For html documentation bundles that link to Javadoc
574 local symlink
575 if [[ ${1} = --symlink ]]; then
576 symlink=${2}
577 shift 2
578 fi
579
443 local dir="$1" 580 local dir="$1"
581 local dest=/usr/share/doc/${PF}/html
582
583 # QA checks
444 584
445 java-pkg_check-phase install 585 java-pkg_check-phase install
446 586
447 [[ -z "${dir}" ]] && die "Must specify a directory!" 587 [[ -z "${dir}" ]] && die "Must specify a directory!"
448 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 588 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
589 if [[ ! -e "${dir}/index.html" ]]; then
590 local msg="No index.html in javadoc directory"
591 ewarn "${msg}"
592 is-java-strict && die "${msg}"
593 fi
594
595 if [[ -e ${D}/${dest}/api ]]; then
596 eerror "${dest} already exists. Will not overwrite."
597 die "${dest}"
598 fi
599
600 # Renaming to match our directory layout
449 601
450 local dir_to_install="${dir}" 602 local dir_to_install="${dir}"
451 if [[ "$(basename "${dir}")" != "api" ]]; then 603 if [[ "$(basename "${dir}")" != "api" ]]; then
452 dir_to_install="${T}/api" 604 dir_to_install="${T}/api"
453 # TODO use doins 605 # TODO use doins
454 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 606 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
455 fi 607 fi
456 608
609 # Actual installation
610
457 java-pkg_dohtml -r ${dir_to_install} 611 java-pkg_dohtml -r "${dir_to_install}"
612
613 # Let's make a symlink to the directory we have everything else under
614 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
615
616 if [[ ${symlink} ]]; then
617 dosym ${dest}/{api,${symlink}} || die
618 fi
458} 619}
459 620
460# ------------------------------------------------------------------------------ 621# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 622# @ebuild-function java-pkg_dosrc
462# 623#
478# FIXME apparently this fails if you give it an empty directories 639# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 640java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 641 debug-print-function ${FUNCNAME} $*
481 642
482 [ ${#} -lt 1 ] && die "At least one argument needed" 643 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi
486 644
487 java-pkg_check-phase install 645 java-pkg_check-phase install
488 646
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 647 [[ ${#} -lt 1 ]] && die "At least one argument needed"
648
649 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
650 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
651 java-pkg_announce-qa-violation ${msg}
652 fi
490 653
491 java-pkg_init_paths_ 654 java-pkg_init_paths_
492 655
493 local zip_name="${PN}-src.zip" 656 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 657 local zip_path="${T}/${zip_name}"
495 local dir 658 local dir
496 for dir in ${@}; do 659 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 660 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 661 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 662 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 663 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 664 local result=$?
518# @ebuild-function java-pkg_dolauncher 681# @ebuild-function java-pkg_dolauncher
519# 682#
520# Make a wrapper script to lauch/start this package 683# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 684# If necessary, the wrapper will switch to the appropriate VM.
522# 685#
686# Can be called without parameters if the package installs only one jar
687# that has the Main-class attribute set. The wrapper will be named ${PN}.
688#
523# @param $1 - filename of launcher to create 689# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 690# @param $2 - options, as follows:
525# --main the.main.class.too.start 691# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 692# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 693# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 694# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 695# --pwd Directory the launcher changes to before executing java
530# -into 696# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 697# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 698# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 699java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 700 debug-print-function ${FUNCNAME} $*
535 701
536 java-pkg_check-phase install 702 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 703 java-pkg_init_paths_
541 704
705 if [[ ${#} = 0 ]]; then
706 local name="${PN}"
707 else
542 local name="${1}" 708 local name="${1}"
709 shift
710 fi
711
543 # TODO rename to launcher 712 # TODO rename to launcher
544 local target="${T}/${name}" 713 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 714 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 715 local target_dir pre
547 shift
548 716
549 # Process the other the rest of the arguments 717 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 718 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 719 local var="${1}" value="${2}"
552 if [[ "${var:0:2}" == "--" ]]; then 720 if [[ "${var:0:2}" == "--" ]]; then
721 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 722 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
723 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 724 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 725 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 726 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 727 pre="${value}"
558 fi 728 fi
559 shift 2 729 shift 2
560 done 730 done
561 731
732 # Test if no --jar and --main arguments were given and
733 # in that case check if the package only installs one jar
734 # and use that jar.
735 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
736 local cp="${JAVA_PKG_CLASSPATH}"
737 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
738 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
739 else
740 local msg="Not enough information to create a launcher given."
741 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
742 die "${msg}"
743 fi
744 fi
745
562 # Write the actual script 746 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 747 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 748 if [[ -n "${pre}" ]]; then
749 if [[ -f "${pre}" ]]; then
750 cat "${pre}" >> "${target}"
751 else
752 die "-pre specified file '${pre}' does not exist"
753 fi
754 fi
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 755 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
566 cat "${var_tmp}" >> "${target}" 756 cat "${var_tmp}" >> "${target}"
567 rm -f "${var_tmp}" 757 rm -f "${var_tmp}"
568 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 758 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
569 759
661# Example: get a specific jar from xerces slot 2, and name it diffrently 851# Example: get a specific jar from xerces slot 2, and name it diffrently
662# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 852# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
663# Example: get junit.jar which is needed only for building 853# Example: get junit.jar which is needed only for building
664# java-pkg_jar-from --build-only junit junit.jar 854# java-pkg_jar-from --build-only junit junit.jar
665# 855#
666# @param $1 - (optional) "--build-only" makes the jar(s) not added into 856# @param $opt
667# package.env DEPEND line. 857# --build-only - makes the jar(s) not added into package.env DEPEND line.
668# @param $1 - Package to get jars from. 858# (assumed automatically when called inside src_test)
859# --with-dependencies - get jars also from requested package's dependencies
860# transitively.
861# --virtual - Packages passed to this function are to be handled as virtuals
862# and will not have individual jar dependencies recorded.
863# --into $dir - symlink jar(s) into $dir (must exist) instead of .
864# @param $1 - Package to get jars from, or comma-separated list of packages in
865# case other parameters are not used.
669# @param $2 - jar from package. If not specified, all jars will be used. 866# @param $2 - jar from package. If not specified, all jars will be used.
670# @param $3 - When a single jar is specified, destination filename of the 867# @param $3 - When a single jar is specified, destination filename of the
671# symlink. Defaults to the name of the jar. 868# symlink. Defaults to the name of the jar.
672# ------------------------------------------------------------------------------ 869# ------------------------------------------------------------------------------
673# TODO could probably be cleaned up a little 870# TODO could probably be cleaned up a little
674java-pkg_jar-from() { 871java-pkg_jar-from() {
675 debug-print-function ${FUNCNAME} $* 872 debug-print-function ${FUNCNAME} $*
676 873
677 local build_only="" 874 local build_only=""
875 local destdir="."
876 local deep=""
877 local virtual=""
678 878
879 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
880
881 while [[ "${1}" == --* ]]; do
679 if [[ "${1}" = "--build-only" ]]; then 882 if [[ "${1}" = "--build-only" ]]; then
680 build_only="true" 883 build_only="build"
884 elif [[ "${1}" = "--with-dependencies" ]]; then
885 deep="--with-dependencies"
886 elif [[ "${1}" = "--virtual" ]]; then
887 virtual="true"
888 elif [[ "${1}" = "--into" ]]; then
889 destdir="${2}"
890 shift
891 else
892 die "java-pkg_jar-from called with unknown parameter: ${1}"
893 fi
681 shift 894 shift
682 fi 895 done
683 896
684 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 897 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
685 898
686 [[ -z ${target_pkg} ]] && die "Must specify a package" 899 [[ -z ${target_pkg} ]] && die "Must specify a package"
687 900
688 # default destjar to the target jar 901 # default destjar to the target jar
689 [[ -z "${destjar}" ]] && destjar="${target_jar}" 902 [[ -z "${destjar}" ]] && destjar="${target_jar}"
690 903
691 local error_msg="There was a problem getting the classpath for ${target_pkg}." 904 local error_msg="There was a problem getting the classpath for ${target_pkg}."
692 local classpath 905 local classpath
693 classpath="$(java-config --classpath=${target_pkg})" 906 classpath="$(java-config ${deep} --classpath=${target_pkg})"
694 [[ $? != 0 ]] && die ${error_msg} 907 [[ $? != 0 ]] && die ${error_msg}
908
909 # When we have commas this functions is called to bring jars from multiple
910 # packages. This affects recording of dependencencies performed later
911 # which expects one package only, so we do it here.
912 if [[ ${target_pkg} = *,* ]]; then
913 for pkg in ${target_pkg//,/ }; do
914 java-pkg_ensure-dep "${build_only}" "${pkg}"
915 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
916 done
917 # setting this disables further record-jar_ calls later
918 build_only="build"
919 else
920 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
921 fi
922
923 # Record the entire virtual as a dependency so that
924 # no jars are missed.
925 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
926 java-pkg_record-jar_ "${target_pkg}"
927 # setting this disables further record-jars_ calls later
928 build_only="build"
929 fi
930
931 pushd ${destdir} > /dev/null \
932 || die "failed to change directory to ${destdir}"
695 933
696 local jar 934 local jar
697 for jar in ${classpath//:/ }; do 935 for jar in ${classpath//:/ }; do
698 local jar_name=$(basename "${jar}") 936 local jar_name=$(basename "${jar}")
699 if [[ ! -f "${jar}" ]] ; then 937 if [[ ! -f "${jar}" ]] ; then
710 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 948 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
711 [[ -f "${destjar}" ]] && rm "${destjar}" 949 [[ -f "${destjar}" ]] && rm "${destjar}"
712 ln -snf "${jar}" "${destjar}" \ 950 ln -snf "${jar}" "${destjar}" \
713 || die "Failed to make symlink from ${jar} to ${destjar}" 951 || die "Failed to make symlink from ${jar} to ${destjar}"
714 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
953 popd > /dev/null
715 return 0 954 return 0
716 fi 955 fi
717 done 956 done
957 popd > /dev/null
718 # if no target was specified, we're ok 958 # if no target was specified, we're ok
719 if [[ -z "${target_jar}" ]] ; then 959 if [[ -z "${target_jar}" ]] ; then
720 return 0 960 return 0
721 # otherwise, die bitterly 961 # otherwise, die bitterly
722 else 962 else
741# The providing packages are recorded as dependencies into package.env DEPEND 981# The providing packages are recorded as dependencies into package.env DEPEND
742# line, unless "--build-only" is passed as the very first argument, for jars 982# line, unless "--build-only" is passed as the very first argument, for jars
743# that have to be present only at build time and are not needed on runtime 983# that have to be present only at build time and are not needed on runtime
744# (junit testing etc). 984# (junit testing etc).
745# 985#
746# Example: Get the classpath for xerces-2, 986# Example: Get the classpath for xerces-2 and xalan,
747# java-pkg_getjars xerces-2 xalan 987# java-pkg_getjars xerces-2,xalan
748# Example Return: 988# Example Return:
749# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 989# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
750# 990#
751# @param $1 - (optional) "--build-only" makes the jar(s) not added into 991# @param $opt
752# package.env DEPEND line. 992# --build-only - makes the jar(s) not added into package.env DEPEND line.
993# (assumed automatically when called inside src_test)
994# --with-dependencies - get jars also from requested package's dependencies
995# transitively.
753# @param $@ - list of packages to get jars from 996# @param $1 - list of packages to get jars from
997# (passed to java-config --classpath)
754# ------------------------------------------------------------------------------ 998# ------------------------------------------------------------------------------
755java-pkg_getjars() { 999java-pkg_getjars() {
756 debug-print-function ${FUNCNAME} $* 1000 debug-print-function ${FUNCNAME} $*
757 1001
758 local build_only="" 1002 local build_only=""
1003 local deep=""
759 1004
1005 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1006
1007 while [[ "${1}" == --* ]]; do
760 if [[ "${1}" = "--build-only" ]]; then 1008 if [[ "${1}" = "--build-only" ]]; then
761 build_only="true" 1009 build_only="build"
1010 elif [[ "${1}" = "--with-dependencies" ]]; then
1011 deep="--with-dependencies"
1012 else
1013 die "java-pkg_jar-from called with unknown parameter: ${1}"
1014 fi
762 shift 1015 shift
763 fi
764
765 [[ ${#} -lt 1 ]] && die "At least one argument needed"
766
767 # NOTE could probably just pass $@ to java-config --classpath. and return it
768 local classpath pkg
769 for pkg in ${@//,/ }; do
770 #for pkg in $(echo "$@" | tr ',' ' '); do
771 jars="$(java-config --classpath=${pkg})"
772 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
773 debug-print "${pkg}:${jars}"
774
775 if [[ -z "${classpath}" ]]; then
776 classpath="${jars}"
777 else
778 classpath="${classpath}:${jars}"
779 fi
780 # Only record jars that aren't build-only
781 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
782 done 1016 done
1017
1018 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1019
1020
1021 local classpath pkgs="${1}"
1022 jars="$(java-config ${deep} --classpath=${pkgs})"
1023 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
1024 debug-print "${pkgs}:${jars}"
1025
1026 for pkg in ${pkgs//,/ }; do
1027 java-pkg_ensure-dep "${build_only}" "${pkg}"
1028 done
1029
1030 if [[ -z "${classpath}" ]]; then
1031 classpath="${jars}"
1032 else
1033 classpath="${classpath}:${jars}"
1034 fi
1035
1036 # Only record jars that aren't build-only
1037 if [[ -z "${build_only}" ]]; then
1038 for pkg in ${pkgs//,/ }; do
1039 java-pkg_record-jar_ "${pkg}"
1040 done
1041 fi
1042
783 echo "${classpath}" 1043 echo "${classpath}"
784} 1044}
785 1045
786# ------------------------------------------------------------------------------ 1046# ------------------------------------------------------------------------------
787# @ebuild-function java-pkg_getjar 1047# @ebuild-function java-pkg_getjar
795# @example 1055# @example
796# java-pkg_getjar xerces-2 xml-apis.jar 1056# java-pkg_getjar xerces-2 xml-apis.jar
797# @example-return 1057# @example-return
798# /usr/share/xerces-2/lib/xml-apis.jar 1058# /usr/share/xerces-2/lib/xml-apis.jar
799# 1059#
800# @param $1 - (optional) "--build-only" makes the jar not added into 1060# @param $opt
801# package.env DEPEND line. 1061# --build-only - makes the jar not added into package.env DEPEND line.
1062# --virtual - Packages passed to this function are to be handled as virtuals
1063# and will not have individual jar dependencies recorded.
802# @param $1 - package to use 1064# @param $1 - package to use
803# @param $2 - jar to get 1065# @param $2 - jar to get
804# ------------------------------------------------------------------------------ 1066# ------------------------------------------------------------------------------
805java-pkg_getjar() { 1067java-pkg_getjar() {
806 debug-print-function ${FUNCNAME} $* 1068 debug-print-function ${FUNCNAME} $*
807 1069
808 local build_only="" 1070 local build_only=""
1071 local virtual=""
809 1072
1073 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1074
1075 while [[ "${1}" == --* ]]; do
810 if [[ "${1}" = "--build-only" ]]; then 1076 if [[ "${1}" = "--build-only" ]]; then
811 build_only="true" 1077 build_only="build"
1078 elif [[ "${1}" == "--virtual" ]]; then
1079 virtual="true"
1080 else
1081 die "java-pkg_getjar called with unknown parameter: ${1}"
1082 fi
812 shift 1083 shift
813 fi 1084 done
1085
1086 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
814 1087
815 local pkg="${1}" target_jar="${2}" jar 1088 local pkg="${1}" target_jar="${2}" jar
816 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1089 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
817 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1090 [[ -z ${target_jar} ]] && die "Must specify jar to get"
818 1091
819 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1092 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
820 local classpath 1093 local classpath
821 classpath=$(java-config --classpath=${pkg}) 1094 classpath=$(java-config --classpath=${pkg})
822 [[ $? != 0 ]] && die ${error_msg} 1095 [[ $? != 0 ]] && die ${error_msg}
1096
1097 java-pkg_ensure-dep "${build_only}" "${pkg}"
1098
1099 # Record the package(Virtual) as a dependency and then set build_only
1100 # So that individual jars are not recorded.
1101 if [[ -n "${virtual}" ]]; then
1102 java-pkg_record-jar_ "${pkg}"
1103 build_only="true"
1104 fi
823 1105
824 for jar in ${classpath//:/ }; do 1106 for jar in ${classpath//:/ }; do
825 if [[ ! -f "${jar}" ]] ; then 1107 if [[ ! -f "${jar}" ]] ; then
826 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1108 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
827 fi 1109 fi
834 fi 1116 fi
835 done 1117 done
836 1118
837 die "Could not find ${target_jar} in ${pkg}" 1119 die "Could not find ${target_jar} in ${pkg}"
838 return 1 1120 return 1
1121}
1122
1123# ------------------------------------------------------------------------------
1124# @ebuild-function java-pkg_register-dependency
1125#
1126# Registers runtime dependency on a package, list of packages, or a single jar
1127# from a package, into package.env DEPEND line. Can only be called in
1128# src_install phase.
1129# Intended for binary packages where you don't need to symlink the jars or get
1130# their classpath during build. As such, the dependencies only need to be
1131# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1132#
1133# @param $1 - comma-separated list of packages, or a single package
1134# @param $2 - if param $1 is a single package, optionally specify the jar
1135# to depend on
1136#
1137# Example: Record the dependency on whole xerces-2 and xalan,
1138# java-pkg_register-dependency xerces-2,xalan
1139# Example: Record the dependency on ant.jar from ant-core
1140# java-pkg_register-dependency ant-core ant.jar
1141#
1142# Note: Passing both list of packages as the first parameter AND specifying the
1143# jar as the second is not allowed and will cause the function to die. We assume
1144# that there's more chance one passes such combination as a mistake, than that
1145# there are more packages providing identically named jar without class
1146# collisions.
1147# ------------------------------------------------------------------------------
1148java-pkg_register-dependency() {
1149 debug-print-function ${FUNCNAME} $*
1150
1151 java-pkg_check-phase install
1152
1153 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1154
1155 local pkgs="${1}"
1156 local jar="${2}"
1157
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159
1160 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do
1162 java-pkg_ensure-dep runtime "${pkg}"
1163 java-pkg_record-jar_ "${pkg}"
1164 done
1165 else
1166 [[ ${pkgs} == *,* ]] && \
1167 die "${FUNCNAME} called with both package list and jar name"
1168 java-pkg_ensure-dep runtime "${pkgs}"
1169 java-pkg_record-jar_ "${pkgs}" "${jar}"
1170 fi
1171
1172 java-pkg_do_write_
1173}
1174
1175# ------------------------------------------------------------------------------
1176# @ebuild-function java-pkg_register-optional-dependency
1177#
1178# Registers optional runtime dependency on a package, list of packages, or a
1179# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1180# called in src_install phase.
1181# Intended for packages that can use other packages when those are in classpath.
1182# Will be put on classpath by launcher if they are installed. Typical case is
1183# JDBC implementations for various databases. It's better than having USE flag
1184# for each implementation triggering hard dependency.
1185#
1186# @param $1 - comma-separated list of packages, or a single package
1187# @param $2 - if param $1 is a single package, optionally specify the jar
1188# to depend on
1189#
1190# Example: Record the optional dependency on some jdbc providers
1191# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1192#
1193# Note: Passing both list of packages as the first parameter AND specifying the
1194# jar as the second is not allowed and will cause the function to die. We assume
1195# that there's more chance one passes such combination as a mistake, than that
1196# there are more packages providing identically named jar without class
1197# collisions.
1198# ------------------------------------------------------------------------------
1199java-pkg_register-optional-dependency() {
1200 debug-print-function ${FUNCNAME} $*
1201
1202 java-pkg_check-phase install
1203
1204 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1205
1206 local pkgs="${1}"
1207 local jar="${2}"
1208
1209 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1210
1211 if [[ -z "${jar}" ]]; then
1212 for pkg in ${pkgs//,/ }; do
1213 java-pkg_record-jar_ --optional "${pkg}"
1214 done
1215 else
1216 [[ ${pkgs} == *,* ]] && \
1217 die "${FUNCNAME} called with both package list and jar name"
1218 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1219 fi
1220
1221 java-pkg_do_write_
1222}
1223
1224# ------------------------------------------------------------------------------
1225# @ebuild-function java-pkg_register-environment-variable
1226#
1227# Register an arbitrary environment variable into package.env. The gjl launcher
1228# for this package or any package depending on this will export it into
1229# environement before executing java command.
1230# Must only be called in src_install phase.
1231#
1232# @param $1 - variable name
1233# @param $2 - variable value
1234# ------------------------------------------------------------------------------
1235JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1236JAVA_PKG_EXTRA_ENV_VARS=""
1237java-pkg_register-environment-variable() {
1238 debug-print-function ${FUNCNAME} $*
1239
1240 java-pkg_check-phase install
1241
1242 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1243
1244 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1245 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1246
1247 java-pkg_do_write_
839} 1248}
840 1249
841# This function reads stdin, and based on that input, figures out how to 1250# This function reads stdin, and based on that input, figures out how to
842# populate jars from the filesystem. 1251# populate jars from the filesystem.
843# Need to figure out a good way of making use of this, ie be able to use a 1252# Need to figure out a good way of making use of this, ie be able to use a
960# 1369#
961# export DEPEND="${DEPEND} ${depstr}" 1370# export DEPEND="${DEPEND} ${depstr}"
962# export RDEPEND="${RDEPEND} ${depstr}" 1371# export RDEPEND="${RDEPEND} ${depstr}"
963#} 1372#}
964 1373
1374# ------------------------------------------------------------------------------
1375# @ebuild-function java-pkg_find-normal-jars
1376#
1377# Find the files with suffix .jar file in the given directory or $WORKDIR
1378#
1379# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1380# ------------------------------------------------------------------------------
1381java-pkg_find-normal-jars() {
1382 local dir=$1
1383 [[ "${dir}" ]] || dir="${WORKDIR}"
1384 local found
1385 for jar in $(find "${dir}" -name "*.jar" -type f); do
1386 echo "${jar}"
1387 found="true"
1388 done
1389 [[ "${found}" ]]
1390 return $?
1391}
1392
1393# ------------------------------------------------------------------------------
1394# @ebuild-function java-pkg_ensure-no-bundled-jars
1395#
1396# Try to locate bundled jar files in ${WORKDIR} and die if found.
965# This should be used after S has been populated with symlinks to jars 1397# This function should be called after WORKDIR has been populated with symlink
966# TODO document 1398# to system jar files or bundled jars removed.
1399# ------------------------------------------------------------------------------
967java-pkg_ensure-no-bundled-jars() { 1400java-pkg_ensure-no-bundled-jars() {
968 debug-print-function ${FUNCNAME} $* 1401 debug-print-function ${FUNCNAME} $*
969 pushd ${WORKDIR} >/dev/null 2>/dev/null
970 1402
971 local bundled_jars=$(find . -name "*.jar" -type f) 1403 local bundled_jars=$(java-pkg_find-normal-jars)
972 if [[ -n ${bundled_jars} ]]; then 1404 if [[ -n ${bundled_jars} ]]; then
973 echo "Bundled jars found:" 1405 echo "Bundled jars found:"
974 local jar 1406 local jar
975 for jar in ${bundled_jars}; do 1407 for jar in ${bundled_jars}; do
976 echo $(pwd)${jar/./} 1408 echo $(pwd)${jar/./}
977 done 1409 done
978 die "Bundled jars found!" 1410 die "Bundled jars found!"
979
980 fi 1411 fi
981 popd >/dev/null 2>/dev/null
982} 1412}
983 1413
984# ------------------------------------------------------------------------------ 1414# ------------------------------------------------------------------------------
985# @internal-function java-pkg_ensure-vm-version-sufficient 1415# @internal-function java-pkg_ensure-vm-version-sufficient
986# 1416#
1135# @ebuild-function java-pkg_get-target 1565# @ebuild-function java-pkg_get-target
1136# 1566#
1137# Determines what target version should be used, for passing to -target. 1567# Determines what target version should be used, for passing to -target.
1138# If you don't care about lower versions, you can set _WANT_TARGET to the 1568# If you don't care about lower versions, you can set _WANT_TARGET to the
1139# version of your JDK. 1569# version of your JDK.
1140# Remember doing this will mostly like cause things to break.
1141# Doesn't allow it to be lower then the one in depend.
1142# Doesn't allow it to be higher then the active vm.
1143# 1570#
1144# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1571# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1145# ------------------------------------------------------------------------------ 1572# ------------------------------------------------------------------------------
1146java-pkg_get-target() { 1573java-pkg_get-target() {
1147 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1148 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1149 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1150 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1151 echo ${JAVA_PKG_WANT_TARGET}
1152 else
1153 echo ${min}
1154 fi
1155 else
1156 echo ${min}
1157 fi
1158
1159 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1574 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1160} 1575}
1161 1576
1162java-pkg_get-javac() { 1577java-pkg_get-javac() {
1163 debug-print-function ${FUNCNAME} $* 1578 debug-print-function ${FUNCNAME} $*
1164 1579
1165 java-pkg_init-compiler_ 1580
1166 local compiler="${GENTOO_COMPILER}" 1581 local compiler="${GENTOO_COMPILER}"
1167 1582
1168 local compiler_executable 1583 local compiler_executable
1169 if [[ "${compiler}" = "javac" ]]; then 1584 if [[ "${compiler}" = "javac" ]]; then
1170 # nothing fancy needs to be done for javac 1585 # nothing fancy needs to be done for javac
1178 unset JAVAC 1593 unset JAVAC
1179 # try to get value of JAVAC 1594 # try to get value of JAVAC
1180 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1595 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1181 export JAVAC=${old_javac} 1596 export JAVAC=${old_javac}
1182 1597
1183 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1598 if [[ -z ${compiler_executable} ]]; then
1599 echo "JAVAC is empty or undefined in ${compiler_env}"
1600 return 1
1601 fi
1184 1602
1185 # check that it's executable 1603 # check that it's executable
1186 if [[ ! -x ${compiler_executable} ]]; then 1604 if [[ ! -x ${compiler_executable} ]]; then
1187 eerror "Could not find ${compiler_executable}!"
1188 die "${compiler_executable} doesn't exist, or isn't executable" 1605 echo "${compiler_executable} doesn't exist, or isn't executable"
1606 return 1
1189 fi 1607 fi
1190 else 1608 else
1191 eerror "Could not find environment file for ${compiler}" 1609 echo "Could not find environment file for ${compiler}"
1192 die "Could not find ${compiler_env}" 1610 return 1
1193 fi 1611 fi
1194 fi 1612 fi
1195 echo ${compiler_executable} 1613 echo ${compiler_executable}
1196} 1614}
1197 1615
1214 1632
1215 debug-print "want source: ${want_source}" 1633 debug-print "want source: ${want_source}"
1216 debug-print "want target: ${want_target}" 1634 debug-print "want target: ${want_target}"
1217 1635
1218 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1636 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1219 debug-print "could not find valid -source/-target values" 1637 debug-print "could not find valid -source/-target values for javac"
1220 die "Could not find valid -source/-target values" 1638 echo "Could not find valid -source/-target values for javac"
1639 return 1
1221 else 1640 else
1222 if java-pkg_is-vm-version-ge "1.4"; then 1641 if java-pkg_is-vm-version-ge "1.4"; then
1223 echo "${source_str} ${target_str}" 1642 echo "${source_str} ${target_str}"
1224 else 1643 else
1225 echo "${target_str}" 1644 echo "${target_str}"
1229 1648
1230# TODO document 1649# TODO document
1231java-pkg_get-jni-cflags() { 1650java-pkg_get-jni-cflags() {
1232 local flags="-I${JAVA_HOME}/include" 1651 local flags="-I${JAVA_HOME}/include"
1233 1652
1653 local platform="linux"
1654 use elibc_FreeBSD && platform="freebsd"
1655
1234 # TODO do a check that the directories are valid 1656 # TODO do a check that the directories are valid
1235 # TODO figure out how to cope with other things than linux...
1236 flags="${flags} -I${JAVA_HOME}/include/linux" 1657 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1237 1658
1238 echo ${flags} 1659 echo ${flags}
1239} 1660}
1240 1661
1241java-pkg_ensure-gcj() { 1662java-pkg_ensure-gcj() {
1247 die "No GCJ support found!" 1668 die "No GCJ support found!"
1248 fi 1669 fi
1249} 1670}
1250 1671
1251java-pkg_ensure-test() { 1672java-pkg_ensure-test() {
1252 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1673 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1674 && hasq test ${IUSE} && ! use test;
1675 then
1253 eerror "You specified FEATURES=test, but USE=test is needed" 1676 eerror "You specified FEATURES=test, but USE=test is needed"
1254 eerror "to pull in the additional dependencies for testing" 1677 eerror "to pull in the additional dependencies for testing"
1255 die "Need USE=test enabled" 1678 die "Need USE=test enabled"
1256 fi 1679 fi
1257} 1680}
1258 1681
1259# ------------------------------------------------------------------------------ 1682# ------------------------------------------------------------------------------
1683# @ebuild-function java-pkg_register-ant-task
1684#
1685# Register this package as ant task, so that ant will load it when no specific
1686# ANT_TASKS are specified. Note that even without this registering, all packages
1687# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1688# packages, but can be also used by other ebuilds that used to symlink their
1689# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1690# compatibility.
1691#
1692# @param --version x.y Register only for ant version x.y (otherwise for any ant
1693# version). Used by the ant-* packages to prevent loading of mismatched
1694# ant-core ant tasks after core was updated, before the tasks are updated,
1695# without a need for blockers.
1696# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1697# ------------------------------------------------------------------------------
1698java-pkg_register-ant-task() {
1699 local TASKS_DIR="tasks"
1700
1701 # check for --version x.y parameters
1702 while [[ -n "${1}" && -n "${2}" ]]; do
1703 local var="${1#--}"
1704 local val="${2}"
1705 if [[ "${var}" == "version" ]]; then
1706 TASKS_DIR="tasks-${val}"
1707 else
1708 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1709 fi
1710 shift 2
1711 done
1712
1713 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1714
1715 dodir /usr/share/ant/${TASKS_DIR}
1716 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1717}
1718
1719# ------------------------------------------------------------------------------
1720# @internal-function java-pkg_ant-tasks-depend
1721#
1722# Translates the WANT_ANT_TASKS variable into valid dependencies.
1723# ------------------------------------------------------------------------------
1724java-pkg_ant-tasks-depend() {
1725 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1726
1727 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1728 local DEP=""
1729 for i in ${WANT_ANT_TASKS}
1730 do
1731 if [[ ${i} != ant-* ]]; then
1732 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1733 return 1
1734 fi
1735 DEP="${DEP}dev-java/${i} "
1736 done
1737 echo ${DEP}
1738 return 0
1739 else
1740 return 0
1741 fi
1742}
1743
1744# ------------------------------------------------------------------------------
1745# @ebuild-function ejunit
1746#
1747# Junit wrapper function. Makes it easier to run the tests and checks for
1748# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1749#
1750# Examples:
1751# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1752# ejunit org.blinkenlights.jid3.test.AllTests
1753#
1754# @param $1 - -cp or -classpath
1755# @param $2 - classpath; junit and recorded dependencies get appended
1756# @param $@ - the rest of the parameters are passed to java
1757# ------------------------------------------------------------------------------
1758ejunit() {
1759 debug-print-function ${FUNCNAME} $*
1760
1761 local pkgs
1762 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1763 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1764 done
1765
1766 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1767 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1768 cp="${2}:${cp}"
1769 shift 2
1770 else
1771 cp=".:${cp}"
1772 fi
1773
1774 local runner=junit.textui.TestRunner
1775 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1776 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1777}
1778
1779# ------------------------------------------------------------------------------
1260# @section-end helper 1780# @section-end helper
1261# ------------------------------------------------------------------------------ 1781# ------------------------------------------------------------------------------
1262 1782
1263# ------------------------------------------------------------------------------ 1783# ------------------------------------------------------------------------------
1264# @section-begin build 1784# @section-begin build
1270 1790
1271# ------------------------------------------------------------------------------ 1791# ------------------------------------------------------------------------------
1272# @ebuild-function eant 1792# @ebuild-function eant
1273# 1793#
1274# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1794# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1275# compiler. 1795# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1276# 1796# variables:
1797# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1798# gentoo.classpath property. Be sure to call
1799# java-ant_rewrite-classpath in src_unpack.
1800# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1801# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1277# ------------------------------------------------------------------------------ 1802# ------------------------------------------------------------------------------
1278eant() { 1803eant() {
1279 debug-print-function ${FUNCNAME} $* 1804 debug-print-function ${FUNCNAME} $*
1280 1805
1281 # FIXME get this working 1806 if [[ ${EBUILD_PHASE} = compile ]]; then
1282# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1807 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1808 # finally get rid of the hooks without breaking stuff
1809
1810 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1811 && java-ant_ignore-system-classes "${S}/build.xml"
1812
1813 if hasq java-ant-2 ${INHERITED}; then
1814 java-ant_bsfix
1815 fi
1816
1817 # eant can be called multiple times
1818 JAVA_PKG_BSFIX="off"
1819
1820 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1821 echo "Searching for bundled jars:"
1822 java-pkg_find-normal-jars || echo "None found."
1823 echo "Searching for bundled classes (no output if none found):"
1824 find "${WORKDIR}" -name "*.class"
1825 echo "Search done."
1826 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1827 fi
1828 fi
1829
1830 if ! hasq java-ant-2 ${INHERITED}; then
1831 local msg="You should inherit java-ant-2 when using eant"
1283# java-pkg_announce-qa-violation \ 1832 java-pkg_announce-qa-violation "${msg}"
1284# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1285# fi 1833 fi
1286 1834
1287 local antflags 1835 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1836
1288 java-pkg_init-compiler_ 1837 java-pkg_init-compiler_
1289 local compiler="${GENTOO_COMPILER}" 1838 local compiler="${GENTOO_COMPILER}"
1290 1839
1291 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1840 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1292
1293 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1841 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1294 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1842 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1295 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1843 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1296 fi 1844 fi
1297 1845
1298 if [[ ${compiler} != "javac" ]]; then 1846 if [[ ${compiler} != "javac" ]]; then
1299 antflags="-Dbuild.compiler=${build_compiler}" 1847 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1300 # Figure out any extra stuff to put on the classpath for compilers aside 1848 # Figure out any extra stuff to put on the classpath for compilers aside
1301 # from javac 1849 # from javac
1302 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1850 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1303 # java-config -p 1851 # java-config -p
1304 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1852 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1305 if [[ -n ${build_compiler_deps} ]]; then 1853 if [[ -n ${build_compiler_deps} ]]; then
1306 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1854 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1307 fi 1855 fi
1308 fi 1856 fi
1309 1857
1858 for arg in "${@}"; do
1859 if [[ ${arg} = -lib ]]; then
1310 if is-java-strict; then 1860 if is-java-strict; then
1311 einfo "Disabling system classpath for ant" 1861 eerror "You should not use the -lib argument to eant because it will fail"
1312 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1862 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1863 eerror "or ant properties to make dependencies available."
1864 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1865 eerror "split ant (>=dev-java/ant-core-1.7)."
1866 die "eant -lib is deprecated/forbidden"
1867 else
1868 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1869 echo "more info."
1870 fi
1313 fi 1871 fi
1872 done
1314 1873
1315 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1874 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1316 antflags="${antflags} -debug" 1875 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1876
1877 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1878 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1879
1880 # if ant-tasks is not set by ebuild or forced, use none
1881 ANT_TASKS="${ANT_TASKS:-none}"
1882
1883 # at this point, ANT_TASKS should be "all", "none" or explicit list
1884 if [[ "${ANT_TASKS}" == "all" ]]; then
1885 einfo "Using all available ANT_TASKS"
1886 elif [[ "${ANT_TASKS}" == "none" ]]; then
1887 einfo "Disabling all optional ANT_TASKS"
1888 else
1889 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1890 fi
1891
1892 export ANT_TASKS
1893
1894 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1895 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1896
1897 local gcp="${EANT_GENTOO_CLASSPATH}"
1898 local getjarsarg=""
1899
1900 if [[ ${EBUILD_PHASE} = "test" ]]; then
1901 antflags="${antflags} -DJunit.present=true"
1902 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1903 getjarsarg="--with-dependencies"
1904 fi
1905
1906 local cp
1907
1908 for atom in ${gcp}; do
1909 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1910 done
1911
1912 if [[ ${cp} ]]; then
1913 # It seems ant does not like single quotes around ${cp}
1914 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1317 fi 1915 fi
1318 1916
1319 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1917 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1918 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1320 ant ${antflags} "${@}" || die "eant failed" 1919 ant ${antflags} "${@}" || die "eant failed"
1321
1322} 1920}
1323 1921
1324# ------------------------------------------------------------------------------ 1922# ------------------------------------------------------------------------------
1325# @ebuild-function ejavac 1923# @ebuild-function ejavac
1326# 1924#
1330# @param $@ - Arguments to be passed to the compiler 1928# @param $@ - Arguments to be passed to the compiler
1331# ------------------------------------------------------------------------------ 1929# ------------------------------------------------------------------------------
1332ejavac() { 1930ejavac() {
1333 debug-print-function ${FUNCNAME} $* 1931 debug-print-function ${FUNCNAME} $*
1334 1932
1335 # FIXME using get-javac ends up printing stuff with einfo 1933 java-pkg_init-compiler_
1934
1935 local compiler_executable
1336# local compiler_executable=$(java-pkg_get-javac) 1936 compiler_executable=$(java-pkg_get-javac)
1337 local compiler_executable="javac" 1937 if [[ ${?} != 0 ]]; then
1938 eerror "There was a problem determining compiler: ${compiler_executable}"
1939 die "get-javac failed"
1940 fi
1338 1941
1942 local javac_args
1943 javac_args="$(java-pkg_javac-args)"
1944 if [[ ${?} != 0 ]]; then
1945 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1946 die "java-pkg_javac-args failed"
1947 fi
1948
1339 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1949 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1340 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1950 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1341} 1951}
1342 1952
1343# ------------------------------------------------------------------------------ 1953# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_filter-compiler 1954# @ebuild-function java-pkg_filter-compiler
1345# 1955#
1383# ------------------------------------------------------------------------------ 1993# ------------------------------------------------------------------------------
1384use_doc() { 1994use_doc() {
1385 use doc && echo ${@:-javadoc} 1995 use doc && echo ${@:-javadoc}
1386} 1996}
1387 1997
1998
1388# ------------------------------------------------------------------------------ 1999# ------------------------------------------------------------------------------
1389# @section-end build 2000# @section-end build
1390# ------------------------------------------------------------------------------ 2001# ------------------------------------------------------------------------------
1391 2002
1392# ------------------------------------------------------------------------------ 2003# ------------------------------------------------------------------------------
1408# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2019# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1409# call it during each of the phases of the merge process. 2020# call it during each of the phases of the merge process.
1410# 2021#
1411# ----------------------------------------------------------------------------- 2022# -----------------------------------------------------------------------------
1412java-pkg_init() { 2023java-pkg_init() {
2024 debug-print-function ${FUNCNAME} $*
1413 unset JAVAC 2025 unset JAVAC
1414 unset JAVA_HOME 2026 unset JAVA_HOME
2027
2028 # People do all kinds of weird things.
2029 # http://forums.gentoo.org/viewtopic-p-3943166.html
2030 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2031 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2032 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2033 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2034 ewarn "sun-jdk vms and and as such break configure scripts that"
2035 ewarn "use it (for example app-office/openoffice) so we filter it out."
2036 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2037 ewarn "make.conf for example) to silence this warning or"
2038 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2039 fi
2040
2041 if [[ -z ${accept} ]]; then
2042 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2043 # -version output
2044 unset _JAVA_OPTIONS
2045 # phase hooks make this run many times without this
2046 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2047 fi
2048
2049 if java-pkg_func-exists ant_src_unpack; then
2050 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2051 fi
2052
1415 java-pkg_init_paths_ 2053 java-pkg_init_paths_
1416 java-pkg_switch-vm 2054 java-pkg_switch-vm
1417 PATH=${JAVA_HOME}/bin:${PATH} 2055 PATH=${JAVA_HOME}/bin:${PATH}
1418 2056
1419 # TODO we will probably want to set JAVAC and JAVACFLAGS 2057 # TODO we will probably want to set JAVAC and JAVACFLAGS
1420 2058
1421 # Do some QA checks 2059 # Do some QA checks
1422 java-pkg_check-jikes 2060 java-pkg_check-jikes
2061
2062 # Can't use unset here because Portage does not save the unset
2063 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
1423 2064
1424 # When users have crazy classpaths some packages can fail to compile. 2065 # When users have crazy classpaths some packages can fail to compile.
1425 # and everything should work with empty CLASSPATH. 2066 # and everything should work with empty CLASSPATH.
1426 # This also helps prevent unexpected dependencies on random things 2067 # This also helps prevent unexpected dependencies on random things
1427 # from the CLASSPATH. 2068 # from the CLASSPATH.
1428 unset CLASSPATH 2069 export CLASSPATH=
2070
2071 # Unset external ANT_ stuff
2072 export ANT_TASKS=
2073 export ANT_OPTS=
1429} 2074}
1430 2075
1431# ------------------------------------------------------------------------------ 2076# ------------------------------------------------------------------------------
1432# @function-internal java-pkg-init-compiler_ 2077# @function-internal java-pkg-init-compiler_
1433# 2078#
1524 done 2169 done
1525 2170
1526 # If it hasn't been defined already, default to javac 2171 # If it hasn't been defined already, default to javac
1527 if [[ -z ${GENTOO_COMPILER} ]]; then 2172 if [[ -z ${GENTOO_COMPILER} ]]; then
1528 if [[ -n ${compilers} ]]; then 2173 if [[ -n ${compilers} ]]; then
1529 einfo "No suitable compiler found: defaulting javac for compilation" 2174 einfo "No suitable compiler found: defaulting to JDK default for compilation"
1530 else 2175 else
1531 # probably don't need to notify users about the default. 2176 # probably don't need to notify users about the default.
1532 :;#einfo "Defaulting to javac for compilation" 2177 :;#einfo "Defaulting to javac for compilation"
1533 fi 2178 fi
2179 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2180 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2181 else
1534 export GENTOO_COMPILER=javac 2182 export GENTOO_COMPILER=javac
2183 fi
1535 else 2184 else
1536 einfo "Using ${GENTOO_COMPILER} for compilation" 2185 einfo "Using ${GENTOO_COMPILER} for compilation"
1537 fi 2186 fi
1538 2187
1539} 2188}
1555 fi 2204 fi
1556 2205
1557 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2206 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1558 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2207 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1559 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2208 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2209 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2210 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
1560 2211
1561 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2212 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
1562 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2213 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
1563 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2214 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
1564 2215
1577# Writes the package.env out to disk. 2228# Writes the package.env out to disk.
1578# 2229#
1579# ------------------------------------------------------------------------------ 2230# ------------------------------------------------------------------------------
1580# TODO change to do-write, to match everything else 2231# TODO change to do-write, to match everything else
1581java-pkg_do_write_() { 2232java-pkg_do_write_() {
2233 debug-print-function ${FUNCNAME} $*
2234 java-pkg_init_paths_
1582 # Create directory for package.env 2235 # Create directory for package.env
1583 dodir "${JAVA_PKG_SHAREPATH}" 2236 dodir "${JAVA_PKG_SHAREPATH}"
1584 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2237 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2238 "${JAVA_PKG_DEPEND_FILE}" || -f \
2239 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1585 # Create package.env 2240 # Create package.env
1586 ( 2241 (
1587 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2242 echo "DESCRIPTION=\"${DESCRIPTION}\""
1588 echo "GENERATION=\"2\"" 2243 echo "GENERATION=\"2\""
2244 echo "SLOT=\"${SLOT}\""
1589 2245
1590 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2246 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1591 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2247 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1592 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2248 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1593 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2249 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2250 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2251 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2252 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
1594 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2253 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1595 ) > "${JAVA_PKG_ENV}" 2254 ) > "${JAVA_PKG_ENV}"
1596 2255
1597 # register target/source 2256 # register target/source
1598 local target="$(java-pkg_get-target)" 2257 local target="$(java-pkg_get-target)"
1609 2268
1610 2269
1611 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2270 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1612 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2271 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1613 2272
2273 # extra env variables
2274 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2275 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2276 # nested echo to remove leading/trailing spaces
2277 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2278 >> "${JAVA_PKG_ENV}" || die
2279 fi
2280
1614 # Strip unnecessary leading and trailing colons 2281 # Strip unnecessary leading and trailing colons
1615 # TODO try to cleanup if possible 2282 # TODO try to cleanup if possible
1616 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2283 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2284 else
2285 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2286 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2287 debug-print "write package.env."
1617 fi 2288 fi
1618} 2289}
1619
1620 2290
1621# ------------------------------------------------------------------------------ 2291# ------------------------------------------------------------------------------
1622# @internal-function java-pkg_record-jar_ 2292# @internal-function java-pkg_record-jar_
1623# 2293#
1624# Record a dependency to the package.env 2294# Record an (optional) dependency to the package.env
1625# 2295# @param --optional - record dependency as optional
2296# @param $1 - package to record
2297# @param $2 - (optional) jar of package to record
1626# ------------------------------------------------------------------------------ 2298# ------------------------------------------------------------------------------
1627JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2299JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2300JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
1628 2301
1629java-pkg_record-jar_() { 2302java-pkg_record-jar_() {
1630 debug-print-function ${FUNCNAME} $* 2303 debug-print-function ${FUNCNAME} $*
2304
2305 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2306 if [[ "${1}" == "--optional" ]]; then
2307 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2308 shift
2309 fi
1631 2310
1632 local pkg=${1} jar=${2} append 2311 local pkg=${1} jar=${2} append
1633 if [[ -z "${jar}" ]]; then 2312 if [[ -z "${jar}" ]]; then
1634 append="${pkg}" 2313 append="${pkg}"
1635 else 2314 else
1636 append="$(basename ${jar})@${pkg}" 2315 append="$(basename ${jar})@${pkg}"
1637 fi 2316 fi
1638 2317
1639 echo ${append} >> ${JAVA_PKG_DEPEND} 2318 echo "${append}" >> "${depend_file}"
1640} 2319}
1641 2320
1642# ------------------------------------------------------------------------------ 2321# ------------------------------------------------------------------------------
1643# @internal-function java-pkg_append_ 2322# @internal-function java-pkg_append_
1644# 2323#
1704# 2383#
1705# ------------------------------------------------------------------------------ 2384# ------------------------------------------------------------------------------
1706java-pkg_setup-vm() { 2385java-pkg_setup-vm() {
1707 debug-print-function ${FUNCNAME} $* 2386 debug-print-function ${FUNCNAME} $*
1708 2387
2388 export LANG="C" LC_ALL="C"
2389
1709 local vendor="$(java-pkg_get-vm-vendor)" 2390 local vendor="$(java-pkg_get-vm-vendor)"
1710 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2391 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1711 addpredict "/dev/random" 2392 addpredict "/dev/random"
1712 elif [[ "${vendor}" == "ibm" ]]; then 2393 elif [[ "${vendor}" == "ibm" ]]; then
1713 addpredict "/proc/self/maps" 2394 addpredict "/proc/self/maps"
1714 addpredict "/proc/cpuinfo" 2395 addpredict "/proc/cpuinfo"
1715 export LANG="C" LC_ALL="C"
1716 elif [[ "${vendor}" == "jrockit" ]]; then 2396 elif [[ "${vendor}" == "jrockit" ]]; then
1717 addpredict "/proc/cpuinfo" 2397 addpredict "/proc/cpuinfo"
1718 fi 2398 fi
1719} 2399}
1720 2400
1775# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2455# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1776# verify that the current VM is sufficient. 2456# verify that the current VM is sufficient.
1777# Setup the environment for the VM being used. 2457# Setup the environment for the VM being used.
1778# ------------------------------------------------------------------------------ 2458# ------------------------------------------------------------------------------
1779java-pkg_switch-vm() { 2459java-pkg_switch-vm() {
2460 debug-print-function ${FUNCNAME} $*
2461
1780 if java-pkg_needs-vm; then 2462 if java-pkg_needs-vm; then
1781 # Use the VM specified by JAVA_PKG_FORCE_VM 2463 # Use the VM specified by JAVA_PKG_FORCE_VM
1782 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2464 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1783 # If you're forcing the VM, I hope you know what your doing... 2465 # If you're forcing the VM, I hope you know what your doing...
2466 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1784 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2467 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1785 # if we're allowed to switch the vm... 2468 # if we're allowed to switch the vm...
1786 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2469 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1787 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2470 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1788 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2471 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1789 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2472 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1790 else 2473 else
1791 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2474 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2475 fi
2476 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2477 eerror "Unable to determine VM for building from dependencies:"
2478 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2479 echo "VNEED: ${JAVA_PKG_VNEED}"
2480 die "Failed to determine VM for building."
2481 else
2482 export GENTOO_VM
1792 fi 2483 fi
1793 # otherwise just make sure the current VM is sufficient 2484 # otherwise just make sure the current VM is sufficient
1794 else 2485 else
1795 java-pkg_ensure-vm-version-sufficient 2486 java-pkg_ensure-vm-version-sufficient
1796 fi 2487 fi
1798 2489
1799 java-pkg_setup-vm 2490 java-pkg_setup-vm
1800 2491
1801 export JAVA=$(java-config --java) 2492 export JAVA=$(java-config --java)
1802 export JAVAC=$(java-config --javac) 2493 export JAVAC=$(java-config --javac)
1803 export JAVACFLAGS="$(java-pkg_javac-args)" 2494 JAVACFLAGS="$(java-pkg_javac-args)"
2495 if [[ ${?} != 0 ]]; then
2496 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2497 die "java-pkg_javac-args failed"
2498 fi
1804 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2499 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2500 export JAVACFLAGS
1805 2501
1806 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2502 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1807 export JDK_HOME=${JAVA_HOME} 2503 export JDK_HOME=${JAVA_HOME}
1808 2504
1809 #TODO If you know a better solution let us know. 2505 #TODO If you know a better solution let us know.
1810 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2506 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1811 2507
1812 local tann="${T}/announced-vm" 2508 local tann="${T}/announced-vm"
2509 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2510 # if people have for example modified eclasses some where
1813 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2511 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1814 # Add a check for setup/preinst phase... to avoid duplicate outputs
1815 # for when FEATURES=buildpkg
1816 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1817 then
1818 einfo "Using: $(java-config -f)" 2512 einfo "Using: $(java-config -f)"
1819 [[ ! -f "${tann}" ]] && touch "${tann}" 2513 [[ ! -f "${tann}" ]] && touch "${tann}"
1820 fi
1821 fi 2514 fi
1822 2515
1823 else 2516 else
1824 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2517 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
1825 fi 2518 fi
1855 einfo "Classes" 2548 einfo "Classes"
1856 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2549 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1857 fi 2550 fi
1858} 2551}
1859 2552
1860# TODO document 2553# ------------------------------------------------------------------------------
2554# @internal-function java-pkg_verify-classes
2555#
1861# Verify that the classes were compiled for the right source / target 2556# Verify that the classes were compiled for the right source / target. Dies if
2557# not.
2558# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2559# ------------------------------------------------------------------------------
1862java-pkg_verify-classes() { 2560java-pkg_verify-classes() {
1863 ebegin "Verifying java class versions"
1864 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2561 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1865 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2562 local target=$(java-pkg_get-target)
2563 local result
2564 local log="${T}/class-version-verify.log"
2565 if [[ -n "${1}" ]]; then
2566 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1866 result=$? 2567 result=$?
1867 eend ${result}
1868 if [[ ${result} == 0 ]]; then
1869 einfo "All good"
1870 else 2568 else
1871 ewarn "Possible problem" 2569 ebegin "Verifying java class versions (target: ${target})"
1872 die "Bad class files found" 2570 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2571 result=$?
2572 eend ${result}
2573 fi
2574 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2575 if [[ ${result} != 0 ]]; then
2576 eerror "Incorrect bytecode version found"
2577 [[ -n "${1}" ]] && eerror "in file: ${1}"
2578 eerror "See ${log} for more details."
2579 die "Incorrect bytecode found"
2580 fi
2581}
2582
2583# ----------------------------------------------------------------------------
2584# @internal-function java-pkg_ensure-dep
2585# Check that a package being used in jarfrom, getjars and getjar is contained
2586# within DEPEND or RDEPEND.
2587# @param $1 - empty - check both vars; "runtime" or "build" - check only
2588# RDEPEND, resp. DEPEND
2589# @param $2 - Package name and slot.
2590
2591java-pkg_ensure-dep() {
2592 debug-print-function ${FUNCNAME} $*
2593
2594 local limit_to="${1}"
2595 local target_pkg="${2}"
2596 local dev_error=""
2597
2598 local stripped_pkg=$(echo "${target_pkg}" | sed \
2599 's/-[0-9]*\(\.[0-9]\)*$//')
2600
2601 debug-print "Matching against: ${stripped_pkg}"
2602
2603 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2604 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2605 dev_error="${dev_error} declared in DEPEND."
2606 if is-java-strict; then
2607 eerror "${dev_error}"
2608 die "${dev_error}"
2609 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2610 eerror "${dev_error}"
2611 elog "Because you have this package installed the package will"
2612 elog "build without problems, but please report this to"
2613 elog "http://bugs.gentoo.org"
1873 fi 2614 fi
1874} 2615 fi
1875 2616
2617 if [[ ${limit_to} != build ]]; then
2618 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2619 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2620 dev_error="The ebuild is attempting to use ${target_pkg},"
2621 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2622 dev_error="${dev_error} or PDEPEND."
2623 if is-java-strict; then
2624 eerror "${dev_error}"
2625 die "${dev_error}"
2626 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2627 eerror "${dev_error}"
2628 elog "The package will build without problems, but may fail to run"
2629 elog "if you don't have ${target_pkg} installed, so please report"
2630 elog "this to http://bugs.gentoo.org"
2631 fi
2632 fi
2633 fi
2634 fi
2635}
1876 2636
1877# ------------------------------------------------------------------------------ 2637# ------------------------------------------------------------------------------
1878# @section-end internal 2638# @section-end internal
1879# ------------------------------------------------------------------------------ 2639# ------------------------------------------------------------------------------
1880 2640
1881java-pkg_check-phase() { 2641java-pkg_check-phase() {
1882 local phase=${1} 2642 local phase=${1}
1883 local funcname=${2} 2643 local funcname=${FUNCNAME[1]}
1884 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2644 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
1885 java-pkg_announce-qa-violation \
1886 "${funcname} used outside of src_${phase}" 2645 local msg="${funcname} used outside of src_${phase}"
2646 java-pkg_announce-qa-violation "${msg}"
1887 fi 2647 fi
1888} 2648}
1889 2649
1890java-pkg_check-versioned-jar() { 2650java-pkg_check-versioned-jar() {
1891 local jar=${1} 2651 local jar=${1}
1900 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2660 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1901 fi 2661 fi
1902} 2662}
1903 2663
1904java-pkg_announce-qa-violation() { 2664java-pkg_announce-qa-violation() {
1905 if is-java-strict; then 2665 local nodie
2666 if [[ ${1} == "--nodie" ]]; then
2667 nodie="true"
2668 shift
2669 fi
1906 echo "Java QA Notice: $@" >&2 2670 echo "Java QA Notice: $@" >&2
1907 increment-qa-violations 2671 increment-qa-violations
1908 fi 2672 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
1909} 2673}
1910 2674
1911increment-qa-violations() { 2675increment-qa-violations() {
1912 let "JAVA_PKG_QA_VIOLATIONS+=1" 2676 let "JAVA_PKG_QA_VIOLATIONS+=1"
1913 export JAVA_PKG_QA_VIOLATIONS 2677 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.104

  ViewVC Help
Powered by ViewVC 1.1.20