/[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.106 Revision 1.137
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.106 2008/05/03 21:28:07 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.137 2011/03/15 19:54:12 serkan Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66hasq "${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 )" 76hasq 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#
365 if [[ ${jar} = *\** ]]; then 382 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 383 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 384 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 385 eerror '${D} add ${D} to the argument.'
369 fi 386 fi
387 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 388 die "${jar} does not exist"
371 fi 389 fi
372 done 390 done
373 391
374 java-pkg_do_write_ 392 java-pkg_do_write_
429# @param $@ - JNI libraries to install 447# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 448# ------------------------------------------------------------------------------
431java-pkg_doso() { 449java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 450 debug-print-function ${FUNCNAME} $*
433 451
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 452 java-pkg_check-phase install
436 453
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 454 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 455
439 java-pkg_init_paths_ 456 java-pkg_init_paths_
440 457
441 local lib 458 local lib
442 # for each lib 459 # for each lib
445 if [[ -e "${lib}" ]] ; then 462 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 463 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 464 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 465 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 466 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 467 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 468 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 469 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 470 # otherwise make a symlink to the symlink's origin
454 else 471 else
455 # TODO use dosym 472 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" 473 debug-print "${lib} is a symlink, linking accordantly"
459 fi 474 fi
460 # otherwise die 475 # otherwise die
461 else 476 else
462 die "${lib} does not exist" 477 die "${lib} does not exist"
463 fi 478 fi
479java-pkg_regso() { 494java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 495 debug-print-function ${FUNCNAME} $*
481 496
482 java-pkg_check-phase install 497 java-pkg_check-phase install
483 498
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 499 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 500
486 java-pkg_init_paths_ 501 java-pkg_init_paths_
487 502
488 local lib target_dir 503 local lib target_dir
489 for lib in "$@" ; do 504 for lib in "$@" ; do
874 889
875 local build_only="" 890 local build_only=""
876 local destdir="." 891 local destdir="."
877 local deep="" 892 local deep=""
878 local virtual="" 893 local virtual=""
894 local record_jar=""
879 895
880 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 896 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
881 897
882 while [[ "${1}" == --* ]]; do 898 while [[ "${1}" == --* ]]; do
883 if [[ "${1}" = "--build-only" ]]; then 899 if [[ "${1}" = "--build-only" ]]; then
918 for pkg in ${target_pkg//,/ }; do 934 for pkg in ${target_pkg//,/ }; do
919 java-pkg_ensure-dep "${build_only}" "${pkg}" 935 java-pkg_ensure-dep "${build_only}" "${pkg}"
920 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 936 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
921 done 937 done
922 # setting this disables further record-jar_ calls later 938 # setting this disables further record-jar_ calls later
923 build_only="build" 939 record_jar="true"
924 else 940 else
925 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 941 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
926 fi 942 fi
927 943
928 # Record the entire virtual as a dependency so that 944 # Record the entire virtual as a dependency so that
929 # no jars are missed. 945 # no jars are missed.
930 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 946 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
931 java-pkg_record-jar_ "${target_pkg}" 947 java-pkg_record-jar_ "${target_pkg}"
932 # setting this disables further record-jars_ calls later 948 # setting this disables further record-jars_ calls later
933 build_only="build" 949 record_jar="true"
934 fi 950 fi
935 951
936 pushd ${destdir} > /dev/null \ 952 pushd ${destdir} > /dev/null \
937 || die "failed to change directory to ${destdir}" 953 || die "failed to change directory to ${destdir}"
938 954
946 # If no specific target jar was indicated, link it 962 # If no specific target jar was indicated, link it
947 if [[ -z "${target_jar}" ]] ; then 963 if [[ -z "${target_jar}" ]] ; then
948 [[ -f "${target_jar}" ]] && rm "${target_jar}" 964 [[ -f "${target_jar}" ]] && rm "${target_jar}"
949 ln -snf "${jar}" \ 965 ln -snf "${jar}" \
950 || die "Failed to make symlink from ${jar} to ${jar_name}" 966 || die "Failed to make symlink from ${jar} to ${jar_name}"
967 if [[ -z "${record_jar}" ]]; then
968 if [[ -z "${build_only}" ]]; then
951 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 969 java-pkg_record-jar_ "${target_pkg}" "${jar}"
970 else
971 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
972 fi
973 fi
952 # otherwise, if the current jar is the target jar, link it 974 # otherwise, if the current jar is the target jar, link it
953 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 975 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
954 [[ -f "${destjar}" ]] && rm "${destjar}" 976 [[ -f "${destjar}" ]] && rm "${destjar}"
955 ln -snf "${jar}" "${destjar}" \ 977 ln -snf "${jar}" "${destjar}" \
956 || die "Failed to make symlink from ${jar} to ${destjar}" 978 || die "Failed to make symlink from ${jar} to ${destjar}"
979 if [[ -z "${record_jar}" ]]; then
980 if [[ -z "${build_only}" ]]; then
957 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 981 java-pkg_record-jar_ "${target_pkg}" "${jar}"
982 else
983 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
984 fi
985 fi
958 popd > /dev/null 986 popd > /dev/null
959 return 0 987 return 0
960 fi 988 fi
961 done 989 done
962 popd > /dev/null 990 popd > /dev/null
1035 1063
1036 for pkg in ${pkgs//,/ }; do 1064 for pkg in ${pkgs//,/ }; do
1037 java-pkg_ensure-dep "${build_only}" "${pkg}" 1065 java-pkg_ensure-dep "${build_only}" "${pkg}"
1038 done 1066 done
1039 1067
1040 # Only record jars that aren't build-only 1068 for pkg in ${pkgs//,/ }; do
1041 if [[ -z "${build_only}" ]]; then 1069 if [[ -z "${build_only}" ]]; then
1042 for pkg in ${pkgs//,/ }; do
1043 java-pkg_record-jar_ "${pkg}" 1070 java-pkg_record-jar_ "${pkg}"
1071 else
1072 java-pkg_record-jar_ --build-only "${pkg}"
1073 fi
1044 done 1074 done
1045 fi
1046 1075
1047 echo "${jars}" 1076 echo "${jars}"
1048} 1077}
1049 1078
1050# ------------------------------------------------------------------------------ 1079# ------------------------------------------------------------------------------
1071java-pkg_getjar() { 1100java-pkg_getjar() {
1072 debug-print-function ${FUNCNAME} $* 1101 debug-print-function ${FUNCNAME} $*
1073 1102
1074 local build_only="" 1103 local build_only=""
1075 local virtual="" 1104 local virtual=""
1105 local record_jar=""
1076 1106
1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1107 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1078 1108
1079 while [[ "${1}" == --* ]]; do 1109 while [[ "${1}" == --* ]]; do
1080 if [[ "${1}" = "--build-only" ]]; then 1110 if [[ "${1}" = "--build-only" ]]; then
1106 java-pkg_ensure-dep "${build_only}" "${pkg}" 1136 java-pkg_ensure-dep "${build_only}" "${pkg}"
1107 1137
1108 # Record the package(Virtual) as a dependency and then set build_only 1138 # Record the package(Virtual) as a dependency and then set build_only
1109 # So that individual jars are not recorded. 1139 # So that individual jars are not recorded.
1110 if [[ -n "${virtual}" ]]; then 1140 if [[ -n "${virtual}" ]]; then
1141 if [[ -z "${build_only}" ]]; then
1111 java-pkg_record-jar_ "${pkg}" 1142 java-pkg_record-jar_ "${pkg}"
1112 build_only="true" 1143 else
1144 java-pkg_record-jar_ --build-only "${pkg}"
1145 fi
1146 record_jar="true"
1113 fi 1147 fi
1114 1148
1115 for jar in ${classpath//:/ }; do 1149 for jar in ${classpath//:/ }; do
1116 if [[ ! -f "${jar}" ]] ; then 1150 if [[ ! -f "${jar}" ]] ; then
1117 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1151 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1118 fi 1152 fi
1119 1153
1120 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1154 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1121 # Only record jars that aren't build-only 1155 # Only record jars that aren't build-only
1122 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1156 if [[ -z "${record_jar}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}" "${jar}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1161 fi
1162 fi
1123 echo "${jar}" 1163 echo "${jar}"
1124 return 0 1164 return 0
1125 fi 1165 fi
1126 done 1166 done
1127 1167
1261 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1301 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1262 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1302 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1263 1303
1264 java-pkg_do_write_ 1304 java-pkg_do_write_
1265} 1305}
1306
1307# ------------------------------------------------------------------------------
1308# @ebuild-function java-pkg_get-bootclasspath
1309#
1310# Returns classpath of a given bootclasspath-providing package version.
1311#
1312# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1313# of the current JDK
1314# ------------------------------------------------------------------------------
1315
1316java-pkg_get-bootclasspath() {
1317 local version="${1}"
1318
1319 local bcp
1320 case "${version}" in
1321 auto)
1322 bcp="$(java-config -g BOOTCLASSPATH)"
1323 ;;
1324 1.5)
1325 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1326 ;;
1327 *)
1328 eerror "unknown parameter of java-pkg_get-bootclasspath"
1329 die "unknown parameter of java-pkg_get-bootclasspath"
1330 ;;
1331 esac
1332
1333 echo "${bcp}"
1334}
1335
1266 1336
1267# This function reads stdin, and based on that input, figures out how to 1337# This function reads stdin, and based on that input, figures out how to
1268# populate jars from the filesystem. 1338# populate jars from the filesystem.
1269# Need to figure out a good way of making use of this, ie be able to use a 1339# 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 1340# string that was built instead of stdin
1308# @section-begin helper 1378# @section-begin helper
1309# @section-summary Helper functions 1379# @section-summary Helper functions
1310# 1380#
1311# Various other functions to use from an ebuild 1381# Various other functions to use from an ebuild
1312# ------------------------------------------------------------------------------ 1382# ------------------------------------------------------------------------------
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 1383
1391# ------------------------------------------------------------------------------ 1384# ------------------------------------------------------------------------------
1392# @ebuild-function java-pkg_find-normal-jars 1385# @ebuild-function java-pkg_find-normal-jars
1393# 1386#
1394# Find the files with suffix .jar file in the given directory or $WORKDIR 1387# Find the files with suffix .jar file in the given directory or $WORKDIR
1743 1736
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1737 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1738 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1739 for i in ${WANT_ANT_TASKS}
1747 do 1740 do
1748 if [[ ${i} != ant-* ]]; then 1741 if [[ ${i} = ant-* ]]; then
1742 DEP="${DEP}dev-java/${i} "
1743 elif [[ ${i} = */*:* ]]; then
1744 DEP="${DEP}${i} "
1745 else
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1746 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1747 return 1
1751 fi 1748 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1749 done
1754 echo ${DEP} 1750 echo ${DEP}
1755 return 0 1751 return 0
1756 else 1752 else
1757 return 0 1753 return 0
1758 fi 1754 fi
1759} 1755}
1760 1756
1757
1761# ------------------------------------------------------------------------------ 1758# ------------------------------------------------------------------------------
1762# @ebuild-function ejunit 1759# @internal-function ejunit_
1763# 1760#
1764# Junit wrapper function. Makes it easier to run the tests and checks for 1761# 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. 1762# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1766# 1763#
1767# Examples: 1764# @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 1765# @param $2 - -cp or -classpath
1772# @param $2 - classpath; junit and recorded dependencies get appended 1766# @param $3 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java 1767# @param $@ - the rest of the parameters are passed to java
1774# ------------------------------------------------------------------------------
1775ejunit{ 1768ejunit_() {
1776 debug-print-function ${FUNCNAME} $* 1769 debug-print-function ${FUNCNAME} $*
1777 1770
1778 local pkgs 1771 local pkgs
1779 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1772 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1773 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1774 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1782 done 1775 done
1783 fi 1776 fi
1784 1777
1778 local junit=${1}
1779 shift 1
1780
1785 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1781 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1786 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1782 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1787 cp="${2}:${cp}" 1783 cp="${2}:${cp}"
1788 shift 2 1784 shift 2
1789 else 1785 else
1790 cp=".:${cp}" 1786 cp=".:${cp}"
1794 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1790 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1795 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1791 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1796} 1792}
1797 1793
1798# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1795# @ebuild-function ejunit
1796#
1797# Junit wrapper function. Makes it easier to run the tests and checks for
1798# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1799#
1800# Examples:
1801# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1802# ejunit org.blinkenlights.jid3.test.AllTests
1803#
1804# @param $1 - -cp or -classpath
1805# @param $2 - classpath; junit and recorded dependencies get appended
1806# @param $@ - the rest of the parameters are passed to java
1807# ------------------------------------------------------------------------------
1808ejunit() {
1809 debug-print-function ${FUNCNAME} $*
1810
1811 ejunit_ "junit" "${@}"
1812}
1813
1814# ------------------------------------------------------------------------------
1815# @ebuild-function ejunit4
1816#
1817# Junit4 wrapper function. Makes it easier to run the tests and checks for
1818# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1819#
1820# Examples:
1821# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1822# ejunit4 org.blinkenlights.jid3.test.AllTests
1823#
1824# @param $1 - -cp or -classpath
1825# @param $2 - classpath; junit and recorded dependencies get appended
1826# @param $@ - the rest of the parameters are passed to java
1827# ------------------------------------------------------------------------------
1828ejunit4() {
1829 debug-print-function ${FUNCNAME} $*
1830
1831 ejunit_ "junit-4" "${@}"
1832}
1833
1834# ------------------------------------------------------------------------------
1799# @section-end helper 1835# @section-end helper
1800# ------------------------------------------------------------------------------ 1836# ------------------------------------------------------------------------------
1837
1838# ------------------------------------------------------------------------------
1839# @eclass-src_prepare
1840#
1841# src_prepare Searches for bundled jars
1842# Don't call directly, but via java-pkg-2_src_prepare!
1843# ------------------------------------------------------------------------------
1844
1845java-utils-2_src_prepare() {
1846 [[ ${EBUILD_PHASE} == prepare ]] &&
1847 java-pkg_func-exists java_prepare && java_prepare
1848
1849 # Remember that eant will call this unless called via Portage
1850 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1851 echo "Searching for bundled jars:"
1852 java-pkg_find-normal-jars || echo "None found."
1853 echo "Searching for bundled classes (no output if none found):"
1854 find "${WORKDIR}" -name "*.class"
1855 echo "Search done."
1856 fi
1857 touch "${T}/java-utils-2_src_prepare-run"
1858}
1859
1860# ------------------------------------------------------------------------------
1861# @eclass-pkg_preinst
1862#
1863# pkg_preinst Searches for missing and unneeded dependencies
1864# Don't call directly, but via java-pkg-2_pkg_preinst!
1865# ------------------------------------------------------------------------------
1866
1867java-utils-2_pkg_preinst() {
1868 if is-java-strict; then
1869 if has_version dev-java/java-dep-check; then
1870 [[ -e "${JAVA_PKG_ENV}" ]] || return
1871 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1872 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1873 ewarn "Possibly unneeded dependencies found in package.env:"
1874 for dep in ${output}; do
1875 ewarn "\t${dep}"
1876 done
1877 fi
1878 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1879 ewarn "${output}"
1880 fi
1881 else
1882 eerror "Install dev-java/java-dep-check for dependency checking"
1883 fi
1884 fi
1885}
1801 1886
1802# ------------------------------------------------------------------------------ 1887# ------------------------------------------------------------------------------
1803# @section-begin build 1888# @section-begin build
1804# @section-summary Build functions 1889# @section-summary Build functions
1805# 1890#
1814# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1899# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1815# variables: 1900# variables:
1816# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1901# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1817# gentoo.classpath property. Be sure to call 1902# gentoo.classpath property. Be sure to call
1818# java-ant_rewrite-classpath in src_unpack. 1903# java-ant_rewrite-classpath in src_unpack.
1904# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1905# for build-time purposes, the dependency is not recorded to
1906# package.env!
1819# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1907# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1820# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1908# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1821# ------------------------------------------------------------------------------ 1909# ------------------------------------------------------------------------------
1822eant() { 1910eant() {
1823 debug-print-function ${FUNCNAME} $* 1911 debug-print-function ${FUNCNAME} $*
1824 1912
1825 if [[ ${EBUILD_PHASE} = compile ]]; then 1913 if [[ ${EBUILD_PHASE} = compile ]]; then
1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1914 java-ant-2_src_configure
1827 # finally get rid of the hooks without breaking stuff 1915 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
1835
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 1916 fi
1848 1917
1849 if ! hasq java-ant-2 ${INHERITED}; then 1918 if ! hasq java-ant-2 ${INHERITED}; then
1850 local msg="You should inherit java-ant-2 when using eant" 1919 local msg="You should inherit java-ant-2 when using eant"
1851 java-pkg_announce-qa-violation "${msg}" 1920 java-pkg_announce-qa-violation "${msg}"
1888 echo "more info." 1957 echo "more info."
1889 fi 1958 fi
1890 fi 1959 fi
1891 done 1960 done
1892 1961
1962 # parse WANT_ANT_TASKS for atoms
1963 local want_ant_tasks
1964 for i in ${WANT_ANT_TASKS}; do
1965 if [[ ${i} = */*:* ]]; then
1966 i=${i#*/}
1967 i=${i%:0}
1968 want_ant_tasks+="${i/:/-} "
1969 else
1970 want_ant_tasks+="${i} "
1971 fi
1972 done
1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1973 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1974 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1895 1975
1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1976 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1977 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1898 1978
1899 # if ant-tasks is not set by ebuild or forced, use none 1979 # if ant-tasks is not set by ebuild or forced, use none
1916 local gcp="${EANT_GENTOO_CLASSPATH}" 1996 local gcp="${EANT_GENTOO_CLASSPATH}"
1917 local getjarsarg="" 1997 local getjarsarg=""
1918 1998
1919 if [[ ${EBUILD_PHASE} = "test" ]]; then 1999 if [[ ${EBUILD_PHASE} = "test" ]]; then
1920 antflags="${antflags} -DJunit.present=true" 2000 antflags="${antflags} -DJunit.present=true"
1921 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2001 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1922 getjarsarg="--with-dependencies" 2002 getjarsarg="--with-dependencies"
1923 fi 2003 fi
1924 2004
1925 local cp 2005 local cp
1926 2006
1927 for atom in ${gcp}; do 2007 for atom in ${gcp}; do
1928 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2008 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1929 done 2009 done
1930 2010
2011 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2012
1931 if [[ ${cp} ]]; then 2013 if [[ ${cp} ]]; then
1932 # It seems ant does not like single quotes around ${cp} 2014 # It seems ant does not like single quotes around ${cp}
2015 cp=${cp#:}
2016 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2017 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1933 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2018 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1934 fi 2019 fi
1935 2020
1936 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2021 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1937 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2022 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1938 ant ${antflags} "${@}" || die "eant failed" 2023 ant ${antflags} "${@}" || die "eant failed"
2041# ----------------------------------------------------------------------------- 2126# -----------------------------------------------------------------------------
2042java-pkg_init() { 2127java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $* 2128 debug-print-function ${FUNCNAME} $*
2044 unset JAVAC 2129 unset JAVAC
2045 unset JAVA_HOME 2130 unset JAVA_HOME
2131
2132 java-config --help >/dev/null || {
2133 eerror ""
2134 eerror "Can't run java-config --help"
2135 eerror "Have you upgraded python recently but haven't"
2136 eerror "run python-updater yet?"
2137 die "Can't run java-config --help"
2138 }
2046 2139
2047 # People do all kinds of weird things. 2140 # People do all kinds of weird things.
2048 # http://forums.gentoo.org/viewtopic-p-3943166.html 2141 # http://forums.gentoo.org/viewtopic-p-3943166.html
2049 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2142 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2050 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2143 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2088 export CLASSPATH= 2181 export CLASSPATH=
2089 2182
2090 # Unset external ANT_ stuff 2183 # Unset external ANT_ stuff
2091 export ANT_TASKS= 2184 export ANT_TASKS=
2092 export ANT_OPTS= 2185 export ANT_OPTS=
2186 export ANT_RESPECT_JAVA_HOME=
2093} 2187}
2094 2188
2095# ------------------------------------------------------------------------------ 2189# ------------------------------------------------------------------------------
2096# @function-internal java-pkg-init-compiler_ 2190# @function-internal java-pkg-init-compiler_
2097# 2191#
2259 # Create package.env 2353 # Create package.env
2260 ( 2354 (
2261 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2355 echo "DESCRIPTION=\"${DESCRIPTION}\""
2262 echo "GENERATION=\"2\"" 2356 echo "GENERATION=\"2\""
2263 echo "SLOT=\"${SLOT}\"" 2357 echo "SLOT=\"${SLOT}\""
2358 echo "CATEGORY=\"${CATEGORY}\""
2359 echo "PVR=\"${PVR}\""
2264 2360
2265 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2361 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2266 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2362 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2267 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2363 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2268 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2364 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2269 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2365 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2270 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2366 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2271 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2367 && 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 ! 2368 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2369 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2370 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2273 ) > "${JAVA_PKG_ENV}" 2371 ) > "${JAVA_PKG_ENV}"
2274 2372
2275 # register target/source 2373 # register target/source
2276 local target="$(java-pkg_get-target)" 2374 local target="$(java-pkg_get-target)"
2277 local source="$(java-pkg_get-source)" 2375 local source="$(java-pkg_get-source)"
2310# ------------------------------------------------------------------------------ 2408# ------------------------------------------------------------------------------
2311# @internal-function java-pkg_record-jar_ 2409# @internal-function java-pkg_record-jar_
2312# 2410#
2313# Record an (optional) dependency to the package.env 2411# Record an (optional) dependency to the package.env
2314# @param --optional - record dependency as optional 2412# @param --optional - record dependency as optional
2413# @param --build - record dependency as build_only
2315# @param $1 - package to record 2414# @param $1 - package to record
2316# @param $2 - (optional) jar of package to record 2415# @param $2 - (optional) jar of package to record
2317# ------------------------------------------------------------------------------ 2416# ------------------------------------------------------------------------------
2318JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2417JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2319JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2418JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2419JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2320 2420
2321java-pkg_record-jar_() { 2421java-pkg_record-jar_() {
2322 debug-print-function ${FUNCNAME} $* 2422 debug-print-function ${FUNCNAME} $*
2323 2423
2324 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2424 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2325 if [[ "${1}" == "--optional" ]]; then 2425 case "${1}" in
2326 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2426 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2327 shift 2427 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2328 fi 2428 esac
2329 2429
2330 local pkg=${1} jar=${2} append 2430 local pkg=${1} jar=${2} append
2331 if [[ -z "${jar}" ]]; then 2431 if [[ -z "${jar}" ]]; then
2332 append="${pkg}" 2432 append="${pkg}"
2333 else 2433 else
2386# 2486#
2387# @return 0 - function is declared 2487# @return 0 - function is declared
2388# @return 1 - function is undeclared 2488# @return 1 - function is undeclared
2389# ------------------------------------------------------------------------------ 2489# ------------------------------------------------------------------------------
2390java-pkg_func-exists() { 2490java-pkg_func-exists() {
2391 if [[ -n "$(declare -f ${1})" ]]; then 2491 declare -F ${1} > /dev/null
2392 return 0
2393 else
2394 return 1
2395 fi
2396} 2492}
2397 2493
2398# ------------------------------------------------------------------------------ 2494# ------------------------------------------------------------------------------
2399# @internal-function java-pkg_setup-vm 2495# @internal-function java-pkg_setup-vm
2400# 2496#
2426# @return 1 - Package does not depend on virtual/jdk 2522# @return 1 - Package does not depend on virtual/jdk
2427# ------------------------------------------------------------------------------ 2523# ------------------------------------------------------------------------------
2428java-pkg_needs-vm() { 2524java-pkg_needs-vm() {
2429 debug-print-function ${FUNCNAME} $* 2525 debug-print-function ${FUNCNAME} $*
2430 2526
2431 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2527 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2432 return 0 2528 return 0
2433 fi 2529 fi
2434 2530
2435 return 1 2531 return 1
2436} 2532}
2484 # If you're forcing the VM, I hope you know what your doing... 2580 # 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}" 2581 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2486 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2582 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2487 # if we're allowed to switch the vm... 2583 # if we're allowed to switch the vm...
2488 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2584 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}" 2585 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}}")" 2586 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2494 fi
2495 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2587 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2496 eerror "Unable to determine VM for building from dependencies:" 2588 eerror "Unable to determine VM for building from dependencies:"
2497 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2589 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2498 echo "VNEED: ${JAVA_PKG_VNEED}"
2499 die "Failed to determine VM for building." 2590 die "Failed to determine VM for building."
2500 else 2591 else
2501 export GENTOO_VM 2592 export GENTOO_VM
2502 fi 2593 fi
2503 # otherwise just make sure the current VM is sufficient 2594 # otherwise just make sure the current VM is sufficient
2576# not. 2667# not.
2577# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2668# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2578# ------------------------------------------------------------------------------ 2669# ------------------------------------------------------------------------------
2579java-pkg_verify-classes() { 2670java-pkg_verify-classes() {
2580 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2671 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2672
2673 local version_verify="/usr/bin/class-version-verify.py"
2674
2675 if [[ ! -x "${version_verify}" ]]; then
2676 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2677 fi
2678
2679 if [[ ! -x "${version_verify}" ]]; then
2680 ewarn "Unable to perform class version checks as"
2681 ewarn "class-version-verify.py is unavailable"
2682 ewarn "Please install dev-java/javatoolkit."
2683 return
2684 fi
2685
2581 local target=$(java-pkg_get-target) 2686 local target=$(java-pkg_get-target)
2582 local result 2687 local result
2583 local log="${T}/class-version-verify.log" 2688 local log="${T}/class-version-verify.log"
2584 if [[ -n "${1}" ]]; then 2689 if [[ -n "${1}" ]]; then
2585 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2690 ${version_verify} -v -t ${target} "${1}" > "${log}"
2586 result=$? 2691 result=$?
2587 else 2692 else
2588 ebegin "Verifying java class versions (target: ${target})" 2693 ebegin "Verifying java class versions (target: ${target})"
2589 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2694 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2590 result=$? 2695 result=$?
2591 eend ${result} 2696 eend ${result}
2592 fi 2697 fi
2593 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2698 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2594 if [[ ${result} != 0 ]]; then 2699 if [[ ${result} != 0 ]]; then
2612 2717
2613 local limit_to="${1}" 2718 local limit_to="${1}"
2614 local target_pkg="${2}" 2719 local target_pkg="${2}"
2615 local dev_error="" 2720 local dev_error=""
2616 2721
2722 # remove the version specification, which may include globbing (* and [123])
2617 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2723 local stripped_pkg=$(echo "${target_pkg}" | sed \
2618 's/-[0-9]*\(\.[0-9]\)*$//') 2724 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2619 2725
2620 debug-print "Matching against: ${stripped_pkg}" 2726 debug-print "Matching against: ${stripped_pkg}"
2621 2727
2622 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2728 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2623 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2729 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2699is-java-strict() { 2805is-java-strict() {
2700 [[ -n ${JAVA_PKG_STRICT} ]] 2806 [[ -n ${JAVA_PKG_STRICT} ]]
2701 return $? 2807 return $?
2702} 2808}
2703 2809
2810
2704# ------------------------------------------------------------------------------ 2811# ------------------------------------------------------------------------------
2705# @eclass-end 2812# @eclass-end
2706# ------------------------------------------------------------------------------ 2813# ------------------------------------------------------------------------------

Legend:
Removed from v.1.106  
changed lines
  Added in v.1.137

  ViewVC Help
Powered by ViewVC 1.1.20