/[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.101 Revision 1.151
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
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-2011, 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.101 2008/01/12 15:03:13 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.151 2012/07/05 20:07:47 sera 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}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 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
77 94
78# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
80# @variable-default yes 97# @variable-default yes
81# 98#
94# Should only be used for testing and debugging. 111# Should only be used for testing and debugging.
95# 112#
96# @example Use sun-jdk-1.5 to emerge foo 113# @example Use sun-jdk-1.5 to emerge foo
97# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
98# 115#
116# -----------------------------------------------------------------------------
117
118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
99# ----------------------------------------------------------------------------- 129# -----------------------------------------------------------------------------
100 130
101# ----------------------------------------------------------------------------- 131# -----------------------------------------------------------------------------
102# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
103# 133#
224 ( # dont want to pollute calling env 254 ( # dont want to pollute calling env
225 insinto "${dest}" 255 insinto "${dest}"
226 doins -r "$@" 256 doins -r "$@"
227 ) || die "Installing examples failed" 257 ) || die "Installing examples failed"
228 fi 258 fi
259
260 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
229} 262}
230 263
231# ----------------------------------------------------------------------------- 264# -----------------------------------------------------------------------------
232# @ebuild-function java-pkg_dojar 265# @ebuild-function java-pkg_dojar
233# 266#
291 done 324 done
292 325
293 java-pkg_do_write_ 326 java-pkg_do_write_
294} 327}
295 328
296
297# ------------------------------------------------------------------------------ 329# ------------------------------------------------------------------------------
298# @internal-function depend-java-query 330# @internal-function depend-java-query
299# 331#
300# Wrapper for the depend-java-query binary to enable passing USE in env. 332# Wrapper for the depend-java-query binary to enable passing USE in env.
301# Using env variables keeps this eclass working with java-config versions that 333# Using env variables keeps this eclass working with java-config versions that
366 if [[ ${jar} = *\** ]]; then 398 if [[ ${jar} = *\** ]]; then
367 eerror "The argument ${jar} to ${FUNCNAME}" 399 eerror "The argument ${jar} to ${FUNCNAME}"
368 eerror "has * in it. If you want it to glob in" 400 eerror "has * in it. If you want it to glob in"
369 eerror '${D} add ${D} to the argument.' 401 eerror '${D} add ${D} to the argument.'
370 fi 402 fi
403 debug-print "${jar} or ${D}${jar} not found"
371 die "${jar} does not exist" 404 die "${jar} does not exist"
372 fi 405 fi
373 done 406 done
374 407
375 java-pkg_do_write_ 408 java-pkg_do_write_
430# @param $@ - JNI libraries to install 463# @param $@ - JNI libraries to install
431# ------------------------------------------------------------------------------ 464# ------------------------------------------------------------------------------
432java-pkg_doso() { 465java-pkg_doso() {
433 debug-print-function ${FUNCNAME} $* 466 debug-print-function ${FUNCNAME} $*
434 467
435 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
436 java-pkg_check-phase install 468 java-pkg_check-phase install
437 469
438 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 470 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
439 471
440 java-pkg_init_paths_ 472 java-pkg_init_paths_
441 473
442 local lib 474 local lib
443 # for each lib 475 # for each lib
446 if [[ -e "${lib}" ]] ; then 478 if [[ -e "${lib}" ]] ; then
447 # install if it isn't a symlink 479 # install if it isn't a symlink
448 if [[ ! -L "${lib}" ]] ; then 480 if [[ ! -L "${lib}" ]] ; then
449 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 481 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
450 INSOPTIONS="${LIBOPTIONS}" \ 482 INSOPTIONS="${LIBOPTIONS}" \
451 doins "${lib}" || "failed to install ${lib}" 483 doins "${lib}" || die "failed to install ${lib}"
452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 484 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 485 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
454 # otherwise make a symlink to the symlink's origin 486 # otherwise make a symlink to the symlink's origin
455 else 487 else
456 # TODO use dosym 488 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
457 ln -s "$(readlink "${lib}")" \
458 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
459 debug-print "${lib} is a symlink, linking accordanly" 489 debug-print "${lib} is a symlink, linking accordantly"
460 fi 490 fi
461 # otherwise die 491 # otherwise die
462 else 492 else
463 die "${lib} does not exist" 493 die "${lib} does not exist"
464 fi 494 fi
480java-pkg_regso() { 510java-pkg_regso() {
481 debug-print-function ${FUNCNAME} $* 511 debug-print-function ${FUNCNAME} $*
482 512
483 java-pkg_check-phase install 513 java-pkg_check-phase install
484 514
485 [[ ${#} -lt 1 ]] && "at least one argument needed" 515 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
486 516
487 java-pkg_init_paths_ 517 java-pkg_init_paths_
488 518
489 local lib target_dir 519 local lib target_dir
490 for lib in "$@" ; do 520 for lib in "$@" ; do
613 643
614 # Let's make a symlink to the directory we have everything else under 644 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die 645 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616 646
617 if [[ ${symlink} ]]; then 647 if [[ ${symlink} ]]; then
648 debug-print "symlinking ${dest}/{api,${symlink}}"
618 dosym ${dest}/{api,${symlink}} || die 649 dosym ${dest}/{api,${symlink}} || die
619 fi 650 fi
620} 651}
621 652
622# ------------------------------------------------------------------------------ 653# ------------------------------------------------------------------------------
647 678
648 [[ ${#} -lt 1 ]] && die "At least one argument needed" 679 [[ ${#} -lt 1 ]] && die "At least one argument needed"
649 680
650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 681 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 682 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
652 if is-java-strict; then 683 java-pkg_announce-qa-violation ${msg}
653 eerror "${msg}"
654 die "${msg}"
655 else
656 echo "${msg}"
657 echo "Please report this to http://bugs.gentoo.org."
658 fi
659 fi 684 fi
660 685
661 java-pkg_init_paths_ 686 java-pkg_init_paths_
662 687
663 local zip_name="${PN}-src.zip" 688 local zip_name="${PN}-src.zip"
880 905
881 local build_only="" 906 local build_only=""
882 local destdir="." 907 local destdir="."
883 local deep="" 908 local deep=""
884 local virtual="" 909 local virtual=""
910 local record_jar=""
885 911
886 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 912 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
887 913
888 while [[ "${1}" == --* ]]; do 914 while [[ "${1}" == --* ]]; do
889 if [[ "${1}" = "--build-only" ]]; then 915 if [[ "${1}" = "--build-only" ]]; then
903 929
904 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 930 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
905 931
906 [[ -z ${target_pkg} ]] && die "Must specify a package" 932 [[ -z ${target_pkg} ]] && die "Must specify a package"
907 933
934 if [[ "${EAPI}" == "1" ]]; then
935 target_pkg="${target_pkg//:/-}"
936 fi
937
908 # default destjar to the target jar 938 # default destjar to the target jar
909 [[ -z "${destjar}" ]] && destjar="${target_jar}" 939 [[ -z "${destjar}" ]] && destjar="${target_jar}"
910 940
911 local error_msg="There was a problem getting the classpath for ${target_pkg}." 941 local error_msg="There was a problem getting the classpath for ${target_pkg}."
912 local classpath 942 local classpath
920 for pkg in ${target_pkg//,/ }; do 950 for pkg in ${target_pkg//,/ }; do
921 java-pkg_ensure-dep "${build_only}" "${pkg}" 951 java-pkg_ensure-dep "${build_only}" "${pkg}"
922 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
923 done 953 done
924 # setting this disables further record-jar_ calls later 954 # setting this disables further record-jar_ calls later
925 build_only="build" 955 record_jar="true"
926 else 956 else
927 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 957 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
928 fi 958 fi
929 959
930 # Record the entire virtual as a dependency so that 960 # Record the entire virtual as a dependency so that
931 # no jars are missed. 961 # no jars are missed.
932 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 962 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
933 java-pkg_record-jar_ "${target_pkg}" 963 java-pkg_record-jar_ "${target_pkg}"
934 # setting this disables further record-jars_ calls later 964 # setting this disables further record-jars_ calls later
935 build_only="build" 965 record_jar="true"
936 fi 966 fi
937 967
938 pushd ${destdir} > /dev/null \ 968 pushd ${destdir} > /dev/null \
939 || die "failed to change directory to ${destdir}" 969 || die "failed to change directory to ${destdir}"
940 970
948 # If no specific target jar was indicated, link it 978 # If no specific target jar was indicated, link it
949 if [[ -z "${target_jar}" ]] ; then 979 if [[ -z "${target_jar}" ]] ; then
950 [[ -f "${target_jar}" ]] && rm "${target_jar}" 980 [[ -f "${target_jar}" ]] && rm "${target_jar}"
951 ln -snf "${jar}" \ 981 ln -snf "${jar}" \
952 || die "Failed to make symlink from ${jar} to ${jar_name}" 982 || die "Failed to make symlink from ${jar} to ${jar_name}"
983 if [[ -z "${record_jar}" ]]; then
984 if [[ -z "${build_only}" ]]; then
953 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 985 java-pkg_record-jar_ "${target_pkg}" "${jar}"
986 else
987 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
988 fi
989 fi
954 # otherwise, if the current jar is the target jar, link it 990 # otherwise, if the current jar is the target jar, link it
955 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 991 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
956 [[ -f "${destjar}" ]] && rm "${destjar}" 992 [[ -f "${destjar}" ]] && rm "${destjar}"
957 ln -snf "${jar}" "${destjar}" \ 993 ln -snf "${jar}" "${destjar}" \
958 || die "Failed to make symlink from ${jar} to ${destjar}" 994 || die "Failed to make symlink from ${jar} to ${destjar}"
995 if [[ -z "${record_jar}" ]]; then
996 if [[ -z "${build_only}" ]]; then
959 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 997 java-pkg_record-jar_ "${target_pkg}" "${jar}"
998 else
999 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
1000 fi
1001 fi
960 popd > /dev/null 1002 popd > /dev/null
961 return 0 1003 return 0
962 fi 1004 fi
963 done 1005 done
964 popd > /dev/null 1006 popd > /dev/null
1023 done 1065 done
1024 1066
1025 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1067 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1026 1068
1027 1069
1028 local classpath pkgs="${1}" 1070 local pkgs="${1}"
1071
1072 if [[ "${EAPI}" == "1" ]]; then
1073 pkgs="${pkgs//:/-}"
1074 fi
1075
1029 jars="$(java-config ${deep} --classpath=${pkgs})" 1076 jars="$(java-config ${deep} --classpath=${pkgs})"
1030 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1077 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1031 debug-print "${pkgs}:${jars}" 1078 debug-print "${pkgs}:${jars}"
1032 1079
1033 for pkg in ${pkgs//,/ }; do 1080 for pkg in ${pkgs//,/ }; do
1034 java-pkg_ensure-dep "${build_only}" "${pkg}" 1081 java-pkg_ensure-dep "${build_only}" "${pkg}"
1035 done 1082 done
1036 1083
1037 if [[ -z "${classpath}" ]]; then 1084 for pkg in ${pkgs//,/ }; do
1038 classpath="${jars}"
1039 else
1040 classpath="${classpath}:${jars}"
1041 fi
1042
1043 # Only record jars that aren't build-only
1044 if [[ -z "${build_only}" ]]; then 1085 if [[ -z "${build_only}" ]]; then
1045 for pkg in ${pkgs//,/ }; do
1046 java-pkg_record-jar_ "${pkg}" 1086 java-pkg_record-jar_ "${pkg}"
1087 else
1088 java-pkg_record-jar_ --build-only "${pkg}"
1089 fi
1047 done 1090 done
1048 fi
1049 1091
1050 echo "${classpath}" 1092 echo "${jars}"
1051} 1093}
1052 1094
1053# ------------------------------------------------------------------------------ 1095# ------------------------------------------------------------------------------
1054# @ebuild-function java-pkg_getjar 1096# @ebuild-function java-pkg_getjar
1055# 1097#
1074java-pkg_getjar() { 1116java-pkg_getjar() {
1075 debug-print-function ${FUNCNAME} $* 1117 debug-print-function ${FUNCNAME} $*
1076 1118
1077 local build_only="" 1119 local build_only=""
1078 local virtual="" 1120 local virtual=""
1121 local record_jar=""
1079 1122
1080 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1123 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1081 1124
1082 while [[ "${1}" == --* ]]; do 1125 while [[ "${1}" == --* ]]; do
1083 if [[ "${1}" = "--build-only" ]]; then 1126 if [[ "${1}" = "--build-only" ]]; then
1084 build_only="build" 1127 build_only="build"
1085 elif [[ "${1}" == "--virtual" ]]; then 1128 elif [[ "${1}" == "--virtual" ]]; then
1086 virtual="true" 1129 virtual="true"
1087 else 1130 else
1088 die "java-pkg_jar-from called with unknown parameter: ${1}" 1131 die "java-pkg_getjar called with unknown parameter: ${1}"
1089 fi 1132 fi
1090 shift 1133 shift
1091 done 1134 done
1092 1135
1093 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1136 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1094 1137
1095 local pkg="${1}" target_jar="${2}" jar 1138 local pkg="${1}" target_jar="${2}" jar
1139
1140 if [[ "${EAPI}" == "1" ]]; then
1141 pkg="${pkg//:/-}"
1142 fi
1143
1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1144 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1097 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1145 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1098 1146
1099 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1147 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1100 local classpath 1148 local classpath
1104 java-pkg_ensure-dep "${build_only}" "${pkg}" 1152 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105 1153
1106 # Record the package(Virtual) as a dependency and then set build_only 1154 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded. 1155 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then 1156 if [[ -n "${virtual}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1109 java-pkg_record-jar_ "${pkg}" 1158 java-pkg_record-jar_ "${pkg}"
1110 build_only="true" 1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}"
1161 fi
1162 record_jar="true"
1111 fi 1163 fi
1112 1164
1113 for jar in ${classpath//:/ }; do 1165 for jar in ${classpath//:/ }; do
1114 if [[ ! -f "${jar}" ]] ; then 1166 if [[ ! -f "${jar}" ]] ; then
1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1167 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1116 fi 1168 fi
1117 1169
1118 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1170 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1119 # Only record jars that aren't build-only 1171 # Only record jars that aren't build-only
1120 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1172 if [[ -z "${record_jar}" ]]; then
1173 if [[ -z "${build_only}" ]]; then
1174 java-pkg_record-jar_ "${pkg}" "${jar}"
1175 else
1176 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1177 fi
1178 fi
1121 echo "${jar}" 1179 echo "${jar}"
1122 return 0 1180 return 0
1123 fi 1181 fi
1124 done 1182 done
1125 1183
1161 1219
1162 local pkgs="${1}" 1220 local pkgs="${1}"
1163 local jar="${2}" 1221 local jar="${2}"
1164 1222
1165 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1223 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1224
1225 if [[ "${EAPI}" == "1" ]]; then
1226 pkgs="${pkgs//:/-}"
1227 fi
1166 1228
1167 if [[ -z "${jar}" ]]; then 1229 if [[ -z "${jar}" ]]; then
1168 for pkg in ${pkgs//,/ }; do 1230 for pkg in ${pkgs//,/ }; do
1169 java-pkg_ensure-dep runtime "${pkg}" 1231 java-pkg_ensure-dep runtime "${pkg}"
1170 java-pkg_record-jar_ "${pkg}" 1232 java-pkg_record-jar_ "${pkg}"
1213 local pkgs="${1}" 1275 local pkgs="${1}"
1214 local jar="${2}" 1276 local jar="${2}"
1215 1277
1216 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1278 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1217 1279
1280 if [[ "${EAPI}" == "1" ]]; then
1281 pkgs="${pkgs//:/-}"
1282 fi
1283
1218 if [[ -z "${jar}" ]]; then 1284 if [[ -z "${jar}" ]]; then
1219 for pkg in ${pkgs//,/ }; do 1285 for pkg in ${pkgs//,/ }; do
1220 java-pkg_record-jar_ --optional "${pkg}" 1286 java-pkg_record-jar_ --optional "${pkg}"
1221 done 1287 done
1222 else 1288 else
1251 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1317 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1252 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1253 1319
1254 java-pkg_do_write_ 1320 java-pkg_do_write_
1255} 1321}
1322
1323# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_get-bootclasspath
1325#
1326# Returns classpath of a given bootclasspath-providing package version.
1327#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() {
1333 local version="${1}"
1334
1335 local bcp
1336 case "${version}" in
1337 auto)
1338 bcp="$(java-config -g BOOTCLASSPATH)"
1339 ;;
1340 1.5)
1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1342 ;;
1343 *)
1344 eerror "unknown parameter of java-pkg_get-bootclasspath"
1345 die "unknown parameter of java-pkg_get-bootclasspath"
1346 ;;
1347 esac
1348
1349 echo "${bcp}"
1350}
1351
1256 1352
1257# This function reads stdin, and based on that input, figures out how to 1353# This function reads stdin, and based on that input, figures out how to
1258# populate jars from the filesystem. 1354# populate jars from the filesystem.
1259# Need to figure out a good way of making use of this, ie be able to use a 1355# Need to figure out a good way of making use of this, ie be able to use a
1260# string that was built instead of stdin 1356# string that was built instead of stdin
1298# @section-begin helper 1394# @section-begin helper
1299# @section-summary Helper functions 1395# @section-summary Helper functions
1300# 1396#
1301# Various other functions to use from an ebuild 1397# Various other functions to use from an ebuild
1302# ------------------------------------------------------------------------------ 1398# ------------------------------------------------------------------------------
1303
1304# ------------------------------------------------------------------------------
1305# @ebuild-function java-pkg_need
1306#
1307# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1308# Currently supported virtuals are:
1309# javamail
1310# jdbc-stdext
1311# jaf
1312# jdbc-rowset
1313# jms
1314#
1315# @param $1 - Optionally indicate that the dependencies are controlled by
1316# a use flag by specifying '--use' Requires $2.
1317# @param $2 - USE flag which will enable the dependencies.
1318# @param $@ - virtual packages to add depenedencies for
1319# ------------------------------------------------------------------------------
1320# TODO rewrite to parse a line based declaration file instead -- karltk
1321#java-pkg_need() {
1322# debug-print-function ${FUNCNAME} $*
1323# local useflag
1324# if [[ ${1} == "--use" ]]; then
1325# useflag="${2}"
1326# shift 2
1327# fi
1328#
1329# if [[ -z ${1} ]]; then
1330# die "Must specify at least one virtual package."
1331# fi
1332#
1333# local depstr newdepstr
1334#
1335# for virtual in ${@}; do
1336# if has ${virtual} ${JAVA_PKG_VNEED}; then
1337# debug-print "Already registered virtual ${virtual}"
1338# continue
1339# fi
1340# case ${virtual} in
1341# javamail)
1342# debug-print "java-pkg_need: adding javamail dependencies"
1343# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1344# ;;
1345# jdbc-stdext)
1346# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1347# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1348# ;;
1349# jaf)
1350# debug-print "java-pkg_need: adding jaf dependencies"
1351# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1352# ;;
1353# jdbc-rowset)
1354# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1355# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1356# ;;
1357# jms)
1358# debug-print "java-pkg_need: adding jms dependencies"
1359# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1360# ;;
1361# *)
1362# die "Invalid virtual: ${virtual}"
1363# esac
1364#
1365# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1366#
1367# if [[ -n ${useflag} ]]; then
1368# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1369# else
1370# depstr="${depstr} ${newdepstr}"
1371# fi
1372# done
1373#
1374# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1375# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1376#
1377# export DEPEND="${DEPEND} ${depstr}"
1378# export RDEPEND="${RDEPEND} ${depstr}"
1379#}
1380 1399
1381# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
1382# @ebuild-function java-pkg_find-normal-jars 1401# @ebuild-function java-pkg_find-normal-jars
1383# 1402#
1384# Find the files with suffix .jar file in the given directory or $WORKDIR 1403# Find the files with suffix .jar file in the given directory or $WORKDIR
1550java-pkg_get-current-vm() { 1569java-pkg_get-current-vm() {
1551 echo ${GENTOO_VM} 1570 echo ${GENTOO_VM}
1552} 1571}
1553 1572
1554java-pkg_current-vm-matches() { 1573java-pkg_current-vm-matches() {
1555 hasq $(java-pkg_get-current-vm) ${@} 1574 has $(java-pkg_get-current-vm) ${@}
1556 return $? 1575 return $?
1557} 1576}
1558 1577
1559# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1560# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1665 1684
1666 echo ${flags} 1685 echo ${flags}
1667} 1686}
1668 1687
1669java-pkg_ensure-gcj() { 1688java-pkg_ensure-gcj() {
1670 if ! built_with_use sys-devel/gcc gcj ; then 1689 # was enforcing sys-devel/gcc[gcj]
1671 ewarn 1690 die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
1672 ewarn "You must build gcc with the gcj support to build with gcj"
1673 ewarn
1674 ebeep 5
1675 die "No GCJ support found!"
1676 fi
1677} 1691}
1678 1692
1679java-pkg_ensure-test() { 1693java-pkg_ensure-test() {
1680 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1694 # was enforcing USE=test if FEATURES=test
1681 && hasq test ${IUSE} && ! use test; 1695 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1682 then
1683 eerror "You specified FEATURES=test, but USE=test is needed"
1684 eerror "to pull in the additional dependencies for testing"
1685 die "Need USE=test enabled"
1686 fi
1687} 1696}
1688 1697
1689# ------------------------------------------------------------------------------ 1698# ------------------------------------------------------------------------------
1690# @ebuild-function java-pkg_register-ant-task 1699# @ebuild-function java-pkg_register-ant-task
1691# 1700#
1722 dodir /usr/share/ant/${TASKS_DIR} 1731 dodir /usr/share/ant/${TASKS_DIR}
1723 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1732 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1724} 1733}
1725 1734
1726# ------------------------------------------------------------------------------ 1735# ------------------------------------------------------------------------------
1727# @internal-function java-pkg_ant-tasks-from-deps
1728#
1729# Function to determine ANT_TASKS from DEPEND variable for backwards
1730# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1731# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1732# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1733# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1734# be a problem, the worst it can do is activace all tasks when not needed.
1735# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1736# insufficient dependencies, otherwise all available tasks are used for
1737# backwards compatilbility.
1738#
1739# @return "all" or "none"
1740# ------------------------------------------------------------------------------
1741java-pkg_ant-tasks-from-deps() {
1742 local found_ant found_ant_tasks
1743
1744 for dep in ${DEPEND}
1745 do
1746 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1747 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1748 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1749 done
1750
1751 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1752 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1753 echo "all"
1754 else
1755 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1756 # so we deactivate all tasks that may be installed
1757 echo "none"
1758 fi
1759}
1760
1761# ------------------------------------------------------------------------------
1762# @internal-function java-pkg_ant-tasks-depend 1736# @internal-function java-pkg_ant-tasks-depend
1763# 1737#
1764# Translates the WANT_ANT_TASKS variable into valid dependencies. 1738# Translates the WANT_ANT_TASKS variable into valid dependencies.
1765# ------------------------------------------------------------------------------ 1739# ------------------------------------------------------------------------------
1766java-pkg_ant-tasks-depend() { 1740java-pkg_ant-tasks-depend() {
1768 1742
1769 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1743 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1770 local DEP="" 1744 local DEP=""
1771 for i in ${WANT_ANT_TASKS} 1745 for i in ${WANT_ANT_TASKS}
1772 do 1746 do
1773 if [[ ${i} != ant-* ]]; then 1747 if [[ ${i} = ant-* ]]; then
1748 DEP="${DEP}dev-java/${i} "
1749 elif [[ ${i} = */*:* ]]; then
1750 DEP="${DEP}${i} "
1751 else
1774 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1752 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1775 return 1 1753 return 1
1776 fi 1754 fi
1777 DEP="${DEP}dev-java/${i} "
1778 done 1755 done
1779 echo ${DEP} 1756 echo ${DEP}
1780 return 0 1757 return 0
1781 else 1758 else
1782 return 0 1759 return 0
1783 fi 1760 fi
1784} 1761}
1785 1762
1763
1786# ------------------------------------------------------------------------------ 1764# ------------------------------------------------------------------------------
1787# @ebuild-function ejunit 1765# @internal-function ejunit_
1788# 1766#
1789# Junit wrapper function. Makes it easier to run the tests and checks for 1767# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1790# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1768# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1791# 1769#
1792# Examples: 1770# @param $1 - junit package (junit or junit-4)
1793# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1794# ejunit org.blinkenlights.jid3.test.AllTests
1795#
1796# @param $1 - -cp or -classpath 1771# @param $2 - -cp or -classpath
1797# @param $2 - classpath; junit and recorded dependencies get appended 1772# @param $3 - classpath; junit and recorded dependencies get appended
1798# @param $@ - the rest of the parameters are passed to java 1773# @param $@ - the rest of the parameters are passed to java
1799# ------------------------------------------------------------------------------
1800ejunit() { 1774ejunit_() {
1801 debug-print-function ${FUNCNAME} $* 1775 debug-print-function ${FUNCNAME} $*
1802 1776
1803 local pkgs 1777 local pkgs
1778 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1804 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1779 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1805 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1780 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1806 done 1781 done
1782 fi
1807 1783
1784 local junit=${1}
1785 shift 1
1786
1808 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1787 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1809 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1788 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1810 cp="${2}:${cp}" 1789 cp="${2}:${cp}"
1811 shift 2 1790 shift 2
1812 else 1791 else
1813 cp=".:${cp}" 1792 cp=".:${cp}"
1814 fi 1793 fi
1815 1794
1816 local runner=junit.textui.TestRunner 1795 local runner=junit.textui.TestRunner
1796 if [[ "${junit}" == "junit-4" ]] ; then
1797 runner=org.junit.runner.JUnitCore
1798 fi
1817 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1799 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1818 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1800 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1819} 1801}
1820 1802
1821# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1804# @ebuild-function ejunit
1805#
1806# Junit wrapper function. Makes it easier to run the tests and checks for
1807# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1808#
1809# Examples:
1810# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1811# ejunit org.blinkenlights.jid3.test.AllTests
1812# ejunit org.blinkenlights.jid3.test.FirstTest \
1813# org.blinkenlights.jid3.test.SecondTest
1814#
1815# @param $1 - -cp or -classpath
1816# @param $2 - classpath; junit and recorded dependencies get appended
1817# @param $@ - the rest of the parameters are passed to java
1818# ------------------------------------------------------------------------------
1819ejunit() {
1820 debug-print-function ${FUNCNAME} $*
1821
1822 ejunit_ "junit" "${@}"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @ebuild-function ejunit4
1827#
1828# Junit4 wrapper function. Makes it easier to run the tests and checks for
1829# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1830#
1831# Examples:
1832# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1833# ejunit4 org.blinkenlights.jid3.test.AllTests
1834# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1835# org.blinkenlights.jid3.test.SecondTest
1836#
1837# @param $1 - -cp or -classpath
1838# @param $2 - classpath; junit and recorded dependencies get appended
1839# @param $@ - the rest of the parameters are passed to java
1840# ------------------------------------------------------------------------------
1841ejunit4() {
1842 debug-print-function ${FUNCNAME} $*
1843
1844 ejunit_ "junit-4" "${@}"
1845}
1846
1847# ------------------------------------------------------------------------------
1822# @section-end helper 1848# @section-end helper
1823# ------------------------------------------------------------------------------ 1849# ------------------------------------------------------------------------------
1850
1851# ------------------------------------------------------------------------------
1852# @eclass-src_prepare
1853#
1854# src_prepare Searches for bundled jars
1855# Don't call directly, but via java-pkg-2_src_prepare!
1856# ------------------------------------------------------------------------------
1857
1858java-utils-2_src_prepare() {
1859 [[ ${EBUILD_PHASE} == prepare ]] &&
1860 java-pkg_func-exists java_prepare && java_prepare
1861
1862 # Remember that eant will call this unless called via Portage
1863 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1864 echo "Searching for bundled jars:"
1865 java-pkg_find-normal-jars || echo "None found."
1866 echo "Searching for bundled classes (no output if none found):"
1867 find "${WORKDIR}" -name "*.class"
1868 echo "Search done."
1869 fi
1870 touch "${T}/java-utils-2_src_prepare-run"
1871}
1872
1873# ------------------------------------------------------------------------------
1874# @eclass-pkg_preinst
1875#
1876# pkg_preinst Searches for missing and unneeded dependencies
1877# Don't call directly, but via java-pkg-2_pkg_preinst!
1878# ------------------------------------------------------------------------------
1879
1880java-utils-2_pkg_preinst() {
1881 if is-java-strict; then
1882 if has_version dev-java/java-dep-check; then
1883 [[ -e "${JAVA_PKG_ENV}" ]] || return
1884 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1885 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1886 ewarn "Possibly unneeded dependencies found in package.env:"
1887 for dep in ${output}; do
1888 ewarn "\t${dep}"
1889 done
1890 fi
1891 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1892 ewarn "${output}"
1893 fi
1894 else
1895 eerror "Install dev-java/java-dep-check for dependency checking"
1896 fi
1897 fi
1898}
1824 1899
1825# ------------------------------------------------------------------------------ 1900# ------------------------------------------------------------------------------
1826# @section-begin build 1901# @section-begin build
1827# @section-summary Build functions 1902# @section-summary Build functions
1828# 1903#
1837# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1912# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1838# variables: 1913# variables:
1839# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1914# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1840# gentoo.classpath property. Be sure to call 1915# gentoo.classpath property. Be sure to call
1841# java-ant_rewrite-classpath in src_unpack. 1916# java-ant_rewrite-classpath in src_unpack.
1842# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1917# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1918# for build-time purposes, the dependency is not recorded to
1919# package.env!
1843# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1920# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1844# ------------------------------------------------------------------------------ 1921# ------------------------------------------------------------------------------
1845eant() { 1922eant() {
1846 debug-print-function ${FUNCNAME} $* 1923 debug-print-function ${FUNCNAME} $*
1847 1924
1848 if [[ ${EBUILD_PHASE} = compile ]]; then 1925 if [[ ${EBUILD_PHASE} = compile ]]; then
1849 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1926 java-ant-2_src_configure
1850 # finally get rid of the hooks without breaking stuff 1927 java-utils-2_src_prepare
1851
1852 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1853 && java-ant_ignore-system-classes "${S}/build.xml"
1854
1855 if hasq java-ant-2 ${INHERITED}; then
1856 java-ant_bsfix
1857 fi 1928 fi
1858 1929
1859 # eant can be called multiple times
1860 JAVA_PKG_BSFIX="off"
1861
1862 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1863 echo "Searching for bundled jars:"
1864 java-pkg_find-normal-jars || echo "None found."
1865 echo "Searching for bundled classes (no output if none found):"
1866 find "${WORKDIR}" -name "*.class"
1867 echo "Search done."
1868 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1869 fi
1870 fi
1871
1872 if ! hasq java-ant-2 ${INHERITED}; then 1930 if ! has java-ant-2 ${INHERITED}; then
1873 local msg="You should inherit java-ant-2 when using eant" 1931 local msg="You should inherit java-ant-2 when using eant"
1874 java-pkg_announce-qa-violation "${msg}" 1932 java-pkg_announce-qa-violation "${msg}"
1875 fi 1933 fi
1876 1934
1877 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1935 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1911 echo "more info." 1969 echo "more info."
1912 fi 1970 fi
1913 fi 1971 fi
1914 done 1972 done
1915 1973
1916 # we use this in src_* so we run ant from / 1974 # parse WANT_ANT_TASKS for atoms
1917 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1975 local want_ant_tasks
1918 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1976 for i in ${WANT_ANT_TASKS}; do
1919 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1977 if [[ ${i} = */*:* ]]; then
1920 1978 i=${i#*/}
1921 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1979 i=${i%:0}
1922 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1980 want_ant_tasks+="${i/:/-} "
1923
1924 if is-java-strict; then
1925 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1926 if [[ -z "${ANT_TASKS}" ]]; then
1927 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1928 fi
1929 else 1981 else
1982 want_ant_tasks+="${i} "
1983 fi
1984 done
1985 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1986 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1987
1988 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1989 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1990
1930 # if ant-tasks is not set by ebuild or forced, activate all of them 1991 # if ant-tasks is not set by ebuild or forced, use none
1931 ANT_TASKS="${ANT_TASKS:-all}" 1992 ANT_TASKS="${ANT_TASKS:-none}"
1932 fi
1933 1993
1934 # at this point, ANT_TASKS should be "all", "none" or explicit list 1994 # at this point, ANT_TASKS should be "all", "none" or explicit list
1935 if [[ "${ANT_TASKS}" == "all" ]]; then 1995 if [[ "${ANT_TASKS}" == "all" ]]; then
1936 einfo "Using all available ANT_TASKS" 1996 einfo "Using all available ANT_TASKS"
1937 elif [[ "${ANT_TASKS}" == "none" ]]; then 1997 elif [[ "${ANT_TASKS}" == "none" ]]; then
1938 einfo "Disabling all optional ANT_TASKS" 1998 einfo "Disabling all optional ANT_TASKS"
1939 else 1999 else
1940 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 2000 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1941 fi 2001 fi
1942 2002
1943 export ANT_TASKS 2003 export ANT_TASKS
1944 fi
1945 2004
1946 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 2005 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1947 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 2006 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1948 2007
1949 local gcp="${EANT_GENTOO_CLASSPATH}" 2008 local gcp="${EANT_GENTOO_CLASSPATH}"
1950 local getjarsarg="" 2009 local getjarsarg=""
1951 2010
1952 if [[ ${EBUILD_PHASE} = "test" ]]; then 2011 if [[ ${EBUILD_PHASE} = "test" ]]; then
1953 antflags="${antflags} -DJunit.present=true" 2012 antflags="${antflags} -DJunit.present=true"
1954 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2013 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1955 getjarsarg="--with-dependencies" 2014 getjarsarg="--with-dependencies"
2015 else
2016 antflags="${antflags} -Dmaven.test.skip=true"
1956 fi 2017 fi
1957 2018
1958 local cp 2019 local cp
1959 2020
1960 for atom in ${gcp}; do 2021 for atom in ${gcp}; do
1961 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2022 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1962 done 2023 done
1963 2024
2025 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2026
1964 if [[ ${cp} ]]; then 2027 if [[ ${cp} ]]; then
1965 # It seems ant does not like single quotes around ${cp} 2028 # It seems ant does not like single quotes around ${cp}
2029 cp=${cp#:}
2030 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2031 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1966 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2032 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1967 fi 2033 fi
1968 2034
1969 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2035 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1970 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2036 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1971 ant ${antflags} "${@}" || die "eant failed" 2037 ant ${antflags} "${@}" || die "eant failed"
2072# call it during each of the phases of the merge process. 2138# call it during each of the phases of the merge process.
2073# 2139#
2074# ----------------------------------------------------------------------------- 2140# -----------------------------------------------------------------------------
2075java-pkg_init() { 2141java-pkg_init() {
2076 debug-print-function ${FUNCNAME} $* 2142 debug-print-function ${FUNCNAME} $*
2143
2144 # Don't set up build environment if installing from binary. #206024 #258423
2145 [[ "${MERGE_TYPE}" == "binary" ]] && return
2146 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2147 # work nothing is lost.
2148 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2149
2077 unset JAVAC 2150 unset JAVAC
2078 unset JAVA_HOME 2151 unset JAVA_HOME
2152
2153 java-config --help >/dev/null || {
2154 eerror ""
2155 eerror "Can't run java-config --help"
2156 eerror "Have you upgraded python recently but haven't"
2157 eerror "run python-updater yet?"
2158 die "Can't run java-config --help"
2159 }
2079 2160
2080 # People do all kinds of weird things. 2161 # People do all kinds of weird things.
2081 # http://forums.gentoo.org/viewtopic-p-3943166.html 2162 # http://forums.gentoo.org/viewtopic-p-3943166.html
2082 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2163 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2083 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2164 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2121 export CLASSPATH= 2202 export CLASSPATH=
2122 2203
2123 # Unset external ANT_ stuff 2204 # Unset external ANT_ stuff
2124 export ANT_TASKS= 2205 export ANT_TASKS=
2125 export ANT_OPTS= 2206 export ANT_OPTS=
2207 export ANT_RESPECT_JAVA_HOME=
2126} 2208}
2127 2209
2128# ------------------------------------------------------------------------------ 2210# ------------------------------------------------------------------------------
2129# @function-internal java-pkg-init-compiler_ 2211# @function-internal java-pkg-init-compiler_
2130# 2212#
2221 done 2303 done
2222 2304
2223 # If it hasn't been defined already, default to javac 2305 # If it hasn't been defined already, default to javac
2224 if [[ -z ${GENTOO_COMPILER} ]]; then 2306 if [[ -z ${GENTOO_COMPILER} ]]; then
2225 if [[ -n ${compilers} ]]; then 2307 if [[ -n ${compilers} ]]; then
2226 einfo "No suitable compiler found: defaulting javac for compilation" 2308 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2227 else 2309 else
2228 # probably don't need to notify users about the default. 2310 # probably don't need to notify users about the default.
2229 :;#einfo "Defaulting to javac for compilation" 2311 :;#einfo "Defaulting to javac for compilation"
2230 fi 2312 fi
2313 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2314 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2315 else
2231 export GENTOO_COMPILER=javac 2316 export GENTOO_COMPILER=javac
2317 fi
2232 else 2318 else
2233 einfo "Using ${GENTOO_COMPILER} for compilation" 2319 einfo "Using ${GENTOO_COMPILER} for compilation"
2234 fi 2320 fi
2235 2321
2236} 2322}
2287 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2373 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2288 # Create package.env 2374 # Create package.env
2289 ( 2375 (
2290 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2376 echo "DESCRIPTION=\"${DESCRIPTION}\""
2291 echo "GENERATION=\"2\"" 2377 echo "GENERATION=\"2\""
2378 echo "SLOT=\"${SLOT}\""
2379 echo "CATEGORY=\"${CATEGORY}\""
2380 echo "PVR=\"${PVR}\""
2292 2381
2293 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2382 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2294 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2383 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2295 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2384 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2296 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2385 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2297 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2386 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2298 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2387 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2299 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2388 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2300 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2389 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2390 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2391 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2301 ) > "${JAVA_PKG_ENV}" 2392 ) > "${JAVA_PKG_ENV}"
2302 2393
2303 # register target/source 2394 # register target/source
2304 local target="$(java-pkg_get-target)" 2395 local target="$(java-pkg_get-target)"
2305 local source="$(java-pkg_get-source)" 2396 local source="$(java-pkg_get-source)"
2338# ------------------------------------------------------------------------------ 2429# ------------------------------------------------------------------------------
2339# @internal-function java-pkg_record-jar_ 2430# @internal-function java-pkg_record-jar_
2340# 2431#
2341# Record an (optional) dependency to the package.env 2432# Record an (optional) dependency to the package.env
2342# @param --optional - record dependency as optional 2433# @param --optional - record dependency as optional
2434# @param --build - record dependency as build_only
2343# @param $1 - package to record 2435# @param $1 - package to record
2344# @param $2 - (optional) jar of package to record 2436# @param $2 - (optional) jar of package to record
2345# ------------------------------------------------------------------------------ 2437# ------------------------------------------------------------------------------
2346JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2438JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2347JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2439JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2440JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2348 2441
2349java-pkg_record-jar_() { 2442java-pkg_record-jar_() {
2350 debug-print-function ${FUNCNAME} $* 2443 debug-print-function ${FUNCNAME} $*
2351 2444
2352 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2445 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2353 if [[ "${1}" == "--optional" ]]; then 2446 case "${1}" in
2354 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2447 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2355 shift 2448 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2356 fi 2449 esac
2357 2450
2358 local pkg=${1} jar=${2} append 2451 local pkg=${1} jar=${2} append
2359 if [[ -z "${jar}" ]]; then 2452 if [[ -z "${jar}" ]]; then
2360 append="${pkg}" 2453 append="${pkg}"
2361 else 2454 else
2414# 2507#
2415# @return 0 - function is declared 2508# @return 0 - function is declared
2416# @return 1 - function is undeclared 2509# @return 1 - function is undeclared
2417# ------------------------------------------------------------------------------ 2510# ------------------------------------------------------------------------------
2418java-pkg_func-exists() { 2511java-pkg_func-exists() {
2419 if [[ -n "$(declare -f ${1})" ]]; then 2512 declare -F ${1} > /dev/null
2420 return 0
2421 else
2422 return 1
2423 fi
2424} 2513}
2425 2514
2426# ------------------------------------------------------------------------------ 2515# ------------------------------------------------------------------------------
2427# @internal-function java-pkg_setup-vm 2516# @internal-function java-pkg_setup-vm
2428# 2517#
2429# Sets up the environment for a specific VM 2518# Sets up the environment for a specific VM
2430# 2519#
2431# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
2432java-pkg_setup-vm() { 2521java-pkg_setup-vm() {
2433 debug-print-function ${FUNCNAME} $* 2522 debug-print-function ${FUNCNAME} $*
2434
2435 export LANG="C" LC_ALL="C"
2436 2523
2437 local vendor="$(java-pkg_get-vm-vendor)" 2524 local vendor="$(java-pkg_get-vm-vendor)"
2438 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2525 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2439 addpredict "/dev/random" 2526 addpredict "/dev/random"
2440 elif [[ "${vendor}" == "ibm" ]]; then 2527 elif [[ "${vendor}" == "ibm" ]]; then
2441 addpredict "/proc/self/maps" 2528 addpredict "/proc/self/maps"
2442 addpredict "/proc/cpuinfo" 2529 addpredict "/proc/cpuinfo"
2530 addpredict "/proc/self/coredump_filter"
2531 elif [[ "${vendor}" == "oracle" ]]; then
2532 addpredict "/dev/random"
2533 addpredict "/proc/self/coredump_filter"
2534 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2535 addpredict "/dev/random"
2536 addpredict "/proc/self/coredump_filter"
2443 elif [[ "${vendor}" == "jrockit" ]]; then 2537 elif [[ "${vendor}" == "jrockit" ]]; then
2444 addpredict "/proc/cpuinfo" 2538 addpredict "/proc/cpuinfo"
2445 fi 2539 fi
2446} 2540}
2447 2541
2448# ------------------------------------------------------------------------------ 2542# ------------------------------------------------------------------------------
2449# @internal-function java-pkg_needs-vm 2543# @internal-function java-pkg_needs-vm
2450# 2544#
2451# Does the current package depend on virtual/jdk? 2545# Does the current package depend on virtual/jdk or does it set
2546# JAVA_PKG_WANT_BUILD_VM?
2452# 2547#
2453# @return 0 - Package depends on virtual/jdk 2548# @return 0 - Package depends on virtual/jdk
2454# @return 1 - Package does not depend on virtual/jdk 2549# @return 1 - Package does not depend on virtual/jdk
2455# ------------------------------------------------------------------------------ 2550# ------------------------------------------------------------------------------
2456java-pkg_needs-vm() { 2551java-pkg_needs-vm() {
2457 debug-print-function ${FUNCNAME} $* 2552 debug-print-function ${FUNCNAME} $*
2458 2553
2459 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2554 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2460 return 0 2555 return 0
2461 fi 2556 fi
2557
2558 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2462 2559
2463 return 1 2560 return 1
2464} 2561}
2465 2562
2466# ------------------------------------------------------------------------------ 2563# ------------------------------------------------------------------------------
2492# ------------------------------------------------------------------------------ 2589# ------------------------------------------------------------------------------
2493java-pkg_get-vm-version() { 2590java-pkg_get-vm-version() {
2494 debug-print-function ${FUNCNAME} $* 2591 debug-print-function ${FUNCNAME} $*
2495 2592
2496 java-config -g PROVIDES_VERSION 2593 java-config -g PROVIDES_VERSION
2594}
2595
2596# ------------------------------------------------------------------------------
2597# @internal-function java-pkg_build-vm-from-handle
2598#
2599# Selects a build vm from a list of vm handles. First checks for the system-vm
2600# beeing usable, then steps through the listed handles till a suitable vm is
2601# found.
2602#
2603# @return - VM handle of an available JDK
2604# ------------------------------------------------------------------------------
2605java-pkg_build-vm-from-handle() {
2606 debug-print-function ${FUNCNAME} "$*"
2607
2608 local vm
2609 vm=$(java-pkg_get-current-vm)
2610 if [[ $? != 0 ]]; then
2611 eerror "${FUNCNAME}: Failed to get active vm"
2612 return 1
2613 fi
2614
2615 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2616 echo ${vm}
2617 return 0
2618 fi
2619
2620 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2621 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2622 echo ${vm}
2623 return 0
2624 fi
2625 done
2626
2627 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2628 return 1
2497} 2629}
2498 2630
2499# ------------------------------------------------------------------------------ 2631# ------------------------------------------------------------------------------
2500# @internal-function java-pkg_switch-vm 2632# @internal-function java-pkg_switch-vm
2501# 2633#
2512 # If you're forcing the VM, I hope you know what your doing... 2644 # If you're forcing the VM, I hope you know what your doing...
2513 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2645 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2514 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2646 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2515 # if we're allowed to switch the vm... 2647 # if we're allowed to switch the vm...
2516 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2648 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2517 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2649 # if there is an explicit list of handles to choose from
2518 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2650 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2519 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2651 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2652 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2653 if [[ $? != 0 ]]; then
2654 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2655 die "${FUNCNAME}: Failed to determine VM for building"
2656 fi
2657 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2658 # they can't be deduced from handles.
2659 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2660 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2661 die "Specify JAVA_PKG_WANT_SOURCE"
2662 fi
2663 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2664 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2665 die "Specify JAVA_PKG_WANT_TARGET"
2666 fi
2667 # otherwise determine a vm from dep string
2520 else 2668 else
2669 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2521 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2670 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2671 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2672 eerror "Unable to determine VM for building from dependencies:"
2673 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2674 die "Failed to determine VM for building."
2675 fi
2522 fi 2676 fi
2523 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2524 eerror "Unable to determine VM for building from dependencies:"
2525 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2526 echo "VNEED: ${JAVA_PKG_VNEED}"
2527 die "Failed to determine VM for building."
2528 else
2529 export GENTOO_VM 2677 export GENTOO_VM
2530 fi
2531 # otherwise just make sure the current VM is sufficient 2678 # otherwise just make sure the current VM is sufficient
2532 else 2679 else
2533 java-pkg_ensure-vm-version-sufficient 2680 java-pkg_ensure-vm-version-sufficient
2534 fi 2681 fi
2535 debug-print "Using: $(java-config -f)" 2682 debug-print "Using: $(java-config -f)"
2570# 2717#
2571# Enhanced die for Java packages, which displays some information that may be 2718# Enhanced die for Java packages, which displays some information that may be
2572# useful for debugging bugs on bugzilla. 2719# useful for debugging bugs on bugzilla.
2573# ------------------------------------------------------------------------------ 2720# ------------------------------------------------------------------------------
2574#register_die_hook java-pkg_die 2721#register_die_hook java-pkg_die
2575if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2722if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2576 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2723 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2577fi 2724fi
2578 2725
2579java-pkg_die() { 2726java-pkg_die() {
2580 echo "!!! When you file a bug report, please include the following information:" >&2 2727 echo "!!! When you file a bug report, please include the following information:" >&2
2604# not. 2751# not.
2605# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2752# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2606# ------------------------------------------------------------------------------ 2753# ------------------------------------------------------------------------------
2607java-pkg_verify-classes() { 2754java-pkg_verify-classes() {
2608 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2755 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2756
2757 local version_verify="/usr/bin/class-version-verify.py"
2758
2759 if [[ ! -x "${version_verify}" ]]; then
2760 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2761 fi
2762
2763 if [[ ! -x "${version_verify}" ]]; then
2764 ewarn "Unable to perform class version checks as"
2765 ewarn "class-version-verify.py is unavailable"
2766 ewarn "Please install dev-java/javatoolkit."
2767 return
2768 fi
2769
2609 local target=$(java-pkg_get-target) 2770 local target=$(java-pkg_get-target)
2610 local result 2771 local result
2611 local log="${T}/class-version-verify.log" 2772 local log="${T}/class-version-verify.log"
2612 if [[ -n "${1}" ]]; then 2773 if [[ -n "${1}" ]]; then
2613 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2774 ${version_verify} -v -t ${target} "${1}" > "${log}"
2614 result=$? 2775 result=$?
2615 else 2776 else
2616 ebegin "Verifying java class versions (target: ${target})" 2777 ebegin "Verifying java class versions (target: ${target})"
2617 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2778 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2618 result=$? 2779 result=$?
2619 eend ${result} 2780 eend ${result}
2620 fi 2781 fi
2621 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2782 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2622 if [[ ${result} != 0 ]]; then 2783 if [[ ${result} != 0 ]]; then
2640 2801
2641 local limit_to="${1}" 2802 local limit_to="${1}"
2642 local target_pkg="${2}" 2803 local target_pkg="${2}"
2643 local dev_error="" 2804 local dev_error=""
2644 2805
2806 # remove the version specification, which may include globbing (* and [123])
2645 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2807 local stripped_pkg=$(echo "${target_pkg}" | sed \
2646 's/-[0-9]*\(\.[0-9]\)*$//') 2808 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2647 2809
2648 debug-print "Matching against: ${stripped_pkg}" 2810 debug-print "Matching against: ${stripped_pkg}"
2649 2811
2650 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2812 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2651 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2813 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2701 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2863 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2702 fi 2864 fi
2703} 2865}
2704 2866
2705java-pkg_check-jikes() { 2867java-pkg_check-jikes() {
2706 if hasq jikes ${IUSE}; then 2868 if has jikes ${IUSE}; then
2707 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2869 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2708 fi 2870 fi
2709} 2871}
2710 2872
2711java-pkg_announce-qa-violation() { 2873java-pkg_announce-qa-violation() {
2727is-java-strict() { 2889is-java-strict() {
2728 [[ -n ${JAVA_PKG_STRICT} ]] 2890 [[ -n ${JAVA_PKG_STRICT} ]]
2729 return $? 2891 return $?
2730} 2892}
2731 2893
2894
2732# ------------------------------------------------------------------------------ 2895# ------------------------------------------------------------------------------
2733# @eclass-end 2896# @eclass-end
2734# ------------------------------------------------------------------------------ 2897# ------------------------------------------------------------------------------

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.151

  ViewVC Help
Powered by ViewVC 1.1.20