/[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.107 Revision 1.142
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.107 2008/05/03 21:28:45 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.142 2011/08/29 01:28:10 vapier 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#
365 if [[ ${jar} = *\** ]]; then 385 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 386 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 387 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 388 eerror '${D} add ${D} to the argument.'
369 fi 389 fi
390 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 391 die "${jar} does not exist"
371 fi 392 fi
372 done 393 done
373 394
374 java-pkg_do_write_ 395 java-pkg_do_write_
429# @param $@ - JNI libraries to install 450# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 451# ------------------------------------------------------------------------------
431java-pkg_doso() { 452java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 453 debug-print-function ${FUNCNAME} $*
433 454
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 455 java-pkg_check-phase install
436 456
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 457 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 458
439 java-pkg_init_paths_ 459 java-pkg_init_paths_
440 460
441 local lib 461 local lib
442 # for each lib 462 # for each lib
445 if [[ -e "${lib}" ]] ; then 465 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 466 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 467 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 468 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 469 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 470 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 471 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 472 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 473 # otherwise make a symlink to the symlink's origin
454 else 474 else
455 # TODO use dosym 475 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 476 debug-print "${lib} is a symlink, linking accordantly"
459 fi 477 fi
460 # otherwise die 478 # otherwise die
461 else 479 else
462 die "${lib} does not exist" 480 die "${lib} does not exist"
463 fi 481 fi
479java-pkg_regso() { 497java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 498 debug-print-function ${FUNCNAME} $*
481 499
482 java-pkg_check-phase install 500 java-pkg_check-phase install
483 501
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 502 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 503
486 java-pkg_init_paths_ 504 java-pkg_init_paths_
487 505
488 local lib target_dir 506 local lib target_dir
489 for lib in "$@" ; do 507 for lib in "$@" ; do
874 892
875 local build_only="" 893 local build_only=""
876 local destdir="." 894 local destdir="."
877 local deep="" 895 local deep=""
878 local virtual="" 896 local virtual=""
897 local record_jar=""
879 898
880 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 899 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
881 900
882 while [[ "${1}" == --* ]]; do 901 while [[ "${1}" == --* ]]; do
883 if [[ "${1}" = "--build-only" ]]; then 902 if [[ "${1}" = "--build-only" ]]; then
918 for pkg in ${target_pkg//,/ }; do 937 for pkg in ${target_pkg//,/ }; do
919 java-pkg_ensure-dep "${build_only}" "${pkg}" 938 java-pkg_ensure-dep "${build_only}" "${pkg}"
920 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 939 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
921 done 940 done
922 # setting this disables further record-jar_ calls later 941 # setting this disables further record-jar_ calls later
923 build_only="build" 942 record_jar="true"
924 else 943 else
925 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 944 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
926 fi 945 fi
927 946
928 # Record the entire virtual as a dependency so that 947 # Record the entire virtual as a dependency so that
929 # no jars are missed. 948 # no jars are missed.
930 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 949 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
931 java-pkg_record-jar_ "${target_pkg}" 950 java-pkg_record-jar_ "${target_pkg}"
932 # setting this disables further record-jars_ calls later 951 # setting this disables further record-jars_ calls later
933 build_only="build" 952 record_jar="true"
934 fi 953 fi
935 954
936 pushd ${destdir} > /dev/null \ 955 pushd ${destdir} > /dev/null \
937 || die "failed to change directory to ${destdir}" 956 || die "failed to change directory to ${destdir}"
938 957
946 # If no specific target jar was indicated, link it 965 # If no specific target jar was indicated, link it
947 if [[ -z "${target_jar}" ]] ; then 966 if [[ -z "${target_jar}" ]] ; then
948 [[ -f "${target_jar}" ]] && rm "${target_jar}" 967 [[ -f "${target_jar}" ]] && rm "${target_jar}"
949 ln -snf "${jar}" \ 968 ln -snf "${jar}" \
950 || 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
951 [[ -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
952 # otherwise, if the current jar is the target jar, link it 977 # otherwise, if the current jar is the target jar, link it
953 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 978 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
954 [[ -f "${destjar}" ]] && rm "${destjar}" 979 [[ -f "${destjar}" ]] && rm "${destjar}"
955 ln -snf "${jar}" "${destjar}" \ 980 ln -snf "${jar}" "${destjar}" \
956 || 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
957 [[ -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
958 popd > /dev/null 989 popd > /dev/null
959 return 0 990 return 0
960 fi 991 fi
961 done 992 done
962 popd > /dev/null 993 popd > /dev/null
1035 1066
1036 for pkg in ${pkgs//,/ }; do 1067 for pkg in ${pkgs//,/ }; do
1037 java-pkg_ensure-dep "${build_only}" "${pkg}" 1068 java-pkg_ensure-dep "${build_only}" "${pkg}"
1038 done 1069 done
1039 1070
1040 # Only record jars that aren't build-only 1071 for pkg in ${pkgs//,/ }; do
1041 if [[ -z "${build_only}" ]]; then 1072 if [[ -z "${build_only}" ]]; then
1042 for pkg in ${pkgs//,/ }; do
1043 java-pkg_record-jar_ "${pkg}" 1073 java-pkg_record-jar_ "${pkg}"
1074 else
1075 java-pkg_record-jar_ --build-only "${pkg}"
1076 fi
1044 done 1077 done
1045 fi
1046 1078
1047 echo "${jars}" 1079 echo "${jars}"
1048} 1080}
1049 1081
1050# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1071java-pkg_getjar() { 1103java-pkg_getjar() {
1072 debug-print-function ${FUNCNAME} $* 1104 debug-print-function ${FUNCNAME} $*
1073 1105
1074 local build_only="" 1106 local build_only=""
1075 local virtual="" 1107 local virtual=""
1108 local record_jar=""
1076 1109
1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1110 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1078 1111
1079 while [[ "${1}" == --* ]]; do 1112 while [[ "${1}" == --* ]]; do
1080 if [[ "${1}" = "--build-only" ]]; then 1113 if [[ "${1}" = "--build-only" ]]; then
1106 java-pkg_ensure-dep "${build_only}" "${pkg}" 1139 java-pkg_ensure-dep "${build_only}" "${pkg}"
1107 1140
1108 # 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
1109 # So that individual jars are not recorded. 1142 # So that individual jars are not recorded.
1110 if [[ -n "${virtual}" ]]; then 1143 if [[ -n "${virtual}" ]]; then
1144 if [[ -z "${build_only}" ]]; then
1111 java-pkg_record-jar_ "${pkg}" 1145 java-pkg_record-jar_ "${pkg}"
1112 build_only="true" 1146 else
1147 java-pkg_record-jar_ --build-only "${pkg}"
1148 fi
1149 record_jar="true"
1113 fi 1150 fi
1114 1151
1115 for jar in ${classpath//:/ }; do 1152 for jar in ${classpath//:/ }; do
1116 if [[ ! -f "${jar}" ]] ; then 1153 if [[ ! -f "${jar}" ]] ; then
1117 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1154 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1118 fi 1155 fi
1119 1156
1120 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1157 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1121 # Only record jars that aren't build-only 1158 # Only record jars that aren't build-only
1122 [[ -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
1123 echo "${jar}" 1166 echo "${jar}"
1124 return 0 1167 return 0
1125 fi 1168 fi
1126 done 1169 done
1127 1170
1261 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1304 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1262 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1305 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1263 1306
1264 java-pkg_do_write_ 1307 java-pkg_do_write_
1265} 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
1266 1339
1267# 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
1268# populate jars from the filesystem. 1341# populate jars from the filesystem.
1269# 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
1270# string that was built instead of stdin 1343# string that was built instead of stdin
1308# @section-begin helper 1381# @section-begin helper
1309# @section-summary Helper functions 1382# @section-summary Helper functions
1310# 1383#
1311# Various other functions to use from an ebuild 1384# Various other functions to use from an ebuild
1312# ------------------------------------------------------------------------------ 1385# ------------------------------------------------------------------------------
1313
1314# ------------------------------------------------------------------------------
1315# @ebuild-function java-pkg_need
1316#
1317# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1318# Currently supported virtuals are:
1319# javamail
1320# jdbc-stdext
1321# jaf
1322# jdbc-rowset
1323# jms
1324#
1325# @param $1 - Optionally indicate that the dependencies are controlled by
1326# a use flag by specifying '--use' Requires $2.
1327# @param $2 - USE flag which will enable the dependencies.
1328# @param $@ - virtual packages to add depenedencies for
1329# ------------------------------------------------------------------------------
1330# TODO rewrite to parse a line based declaration file instead -- karltk
1331#java-pkg_need() {
1332# debug-print-function ${FUNCNAME} $*
1333# local useflag
1334# if [[ ${1} == "--use" ]]; then
1335# useflag="${2}"
1336# shift 2
1337# fi
1338#
1339# if [[ -z ${1} ]]; then
1340# die "Must specify at least one virtual package."
1341# fi
1342#
1343# local depstr newdepstr
1344#
1345# for virtual in ${@}; do
1346# if has ${virtual} ${JAVA_PKG_VNEED}; then
1347# debug-print "Already registered virtual ${virtual}"
1348# continue
1349# fi
1350# case ${virtual} in
1351# javamail)
1352# debug-print "java-pkg_need: adding javamail dependencies"
1353# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1354# ;;
1355# jdbc-stdext)
1356# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1357# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1358# ;;
1359# jaf)
1360# debug-print "java-pkg_need: adding jaf dependencies"
1361# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1362# ;;
1363# jdbc-rowset)
1364# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1365# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1366# ;;
1367# jms)
1368# debug-print "java-pkg_need: adding jms dependencies"
1369# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1370# ;;
1371# *)
1372# die "Invalid virtual: ${virtual}"
1373# esac
1374#
1375# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1376#
1377# if [[ -n ${useflag} ]]; then
1378# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1379# else
1380# depstr="${depstr} ${newdepstr}"
1381# fi
1382# done
1383#
1384# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1385# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1386#
1387# export DEPEND="${DEPEND} ${depstr}"
1388# export RDEPEND="${RDEPEND} ${depstr}"
1389#}
1390 1386
1391# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1392# @ebuild-function java-pkg_find-normal-jars 1388# @ebuild-function java-pkg_find-normal-jars
1393# 1389#
1394# 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
1560java-pkg_get-current-vm() { 1556java-pkg_get-current-vm() {
1561 echo ${GENTOO_VM} 1557 echo ${GENTOO_VM}
1562} 1558}
1563 1559
1564java-pkg_current-vm-matches() { 1560java-pkg_current-vm-matches() {
1565 hasq $(java-pkg_get-current-vm) ${@} 1561 has $(java-pkg_get-current-vm) ${@}
1566 return $? 1562 return $?
1567} 1563}
1568 1564
1569# ------------------------------------------------------------------------------ 1565# ------------------------------------------------------------------------------
1570# @ebuild-function java-pkg_get-source 1566# @ebuild-function java-pkg_get-source
1685 die "No GCJ support found!" 1681 die "No GCJ support found!"
1686 fi 1682 fi
1687} 1683}
1688 1684
1689java-pkg_ensure-test() { 1685java-pkg_ensure-test() {
1690 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1686 if has test ${FEATURES} && ! has -test ${FEATURES} \
1691 && hasq test ${IUSE} && ! use test; 1687 && has test ${IUSE} && ! use test;
1692 then 1688 then
1693 eerror "You specified FEATURES=test, but USE=test is needed" 1689 eerror "You specified FEATURES=test, but USE=test is needed"
1694 eerror "to pull in the additional dependencies for testing" 1690 eerror "to pull in the additional dependencies for testing"
1695 die "Need USE=test enabled" 1691 die "Need USE=test enabled"
1696 fi 1692 fi
1743 1739
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1740 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1741 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1742 for i in ${WANT_ANT_TASKS}
1747 do 1743 do
1748 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
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1750 return 1
1751 fi 1751 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1752 done
1754 echo ${DEP} 1753 echo ${DEP}
1755 return 0 1754 return 0
1756 else 1755 else
1757 return 0 1756 return 0
1758 fi 1757 fi
1759} 1758}
1760 1759
1760
1761# ------------------------------------------------------------------------------ 1761# ------------------------------------------------------------------------------
1762# @ebuild-function ejunit 1762# @internal-function ejunit_
1763# 1763#
1764# 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
1765# 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.
1766# 1766#
1767# Examples: 1767# @param $1 - junit package (junit or junit-4)
1768# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1769# ejunit org.blinkenlights.jid3.test.AllTests
1770#
1771# @param $1 - -cp or -classpath 1768# @param $2 - -cp or -classpath
1772# @param $2 - classpath; junit and recorded dependencies get appended 1769# @param $3 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java 1770# @param $@ - the rest of the parameters are passed to java
1774# ------------------------------------------------------------------------------
1775ejunit() { 1771ejunit_() {
1776 debug-print-function ${FUNCNAME} $* 1772 debug-print-function ${FUNCNAME} $*
1777 1773
1778 local pkgs 1774 local pkgs
1779 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1775 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1776 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1777 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1782 done 1778 done
1783 fi 1779 fi
1784 1780
1781 local junit=${1}
1782 shift 1
1783
1785 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1784 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1786 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1787 cp="${2}:${cp}" 1786 cp="${2}:${cp}"
1788 shift 2 1787 shift 2
1789 else 1788 else
1790 cp=".:${cp}" 1789 cp=".:${cp}"
1791 fi 1790 fi
1792 1791
1793 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
1794 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1796 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1795 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"
1796} 1798}
1797 1799
1798# ------------------------------------------------------------------------------ 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# ------------------------------------------------------------------------------
1799# @section-end helper 1845# @section-end helper
1800# ------------------------------------------------------------------------------ 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}
1801 1896
1802# ------------------------------------------------------------------------------ 1897# ------------------------------------------------------------------------------
1803# @section-begin build 1898# @section-begin build
1804# @section-summary Build functions 1899# @section-summary Build functions
1805# 1900#
1814# 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,
1815# variables: 1910# variables:
1816# 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
1817# gentoo.classpath property. Be sure to call 1912# gentoo.classpath property. Be sure to call
1818# java-ant_rewrite-classpath in src_unpack. 1913# java-ant_rewrite-classpath in src_unpack.
1819# 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!
1820# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1917# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1821# ------------------------------------------------------------------------------ 1918# ------------------------------------------------------------------------------
1822eant() { 1919eant() {
1823 debug-print-function ${FUNCNAME} $* 1920 debug-print-function ${FUNCNAME} $*
1824 1921
1825 if [[ ${EBUILD_PHASE} = compile ]]; then 1922 if [[ ${EBUILD_PHASE} = compile ]]; then
1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1923 java-ant-2_src_configure
1827 # finally get rid of the hooks without breaking stuff 1924 java-utils-2_src_prepare
1828
1829 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1830 && java-ant_ignore-system-classes "${S}/build.xml"
1831
1832 if hasq java-ant-2 ${INHERITED}; then
1833 java-ant_bsfix
1834 fi 1925 fi
1835 1926
1836 # eant can be called multiple times
1837 JAVA_PKG_BSFIX="off"
1838
1839 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1840 echo "Searching for bundled jars:"
1841 java-pkg_find-normal-jars || echo "None found."
1842 echo "Searching for bundled classes (no output if none found):"
1843 find "${WORKDIR}" -name "*.class"
1844 echo "Search done."
1845 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1846 fi
1847 fi
1848
1849 if ! hasq java-ant-2 ${INHERITED}; then 1927 if ! has java-ant-2 ${INHERITED}; then
1850 local msg="You should inherit java-ant-2 when using eant" 1928 local msg="You should inherit java-ant-2 when using eant"
1851 java-pkg_announce-qa-violation "${msg}" 1929 java-pkg_announce-qa-violation "${msg}"
1852 fi 1930 fi
1853 1931
1854 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1932 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1888 echo "more info." 1966 echo "more info."
1889 fi 1967 fi
1890 fi 1968 fi
1891 done 1969 done
1892 1970
1971 # parse WANT_ANT_TASKS for atoms
1972 local want_ant_tasks
1973 for i in ${WANT_ANT_TASKS}; do
1974 if [[ ${i} = */*:* ]]; then
1975 i=${i#*/}
1976 i=${i%:0}
1977 want_ant_tasks+="${i/:/-} "
1978 else
1979 want_ant_tasks+="${i} "
1980 fi
1981 done
1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1982 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1983 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1895 1984
1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1985 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1986 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1898 1987
1899 # if ant-tasks is not set by ebuild or forced, use none 1988 # if ant-tasks is not set by ebuild or forced, use none
1916 local gcp="${EANT_GENTOO_CLASSPATH}" 2005 local gcp="${EANT_GENTOO_CLASSPATH}"
1917 local getjarsarg="" 2006 local getjarsarg=""
1918 2007
1919 if [[ ${EBUILD_PHASE} = "test" ]]; then 2008 if [[ ${EBUILD_PHASE} = "test" ]]; then
1920 antflags="${antflags} -DJunit.present=true" 2009 antflags="${antflags} -DJunit.present=true"
1921 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2010 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1922 getjarsarg="--with-dependencies" 2011 getjarsarg="--with-dependencies"
1923 fi 2012 fi
1924 2013
1925 local cp 2014 local cp
1926 2015
1927 for atom in ${gcp}; do 2016 for atom in ${gcp}; do
1928 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2017 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1929 done 2018 done
1930 2019
2020 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2021
1931 if [[ ${cp} ]]; then 2022 if [[ ${cp} ]]; then
1932 # 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}"
1933 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2027 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1934 fi 2028 fi
1935 2029
1936 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2030 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1937 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2031 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1938 ant ${antflags} "${@}" || die "eant failed" 2032 ant ${antflags} "${@}" || die "eant failed"
2041# ----------------------------------------------------------------------------- 2135# -----------------------------------------------------------------------------
2042java-pkg_init() { 2136java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $* 2137 debug-print-function ${FUNCNAME} $*
2044 unset JAVAC 2138 unset JAVAC
2045 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 }
2046 2148
2047 # People do all kinds of weird things. 2149 # People do all kinds of weird things.
2048 # http://forums.gentoo.org/viewtopic-p-3943166.html 2150 # http://forums.gentoo.org/viewtopic-p-3943166.html
2049 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2151 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2050 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2152 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2088 export CLASSPATH= 2190 export CLASSPATH=
2089 2191
2090 # Unset external ANT_ stuff 2192 # Unset external ANT_ stuff
2091 export ANT_TASKS= 2193 export ANT_TASKS=
2092 export ANT_OPTS= 2194 export ANT_OPTS=
2195 export ANT_RESPECT_JAVA_HOME=
2093} 2196}
2094 2197
2095# ------------------------------------------------------------------------------ 2198# ------------------------------------------------------------------------------
2096# @function-internal java-pkg-init-compiler_ 2199# @function-internal java-pkg-init-compiler_
2097# 2200#
2259 # Create package.env 2362 # Create package.env
2260 ( 2363 (
2261 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2364 echo "DESCRIPTION=\"${DESCRIPTION}\""
2262 echo "GENERATION=\"2\"" 2365 echo "GENERATION=\"2\""
2263 echo "SLOT=\"${SLOT}\"" 2366 echo "SLOT=\"${SLOT}\""
2367 echo "CATEGORY=\"${CATEGORY}\""
2368 echo "PVR=\"${PVR}\""
2264 2369
2265 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2370 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2266 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2371 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2267 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2372 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2268 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2373 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2269 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2374 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2270 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2375 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2271 && 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' ':')\""
2272 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' ':')\""
2273 ) > "${JAVA_PKG_ENV}" 2380 ) > "${JAVA_PKG_ENV}"
2274 2381
2275 # register target/source 2382 # register target/source
2276 local target="$(java-pkg_get-target)" 2383 local target="$(java-pkg_get-target)"
2277 local source="$(java-pkg_get-source)" 2384 local source="$(java-pkg_get-source)"
2310# ------------------------------------------------------------------------------ 2417# ------------------------------------------------------------------------------
2311# @internal-function java-pkg_record-jar_ 2418# @internal-function java-pkg_record-jar_
2312# 2419#
2313# Record an (optional) dependency to the package.env 2420# Record an (optional) dependency to the package.env
2314# @param --optional - record dependency as optional 2421# @param --optional - record dependency as optional
2422# @param --build - record dependency as build_only
2315# @param $1 - package to record 2423# @param $1 - package to record
2316# @param $2 - (optional) jar of package to record 2424# @param $2 - (optional) jar of package to record
2317# ------------------------------------------------------------------------------ 2425# ------------------------------------------------------------------------------
2318JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2426JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2319JAVA_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"
2320 2429
2321java-pkg_record-jar_() { 2430java-pkg_record-jar_() {
2322 debug-print-function ${FUNCNAME} $* 2431 debug-print-function ${FUNCNAME} $*
2323 2432
2324 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2433 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2325 if [[ "${1}" == "--optional" ]]; then 2434 case "${1}" in
2326 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2435 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2327 shift 2436 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2328 fi 2437 esac
2329 2438
2330 local pkg=${1} jar=${2} append 2439 local pkg=${1} jar=${2} append
2331 if [[ -z "${jar}" ]]; then 2440 if [[ -z "${jar}" ]]; then
2332 append="${pkg}" 2441 append="${pkg}"
2333 else 2442 else
2386# 2495#
2387# @return 0 - function is declared 2496# @return 0 - function is declared
2388# @return 1 - function is undeclared 2497# @return 1 - function is undeclared
2389# ------------------------------------------------------------------------------ 2498# ------------------------------------------------------------------------------
2390java-pkg_func-exists() { 2499java-pkg_func-exists() {
2391 if [[ -n "$(declare -f ${1})" ]]; then 2500 declare -F ${1} > /dev/null
2392 return 0
2393 else
2394 return 1
2395 fi
2396} 2501}
2397 2502
2398# ------------------------------------------------------------------------------ 2503# ------------------------------------------------------------------------------
2399# @internal-function java-pkg_setup-vm 2504# @internal-function java-pkg_setup-vm
2400# 2505#
2426# @return 1 - Package does not depend on virtual/jdk 2531# @return 1 - Package does not depend on virtual/jdk
2427# ------------------------------------------------------------------------------ 2532# ------------------------------------------------------------------------------
2428java-pkg_needs-vm() { 2533java-pkg_needs-vm() {
2429 debug-print-function ${FUNCNAME} $* 2534 debug-print-function ${FUNCNAME} $*
2430 2535
2431 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2536 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2432 return 0 2537 return 0
2433 fi 2538 fi
2434 2539
2435 return 1 2540 return 1
2436} 2541}
2484 # If you're forcing the VM, I hope you know what your doing... 2589 # If you're forcing the VM, I hope you know what your doing...
2485 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2590 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2486 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2591 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2487 # if we're allowed to switch the vm... 2592 # if we're allowed to switch the vm...
2488 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2593 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2489 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2594 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2490 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2491 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2492 else
2493 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2595 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2494 fi
2495 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2596 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2496 eerror "Unable to determine VM for building from dependencies:" 2597 eerror "Unable to determine VM for building from dependencies:"
2497 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2598 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2498 echo "VNEED: ${JAVA_PKG_VNEED}"
2499 die "Failed to determine VM for building." 2599 die "Failed to determine VM for building."
2500 else 2600 else
2501 export GENTOO_VM 2601 export GENTOO_VM
2502 fi 2602 fi
2503 # otherwise just make sure the current VM is sufficient 2603 # otherwise just make sure the current VM is sufficient
2542# 2642#
2543# Enhanced die for Java packages, which displays some information that may be 2643# Enhanced die for Java packages, which displays some information that may be
2544# useful for debugging bugs on bugzilla. 2644# useful for debugging bugs on bugzilla.
2545# ------------------------------------------------------------------------------ 2645# ------------------------------------------------------------------------------
2546#register_die_hook java-pkg_die 2646#register_die_hook java-pkg_die
2547if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2647if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2548 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2648 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2549fi 2649fi
2550 2650
2551java-pkg_die() { 2651java-pkg_die() {
2552 echo "!!! When you file a bug report, please include the following information:" >&2 2652 echo "!!! When you file a bug report, please include the following information:" >&2
2576# not. 2676# not.
2577# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2677# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2578# ------------------------------------------------------------------------------ 2678# ------------------------------------------------------------------------------
2579java-pkg_verify-classes() { 2679java-pkg_verify-classes() {
2580 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2680 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2681
2682 local version_verify="/usr/bin/class-version-verify.py"
2683
2684 if [[ ! -x "${version_verify}" ]]; then
2685 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2686 fi
2687
2688 if [[ ! -x "${version_verify}" ]]; then
2689 ewarn "Unable to perform class version checks as"
2690 ewarn "class-version-verify.py is unavailable"
2691 ewarn "Please install dev-java/javatoolkit."
2692 return
2693 fi
2694
2581 local target=$(java-pkg_get-target) 2695 local target=$(java-pkg_get-target)
2582 local result 2696 local result
2583 local log="${T}/class-version-verify.log" 2697 local log="${T}/class-version-verify.log"
2584 if [[ -n "${1}" ]]; then 2698 if [[ -n "${1}" ]]; then
2585 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2699 ${version_verify} -v -t ${target} "${1}" > "${log}"
2586 result=$? 2700 result=$?
2587 else 2701 else
2588 ebegin "Verifying java class versions (target: ${target})" 2702 ebegin "Verifying java class versions (target: ${target})"
2589 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2703 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2590 result=$? 2704 result=$?
2591 eend ${result} 2705 eend ${result}
2592 fi 2706 fi
2593 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2707 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2594 if [[ ${result} != 0 ]]; then 2708 if [[ ${result} != 0 ]]; then
2612 2726
2613 local limit_to="${1}" 2727 local limit_to="${1}"
2614 local target_pkg="${2}" 2728 local target_pkg="${2}"
2615 local dev_error="" 2729 local dev_error=""
2616 2730
2731 # remove the version specification, which may include globbing (* and [123])
2617 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2732 local stripped_pkg=$(echo "${target_pkg}" | sed \
2618 's/-[0-9]*\(\.[0-9]\)*$//') 2733 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2619 2734
2620 debug-print "Matching against: ${stripped_pkg}" 2735 debug-print "Matching against: ${stripped_pkg}"
2621 2736
2622 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2737 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2623 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2738 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2673 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2788 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2674 fi 2789 fi
2675} 2790}
2676 2791
2677java-pkg_check-jikes() { 2792java-pkg_check-jikes() {
2678 if hasq jikes ${IUSE}; then 2793 if has jikes ${IUSE}; then
2679 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2794 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2680 fi 2795 fi
2681} 2796}
2682 2797
2683java-pkg_announce-qa-violation() { 2798java-pkg_announce-qa-violation() {
2699is-java-strict() { 2814is-java-strict() {
2700 [[ -n ${JAVA_PKG_STRICT} ]] 2815 [[ -n ${JAVA_PKG_STRICT} ]]
2701 return $? 2816 return $?
2702} 2817}
2703 2818
2819
2704# ------------------------------------------------------------------------------ 2820# ------------------------------------------------------------------------------
2705# @eclass-end 2821# @eclass-end
2706# ------------------------------------------------------------------------------ 2822# ------------------------------------------------------------------------------

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.142

  ViewVC Help
Powered by ViewVC 1.1.20