/[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.93 Revision 1.143
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# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.93 2007/09/27 19:47:08 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.143 2011/09/10 14:32:58 serkan 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
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 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 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# 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
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
76 94
77# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 97# @variable-default yes
80# 98#
223 ( # dont want to pollute calling env 241 ( # dont want to pollute calling env
224 insinto "${dest}" 242 insinto "${dest}"
225 doins -r "$@" 243 doins -r "$@"
226 ) || die "Installing examples failed" 244 ) || die "Installing examples failed"
227 fi 245 fi
246
247 # Let's make a symlink to the directory we have everything else under
248 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
228} 249}
229 250
230# ----------------------------------------------------------------------------- 251# -----------------------------------------------------------------------------
231# @ebuild-function java-pkg_dojar 252# @ebuild-function java-pkg_dojar
232# 253#
290 done 311 done
291 312
292 java-pkg_do_write_ 313 java-pkg_do_write_
293} 314}
294 315
295
296# ------------------------------------------------------------------------------ 316# ------------------------------------------------------------------------------
297# @internal-function depend-java-query 317# @internal-function depend-java-query
298# 318#
299# Wrapper for the depend-java-query binary to enable passing USE in env. 319# 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 320# Using env variables keeps this eclass working with java-config versions that
365 if [[ ${jar} = *\** ]]; then 385 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 386 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 387 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 388 eerror '${D} add ${D} to the argument.'
369 fi 389 fi
390 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 391 die "${jar} does not exist"
371 fi 392 fi
372 done 393 done
373 394
374 java-pkg_do_write_ 395 java-pkg_do_write_
429# @param $@ - JNI libraries to install 450# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 451# ------------------------------------------------------------------------------
431java-pkg_doso() { 452java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 453 debug-print-function ${FUNCNAME} $*
433 454
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 455 java-pkg_check-phase install
436 456
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 457 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 458
439 java-pkg_init_paths_ 459 java-pkg_init_paths_
440 460
441 local lib 461 local lib
442 # for each lib 462 # for each lib
445 if [[ -e "${lib}" ]] ; then 465 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 466 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 467 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 468 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 469 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 470 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 471 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 472 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 473 # otherwise make a symlink to the symlink's origin
454 else 474 else
455 # TODO use dosym 475 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 476 debug-print "${lib} is a symlink, linking accordantly"
459 fi 477 fi
460 # otherwise die 478 # otherwise die
461 else 479 else
462 die "${lib} does not exist" 480 die "${lib} does not exist"
463 fi 481 fi
479java-pkg_regso() { 497java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 498 debug-print-function ${FUNCNAME} $*
481 499
482 java-pkg_check-phase install 500 java-pkg_check-phase install
483 501
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 502 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 503
486 java-pkg_init_paths_ 504 java-pkg_init_paths_
487 505
488 local lib target_dir 506 local lib target_dir
489 for lib in "$@" ; do 507 for lib in "$@" ; do
556# ------------------------------------------------------------------------------ 574# ------------------------------------------------------------------------------
557# @ebuild-function java-pkg_dojavadoc 575# @ebuild-function java-pkg_dojavadoc
558# 576#
559# Installs javadoc documentation. This should be controlled by the doc use flag. 577# Installs javadoc documentation. This should be controlled by the doc use flag.
560# 578#
579# @param $1: optional --symlink creates to symlink like this for html
580# documentation bundles.
561# @param $1: - The javadoc root directory. 581# @param $2: - The javadoc root directory.
562# 582#
563# @example: 583# @example:
564# java-pkg_dojavadoc docs/api 584# java-pkg_dojavadoc docs/api
585# java-pkg_dojavadoc --symlink apidocs docs/api
565# 586#
566# ------------------------------------------------------------------------------ 587# ------------------------------------------------------------------------------
567java-pkg_dojavadoc() { 588java-pkg_dojavadoc() {
568 debug-print-function ${FUNCNAME} $* 589 debug-print-function ${FUNCNAME} $*
590
591 # For html documentation bundles that link to Javadoc
592 local symlink
593 if [[ ${1} = --symlink ]]; then
594 symlink=${2}
595 shift 2
596 fi
597
569 local dir="$1" 598 local dir="$1"
599 local dest=/usr/share/doc/${PF}/html
570 600
571 # QA checks 601 # QA checks
572 602
573 java-pkg_check-phase install 603 java-pkg_check-phase install
574 604
578 local msg="No index.html in javadoc directory" 608 local msg="No index.html in javadoc directory"
579 ewarn "${msg}" 609 ewarn "${msg}"
580 is-java-strict && die "${msg}" 610 is-java-strict && die "${msg}"
581 fi 611 fi
582 612
613 if [[ -e ${D}/${dest}/api ]]; then
614 eerror "${dest} already exists. Will not overwrite."
615 die "${dest}"
616 fi
617
583 # Renaming to match our directory layout 618 # Renaming to match our directory layout
584 619
585 local dir_to_install="${dir}" 620 local dir_to_install="${dir}"
586 if [[ "$(basename "${dir}")" != "api" ]]; then 621 if [[ "$(basename "${dir}")" != "api" ]]; then
587 dir_to_install="${T}/api" 622 dir_to_install="${T}/api"
589 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 624 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
590 fi 625 fi
591 626
592 # Actual installation 627 # Actual installation
593 628
594 java-pkg_dohtml -r ${dir_to_install} 629 java-pkg_dohtml -r "${dir_to_install}"
630
631 # Let's make a symlink to the directory we have everything else under
632 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
633
634 if [[ ${symlink} ]]; then
635 debug-print "symlinking ${dest}/{api,${symlink}}"
636 dosym ${dest}/{api,${symlink}} || die
637 fi
595} 638}
596 639
597# ------------------------------------------------------------------------------ 640# ------------------------------------------------------------------------------
598# @ebuild-function java-pkg_dosrc 641# @ebuild-function java-pkg_dosrc
599# 642#
622 665
623 [[ ${#} -lt 1 ]] && die "At least one argument needed" 666 [[ ${#} -lt 1 ]] && die "At least one argument needed"
624 667
625 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 668 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
626 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 669 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
627 if is-java-strict; then 670 java-pkg_announce-qa-violation ${msg}
628 eerror "${msg}"
629 die "${msg}"
630 else
631 echo "${msg}"
632 echo "Please report this to http://bugs.gentoo.org."
633 fi
634 fi 671 fi
635 672
636 java-pkg_init_paths_ 673 java-pkg_init_paths_
637 674
638 local zip_name="${PN}-src.zip" 675 local zip_name="${PN}-src.zip"
838# @param $opt 875# @param $opt
839# --build-only - makes the jar(s) not added into package.env DEPEND line. 876# --build-only - makes the jar(s) not added into package.env DEPEND line.
840# (assumed automatically when called inside src_test) 877# (assumed automatically when called inside src_test)
841# --with-dependencies - get jars also from requested package's dependencies 878# --with-dependencies - get jars also from requested package's dependencies
842# transitively. 879# transitively.
880# --virtual - Packages passed to this function are to be handled as virtuals
881# and will not have individual jar dependencies recorded.
843# --into $dir - symlink jar(s) into $dir (must exist) instead of . 882# --into $dir - symlink jar(s) into $dir (must exist) instead of .
844# @param $1 - Package to get jars from, or comma-separated list of packages in 883# @param $1 - Package to get jars from, or comma-separated list of packages in
845# case other parameters are not used. 884# case other parameters are not used.
846# @param $2 - jar from package. If not specified, all jars will be used. 885# @param $2 - jar from package. If not specified, all jars will be used.
847# @param $3 - When a single jar is specified, destination filename of the 886# @param $3 - When a single jar is specified, destination filename of the
852 debug-print-function ${FUNCNAME} $* 891 debug-print-function ${FUNCNAME} $*
853 892
854 local build_only="" 893 local build_only=""
855 local destdir="." 894 local destdir="."
856 local deep="" 895 local deep=""
896 local virtual=""
897 local record_jar=""
857 898
858 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 899 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
859 900
860 while [[ "${1}" == --* ]]; do 901 while [[ "${1}" == --* ]]; do
861 if [[ "${1}" = "--build-only" ]]; then 902 if [[ "${1}" = "--build-only" ]]; then
862 build_only="build" 903 build_only="build"
863 elif [[ "${1}" = "--with-dependencies" ]]; then 904 elif [[ "${1}" = "--with-dependencies" ]]; then
864 deep="--with-dependencies" 905 deep="--with-dependencies"
906 elif [[ "${1}" = "--virtual" ]]; then
907 virtual="true"
865 elif [[ "${1}" = "--into" ]]; then 908 elif [[ "${1}" = "--into" ]]; then
866 destdir="${2}" 909 destdir="${2}"
867 shift 910 shift
868 else 911 else
869 die "java-pkg_jar-from called with unknown parameter: ${1}" 912 die "java-pkg_jar-from called with unknown parameter: ${1}"
872 done 915 done
873 916
874 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 917 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
875 918
876 [[ -z ${target_pkg} ]] && die "Must specify a package" 919 [[ -z ${target_pkg} ]] && die "Must specify a package"
920
921 if [[ "${EAPI}" == "1" ]]; then
922 target_pkg="${target_pkg//:/-}"
923 fi
877 924
878 # default destjar to the target jar 925 # default destjar to the target jar
879 [[ -z "${destjar}" ]] && destjar="${target_jar}" 926 [[ -z "${destjar}" ]] && destjar="${target_jar}"
880 927
881 local error_msg="There was a problem getting the classpath for ${target_pkg}." 928 local error_msg="There was a problem getting the classpath for ${target_pkg}."
890 for pkg in ${target_pkg//,/ }; do 937 for pkg in ${target_pkg//,/ }; do
891 java-pkg_ensure-dep "${build_only}" "${pkg}" 938 java-pkg_ensure-dep "${build_only}" "${pkg}"
892 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 939 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
893 done 940 done
894 # setting this disables further record-jar_ calls later 941 # setting this disables further record-jar_ calls later
895 build_only="build" 942 record_jar="true"
896 else 943 else
897 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 944 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
945 fi
946
947 # Record the entire virtual as a dependency so that
948 # no jars are missed.
949 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
950 java-pkg_record-jar_ "${target_pkg}"
951 # setting this disables further record-jars_ calls later
952 record_jar="true"
898 fi 953 fi
899 954
900 pushd ${destdir} > /dev/null \ 955 pushd ${destdir} > /dev/null \
901 || die "failed to change directory to ${destdir}" 956 || die "failed to change directory to ${destdir}"
902 957
910 # If no specific target jar was indicated, link it 965 # If no specific target jar was indicated, link it
911 if [[ -z "${target_jar}" ]] ; then 966 if [[ -z "${target_jar}" ]] ; then
912 [[ -f "${target_jar}" ]] && rm "${target_jar}" 967 [[ -f "${target_jar}" ]] && rm "${target_jar}"
913 ln -snf "${jar}" \ 968 ln -snf "${jar}" \
914 || die "Failed to make symlink from ${jar} to ${jar_name}" 969 || die "Failed to make symlink from ${jar} to ${jar_name}"
970 if [[ -z "${record_jar}" ]]; then
971 if [[ -z "${build_only}" ]]; then
915 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 972 java-pkg_record-jar_ "${target_pkg}" "${jar}"
973 else
974 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
975 fi
976 fi
916 # otherwise, if the current jar is the target jar, link it 977 # otherwise, if the current jar is the target jar, link it
917 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 978 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
918 [[ -f "${destjar}" ]] && rm "${destjar}" 979 [[ -f "${destjar}" ]] && rm "${destjar}"
919 ln -snf "${jar}" "${destjar}" \ 980 ln -snf "${jar}" "${destjar}" \
920 || die "Failed to make symlink from ${jar} to ${destjar}" 981 || die "Failed to make symlink from ${jar} to ${destjar}"
982 if [[ -z "${record_jar}" ]]; then
983 if [[ -z "${build_only}" ]]; then
921 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 984 java-pkg_record-jar_ "${target_pkg}" "${jar}"
985 else
986 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
987 fi
988 fi
922 popd > /dev/null 989 popd > /dev/null
923 return 0 990 return 0
924 fi 991 fi
925 done 992 done
926 popd > /dev/null 993 popd > /dev/null
985 done 1052 done
986 1053
987 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1054 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
988 1055
989 1056
990 local classpath pkgs="${1}" 1057 local pkgs="${1}"
1058
1059 if [[ "${EAPI}" == "1" ]]; then
1060 pkgs="${pkgs//:/-}"
1061 fi
1062
991 jars="$(java-config ${deep} --classpath=${pkgs})" 1063 jars="$(java-config ${deep} --classpath=${pkgs})"
992 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1064 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
993 debug-print "${pkgs}:${jars}" 1065 debug-print "${pkgs}:${jars}"
994 1066
995 for pkg in ${pkgs//,/ }; do 1067 for pkg in ${pkgs//,/ }; do
996 java-pkg_ensure-dep "${build_only}" "${pkg}" 1068 java-pkg_ensure-dep "${build_only}" "${pkg}"
997 done 1069 done
998 1070
999 if [[ -z "${classpath}" ]]; then 1071 for pkg in ${pkgs//,/ }; do
1000 classpath="${jars}"
1001 else
1002 classpath="${classpath}:${jars}"
1003 fi
1004
1005 # Only record jars that aren't build-only
1006 if [[ -z "${build_only}" ]]; then 1072 if [[ -z "${build_only}" ]]; then
1007 for pkg in ${pkgs//,/ }; do
1008 java-pkg_record-jar_ "${pkg}" 1073 java-pkg_record-jar_ "${pkg}"
1074 else
1075 java-pkg_record-jar_ --build-only "${pkg}"
1076 fi
1009 done 1077 done
1010 fi
1011 1078
1012 echo "${classpath}" 1079 echo "${jars}"
1013} 1080}
1014 1081
1015# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1016# @ebuild-function java-pkg_getjar 1083# @ebuild-function java-pkg_getjar
1017# 1084#
1026# @example-return 1093# @example-return
1027# /usr/share/xerces-2/lib/xml-apis.jar 1094# /usr/share/xerces-2/lib/xml-apis.jar
1028# 1095#
1029# @param $opt 1096# @param $opt
1030# --build-only - makes the jar not added into package.env DEPEND line. 1097# --build-only - makes the jar not added into package.env DEPEND line.
1098# --virtual - Packages passed to this function are to be handled as virtuals
1099# and will not have individual jar dependencies recorded.
1031# @param $1 - package to use 1100# @param $1 - package to use
1032# @param $2 - jar to get 1101# @param $2 - jar to get
1033# ------------------------------------------------------------------------------ 1102# ------------------------------------------------------------------------------
1034java-pkg_getjar() { 1103java-pkg_getjar() {
1035 debug-print-function ${FUNCNAME} $* 1104 debug-print-function ${FUNCNAME} $*
1036 1105
1037 local build_only="" 1106 local build_only=""
1107 local virtual=""
1108 local record_jar=""
1038 1109
1039 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1110 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1040 1111
1041 while [[ "${1}" == --* ]]; do 1112 while [[ "${1}" == --* ]]; do
1042 if [[ "${1}" = "--build-only" ]]; then 1113 if [[ "${1}" = "--build-only" ]]; then
1043 build_only="build" 1114 build_only="build"
1115 elif [[ "${1}" == "--virtual" ]]; then
1116 virtual="true"
1044 else 1117 else
1045 die "java-pkg_jar-from called with unknown parameter: ${1}" 1118 die "java-pkg_getjar called with unknown parameter: ${1}"
1046 fi 1119 fi
1047 shift 1120 shift
1048 done 1121 done
1049 1122
1050 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1123 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1051 1124
1052 local pkg="${1}" target_jar="${2}" jar 1125 local pkg="${1}" target_jar="${2}" jar
1126
1127 if [[ "${EAPI}" == "1" ]]; then
1128 pkg="${pkg//:/-}"
1129 fi
1130
1053 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1131 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1054 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1132 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1055 1133
1056 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1134 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1057 local classpath 1135 local classpath
1058 classpath=$(java-config --classpath=${pkg}) 1136 classpath=$(java-config --classpath=${pkg})
1059 [[ $? != 0 ]] && die ${error_msg} 1137 [[ $? != 0 ]] && die ${error_msg}
1060 1138
1061 java-pkg_ensure-dep "${build_only}" "${pkg}" 1139 java-pkg_ensure-dep "${build_only}" "${pkg}"
1062 1140
1141 # Record the package(Virtual) as a dependency and then set build_only
1142 # So that individual jars are not recorded.
1143 if [[ -n "${virtual}" ]]; then
1144 if [[ -z "${build_only}" ]]; then
1145 java-pkg_record-jar_ "${pkg}"
1146 else
1147 java-pkg_record-jar_ --build-only "${pkg}"
1148 fi
1149 record_jar="true"
1150 fi
1151
1063 for jar in ${classpath//:/ }; do 1152 for jar in ${classpath//:/ }; do
1064 if [[ ! -f "${jar}" ]] ; then 1153 if [[ ! -f "${jar}" ]] ; then
1065 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1154 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1066 fi 1155 fi
1067 1156
1068 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1157 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1069 # Only record jars that aren't build-only 1158 # Only record jars that aren't build-only
1070 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1159 if [[ -z "${record_jar}" ]]; then
1160 if [[ -z "${build_only}" ]]; then
1161 java-pkg_record-jar_ "${pkg}" "${jar}"
1162 else
1163 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1164 fi
1165 fi
1071 echo "${jar}" 1166 echo "${jar}"
1072 return 0 1167 return 0
1073 fi 1168 fi
1074 done 1169 done
1075 1170
1111 1206
1112 local pkgs="${1}" 1207 local pkgs="${1}"
1113 local jar="${2}" 1208 local jar="${2}"
1114 1209
1115 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1210 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1211
1212 if [[ "${EAPI}" == "1" ]]; then
1213 pkgs="${pkgs//:/-}"
1214 fi
1116 1215
1117 if [[ -z "${jar}" ]]; then 1216 if [[ -z "${jar}" ]]; then
1118 for pkg in ${pkgs//,/ }; do 1217 for pkg in ${pkgs//,/ }; do
1119 java-pkg_ensure-dep runtime "${pkg}" 1218 java-pkg_ensure-dep runtime "${pkg}"
1120 java-pkg_record-jar_ "${pkg}" 1219 java-pkg_record-jar_ "${pkg}"
1163 local pkgs="${1}" 1262 local pkgs="${1}"
1164 local jar="${2}" 1263 local jar="${2}"
1165 1264
1166 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1265 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1167 1266
1267 if [[ "${EAPI}" == "1" ]]; then
1268 pkgs="${pkgs//:/-}"
1269 fi
1270
1168 if [[ -z "${jar}" ]]; then 1271 if [[ -z "${jar}" ]]; then
1169 for pkg in ${pkgs//,/ }; do 1272 for pkg in ${pkgs//,/ }; do
1170 java-pkg_record-jar_ --optional "${pkg}" 1273 java-pkg_record-jar_ --optional "${pkg}"
1171 done 1274 done
1172 else 1275 else
1201 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1304 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1202 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1305 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1203 1306
1204 java-pkg_do_write_ 1307 java-pkg_do_write_
1205} 1308}
1309
1310# ------------------------------------------------------------------------------
1311# @ebuild-function java-pkg_get-bootclasspath
1312#
1313# Returns classpath of a given bootclasspath-providing package version.
1314#
1315# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1316# of the current JDK
1317# ------------------------------------------------------------------------------
1318
1319java-pkg_get-bootclasspath() {
1320 local version="${1}"
1321
1322 local bcp
1323 case "${version}" in
1324 auto)
1325 bcp="$(java-config -g BOOTCLASSPATH)"
1326 ;;
1327 1.5)
1328 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1329 ;;
1330 *)
1331 eerror "unknown parameter of java-pkg_get-bootclasspath"
1332 die "unknown parameter of java-pkg_get-bootclasspath"
1333 ;;
1334 esac
1335
1336 echo "${bcp}"
1337}
1338
1206 1339
1207# This function reads stdin, and based on that input, figures out how to 1340# This function reads stdin, and based on that input, figures out how to
1208# populate jars from the filesystem. 1341# populate jars from the filesystem.
1209# Need to figure out a good way of making use of this, ie be able to use a 1342# Need to figure out a good way of making use of this, ie be able to use a
1210# string that was built instead of stdin 1343# string that was built instead of stdin
1248# @section-begin helper 1381# @section-begin helper
1249# @section-summary Helper functions 1382# @section-summary Helper functions
1250# 1383#
1251# Various other functions to use from an ebuild 1384# Various other functions to use from an ebuild
1252# ------------------------------------------------------------------------------ 1385# ------------------------------------------------------------------------------
1253
1254# ------------------------------------------------------------------------------
1255# @ebuild-function java-pkg_need
1256#
1257# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1258# Currently supported virtuals are:
1259# javamail
1260# jdbc-stdext
1261# jaf
1262# jdbc-rowset
1263# jms
1264#
1265# @param $1 - Optionally indicate that the dependencies are controlled by
1266# a use flag by specifying '--use' Requires $2.
1267# @param $2 - USE flag which will enable the dependencies.
1268# @param $@ - virtual packages to add depenedencies for
1269# ------------------------------------------------------------------------------
1270# TODO rewrite to parse a line based declaration file instead -- karltk
1271#java-pkg_need() {
1272# debug-print-function ${FUNCNAME} $*
1273# local useflag
1274# if [[ ${1} == "--use" ]]; then
1275# useflag="${2}"
1276# shift 2
1277# fi
1278#
1279# if [[ -z ${1} ]]; then
1280# die "Must specify at least one virtual package."
1281# fi
1282#
1283# local depstr newdepstr
1284#
1285# for virtual in ${@}; do
1286# if has ${virtual} ${JAVA_PKG_VNEED}; then
1287# debug-print "Already registered virtual ${virtual}"
1288# continue
1289# fi
1290# case ${virtual} in
1291# javamail)
1292# debug-print "java-pkg_need: adding javamail dependencies"
1293# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1294# ;;
1295# jdbc-stdext)
1296# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1297# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1298# ;;
1299# jaf)
1300# debug-print "java-pkg_need: adding jaf dependencies"
1301# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1302# ;;
1303# jdbc-rowset)
1304# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1305# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1306# ;;
1307# jms)
1308# debug-print "java-pkg_need: adding jms dependencies"
1309# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1310# ;;
1311# *)
1312# die "Invalid virtual: ${virtual}"
1313# esac
1314#
1315# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1316#
1317# if [[ -n ${useflag} ]]; then
1318# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1319# else
1320# depstr="${depstr} ${newdepstr}"
1321# fi
1322# done
1323#
1324# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1325# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1326#
1327# export DEPEND="${DEPEND} ${depstr}"
1328# export RDEPEND="${RDEPEND} ${depstr}"
1329#}
1330 1386
1331# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1332# @ebuild-function java-pkg_find-normal-jars 1388# @ebuild-function java-pkg_find-normal-jars
1333# 1389#
1334# Find the files with suffix .jar file in the given directory or $WORKDIR 1390# Find the files with suffix .jar file in the given directory or $WORKDIR
1500java-pkg_get-current-vm() { 1556java-pkg_get-current-vm() {
1501 echo ${GENTOO_VM} 1557 echo ${GENTOO_VM}
1502} 1558}
1503 1559
1504java-pkg_current-vm-matches() { 1560java-pkg_current-vm-matches() {
1505 hasq $(java-pkg_get-current-vm) ${@} 1561 has $(java-pkg_get-current-vm) ${@}
1506 return $? 1562 return $?
1507} 1563}
1508 1564
1509# ------------------------------------------------------------------------------ 1565# ------------------------------------------------------------------------------
1510# @ebuild-function java-pkg_get-source 1566# @ebuild-function java-pkg_get-source
1625 die "No GCJ support found!" 1681 die "No GCJ support found!"
1626 fi 1682 fi
1627} 1683}
1628 1684
1629java-pkg_ensure-test() { 1685java-pkg_ensure-test() {
1630 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1686 if has test ${FEATURES} && ! has -test ${FEATURES} \
1631 && hasq test ${IUSE} && ! use test; 1687 && has test ${IUSE} && ! use test;
1632 then 1688 then
1633 eerror "You specified FEATURES=test, but USE=test is needed" 1689 eerror "You specified FEATURES=test, but USE=test is needed"
1634 eerror "to pull in the additional dependencies for testing" 1690 eerror "to pull in the additional dependencies for testing"
1635 die "Need USE=test enabled" 1691 die "Need USE=test enabled"
1636 fi 1692 fi
1672 dodir /usr/share/ant/${TASKS_DIR} 1728 dodir /usr/share/ant/${TASKS_DIR}
1673 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1729 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1674} 1730}
1675 1731
1676# ------------------------------------------------------------------------------ 1732# ------------------------------------------------------------------------------
1677# @internal-function java-pkg_ant-tasks-from-deps
1678#
1679# Function to determine ANT_TASKS from DEPEND variable for backwards
1680# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1681# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1682# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1683# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1684# be a problem, the worst it can do is activace all tasks when not needed.
1685# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1686# insufficient dependencies, otherwise all available tasks are used for
1687# backwards compatilbility.
1688#
1689# @return "all" or "none"
1690# ------------------------------------------------------------------------------
1691java-pkg_ant-tasks-from-deps() {
1692 local found_ant found_ant_tasks
1693
1694 for dep in ${DEPEND}
1695 do
1696 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1697 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1698 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1699 done
1700
1701 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1702 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1703 echo "all"
1704 else
1705 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1706 # so we deactivate all tasks that may be installed
1707 echo "none"
1708 fi
1709}
1710
1711# ------------------------------------------------------------------------------
1712# @internal-function java-pkg_ant-tasks-depend 1733# @internal-function java-pkg_ant-tasks-depend
1713# 1734#
1714# Translates the WANT_ANT_TASKS variable into valid dependencies. 1735# Translates the WANT_ANT_TASKS variable into valid dependencies.
1715# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1716java-pkg_ant-tasks-depend() { 1737java-pkg_ant-tasks-depend() {
1718 1739
1719 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1740 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1720 local DEP="" 1741 local DEP=""
1721 for i in ${WANT_ANT_TASKS} 1742 for i in ${WANT_ANT_TASKS}
1722 do 1743 do
1723 if [[ ${i} != ant-* ]]; then 1744 if [[ ${i} = ant-* ]]; then
1745 DEP="${DEP}dev-java/${i} "
1746 elif [[ ${i} = */*:* ]]; then
1747 DEP="${DEP}${i} "
1748 else
1724 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1725 return 1 1750 return 1
1726 fi 1751 fi
1727 DEP="${DEP}dev-java/${i} "
1728 done 1752 done
1729 echo ${DEP} 1753 echo ${DEP}
1730 return 0 1754 return 0
1731 else 1755 else
1732 return 0 1756 return 0
1733 fi 1757 fi
1734} 1758}
1735 1759
1760
1736# ------------------------------------------------------------------------------ 1761# ------------------------------------------------------------------------------
1737# @ebuild-function ejunit 1762# @internal-function ejunit_
1738# 1763#
1739# Junit wrapper function. Makes it easier to run the tests and checks for 1764# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1740# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1765# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1741# 1766#
1742# Examples: 1767# @param $1 - junit package (junit or junit-4)
1743# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1744# ejunit org.blinkenlights.jid3.test.AllTests
1745#
1746# @param $1 - -cp or -classpath 1768# @param $2 - -cp or -classpath
1747# @param $2 - classpath; junit and recorded dependencies get appended 1769# @param $3 - classpath; junit and recorded dependencies get appended
1748# @param $@ - the rest of the parameters are passed to java 1770# @param $@ - the rest of the parameters are passed to java
1749# ------------------------------------------------------------------------------
1750ejunit() { 1771ejunit_() {
1751 debug-print-function ${FUNCNAME} $* 1772 debug-print-function ${FUNCNAME} $*
1752 1773
1753 local pkgs 1774 local pkgs
1775 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1754 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1776 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1755 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1777 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1756 done 1778 done
1779 fi
1757 1780
1781 local junit=${1}
1782 shift 1
1783
1758 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1784 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1759 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1760 cp="${2}:${cp}" 1786 cp="${2}:${cp}"
1761 shift 2 1787 shift 2
1762 else 1788 else
1763 cp=".:${cp}" 1789 cp=".:${cp}"
1764 fi 1790 fi
1765 1791
1766 local runner=junit.textui.TestRunner 1792 local runner=junit.textui.TestRunner
1793 if [[ "${junit}" == "junit-4" ]] ; then
1794 runner=org.junit.runner.JUnitCore
1795 fi
1767 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1796 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1768 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1797 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1769} 1798}
1770 1799
1771# ------------------------------------------------------------------------------ 1800# ------------------------------------------------------------------------------
1801# @ebuild-function ejunit
1802#
1803# Junit wrapper function. Makes it easier to run the tests and checks for
1804# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1805#
1806# Examples:
1807# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1808# ejunit org.blinkenlights.jid3.test.AllTests
1809# ejunit org.blinkenlights.jid3.test.FirstTest \
1810# org.blinkenlights.jid3.test.SecondTest
1811#
1812# @param $1 - -cp or -classpath
1813# @param $2 - classpath; junit and recorded dependencies get appended
1814# @param $@ - the rest of the parameters are passed to java
1815# ------------------------------------------------------------------------------
1816ejunit() {
1817 debug-print-function ${FUNCNAME} $*
1818
1819 ejunit_ "junit" "${@}"
1820}
1821
1822# ------------------------------------------------------------------------------
1823# @ebuild-function ejunit4
1824#
1825# Junit4 wrapper function. Makes it easier to run the tests and checks for
1826# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1827#
1828# Examples:
1829# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1830# ejunit4 org.blinkenlights.jid3.test.AllTests
1831# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1832# org.blinkenlights.jid3.test.SecondTest
1833#
1834# @param $1 - -cp or -classpath
1835# @param $2 - classpath; junit and recorded dependencies get appended
1836# @param $@ - the rest of the parameters are passed to java
1837# ------------------------------------------------------------------------------
1838ejunit4() {
1839 debug-print-function ${FUNCNAME} $*
1840
1841 ejunit_ "junit-4" "${@}"
1842}
1843
1844# ------------------------------------------------------------------------------
1772# @section-end helper 1845# @section-end helper
1773# ------------------------------------------------------------------------------ 1846# ------------------------------------------------------------------------------
1847
1848# ------------------------------------------------------------------------------
1849# @eclass-src_prepare
1850#
1851# src_prepare Searches for bundled jars
1852# Don't call directly, but via java-pkg-2_src_prepare!
1853# ------------------------------------------------------------------------------
1854
1855java-utils-2_src_prepare() {
1856 [[ ${EBUILD_PHASE} == prepare ]] &&
1857 java-pkg_func-exists java_prepare && java_prepare
1858
1859 # Remember that eant will call this unless called via Portage
1860 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1861 echo "Searching for bundled jars:"
1862 java-pkg_find-normal-jars || echo "None found."
1863 echo "Searching for bundled classes (no output if none found):"
1864 find "${WORKDIR}" -name "*.class"
1865 echo "Search done."
1866 fi
1867 touch "${T}/java-utils-2_src_prepare-run"
1868}
1869
1870# ------------------------------------------------------------------------------
1871# @eclass-pkg_preinst
1872#
1873# pkg_preinst Searches for missing and unneeded dependencies
1874# Don't call directly, but via java-pkg-2_pkg_preinst!
1875# ------------------------------------------------------------------------------
1876
1877java-utils-2_pkg_preinst() {
1878 if is-java-strict; then
1879 if has_version dev-java/java-dep-check; then
1880 [[ -e "${JAVA_PKG_ENV}" ]] || return
1881 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1882 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1883 ewarn "Possibly unneeded dependencies found in package.env:"
1884 for dep in ${output}; do
1885 ewarn "\t${dep}"
1886 done
1887 fi
1888 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1889 ewarn "${output}"
1890 fi
1891 else
1892 eerror "Install dev-java/java-dep-check for dependency checking"
1893 fi
1894 fi
1895}
1774 1896
1775# ------------------------------------------------------------------------------ 1897# ------------------------------------------------------------------------------
1776# @section-begin build 1898# @section-begin build
1777# @section-summary Build functions 1899# @section-summary Build functions
1778# 1900#
1787# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1909# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1788# variables: 1910# variables:
1789# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1911# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1790# gentoo.classpath property. Be sure to call 1912# gentoo.classpath property. Be sure to call
1791# java-ant_rewrite-classpath in src_unpack. 1913# java-ant_rewrite-classpath in src_unpack.
1792# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1914# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1915# for build-time purposes, the dependency is not recorded to
1916# package.env!
1793# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1917# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1794# ------------------------------------------------------------------------------ 1918# ------------------------------------------------------------------------------
1795eant() { 1919eant() {
1796 debug-print-function ${FUNCNAME} $* 1920 debug-print-function ${FUNCNAME} $*
1797 1921
1798 if [[ ${EBUILD_PHASE} = compile ]]; then 1922 if [[ ${EBUILD_PHASE} = compile ]]; then
1799 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1923 java-ant-2_src_configure
1800 # finally get rid of the hooks without breaking stuff 1924 java-utils-2_src_prepare
1801
1802 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1803 && java-ant_ignore-system-classes "${S}/build.xml"
1804
1805 if hasq java-ant-2 ${INHERITED}; then
1806 java-ant_bsfix
1807 fi 1925 fi
1808 1926
1809 # eant can be called multiple times
1810 JAVA_PKG_BSFIX="off"
1811
1812 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1813 echo "Searching for bundled jars:"
1814 java-pkg_find-normal-jars || echo "None found."
1815 echo "Searching for bundled classes (no output if none found):"
1816 find "${WORKDIR}" -name "*.class"
1817 echo "Search done."
1818 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1819 fi
1820 fi
1821
1822 if ! hasq java-ant-2 ${INHERITED}; then 1927 if ! has java-ant-2 ${INHERITED}; then
1823 local msg="You should inherit java-ant-2 when using eant" 1928 local msg="You should inherit java-ant-2 when using eant"
1824 java-pkg_announce-qa-violation "${msg}" 1929 java-pkg_announce-qa-violation "${msg}"
1825 fi 1930 fi
1826 1931
1827 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1932 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1828 1933
1829 java-pkg_init-compiler_ 1934 java-pkg_init-compiler_
1830 local compiler="${GENTOO_COMPILER}" 1935 local compiler="${GENTOO_COMPILER}"
1831 1936
1832 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1937 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1843 # java-config -p 1948 # java-config -p
1844 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1949 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1845 if [[ -n ${build_compiler_deps} ]]; then 1950 if [[ -n ${build_compiler_deps} ]]; then
1846 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1951 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1847 fi 1952 fi
1848 fi
1849
1850 if is-java-strict; then
1851 einfo "Disabling system classpath for ant"
1852 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1853 fi 1953 fi
1854 1954
1855 for arg in "${@}"; do 1955 for arg in "${@}"; do
1856 if [[ ${arg} = -lib ]]; then 1956 if [[ ${arg} = -lib ]]; then
1857 if is-java-strict; then 1957 if is-java-strict; then
1866 echo "more info." 1966 echo "more info."
1867 fi 1967 fi
1868 fi 1968 fi
1869 done 1969 done
1870 1970
1871 # we use this in src_* so we run ant from / 1971 # parse WANT_ANT_TASKS for atoms
1872 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1972 local want_ant_tasks
1873 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1973 for i in ${WANT_ANT_TASKS}; do
1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1974 if [[ ${i} = */*:* ]]; then
1875 1975 i=${i#*/}
1876 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1976 i=${i%:0}
1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1977 want_ant_tasks+="${i/:/-} "
1878
1879 if is-java-strict; then
1880 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1881 if [[ -z "${ANT_TASKS}" ]]; then
1882 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1883 fi
1884 else 1978 else
1979 want_ant_tasks+="${i} "
1980 fi
1981 done
1982 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1983 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1984
1985 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1986 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1987
1885 # if ant-tasks is not set by ebuild or forced, activate all of them 1988 # if ant-tasks is not set by ebuild or forced, use none
1886 ANT_TASKS="${ANT_TASKS:-all}" 1989 ANT_TASKS="${ANT_TASKS:-none}"
1887 fi
1888 1990
1889 # at this point, ANT_TASKS should be "all", "none" or explicit list 1991 # at this point, ANT_TASKS should be "all", "none" or explicit list
1890 if [[ "${ANT_TASKS}" == "all" ]]; then 1992 if [[ "${ANT_TASKS}" == "all" ]]; then
1891 einfo "Using all available ANT_TASKS" 1993 einfo "Using all available ANT_TASKS"
1892 elif [[ "${ANT_TASKS}" == "none" ]]; then 1994 elif [[ "${ANT_TASKS}" == "none" ]]; then
1893 einfo "Disabling all optional ANT_TASKS" 1995 einfo "Disabling all optional ANT_TASKS"
1894 else 1996 else
1895 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1997 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1896 fi 1998 fi
1897 1999
1898 export ANT_TASKS 2000 export ANT_TASKS
1899 fi
1900 2001
1901 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 2002 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1902 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 2003 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1903 2004
1904 local gcp="${EANT_GENTOO_CLASSPATH}" 2005 local gcp="${EANT_GENTOO_CLASSPATH}"
1905 local getjarsarg="" 2006 local getjarsarg=""
1906 2007
1907 if [[ ${EBUILD_PHASE} = "test" ]]; then 2008 if [[ ${EBUILD_PHASE} = "test" ]]; then
1908 antflags="${antflags} -DJunit.present=true" 2009 antflags="${antflags} -DJunit.present=true"
1909 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2010 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1910 getjarsarg="--with-dependencies" 2011 getjarsarg="--with-dependencies"
1911 fi 2012 fi
1912 2013
1913 local cp 2014 local cp
1914 2015
1915 for atom in ${gcp}; do 2016 for atom in ${gcp}; do
1916 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2017 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1917 done 2018 done
1918 2019
2020 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2021
1919 if [[ ${cp} ]]; then 2022 if [[ ${cp} ]]; then
1920 # It seems ant does not like single quotes around ${cp} 2023 # It seems ant does not like single quotes around ${cp}
2024 cp=${cp#:}
2025 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2026 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1921 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2027 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1922 fi 2028 fi
1923 2029
1924 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2030 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1925 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2031 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1926 ant ${antflags} "${@}" || die "eant failed" 2032 ant ${antflags} "${@}" || die "eant failed"
2026# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2132# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2027# call it during each of the phases of the merge process. 2133# call it during each of the phases of the merge process.
2028# 2134#
2029# ----------------------------------------------------------------------------- 2135# -----------------------------------------------------------------------------
2030java-pkg_init() { 2136java-pkg_init() {
2137 debug-print-function ${FUNCNAME} $*
2031 unset JAVAC 2138 unset JAVAC
2032 unset JAVA_HOME 2139 unset JAVA_HOME
2140
2141 java-config --help >/dev/null || {
2142 eerror ""
2143 eerror "Can't run java-config --help"
2144 eerror "Have you upgraded python recently but haven't"
2145 eerror "run python-updater yet?"
2146 die "Can't run java-config --help"
2147 }
2033 2148
2034 # People do all kinds of weird things. 2149 # People do all kinds of weird things.
2035 # http://forums.gentoo.org/viewtopic-p-3943166.html 2150 # http://forums.gentoo.org/viewtopic-p-3943166.html
2036 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2151 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2037 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2152 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2043 ewarn "make.conf for example) to silence this warning or" 2158 ewarn "make.conf for example) to silence this warning or"
2044 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2159 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2045 fi 2160 fi
2046 2161
2047 if [[ -z ${accept} ]]; then 2162 if [[ -z ${accept} ]]; then
2163 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2164 # -version output
2048 unset _JAVA_OPTIONS 2165 unset _JAVA_OPTIONS
2049 # phase hooks make this run many times without this 2166 # phase hooks make this run many times without this
2050 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2167 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2051 fi 2168 fi
2052 2169
2060 2177
2061 # TODO we will probably want to set JAVAC and JAVACFLAGS 2178 # TODO we will probably want to set JAVAC and JAVACFLAGS
2062 2179
2063 # Do some QA checks 2180 # Do some QA checks
2064 java-pkg_check-jikes 2181 java-pkg_check-jikes
2182
2183 # Can't use unset here because Portage does not save the unset
2184 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2065 2185
2066 # When users have crazy classpaths some packages can fail to compile. 2186 # When users have crazy classpaths some packages can fail to compile.
2067 # and everything should work with empty CLASSPATH. 2187 # and everything should work with empty CLASSPATH.
2068 # This also helps prevent unexpected dependencies on random things 2188 # This also helps prevent unexpected dependencies on random things
2069 # from the CLASSPATH. 2189 # from the CLASSPATH.
2070 unset CLASSPATH 2190 export CLASSPATH=
2071 2191
2072 # Unset external ANT_ stuff 2192 # Unset external ANT_ stuff
2073 unset ANT_TASKS 2193 export ANT_TASKS=
2074 unset ANT_OPTS 2194 export ANT_OPTS=
2195 export ANT_RESPECT_JAVA_HOME=
2075} 2196}
2076 2197
2077# ------------------------------------------------------------------------------ 2198# ------------------------------------------------------------------------------
2078# @function-internal java-pkg-init-compiler_ 2199# @function-internal java-pkg-init-compiler_
2079# 2200#
2170 done 2291 done
2171 2292
2172 # If it hasn't been defined already, default to javac 2293 # If it hasn't been defined already, default to javac
2173 if [[ -z ${GENTOO_COMPILER} ]]; then 2294 if [[ -z ${GENTOO_COMPILER} ]]; then
2174 if [[ -n ${compilers} ]]; then 2295 if [[ -n ${compilers} ]]; then
2175 einfo "No suitable compiler found: defaulting javac for compilation" 2296 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2176 else 2297 else
2177 # probably don't need to notify users about the default. 2298 # probably don't need to notify users about the default.
2178 :;#einfo "Defaulting to javac for compilation" 2299 :;#einfo "Defaulting to javac for compilation"
2179 fi 2300 fi
2301 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2302 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2303 else
2180 export GENTOO_COMPILER=javac 2304 export GENTOO_COMPILER=javac
2305 fi
2181 else 2306 else
2182 einfo "Using ${GENTOO_COMPILER} for compilation" 2307 einfo "Using ${GENTOO_COMPILER} for compilation"
2183 fi 2308 fi
2184 2309
2185} 2310}
2201 fi 2326 fi
2202 2327
2203 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2328 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2204 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2329 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2205 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2330 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2331 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2332 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2206 2333
2207 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2334 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2208 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2335 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2209 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2336 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2210 2337
2234 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2361 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2235 # Create package.env 2362 # Create package.env
2236 ( 2363 (
2237 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2364 echo "DESCRIPTION=\"${DESCRIPTION}\""
2238 echo "GENERATION=\"2\"" 2365 echo "GENERATION=\"2\""
2366 echo "SLOT=\"${SLOT}\""
2367 echo "CATEGORY=\"${CATEGORY}\""
2368 echo "PVR=\"${PVR}\""
2239 2369
2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2370 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2371 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2372 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2243 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2373 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2244 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2374 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2245 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2375 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2246 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2376 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2247 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2377 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2378 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2379 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2248 ) > "${JAVA_PKG_ENV}" 2380 ) > "${JAVA_PKG_ENV}"
2249 2381
2250 # register target/source 2382 # register target/source
2251 local target="$(java-pkg_get-target)" 2383 local target="$(java-pkg_get-target)"
2252 local source="$(java-pkg_get-source)" 2384 local source="$(java-pkg_get-source)"
2285# ------------------------------------------------------------------------------ 2417# ------------------------------------------------------------------------------
2286# @internal-function java-pkg_record-jar_ 2418# @internal-function java-pkg_record-jar_
2287# 2419#
2288# Record an (optional) dependency to the package.env 2420# Record an (optional) dependency to the package.env
2289# @param --optional - record dependency as optional 2421# @param --optional - record dependency as optional
2422# @param --build - record dependency as build_only
2290# @param $1 - package to record 2423# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record 2424# @param $2 - (optional) jar of package to record
2292# ------------------------------------------------------------------------------ 2425# ------------------------------------------------------------------------------
2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2426JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2427JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2428JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2295 2429
2296java-pkg_record-jar_() { 2430java-pkg_record-jar_() {
2297 debug-print-function ${FUNCNAME} $* 2431 debug-print-function ${FUNCNAME} $*
2298 2432
2299 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2433 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2300 if [[ "${1}" == "--optional" ]]; then 2434 case "${1}" in
2301 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2435 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2302 shift 2436 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2303 fi 2437 esac
2304 2438
2305 local pkg=${1} jar=${2} append 2439 local pkg=${1} jar=${2} append
2306 if [[ -z "${jar}" ]]; then 2440 if [[ -z "${jar}" ]]; then
2307 append="${pkg}" 2441 append="${pkg}"
2308 else 2442 else
2361# 2495#
2362# @return 0 - function is declared 2496# @return 0 - function is declared
2363# @return 1 - function is undeclared 2497# @return 1 - function is undeclared
2364# ------------------------------------------------------------------------------ 2498# ------------------------------------------------------------------------------
2365java-pkg_func-exists() { 2499java-pkg_func-exists() {
2366 if [[ -n "$(declare -f ${1})" ]]; then 2500 declare -F ${1} > /dev/null
2367 return 0
2368 else
2369 return 1
2370 fi
2371} 2501}
2372 2502
2373# ------------------------------------------------------------------------------ 2503# ------------------------------------------------------------------------------
2374# @internal-function java-pkg_setup-vm 2504# @internal-function java-pkg_setup-vm
2375# 2505#
2385 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2515 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2386 addpredict "/dev/random" 2516 addpredict "/dev/random"
2387 elif [[ "${vendor}" == "ibm" ]]; then 2517 elif [[ "${vendor}" == "ibm" ]]; then
2388 addpredict "/proc/self/maps" 2518 addpredict "/proc/self/maps"
2389 addpredict "/proc/cpuinfo" 2519 addpredict "/proc/cpuinfo"
2520 addpredict "/proc/self/coredump_filter"
2521 elif [[ "${vendor}" == "oracle" ]]; then
2522 addpredict "/dev/random"
2523 addpredict "/proc/self/coredump_filter"
2390 elif [[ "${vendor}" == "jrockit" ]]; then 2524 elif [[ "${vendor}" == "jrockit" ]]; then
2391 addpredict "/proc/cpuinfo" 2525 addpredict "/proc/cpuinfo"
2392 fi 2526 fi
2393} 2527}
2394 2528
2401# @return 1 - Package does not depend on virtual/jdk 2535# @return 1 - Package does not depend on virtual/jdk
2402# ------------------------------------------------------------------------------ 2536# ------------------------------------------------------------------------------
2403java-pkg_needs-vm() { 2537java-pkg_needs-vm() {
2404 debug-print-function ${FUNCNAME} $* 2538 debug-print-function ${FUNCNAME} $*
2405 2539
2406 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2540 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2407 return 0 2541 return 0
2408 fi 2542 fi
2409 2543
2410 return 1 2544 return 1
2411} 2545}
2459 # If you're forcing the VM, I hope you know what your doing... 2593 # If you're forcing the VM, I hope you know what your doing...
2460 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2594 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2461 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2595 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2462 # if we're allowed to switch the vm... 2596 # if we're allowed to switch the vm...
2463 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2597 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2464 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2598 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2465 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2466 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2467 else
2468 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2599 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2469 fi
2470 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2600 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2471 eerror "Unable to determine VM for building from dependencies:" 2601 eerror "Unable to determine VM for building from dependencies:"
2472 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2602 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2473 echo "VNEED: ${JAVA_PKG_VNEED}"
2474 die "Failed to determine VM for building." 2603 die "Failed to determine VM for building."
2475 else 2604 else
2476 export GENTOO_VM 2605 export GENTOO_VM
2477 fi 2606 fi
2478 # otherwise just make sure the current VM is sufficient 2607 # otherwise just make sure the current VM is sufficient
2517# 2646#
2518# Enhanced die for Java packages, which displays some information that may be 2647# Enhanced die for Java packages, which displays some information that may be
2519# useful for debugging bugs on bugzilla. 2648# useful for debugging bugs on bugzilla.
2520# ------------------------------------------------------------------------------ 2649# ------------------------------------------------------------------------------
2521#register_die_hook java-pkg_die 2650#register_die_hook java-pkg_die
2522if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2651if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2523 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2652 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2524fi 2653fi
2525 2654
2526java-pkg_die() { 2655java-pkg_die() {
2527 echo "!!! When you file a bug report, please include the following information:" >&2 2656 echo "!!! When you file a bug report, please include the following information:" >&2
2551# not. 2680# not.
2552# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2681# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2553# ------------------------------------------------------------------------------ 2682# ------------------------------------------------------------------------------
2554java-pkg_verify-classes() { 2683java-pkg_verify-classes() {
2555 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2684 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2685
2686 local version_verify="/usr/bin/class-version-verify.py"
2687
2688 if [[ ! -x "${version_verify}" ]]; then
2689 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2690 fi
2691
2692 if [[ ! -x "${version_verify}" ]]; then
2693 ewarn "Unable to perform class version checks as"
2694 ewarn "class-version-verify.py is unavailable"
2695 ewarn "Please install dev-java/javatoolkit."
2696 return
2697 fi
2698
2556 local target=$(java-pkg_get-target) 2699 local target=$(java-pkg_get-target)
2557 local result 2700 local result
2558 local log="${T}/class-version-verify.log" 2701 local log="${T}/class-version-verify.log"
2559 if [[ -n "${1}" ]]; then 2702 if [[ -n "${1}" ]]; then
2560 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2703 ${version_verify} -v -t ${target} "${1}" > "${log}"
2561 result=$? 2704 result=$?
2562 else 2705 else
2563 ebegin "Verifying java class versions (target: ${target})" 2706 ebegin "Verifying java class versions (target: ${target})"
2564 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2707 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2565 result=$? 2708 result=$?
2566 eend ${result} 2709 eend ${result}
2567 fi 2710 fi
2568 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2711 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2569 if [[ ${result} != 0 ]]; then 2712 if [[ ${result} != 0 ]]; then
2587 2730
2588 local limit_to="${1}" 2731 local limit_to="${1}"
2589 local target_pkg="${2}" 2732 local target_pkg="${2}"
2590 local dev_error="" 2733 local dev_error=""
2591 2734
2735 # remove the version specification, which may include globbing (* and [123])
2592 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2736 local stripped_pkg=$(echo "${target_pkg}" | sed \
2593 's/-[0-9]*\(\.[0-9]\)*$//') 2737 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2594 2738
2595 debug-print "Matching against: ${stripped_pkg}" 2739 debug-print "Matching against: ${stripped_pkg}"
2596 2740
2597 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2741 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2598 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2742 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2648 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2792 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2649 fi 2793 fi
2650} 2794}
2651 2795
2652java-pkg_check-jikes() { 2796java-pkg_check-jikes() {
2653 if hasq jikes ${IUSE}; then 2797 if has jikes ${IUSE}; then
2654 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2798 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2655 fi 2799 fi
2656} 2800}
2657 2801
2658java-pkg_announce-qa-violation() { 2802java-pkg_announce-qa-violation() {
2674is-java-strict() { 2818is-java-strict() {
2675 [[ -n ${JAVA_PKG_STRICT} ]] 2819 [[ -n ${JAVA_PKG_STRICT} ]]
2676 return $? 2820 return $?
2677} 2821}
2678 2822
2823
2679# ------------------------------------------------------------------------------ 2824# ------------------------------------------------------------------------------
2680# @eclass-end 2825# @eclass-end
2681# ------------------------------------------------------------------------------ 2826# ------------------------------------------------------------------------------

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.143

  ViewVC Help
Powered by ViewVC 1.1.20