/[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.146
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.101 2008/01/12 15:03:13 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.146 2011/10/29 13:17:15 caster 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#
224 ( # dont want to pollute calling env 241 ( # dont want to pollute calling env
225 insinto "${dest}" 242 insinto "${dest}"
226 doins -r "$@" 243 doins -r "$@"
227 ) || die "Installing examples failed" 244 ) || die "Installing examples failed"
228 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
229} 249}
230 250
231# ----------------------------------------------------------------------------- 251# -----------------------------------------------------------------------------
232# @ebuild-function java-pkg_dojar 252# @ebuild-function java-pkg_dojar
233# 253#
291 done 311 done
292 312
293 java-pkg_do_write_ 313 java-pkg_do_write_
294} 314}
295 315
296
297# ------------------------------------------------------------------------------ 316# ------------------------------------------------------------------------------
298# @internal-function depend-java-query 317# @internal-function depend-java-query
299# 318#
300# 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.
301# 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
366 if [[ ${jar} = *\** ]]; then 385 if [[ ${jar} = *\** ]]; then
367 eerror "The argument ${jar} to ${FUNCNAME}" 386 eerror "The argument ${jar} to ${FUNCNAME}"
368 eerror "has * in it. If you want it to glob in" 387 eerror "has * in it. If you want it to glob in"
369 eerror '${D} add ${D} to the argument.' 388 eerror '${D} add ${D} to the argument.'
370 fi 389 fi
390 debug-print "${jar} or ${D}${jar} not found"
371 die "${jar} does not exist" 391 die "${jar} does not exist"
372 fi 392 fi
373 done 393 done
374 394
375 java-pkg_do_write_ 395 java-pkg_do_write_
430# @param $@ - JNI libraries to install 450# @param $@ - JNI libraries to install
431# ------------------------------------------------------------------------------ 451# ------------------------------------------------------------------------------
432java-pkg_doso() { 452java-pkg_doso() {
433 debug-print-function ${FUNCNAME} $* 453 debug-print-function ${FUNCNAME} $*
434 454
435 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
436 java-pkg_check-phase install 455 java-pkg_check-phase install
437 456
438 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 457 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
439 458
440 java-pkg_init_paths_ 459 java-pkg_init_paths_
441 460
442 local lib 461 local lib
443 # for each lib 462 # for each lib
446 if [[ -e "${lib}" ]] ; then 465 if [[ -e "${lib}" ]] ; then
447 # install if it isn't a symlink 466 # install if it isn't a symlink
448 if [[ ! -L "${lib}" ]] ; then 467 if [[ ! -L "${lib}" ]] ; then
449 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 468 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
450 INSOPTIONS="${LIBOPTIONS}" \ 469 INSOPTIONS="${LIBOPTIONS}" \
451 doins "${lib}" || "failed to install ${lib}" 470 doins "${lib}" || die "failed to install ${lib}"
452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 471 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 472 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
454 # otherwise make a symlink to the symlink's origin 473 # otherwise make a symlink to the symlink's origin
455 else 474 else
456 # TODO use dosym 475 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" 476 debug-print "${lib} is a symlink, linking accordantly"
460 fi 477 fi
461 # otherwise die 478 # otherwise die
462 else 479 else
463 die "${lib} does not exist" 480 die "${lib} does not exist"
464 fi 481 fi
480java-pkg_regso() { 497java-pkg_regso() {
481 debug-print-function ${FUNCNAME} $* 498 debug-print-function ${FUNCNAME} $*
482 499
483 java-pkg_check-phase install 500 java-pkg_check-phase install
484 501
485 [[ ${#} -lt 1 ]] && "at least one argument needed" 502 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
486 503
487 java-pkg_init_paths_ 504 java-pkg_init_paths_
488 505
489 local lib target_dir 506 local lib target_dir
490 for lib in "$@" ; do 507 for lib in "$@" ; do
613 630
614 # Let's make a symlink to the directory we have everything else under 631 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die 632 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616 633
617 if [[ ${symlink} ]]; then 634 if [[ ${symlink} ]]; then
635 debug-print "symlinking ${dest}/{api,${symlink}}"
618 dosym ${dest}/{api,${symlink}} || die 636 dosym ${dest}/{api,${symlink}} || die
619 fi 637 fi
620} 638}
621 639
622# ------------------------------------------------------------------------------ 640# ------------------------------------------------------------------------------
647 665
648 [[ ${#} -lt 1 ]] && die "At least one argument needed" 666 [[ ${#} -lt 1 ]] && die "At least one argument needed"
649 667
650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 668 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 669 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
652 if is-java-strict; then 670 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 671 fi
660 672
661 java-pkg_init_paths_ 673 java-pkg_init_paths_
662 674
663 local zip_name="${PN}-src.zip" 675 local zip_name="${PN}-src.zip"
880 892
881 local build_only="" 893 local build_only=""
882 local destdir="." 894 local destdir="."
883 local deep="" 895 local deep=""
884 local virtual="" 896 local virtual=""
897 local record_jar=""
885 898
886 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 899 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
887 900
888 while [[ "${1}" == --* ]]; do 901 while [[ "${1}" == --* ]]; do
889 if [[ "${1}" = "--build-only" ]]; then 902 if [[ "${1}" = "--build-only" ]]; then
903 916
904 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 917 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
905 918
906 [[ -z ${target_pkg} ]] && die "Must specify a package" 919 [[ -z ${target_pkg} ]] && die "Must specify a package"
907 920
921 if [[ "${EAPI}" == "1" ]]; then
922 target_pkg="${target_pkg//:/-}"
923 fi
924
908 # default destjar to the target jar 925 # default destjar to the target jar
909 [[ -z "${destjar}" ]] && destjar="${target_jar}" 926 [[ -z "${destjar}" ]] && destjar="${target_jar}"
910 927
911 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}."
912 local classpath 929 local classpath
920 for pkg in ${target_pkg//,/ }; do 937 for pkg in ${target_pkg//,/ }; do
921 java-pkg_ensure-dep "${build_only}" "${pkg}" 938 java-pkg_ensure-dep "${build_only}" "${pkg}"
922 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 939 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
923 done 940 done
924 # setting this disables further record-jar_ calls later 941 # setting this disables further record-jar_ calls later
925 build_only="build" 942 record_jar="true"
926 else 943 else
927 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 944 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
928 fi 945 fi
929 946
930 # Record the entire virtual as a dependency so that 947 # Record the entire virtual as a dependency so that
931 # no jars are missed. 948 # no jars are missed.
932 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 949 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
933 java-pkg_record-jar_ "${target_pkg}" 950 java-pkg_record-jar_ "${target_pkg}"
934 # setting this disables further record-jars_ calls later 951 # setting this disables further record-jars_ calls later
935 build_only="build" 952 record_jar="true"
936 fi 953 fi
937 954
938 pushd ${destdir} > /dev/null \ 955 pushd ${destdir} > /dev/null \
939 || die "failed to change directory to ${destdir}" 956 || die "failed to change directory to ${destdir}"
940 957
948 # If no specific target jar was indicated, link it 965 # If no specific target jar was indicated, link it
949 if [[ -z "${target_jar}" ]] ; then 966 if [[ -z "${target_jar}" ]] ; then
950 [[ -f "${target_jar}" ]] && rm "${target_jar}" 967 [[ -f "${target_jar}" ]] && rm "${target_jar}"
951 ln -snf "${jar}" \ 968 ln -snf "${jar}" \
952 || 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
953 [[ -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
954 # otherwise, if the current jar is the target jar, link it 977 # otherwise, if the current jar is the target jar, link it
955 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 978 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
956 [[ -f "${destjar}" ]] && rm "${destjar}" 979 [[ -f "${destjar}" ]] && rm "${destjar}"
957 ln -snf "${jar}" "${destjar}" \ 980 ln -snf "${jar}" "${destjar}" \
958 || 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
959 [[ -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
960 popd > /dev/null 989 popd > /dev/null
961 return 0 990 return 0
962 fi 991 fi
963 done 992 done
964 popd > /dev/null 993 popd > /dev/null
1023 done 1052 done
1024 1053
1025 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1054 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1026 1055
1027 1056
1028 local classpath pkgs="${1}" 1057 local pkgs="${1}"
1058
1059 if [[ "${EAPI}" == "1" ]]; then
1060 pkgs="${pkgs//:/-}"
1061 fi
1062
1029 jars="$(java-config ${deep} --classpath=${pkgs})" 1063 jars="$(java-config ${deep} --classpath=${pkgs})"
1030 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1064 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1031 debug-print "${pkgs}:${jars}" 1065 debug-print "${pkgs}:${jars}"
1032 1066
1033 for pkg in ${pkgs//,/ }; do 1067 for pkg in ${pkgs//,/ }; do
1034 java-pkg_ensure-dep "${build_only}" "${pkg}" 1068 java-pkg_ensure-dep "${build_only}" "${pkg}"
1035 done 1069 done
1036 1070
1037 if [[ -z "${classpath}" ]]; then 1071 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 1072 if [[ -z "${build_only}" ]]; then
1045 for pkg in ${pkgs//,/ }; do
1046 java-pkg_record-jar_ "${pkg}" 1073 java-pkg_record-jar_ "${pkg}"
1074 else
1075 java-pkg_record-jar_ --build-only "${pkg}"
1076 fi
1047 done 1077 done
1048 fi
1049 1078
1050 echo "${classpath}" 1079 echo "${jars}"
1051} 1080}
1052 1081
1053# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1054# @ebuild-function java-pkg_getjar 1083# @ebuild-function java-pkg_getjar
1055# 1084#
1074java-pkg_getjar() { 1103java-pkg_getjar() {
1075 debug-print-function ${FUNCNAME} $* 1104 debug-print-function ${FUNCNAME} $*
1076 1105
1077 local build_only="" 1106 local build_only=""
1078 local virtual="" 1107 local virtual=""
1108 local record_jar=""
1079 1109
1080 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1110 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1081 1111
1082 while [[ "${1}" == --* ]]; do 1112 while [[ "${1}" == --* ]]; do
1083 if [[ "${1}" = "--build-only" ]]; then 1113 if [[ "${1}" = "--build-only" ]]; then
1084 build_only="build" 1114 build_only="build"
1085 elif [[ "${1}" == "--virtual" ]]; then 1115 elif [[ "${1}" == "--virtual" ]]; then
1086 virtual="true" 1116 virtual="true"
1087 else 1117 else
1088 die "java-pkg_jar-from called with unknown parameter: ${1}" 1118 die "java-pkg_getjar called with unknown parameter: ${1}"
1089 fi 1119 fi
1090 shift 1120 shift
1091 done 1121 done
1092 1122
1093 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1123 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1094 1124
1095 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
1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1131 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1097 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1132 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1098 1133
1099 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?"
1100 local classpath 1135 local classpath
1104 java-pkg_ensure-dep "${build_only}" "${pkg}" 1139 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105 1140
1106 # Record the package(Virtual) as a dependency and then set build_only 1141 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded. 1142 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then 1143 if [[ -n "${virtual}" ]]; then
1144 if [[ -z "${build_only}" ]]; then
1109 java-pkg_record-jar_ "${pkg}" 1145 java-pkg_record-jar_ "${pkg}"
1110 build_only="true" 1146 else
1147 java-pkg_record-jar_ --build-only "${pkg}"
1148 fi
1149 record_jar="true"
1111 fi 1150 fi
1112 1151
1113 for jar in ${classpath//:/ }; do 1152 for jar in ${classpath//:/ }; do
1114 if [[ ! -f "${jar}" ]] ; then 1153 if [[ ! -f "${jar}" ]] ; then
1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1154 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1116 fi 1155 fi
1117 1156
1118 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1157 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1119 # Only record jars that aren't build-only 1158 # Only record jars that aren't build-only
1120 [[ -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
1121 echo "${jar}" 1166 echo "${jar}"
1122 return 0 1167 return 0
1123 fi 1168 fi
1124 done 1169 done
1125 1170
1161 1206
1162 local pkgs="${1}" 1207 local pkgs="${1}"
1163 local jar="${2}" 1208 local jar="${2}"
1164 1209
1165 [[ -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
1166 1215
1167 if [[ -z "${jar}" ]]; then 1216 if [[ -z "${jar}" ]]; then
1168 for pkg in ${pkgs//,/ }; do 1217 for pkg in ${pkgs//,/ }; do
1169 java-pkg_ensure-dep runtime "${pkg}" 1218 java-pkg_ensure-dep runtime "${pkg}"
1170 java-pkg_record-jar_ "${pkg}" 1219 java-pkg_record-jar_ "${pkg}"
1213 local pkgs="${1}" 1262 local pkgs="${1}"
1214 local jar="${2}" 1263 local jar="${2}"
1215 1264
1216 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1265 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1217 1266
1267 if [[ "${EAPI}" == "1" ]]; then
1268 pkgs="${pkgs//:/-}"
1269 fi
1270
1218 if [[ -z "${jar}" ]]; then 1271 if [[ -z "${jar}" ]]; then
1219 for pkg in ${pkgs//,/ }; do 1272 for pkg in ${pkgs//,/ }; do
1220 java-pkg_record-jar_ --optional "${pkg}" 1273 java-pkg_record-jar_ --optional "${pkg}"
1221 done 1274 done
1222 else 1275 else
1251 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1304 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1252 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1305 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1253 1306
1254 java-pkg_do_write_ 1307 java-pkg_do_write_
1255} 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
1256 1339
1257# 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
1258# populate jars from the filesystem. 1341# populate jars from the filesystem.
1259# 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
1260# string that was built instead of stdin 1343# string that was built instead of stdin
1298# @section-begin helper 1381# @section-begin helper
1299# @section-summary Helper functions 1382# @section-summary Helper functions
1300# 1383#
1301# Various other functions to use from an ebuild 1384# Various other functions to use from an ebuild
1302# ------------------------------------------------------------------------------ 1385# ------------------------------------------------------------------------------
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 1386
1381# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1382# @ebuild-function java-pkg_find-normal-jars 1388# @ebuild-function java-pkg_find-normal-jars
1383# 1389#
1384# 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
1550java-pkg_get-current-vm() { 1556java-pkg_get-current-vm() {
1551 echo ${GENTOO_VM} 1557 echo ${GENTOO_VM}
1552} 1558}
1553 1559
1554java-pkg_current-vm-matches() { 1560java-pkg_current-vm-matches() {
1555 hasq $(java-pkg_get-current-vm) ${@} 1561 has $(java-pkg_get-current-vm) ${@}
1556 return $? 1562 return $?
1557} 1563}
1558 1564
1559# ------------------------------------------------------------------------------ 1565# ------------------------------------------------------------------------------
1560# @ebuild-function java-pkg_get-source 1566# @ebuild-function java-pkg_get-source
1675 die "No GCJ support found!" 1681 die "No GCJ support found!"
1676 fi 1682 fi
1677} 1683}
1678 1684
1679java-pkg_ensure-test() { 1685java-pkg_ensure-test() {
1680 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1686 if has test ${FEATURES} && ! has -test ${FEATURES} \
1681 && hasq test ${IUSE} && ! use test; 1687 && has test ${IUSE} && ! use test;
1682 then 1688 then
1683 eerror "You specified FEATURES=test, but USE=test is needed" 1689 eerror "You specified FEATURES=test, but USE=test is needed"
1684 eerror "to pull in the additional dependencies for testing" 1690 eerror "to pull in the additional dependencies for testing"
1685 die "Need USE=test enabled" 1691 die "Need USE=test enabled"
1686 fi 1692 fi
1722 dodir /usr/share/ant/${TASKS_DIR} 1728 dodir /usr/share/ant/${TASKS_DIR}
1723 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1729 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1724} 1730}
1725 1731
1726# ------------------------------------------------------------------------------ 1732# ------------------------------------------------------------------------------
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 1733# @internal-function java-pkg_ant-tasks-depend
1763# 1734#
1764# Translates the WANT_ANT_TASKS variable into valid dependencies. 1735# Translates the WANT_ANT_TASKS variable into valid dependencies.
1765# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1766java-pkg_ant-tasks-depend() { 1737java-pkg_ant-tasks-depend() {
1768 1739
1769 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1740 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1770 local DEP="" 1741 local DEP=""
1771 for i in ${WANT_ANT_TASKS} 1742 for i in ${WANT_ANT_TASKS}
1772 do 1743 do
1773 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
1774 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1775 return 1 1750 return 1
1776 fi 1751 fi
1777 DEP="${DEP}dev-java/${i} "
1778 done 1752 done
1779 echo ${DEP} 1753 echo ${DEP}
1780 return 0 1754 return 0
1781 else 1755 else
1782 return 0 1756 return 0
1783 fi 1757 fi
1784} 1758}
1785 1759
1760
1786# ------------------------------------------------------------------------------ 1761# ------------------------------------------------------------------------------
1787# @ebuild-function ejunit 1762# @internal-function ejunit_
1788# 1763#
1789# 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
1790# 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.
1791# 1766#
1792# Examples: 1767# @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 1768# @param $2 - -cp or -classpath
1797# @param $2 - classpath; junit and recorded dependencies get appended 1769# @param $3 - classpath; junit and recorded dependencies get appended
1798# @param $@ - the rest of the parameters are passed to java 1770# @param $@ - the rest of the parameters are passed to java
1799# ------------------------------------------------------------------------------
1800ejunit() { 1771ejunit_() {
1801 debug-print-function ${FUNCNAME} $* 1772 debug-print-function ${FUNCNAME} $*
1802 1773
1803 local pkgs 1774 local pkgs
1775 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1804 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1776 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1805 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1777 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1806 done 1778 done
1779 fi
1807 1780
1781 local junit=${1}
1782 shift 1
1783
1808 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1784 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1809 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1810 cp="${2}:${cp}" 1786 cp="${2}:${cp}"
1811 shift 2 1787 shift 2
1812 else 1788 else
1813 cp=".:${cp}" 1789 cp=".:${cp}"
1814 fi 1790 fi
1815 1791
1816 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
1817 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1796 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1818 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"
1819} 1798}
1820 1799
1821# ------------------------------------------------------------------------------ 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# ------------------------------------------------------------------------------
1822# @section-end helper 1845# @section-end helper
1823# ------------------------------------------------------------------------------ 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}
1824 1896
1825# ------------------------------------------------------------------------------ 1897# ------------------------------------------------------------------------------
1826# @section-begin build 1898# @section-begin build
1827# @section-summary Build functions 1899# @section-summary Build functions
1828# 1900#
1837# 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,
1838# variables: 1910# variables:
1839# 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
1840# gentoo.classpath property. Be sure to call 1912# gentoo.classpath property. Be sure to call
1841# java-ant_rewrite-classpath in src_unpack. 1913# java-ant_rewrite-classpath in src_unpack.
1842# 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!
1843# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1917# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1844# ------------------------------------------------------------------------------ 1918# ------------------------------------------------------------------------------
1845eant() { 1919eant() {
1846 debug-print-function ${FUNCNAME} $* 1920 debug-print-function ${FUNCNAME} $*
1847 1921
1848 if [[ ${EBUILD_PHASE} = compile ]]; then 1922 if [[ ${EBUILD_PHASE} = compile ]]; then
1849 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1923 java-ant-2_src_configure
1850 # finally get rid of the hooks without breaking stuff 1924 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 1925 fi
1858 1926
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 1927 if ! has java-ant-2 ${INHERITED}; then
1873 local msg="You should inherit java-ant-2 when using eant" 1928 local msg="You should inherit java-ant-2 when using eant"
1874 java-pkg_announce-qa-violation "${msg}" 1929 java-pkg_announce-qa-violation "${msg}"
1875 fi 1930 fi
1876 1931
1877 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1932 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1911 echo "more info." 1966 echo "more info."
1912 fi 1967 fi
1913 fi 1968 fi
1914 done 1969 done
1915 1970
1916 # we use this in src_* so we run ant from / 1971 # parse WANT_ANT_TASKS for atoms
1917 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1972 local want_ant_tasks
1918 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1973 for i in ${WANT_ANT_TASKS}; do
1919 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1974 if [[ ${i} = */*:* ]]; then
1920 1975 i=${i#*/}
1921 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1976 i=${i%:0}
1922 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1977 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 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
1930 # 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
1931 ANT_TASKS="${ANT_TASKS:-all}" 1989 ANT_TASKS="${ANT_TASKS:-none}"
1932 fi
1933 1990
1934 # 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
1935 if [[ "${ANT_TASKS}" == "all" ]]; then 1992 if [[ "${ANT_TASKS}" == "all" ]]; then
1936 einfo "Using all available ANT_TASKS" 1993 einfo "Using all available ANT_TASKS"
1937 elif [[ "${ANT_TASKS}" == "none" ]]; then 1994 elif [[ "${ANT_TASKS}" == "none" ]]; then
1938 einfo "Disabling all optional ANT_TASKS" 1995 einfo "Disabling all optional ANT_TASKS"
1939 else 1996 else
1940 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1997 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1941 fi 1998 fi
1942 1999
1943 export ANT_TASKS 2000 export ANT_TASKS
1944 fi
1945 2001
1946 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 2002 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1947 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 2003 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1948 2004
1949 local gcp="${EANT_GENTOO_CLASSPATH}" 2005 local gcp="${EANT_GENTOO_CLASSPATH}"
1950 local getjarsarg="" 2006 local getjarsarg=""
1951 2007
1952 if [[ ${EBUILD_PHASE} = "test" ]]; then 2008 if [[ ${EBUILD_PHASE} = "test" ]]; then
1953 antflags="${antflags} -DJunit.present=true" 2009 antflags="${antflags} -DJunit.present=true"
1954 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2010 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1955 getjarsarg="--with-dependencies" 2011 getjarsarg="--with-dependencies"
1956 fi 2012 fi
1957 2013
1958 local cp 2014 local cp
1959 2015
1960 for atom in ${gcp}; do 2016 for atom in ${gcp}; do
1961 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2017 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1962 done 2018 done
1963 2019
2020 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2021
1964 if [[ ${cp} ]]; then 2022 if [[ ${cp} ]]; then
1965 # 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}"
1966 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2027 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1967 fi 2028 fi
1968 2029
1969 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2030 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1970 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2031 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1971 ant ${antflags} "${@}" || die "eant failed" 2032 ant ${antflags} "${@}" || die "eant failed"
2074# ----------------------------------------------------------------------------- 2135# -----------------------------------------------------------------------------
2075java-pkg_init() { 2136java-pkg_init() {
2076 debug-print-function ${FUNCNAME} $* 2137 debug-print-function ${FUNCNAME} $*
2077 unset JAVAC 2138 unset JAVAC
2078 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 }
2079 2148
2080 # People do all kinds of weird things. 2149 # People do all kinds of weird things.
2081 # http://forums.gentoo.org/viewtopic-p-3943166.html 2150 # http://forums.gentoo.org/viewtopic-p-3943166.html
2082 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2151 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2083 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2152 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2121 export CLASSPATH= 2190 export CLASSPATH=
2122 2191
2123 # Unset external ANT_ stuff 2192 # Unset external ANT_ stuff
2124 export ANT_TASKS= 2193 export ANT_TASKS=
2125 export ANT_OPTS= 2194 export ANT_OPTS=
2195 export ANT_RESPECT_JAVA_HOME=
2126} 2196}
2127 2197
2128# ------------------------------------------------------------------------------ 2198# ------------------------------------------------------------------------------
2129# @function-internal java-pkg-init-compiler_ 2199# @function-internal java-pkg-init-compiler_
2130# 2200#
2221 done 2291 done
2222 2292
2223 # If it hasn't been defined already, default to javac 2293 # If it hasn't been defined already, default to javac
2224 if [[ -z ${GENTOO_COMPILER} ]]; then 2294 if [[ -z ${GENTOO_COMPILER} ]]; then
2225 if [[ -n ${compilers} ]]; then 2295 if [[ -n ${compilers} ]]; then
2226 einfo "No suitable compiler found: defaulting javac for compilation" 2296 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2227 else 2297 else
2228 # probably don't need to notify users about the default. 2298 # probably don't need to notify users about the default.
2229 :;#einfo "Defaulting to javac for compilation" 2299 :;#einfo "Defaulting to javac for compilation"
2230 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
2231 export GENTOO_COMPILER=javac 2304 export GENTOO_COMPILER=javac
2305 fi
2232 else 2306 else
2233 einfo "Using ${GENTOO_COMPILER} for compilation" 2307 einfo "Using ${GENTOO_COMPILER} for compilation"
2234 fi 2308 fi
2235 2309
2236} 2310}
2287 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2361 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2288 # Create package.env 2362 # Create package.env
2289 ( 2363 (
2290 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2364 echo "DESCRIPTION=\"${DESCRIPTION}\""
2291 echo "GENERATION=\"2\"" 2365 echo "GENERATION=\"2\""
2366 echo "SLOT=\"${SLOT}\""
2367 echo "CATEGORY=\"${CATEGORY}\""
2368 echo "PVR=\"${PVR}\""
2292 2369
2293 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2370 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2294 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2371 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2295 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2372 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2296 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2373 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2297 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2374 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2298 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2375 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2299 && 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' ':')\""
2300 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' ':')\""
2301 ) > "${JAVA_PKG_ENV}" 2380 ) > "${JAVA_PKG_ENV}"
2302 2381
2303 # register target/source 2382 # register target/source
2304 local target="$(java-pkg_get-target)" 2383 local target="$(java-pkg_get-target)"
2305 local source="$(java-pkg_get-source)" 2384 local source="$(java-pkg_get-source)"
2338# ------------------------------------------------------------------------------ 2417# ------------------------------------------------------------------------------
2339# @internal-function java-pkg_record-jar_ 2418# @internal-function java-pkg_record-jar_
2340# 2419#
2341# Record an (optional) dependency to the package.env 2420# Record an (optional) dependency to the package.env
2342# @param --optional - record dependency as optional 2421# @param --optional - record dependency as optional
2422# @param --build - record dependency as build_only
2343# @param $1 - package to record 2423# @param $1 - package to record
2344# @param $2 - (optional) jar of package to record 2424# @param $2 - (optional) jar of package to record
2345# ------------------------------------------------------------------------------ 2425# ------------------------------------------------------------------------------
2346JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2426JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2347JAVA_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"
2348 2429
2349java-pkg_record-jar_() { 2430java-pkg_record-jar_() {
2350 debug-print-function ${FUNCNAME} $* 2431 debug-print-function ${FUNCNAME} $*
2351 2432
2352 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2433 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2353 if [[ "${1}" == "--optional" ]]; then 2434 case "${1}" in
2354 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2435 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2355 shift 2436 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2356 fi 2437 esac
2357 2438
2358 local pkg=${1} jar=${2} append 2439 local pkg=${1} jar=${2} append
2359 if [[ -z "${jar}" ]]; then 2440 if [[ -z "${jar}" ]]; then
2360 append="${pkg}" 2441 append="${pkg}"
2361 else 2442 else
2414# 2495#
2415# @return 0 - function is declared 2496# @return 0 - function is declared
2416# @return 1 - function is undeclared 2497# @return 1 - function is undeclared
2417# ------------------------------------------------------------------------------ 2498# ------------------------------------------------------------------------------
2418java-pkg_func-exists() { 2499java-pkg_func-exists() {
2419 if [[ -n "$(declare -f ${1})" ]]; then 2500 declare -F ${1} > /dev/null
2420 return 0
2421 else
2422 return 1
2423 fi
2424} 2501}
2425 2502
2426# ------------------------------------------------------------------------------ 2503# ------------------------------------------------------------------------------
2427# @internal-function java-pkg_setup-vm 2504# @internal-function java-pkg_setup-vm
2428# 2505#
2429# Sets up the environment for a specific VM 2506# Sets up the environment for a specific VM
2430# 2507#
2431# ------------------------------------------------------------------------------ 2508# ------------------------------------------------------------------------------
2432java-pkg_setup-vm() { 2509java-pkg_setup-vm() {
2433 debug-print-function ${FUNCNAME} $* 2510 debug-print-function ${FUNCNAME} $*
2434
2435 export LANG="C" LC_ALL="C"
2436 2511
2437 local vendor="$(java-pkg_get-vm-vendor)" 2512 local vendor="$(java-pkg_get-vm-vendor)"
2438 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2513 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2439 addpredict "/dev/random" 2514 addpredict "/dev/random"
2440 elif [[ "${vendor}" == "ibm" ]]; then 2515 elif [[ "${vendor}" == "ibm" ]]; then
2441 addpredict "/proc/self/maps" 2516 addpredict "/proc/self/maps"
2442 addpredict "/proc/cpuinfo" 2517 addpredict "/proc/cpuinfo"
2518 addpredict "/proc/self/coredump_filter"
2519 elif [[ "${vendor}" == "oracle" ]]; then
2520 addpredict "/dev/random"
2521 addpredict "/proc/self/coredump_filter"
2522 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2523 addpredict "/dev/random"
2524 addpredict "/proc/self/coredump_filter"
2443 elif [[ "${vendor}" == "jrockit" ]]; then 2525 elif [[ "${vendor}" == "jrockit" ]]; then
2444 addpredict "/proc/cpuinfo" 2526 addpredict "/proc/cpuinfo"
2445 fi 2527 fi
2446} 2528}
2447 2529
2454# @return 1 - Package does not depend on virtual/jdk 2536# @return 1 - Package does not depend on virtual/jdk
2455# ------------------------------------------------------------------------------ 2537# ------------------------------------------------------------------------------
2456java-pkg_needs-vm() { 2538java-pkg_needs-vm() {
2457 debug-print-function ${FUNCNAME} $* 2539 debug-print-function ${FUNCNAME} $*
2458 2540
2459 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2541 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2460 return 0 2542 return 0
2461 fi 2543 fi
2462 2544
2463 return 1 2545 return 1
2464} 2546}
2512 # If you're forcing the VM, I hope you know what your doing... 2594 # 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}" 2595 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2514 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2596 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2515 # if we're allowed to switch the vm... 2597 # if we're allowed to switch the vm...
2516 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2598 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}" 2599 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2518 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2519 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2520 else
2521 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2600 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2522 fi
2523 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2601 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2524 eerror "Unable to determine VM for building from dependencies:" 2602 eerror "Unable to determine VM for building from dependencies:"
2525 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2603 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2526 echo "VNEED: ${JAVA_PKG_VNEED}"
2527 die "Failed to determine VM for building." 2604 die "Failed to determine VM for building."
2528 else 2605 else
2529 export GENTOO_VM 2606 export GENTOO_VM
2530 fi 2607 fi
2531 # otherwise just make sure the current VM is sufficient 2608 # otherwise just make sure the current VM is sufficient
2570# 2647#
2571# Enhanced die for Java packages, which displays some information that may be 2648# Enhanced die for Java packages, which displays some information that may be
2572# useful for debugging bugs on bugzilla. 2649# useful for debugging bugs on bugzilla.
2573# ------------------------------------------------------------------------------ 2650# ------------------------------------------------------------------------------
2574#register_die_hook java-pkg_die 2651#register_die_hook java-pkg_die
2575if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2652if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2576 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2653 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2577fi 2654fi
2578 2655
2579java-pkg_die() { 2656java-pkg_die() {
2580 echo "!!! When you file a bug report, please include the following information:" >&2 2657 echo "!!! When you file a bug report, please include the following information:" >&2
2604# not. 2681# not.
2605# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2682# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2606# ------------------------------------------------------------------------------ 2683# ------------------------------------------------------------------------------
2607java-pkg_verify-classes() { 2684java-pkg_verify-classes() {
2608 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2685 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2686
2687 local version_verify="/usr/bin/class-version-verify.py"
2688
2689 if [[ ! -x "${version_verify}" ]]; then
2690 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2691 fi
2692
2693 if [[ ! -x "${version_verify}" ]]; then
2694 ewarn "Unable to perform class version checks as"
2695 ewarn "class-version-verify.py is unavailable"
2696 ewarn "Please install dev-java/javatoolkit."
2697 return
2698 fi
2699
2609 local target=$(java-pkg_get-target) 2700 local target=$(java-pkg_get-target)
2610 local result 2701 local result
2611 local log="${T}/class-version-verify.log" 2702 local log="${T}/class-version-verify.log"
2612 if [[ -n "${1}" ]]; then 2703 if [[ -n "${1}" ]]; then
2613 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2704 ${version_verify} -v -t ${target} "${1}" > "${log}"
2614 result=$? 2705 result=$?
2615 else 2706 else
2616 ebegin "Verifying java class versions (target: ${target})" 2707 ebegin "Verifying java class versions (target: ${target})"
2617 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2708 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2618 result=$? 2709 result=$?
2619 eend ${result} 2710 eend ${result}
2620 fi 2711 fi
2621 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2712 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2622 if [[ ${result} != 0 ]]; then 2713 if [[ ${result} != 0 ]]; then
2640 2731
2641 local limit_to="${1}" 2732 local limit_to="${1}"
2642 local target_pkg="${2}" 2733 local target_pkg="${2}"
2643 local dev_error="" 2734 local dev_error=""
2644 2735
2736 # remove the version specification, which may include globbing (* and [123])
2645 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2737 local stripped_pkg=$(echo "${target_pkg}" | sed \
2646 's/-[0-9]*\(\.[0-9]\)*$//') 2738 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2647 2739
2648 debug-print "Matching against: ${stripped_pkg}" 2740 debug-print "Matching against: ${stripped_pkg}"
2649 2741
2650 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2742 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2651 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2743 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2701 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2793 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2702 fi 2794 fi
2703} 2795}
2704 2796
2705java-pkg_check-jikes() { 2797java-pkg_check-jikes() {
2706 if hasq jikes ${IUSE}; then 2798 if has jikes ${IUSE}; then
2707 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2799 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2708 fi 2800 fi
2709} 2801}
2710 2802
2711java-pkg_announce-qa-violation() { 2803java-pkg_announce-qa-violation() {
2727is-java-strict() { 2819is-java-strict() {
2728 [[ -n ${JAVA_PKG_STRICT} ]] 2820 [[ -n ${JAVA_PKG_STRICT} ]]
2729 return $? 2821 return $?
2730} 2822}
2731 2823
2824
2732# ------------------------------------------------------------------------------ 2825# ------------------------------------------------------------------------------
2733# @eclass-end 2826# @eclass-end
2734# ------------------------------------------------------------------------------ 2827# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20