/[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.98 Revision 1.150
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2011, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.98 2007/11/26 21:00:59 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.150 2012/03/13 10:05:46 sera Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
77 94
78# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
80# @variable-default yes 97# @variable-default yes
81# 98#
94# Should only be used for testing and debugging. 111# Should only be used for testing and debugging.
95# 112#
96# @example Use sun-jdk-1.5 to emerge foo 113# @example Use sun-jdk-1.5 to emerge foo
97# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
98# 115#
116# -----------------------------------------------------------------------------
117
118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
99# ----------------------------------------------------------------------------- 129# -----------------------------------------------------------------------------
100 130
101# ----------------------------------------------------------------------------- 131# -----------------------------------------------------------------------------
102# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
103# 133#
224 ( # dont want to pollute calling env 254 ( # dont want to pollute calling env
225 insinto "${dest}" 255 insinto "${dest}"
226 doins -r "$@" 256 doins -r "$@"
227 ) || die "Installing examples failed" 257 ) || die "Installing examples failed"
228 fi 258 fi
259
260 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
229} 262}
230 263
231# ----------------------------------------------------------------------------- 264# -----------------------------------------------------------------------------
232# @ebuild-function java-pkg_dojar 265# @ebuild-function java-pkg_dojar
233# 266#
291 done 324 done
292 325
293 java-pkg_do_write_ 326 java-pkg_do_write_
294} 327}
295 328
296
297# ------------------------------------------------------------------------------ 329# ------------------------------------------------------------------------------
298# @internal-function depend-java-query 330# @internal-function depend-java-query
299# 331#
300# Wrapper for the depend-java-query binary to enable passing USE in env. 332# Wrapper for the depend-java-query binary to enable passing USE in env.
301# Using env variables keeps this eclass working with java-config versions that 333# Using env variables keeps this eclass working with java-config versions that
366 if [[ ${jar} = *\** ]]; then 398 if [[ ${jar} = *\** ]]; then
367 eerror "The argument ${jar} to ${FUNCNAME}" 399 eerror "The argument ${jar} to ${FUNCNAME}"
368 eerror "has * in it. If you want it to glob in" 400 eerror "has * in it. If you want it to glob in"
369 eerror '${D} add ${D} to the argument.' 401 eerror '${D} add ${D} to the argument.'
370 fi 402 fi
403 debug-print "${jar} or ${D}${jar} not found"
371 die "${jar} does not exist" 404 die "${jar} does not exist"
372 fi 405 fi
373 done 406 done
374 407
375 java-pkg_do_write_ 408 java-pkg_do_write_
430# @param $@ - JNI libraries to install 463# @param $@ - JNI libraries to install
431# ------------------------------------------------------------------------------ 464# ------------------------------------------------------------------------------
432java-pkg_doso() { 465java-pkg_doso() {
433 debug-print-function ${FUNCNAME} $* 466 debug-print-function ${FUNCNAME} $*
434 467
435 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
436 java-pkg_check-phase install 468 java-pkg_check-phase install
437 469
438 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 470 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
439 471
440 java-pkg_init_paths_ 472 java-pkg_init_paths_
441 473
442 local lib 474 local lib
443 # for each lib 475 # for each lib
446 if [[ -e "${lib}" ]] ; then 478 if [[ -e "${lib}" ]] ; then
447 # install if it isn't a symlink 479 # install if it isn't a symlink
448 if [[ ! -L "${lib}" ]] ; then 480 if [[ ! -L "${lib}" ]] ; then
449 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 481 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
450 INSOPTIONS="${LIBOPTIONS}" \ 482 INSOPTIONS="${LIBOPTIONS}" \
451 doins "${lib}" || "failed to install ${lib}" 483 doins "${lib}" || die "failed to install ${lib}"
452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 484 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 485 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
454 # otherwise make a symlink to the symlink's origin 486 # otherwise make a symlink to the symlink's origin
455 else 487 else
456 # TODO use dosym 488 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
457 ln -s "$(readlink "${lib}")" \
458 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
459 debug-print "${lib} is a symlink, linking accordanly" 489 debug-print "${lib} is a symlink, linking accordantly"
460 fi 490 fi
461 # otherwise die 491 # otherwise die
462 else 492 else
463 die "${lib} does not exist" 493 die "${lib} does not exist"
464 fi 494 fi
480java-pkg_regso() { 510java-pkg_regso() {
481 debug-print-function ${FUNCNAME} $* 511 debug-print-function ${FUNCNAME} $*
482 512
483 java-pkg_check-phase install 513 java-pkg_check-phase install
484 514
485 [[ ${#} -lt 1 ]] && "at least one argument needed" 515 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
486 516
487 java-pkg_init_paths_ 517 java-pkg_init_paths_
488 518
489 local lib target_dir 519 local lib target_dir
490 for lib in "$@" ; do 520 for lib in "$@" ; do
557# ------------------------------------------------------------------------------ 587# ------------------------------------------------------------------------------
558# @ebuild-function java-pkg_dojavadoc 588# @ebuild-function java-pkg_dojavadoc
559# 589#
560# Installs javadoc documentation. This should be controlled by the doc use flag. 590# Installs javadoc documentation. This should be controlled by the doc use flag.
561# 591#
592# @param $1: optional --symlink creates to symlink like this for html
593# documentation bundles.
562# @param $1: - The javadoc root directory. 594# @param $2: - The javadoc root directory.
563# 595#
564# @example: 596# @example:
565# java-pkg_dojavadoc docs/api 597# java-pkg_dojavadoc docs/api
598# java-pkg_dojavadoc --symlink apidocs docs/api
566# 599#
567# ------------------------------------------------------------------------------ 600# ------------------------------------------------------------------------------
568java-pkg_dojavadoc() { 601java-pkg_dojavadoc() {
569 debug-print-function ${FUNCNAME} $* 602 debug-print-function ${FUNCNAME} $*
603
604 # For html documentation bundles that link to Javadoc
605 local symlink
606 if [[ ${1} = --symlink ]]; then
607 symlink=${2}
608 shift 2
609 fi
610
570 local dir="$1" 611 local dir="$1"
612 local dest=/usr/share/doc/${PF}/html
571 613
572 # QA checks 614 # QA checks
573 615
574 java-pkg_check-phase install 616 java-pkg_check-phase install
575 617
579 local msg="No index.html in javadoc directory" 621 local msg="No index.html in javadoc directory"
580 ewarn "${msg}" 622 ewarn "${msg}"
581 is-java-strict && die "${msg}" 623 is-java-strict && die "${msg}"
582 fi 624 fi
583 625
626 if [[ -e ${D}/${dest}/api ]]; then
627 eerror "${dest} already exists. Will not overwrite."
628 die "${dest}"
629 fi
630
584 # Renaming to match our directory layout 631 # Renaming to match our directory layout
585 632
586 local dir_to_install="${dir}" 633 local dir_to_install="${dir}"
587 if [[ "$(basename "${dir}")" != "api" ]]; then 634 if [[ "$(basename "${dir}")" != "api" ]]; then
588 dir_to_install="${T}/api" 635 dir_to_install="${T}/api"
590 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 637 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
591 fi 638 fi
592 639
593 # Actual installation 640 # Actual installation
594 641
595 java-pkg_dohtml -r ${dir_to_install} 642 java-pkg_dohtml -r "${dir_to_install}"
643
644 # Let's make a symlink to the directory we have everything else under
645 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
646
647 if [[ ${symlink} ]]; then
648 debug-print "symlinking ${dest}/{api,${symlink}}"
649 dosym ${dest}/{api,${symlink}} || die
650 fi
596} 651}
597 652
598# ------------------------------------------------------------------------------ 653# ------------------------------------------------------------------------------
599# @ebuild-function java-pkg_dosrc 654# @ebuild-function java-pkg_dosrc
600# 655#
623 678
624 [[ ${#} -lt 1 ]] && die "At least one argument needed" 679 [[ ${#} -lt 1 ]] && die "At least one argument needed"
625 680
626 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 681 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
627 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 682 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
628 if is-java-strict; then 683 java-pkg_announce-qa-violation ${msg}
629 eerror "${msg}"
630 die "${msg}"
631 else
632 echo "${msg}"
633 echo "Please report this to http://bugs.gentoo.org."
634 fi
635 fi 684 fi
636 685
637 java-pkg_init_paths_ 686 java-pkg_init_paths_
638 687
639 local zip_name="${PN}-src.zip" 688 local zip_name="${PN}-src.zip"
856 905
857 local build_only="" 906 local build_only=""
858 local destdir="." 907 local destdir="."
859 local deep="" 908 local deep=""
860 local virtual="" 909 local virtual=""
910 local record_jar=""
861 911
862 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 912 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
863 913
864 while [[ "${1}" == --* ]]; do 914 while [[ "${1}" == --* ]]; do
865 if [[ "${1}" = "--build-only" ]]; then 915 if [[ "${1}" = "--build-only" ]]; then
879 929
880 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 930 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
881 931
882 [[ -z ${target_pkg} ]] && die "Must specify a package" 932 [[ -z ${target_pkg} ]] && die "Must specify a package"
883 933
934 if [[ "${EAPI}" == "1" ]]; then
935 target_pkg="${target_pkg//:/-}"
936 fi
937
884 # default destjar to the target jar 938 # default destjar to the target jar
885 [[ -z "${destjar}" ]] && destjar="${target_jar}" 939 [[ -z "${destjar}" ]] && destjar="${target_jar}"
886 940
887 local error_msg="There was a problem getting the classpath for ${target_pkg}." 941 local error_msg="There was a problem getting the classpath for ${target_pkg}."
888 local classpath 942 local classpath
896 for pkg in ${target_pkg//,/ }; do 950 for pkg in ${target_pkg//,/ }; do
897 java-pkg_ensure-dep "${build_only}" "${pkg}" 951 java-pkg_ensure-dep "${build_only}" "${pkg}"
898 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
899 done 953 done
900 # setting this disables further record-jar_ calls later 954 # setting this disables further record-jar_ calls later
901 build_only="build" 955 record_jar="true"
902 else 956 else
903 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 957 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
904 fi 958 fi
905 959
906 # Record the entire virtual as a dependency so that 960 # Record the entire virtual as a dependency so that
907 # no jars are missed. 961 # no jars are missed.
908 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 962 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
909 java-pkg_record-jar_ "${target_pkg}" 963 java-pkg_record-jar_ "${target_pkg}"
910 # setting this disables further record-jars_ calls later 964 # setting this disables further record-jars_ calls later
911 build_only="build" 965 record_jar="true"
912 fi 966 fi
913 967
914 pushd ${destdir} > /dev/null \ 968 pushd ${destdir} > /dev/null \
915 || die "failed to change directory to ${destdir}" 969 || die "failed to change directory to ${destdir}"
916 970
924 # If no specific target jar was indicated, link it 978 # If no specific target jar was indicated, link it
925 if [[ -z "${target_jar}" ]] ; then 979 if [[ -z "${target_jar}" ]] ; then
926 [[ -f "${target_jar}" ]] && rm "${target_jar}" 980 [[ -f "${target_jar}" ]] && rm "${target_jar}"
927 ln -snf "${jar}" \ 981 ln -snf "${jar}" \
928 || die "Failed to make symlink from ${jar} to ${jar_name}" 982 || die "Failed to make symlink from ${jar} to ${jar_name}"
983 if [[ -z "${record_jar}" ]]; then
984 if [[ -z "${build_only}" ]]; then
929 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 985 java-pkg_record-jar_ "${target_pkg}" "${jar}"
986 else
987 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
988 fi
989 fi
930 # otherwise, if the current jar is the target jar, link it 990 # otherwise, if the current jar is the target jar, link it
931 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 991 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
932 [[ -f "${destjar}" ]] && rm "${destjar}" 992 [[ -f "${destjar}" ]] && rm "${destjar}"
933 ln -snf "${jar}" "${destjar}" \ 993 ln -snf "${jar}" "${destjar}" \
934 || die "Failed to make symlink from ${jar} to ${destjar}" 994 || die "Failed to make symlink from ${jar} to ${destjar}"
995 if [[ -z "${record_jar}" ]]; then
996 if [[ -z "${build_only}" ]]; then
935 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 997 java-pkg_record-jar_ "${target_pkg}" "${jar}"
998 else
999 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
1000 fi
1001 fi
936 popd > /dev/null 1002 popd > /dev/null
937 return 0 1003 return 0
938 fi 1004 fi
939 done 1005 done
940 popd > /dev/null 1006 popd > /dev/null
999 done 1065 done
1000 1066
1001 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1067 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1002 1068
1003 1069
1004 local classpath pkgs="${1}" 1070 local pkgs="${1}"
1071
1072 if [[ "${EAPI}" == "1" ]]; then
1073 pkgs="${pkgs//:/-}"
1074 fi
1075
1005 jars="$(java-config ${deep} --classpath=${pkgs})" 1076 jars="$(java-config ${deep} --classpath=${pkgs})"
1006 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1077 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1007 debug-print "${pkgs}:${jars}" 1078 debug-print "${pkgs}:${jars}"
1008 1079
1009 for pkg in ${pkgs//,/ }; do 1080 for pkg in ${pkgs//,/ }; do
1010 java-pkg_ensure-dep "${build_only}" "${pkg}" 1081 java-pkg_ensure-dep "${build_only}" "${pkg}"
1011 done 1082 done
1012 1083
1013 if [[ -z "${classpath}" ]]; then 1084 for pkg in ${pkgs//,/ }; do
1014 classpath="${jars}"
1015 else
1016 classpath="${classpath}:${jars}"
1017 fi
1018
1019 # Only record jars that aren't build-only
1020 if [[ -z "${build_only}" ]]; then 1085 if [[ -z "${build_only}" ]]; then
1021 for pkg in ${pkgs//,/ }; do
1022 java-pkg_record-jar_ "${pkg}" 1086 java-pkg_record-jar_ "${pkg}"
1087 else
1088 java-pkg_record-jar_ --build-only "${pkg}"
1089 fi
1023 done 1090 done
1024 fi
1025 1091
1026 echo "${classpath}" 1092 echo "${jars}"
1027} 1093}
1028 1094
1029# ------------------------------------------------------------------------------ 1095# ------------------------------------------------------------------------------
1030# @ebuild-function java-pkg_getjar 1096# @ebuild-function java-pkg_getjar
1031# 1097#
1050java-pkg_getjar() { 1116java-pkg_getjar() {
1051 debug-print-function ${FUNCNAME} $* 1117 debug-print-function ${FUNCNAME} $*
1052 1118
1053 local build_only="" 1119 local build_only=""
1054 local virtual="" 1120 local virtual=""
1121 local record_jar=""
1055 1122
1056 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1123 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1057 1124
1058 while [[ "${1}" == --* ]]; do 1125 while [[ "${1}" == --* ]]; do
1059 if [[ "${1}" = "--build-only" ]]; then 1126 if [[ "${1}" = "--build-only" ]]; then
1060 build_only="build" 1127 build_only="build"
1061 elif [[ "${1}" == --* ]]; then 1128 elif [[ "${1}" == "--virtual" ]]; then
1062 virtual="true" 1129 virtual="true"
1063 else 1130 else
1064 die "java-pkg_jar-from called with unknown parameter: ${1}" 1131 die "java-pkg_getjar called with unknown parameter: ${1}"
1065 fi 1132 fi
1066 shift 1133 shift
1067 done 1134 done
1068 1135
1069 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1136 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1070 1137
1071 local pkg="${1}" target_jar="${2}" jar 1138 local pkg="${1}" target_jar="${2}" jar
1139
1140 if [[ "${EAPI}" == "1" ]]; then
1141 pkg="${pkg//:/-}"
1142 fi
1143
1072 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1144 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1073 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1145 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1074 1146
1075 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1147 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1076 local classpath 1148 local classpath
1080 java-pkg_ensure-dep "${build_only}" "${pkg}" 1152 java-pkg_ensure-dep "${build_only}" "${pkg}"
1081 1153
1082 # Record the package(Virtual) as a dependency and then set build_only 1154 # Record the package(Virtual) as a dependency and then set build_only
1083 # So that individual jars are not recorded. 1155 # So that individual jars are not recorded.
1084 if [[ -n "${virtual}" ]]; then 1156 if [[ -n "${virtual}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1085 java-pkg_record-jar_ "${pkg}" 1158 java-pkg_record-jar_ "${pkg}"
1086 build_only="true" 1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}"
1161 fi
1162 record_jar="true"
1087 fi 1163 fi
1088 1164
1089 for jar in ${classpath//:/ }; do 1165 for jar in ${classpath//:/ }; do
1090 if [[ ! -f "${jar}" ]] ; then 1166 if [[ ! -f "${jar}" ]] ; then
1091 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1167 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1092 fi 1168 fi
1093 1169
1094 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1170 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1095 # Only record jars that aren't build-only 1171 # Only record jars that aren't build-only
1096 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1172 if [[ -z "${record_jar}" ]]; then
1173 if [[ -z "${build_only}" ]]; then
1174 java-pkg_record-jar_ "${pkg}" "${jar}"
1175 else
1176 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1177 fi
1178 fi
1097 echo "${jar}" 1179 echo "${jar}"
1098 return 0 1180 return 0
1099 fi 1181 fi
1100 done 1182 done
1101 1183
1137 1219
1138 local pkgs="${1}" 1220 local pkgs="${1}"
1139 local jar="${2}" 1221 local jar="${2}"
1140 1222
1141 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1223 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1224
1225 if [[ "${EAPI}" == "1" ]]; then
1226 pkgs="${pkgs//:/-}"
1227 fi
1142 1228
1143 if [[ -z "${jar}" ]]; then 1229 if [[ -z "${jar}" ]]; then
1144 for pkg in ${pkgs//,/ }; do 1230 for pkg in ${pkgs//,/ }; do
1145 java-pkg_ensure-dep runtime "${pkg}" 1231 java-pkg_ensure-dep runtime "${pkg}"
1146 java-pkg_record-jar_ "${pkg}" 1232 java-pkg_record-jar_ "${pkg}"
1189 local pkgs="${1}" 1275 local pkgs="${1}"
1190 local jar="${2}" 1276 local jar="${2}"
1191 1277
1192 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1278 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1193 1279
1280 if [[ "${EAPI}" == "1" ]]; then
1281 pkgs="${pkgs//:/-}"
1282 fi
1283
1194 if [[ -z "${jar}" ]]; then 1284 if [[ -z "${jar}" ]]; then
1195 for pkg in ${pkgs//,/ }; do 1285 for pkg in ${pkgs//,/ }; do
1196 java-pkg_record-jar_ --optional "${pkg}" 1286 java-pkg_record-jar_ --optional "${pkg}"
1197 done 1287 done
1198 else 1288 else
1227 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1317 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1228 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1229 1319
1230 java-pkg_do_write_ 1320 java-pkg_do_write_
1231} 1321}
1322
1323# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_get-bootclasspath
1325#
1326# Returns classpath of a given bootclasspath-providing package version.
1327#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() {
1333 local version="${1}"
1334
1335 local bcp
1336 case "${version}" in
1337 auto)
1338 bcp="$(java-config -g BOOTCLASSPATH)"
1339 ;;
1340 1.5)
1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1342 ;;
1343 *)
1344 eerror "unknown parameter of java-pkg_get-bootclasspath"
1345 die "unknown parameter of java-pkg_get-bootclasspath"
1346 ;;
1347 esac
1348
1349 echo "${bcp}"
1350}
1351
1232 1352
1233# This function reads stdin, and based on that input, figures out how to 1353# This function reads stdin, and based on that input, figures out how to
1234# populate jars from the filesystem. 1354# populate jars from the filesystem.
1235# Need to figure out a good way of making use of this, ie be able to use a 1355# Need to figure out a good way of making use of this, ie be able to use a
1236# string that was built instead of stdin 1356# string that was built instead of stdin
1274# @section-begin helper 1394# @section-begin helper
1275# @section-summary Helper functions 1395# @section-summary Helper functions
1276# 1396#
1277# Various other functions to use from an ebuild 1397# Various other functions to use from an ebuild
1278# ------------------------------------------------------------------------------ 1398# ------------------------------------------------------------------------------
1279
1280# ------------------------------------------------------------------------------
1281# @ebuild-function java-pkg_need
1282#
1283# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1284# Currently supported virtuals are:
1285# javamail
1286# jdbc-stdext
1287# jaf
1288# jdbc-rowset
1289# jms
1290#
1291# @param $1 - Optionally indicate that the dependencies are controlled by
1292# a use flag by specifying '--use' Requires $2.
1293# @param $2 - USE flag which will enable the dependencies.
1294# @param $@ - virtual packages to add depenedencies for
1295# ------------------------------------------------------------------------------
1296# TODO rewrite to parse a line based declaration file instead -- karltk
1297#java-pkg_need() {
1298# debug-print-function ${FUNCNAME} $*
1299# local useflag
1300# if [[ ${1} == "--use" ]]; then
1301# useflag="${2}"
1302# shift 2
1303# fi
1304#
1305# if [[ -z ${1} ]]; then
1306# die "Must specify at least one virtual package."
1307# fi
1308#
1309# local depstr newdepstr
1310#
1311# for virtual in ${@}; do
1312# if has ${virtual} ${JAVA_PKG_VNEED}; then
1313# debug-print "Already registered virtual ${virtual}"
1314# continue
1315# fi
1316# case ${virtual} in
1317# javamail)
1318# debug-print "java-pkg_need: adding javamail dependencies"
1319# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1320# ;;
1321# jdbc-stdext)
1322# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1323# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1324# ;;
1325# jaf)
1326# debug-print "java-pkg_need: adding jaf dependencies"
1327# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1328# ;;
1329# jdbc-rowset)
1330# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1331# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1332# ;;
1333# jms)
1334# debug-print "java-pkg_need: adding jms dependencies"
1335# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1336# ;;
1337# *)
1338# die "Invalid virtual: ${virtual}"
1339# esac
1340#
1341# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1342#
1343# if [[ -n ${useflag} ]]; then
1344# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1345# else
1346# depstr="${depstr} ${newdepstr}"
1347# fi
1348# done
1349#
1350# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1351# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1352#
1353# export DEPEND="${DEPEND} ${depstr}"
1354# export RDEPEND="${RDEPEND} ${depstr}"
1355#}
1356 1399
1357# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
1358# @ebuild-function java-pkg_find-normal-jars 1401# @ebuild-function java-pkg_find-normal-jars
1359# 1402#
1360# Find the files with suffix .jar file in the given directory or $WORKDIR 1403# Find the files with suffix .jar file in the given directory or $WORKDIR
1526java-pkg_get-current-vm() { 1569java-pkg_get-current-vm() {
1527 echo ${GENTOO_VM} 1570 echo ${GENTOO_VM}
1528} 1571}
1529 1572
1530java-pkg_current-vm-matches() { 1573java-pkg_current-vm-matches() {
1531 hasq $(java-pkg_get-current-vm) ${@} 1574 has $(java-pkg_get-current-vm) ${@}
1532 return $? 1575 return $?
1533} 1576}
1534 1577
1535# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1536# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1651 die "No GCJ support found!" 1694 die "No GCJ support found!"
1652 fi 1695 fi
1653} 1696}
1654 1697
1655java-pkg_ensure-test() { 1698java-pkg_ensure-test() {
1656 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1699 if has test ${FEATURES} && ! has -test ${FEATURES} \
1657 && hasq test ${IUSE} && ! use test; 1700 && has test ${IUSE} && ! use test;
1658 then 1701 then
1659 eerror "You specified FEATURES=test, but USE=test is needed" 1702 eerror "You specified FEATURES=test, but USE=test is needed"
1660 eerror "to pull in the additional dependencies for testing" 1703 eerror "to pull in the additional dependencies for testing"
1661 die "Need USE=test enabled" 1704 die "Need USE=test enabled"
1662 fi 1705 fi
1698 dodir /usr/share/ant/${TASKS_DIR} 1741 dodir /usr/share/ant/${TASKS_DIR}
1699 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1742 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1700} 1743}
1701 1744
1702# ------------------------------------------------------------------------------ 1745# ------------------------------------------------------------------------------
1703# @internal-function java-pkg_ant-tasks-from-deps
1704#
1705# Function to determine ANT_TASKS from DEPEND variable for backwards
1706# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1707# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1708# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1709# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1710# be a problem, the worst it can do is activace all tasks when not needed.
1711# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1712# insufficient dependencies, otherwise all available tasks are used for
1713# backwards compatilbility.
1714#
1715# @return "all" or "none"
1716# ------------------------------------------------------------------------------
1717java-pkg_ant-tasks-from-deps() {
1718 local found_ant found_ant_tasks
1719
1720 for dep in ${DEPEND}
1721 do
1722 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1723 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1724 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1725 done
1726
1727 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1728 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1729 echo "all"
1730 else
1731 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1732 # so we deactivate all tasks that may be installed
1733 echo "none"
1734 fi
1735}
1736
1737# ------------------------------------------------------------------------------
1738# @internal-function java-pkg_ant-tasks-depend 1746# @internal-function java-pkg_ant-tasks-depend
1739# 1747#
1740# Translates the WANT_ANT_TASKS variable into valid dependencies. 1748# Translates the WANT_ANT_TASKS variable into valid dependencies.
1741# ------------------------------------------------------------------------------ 1749# ------------------------------------------------------------------------------
1742java-pkg_ant-tasks-depend() { 1750java-pkg_ant-tasks-depend() {
1744 1752
1745 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1753 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1746 local DEP="" 1754 local DEP=""
1747 for i in ${WANT_ANT_TASKS} 1755 for i in ${WANT_ANT_TASKS}
1748 do 1756 do
1749 if [[ ${i} != ant-* ]]; then 1757 if [[ ${i} = ant-* ]]; then
1758 DEP="${DEP}dev-java/${i} "
1759 elif [[ ${i} = */*:* ]]; then
1760 DEP="${DEP}${i} "
1761 else
1750 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1762 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1751 return 1 1763 return 1
1752 fi 1764 fi
1753 DEP="${DEP}dev-java/${i} "
1754 done 1765 done
1755 echo ${DEP} 1766 echo ${DEP}
1756 return 0 1767 return 0
1757 else 1768 else
1758 return 0 1769 return 0
1759 fi 1770 fi
1760} 1771}
1761 1772
1773
1762# ------------------------------------------------------------------------------ 1774# ------------------------------------------------------------------------------
1763# @ebuild-function ejunit 1775# @internal-function ejunit_
1764# 1776#
1765# Junit wrapper function. Makes it easier to run the tests and checks for 1777# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1766# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1778# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1767# 1779#
1768# Examples: 1780# @param $1 - junit package (junit or junit-4)
1769# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1770# ejunit org.blinkenlights.jid3.test.AllTests
1771#
1772# @param $1 - -cp or -classpath 1781# @param $2 - -cp or -classpath
1773# @param $2 - classpath; junit and recorded dependencies get appended 1782# @param $3 - classpath; junit and recorded dependencies get appended
1774# @param $@ - the rest of the parameters are passed to java 1783# @param $@ - the rest of the parameters are passed to java
1775# ------------------------------------------------------------------------------
1776ejunit() { 1784ejunit_() {
1777 debug-print-function ${FUNCNAME} $* 1785 debug-print-function ${FUNCNAME} $*
1778 1786
1779 local pkgs 1787 local pkgs
1788 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1789 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1790 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1782 done 1791 done
1792 fi
1783 1793
1794 local junit=${1}
1795 shift 1
1796
1784 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1797 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1798 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1786 cp="${2}:${cp}" 1799 cp="${2}:${cp}"
1787 shift 2 1800 shift 2
1788 else 1801 else
1789 cp=".:${cp}" 1802 cp=".:${cp}"
1790 fi 1803 fi
1791 1804
1792 local runner=junit.textui.TestRunner 1805 local runner=junit.textui.TestRunner
1806 if [[ "${junit}" == "junit-4" ]] ; then
1807 runner=org.junit.runner.JUnitCore
1808 fi
1793 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1809 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1794 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1810 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1795} 1811}
1796 1812
1797# ------------------------------------------------------------------------------ 1813# ------------------------------------------------------------------------------
1814# @ebuild-function ejunit
1815#
1816# Junit wrapper function. Makes it easier to run the tests and checks for
1817# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1818#
1819# Examples:
1820# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1821# ejunit org.blinkenlights.jid3.test.AllTests
1822# ejunit org.blinkenlights.jid3.test.FirstTest \
1823# org.blinkenlights.jid3.test.SecondTest
1824#
1825# @param $1 - -cp or -classpath
1826# @param $2 - classpath; junit and recorded dependencies get appended
1827# @param $@ - the rest of the parameters are passed to java
1828# ------------------------------------------------------------------------------
1829ejunit() {
1830 debug-print-function ${FUNCNAME} $*
1831
1832 ejunit_ "junit" "${@}"
1833}
1834
1835# ------------------------------------------------------------------------------
1836# @ebuild-function ejunit4
1837#
1838# Junit4 wrapper function. Makes it easier to run the tests and checks for
1839# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1840#
1841# Examples:
1842# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1843# ejunit4 org.blinkenlights.jid3.test.AllTests
1844# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1845# org.blinkenlights.jid3.test.SecondTest
1846#
1847# @param $1 - -cp or -classpath
1848# @param $2 - classpath; junit and recorded dependencies get appended
1849# @param $@ - the rest of the parameters are passed to java
1850# ------------------------------------------------------------------------------
1851ejunit4() {
1852 debug-print-function ${FUNCNAME} $*
1853
1854 ejunit_ "junit-4" "${@}"
1855}
1856
1857# ------------------------------------------------------------------------------
1798# @section-end helper 1858# @section-end helper
1799# ------------------------------------------------------------------------------ 1859# ------------------------------------------------------------------------------
1860
1861# ------------------------------------------------------------------------------
1862# @eclass-src_prepare
1863#
1864# src_prepare Searches for bundled jars
1865# Don't call directly, but via java-pkg-2_src_prepare!
1866# ------------------------------------------------------------------------------
1867
1868java-utils-2_src_prepare() {
1869 [[ ${EBUILD_PHASE} == prepare ]] &&
1870 java-pkg_func-exists java_prepare && java_prepare
1871
1872 # Remember that eant will call this unless called via Portage
1873 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1874 echo "Searching for bundled jars:"
1875 java-pkg_find-normal-jars || echo "None found."
1876 echo "Searching for bundled classes (no output if none found):"
1877 find "${WORKDIR}" -name "*.class"
1878 echo "Search done."
1879 fi
1880 touch "${T}/java-utils-2_src_prepare-run"
1881}
1882
1883# ------------------------------------------------------------------------------
1884# @eclass-pkg_preinst
1885#
1886# pkg_preinst Searches for missing and unneeded dependencies
1887# Don't call directly, but via java-pkg-2_pkg_preinst!
1888# ------------------------------------------------------------------------------
1889
1890java-utils-2_pkg_preinst() {
1891 if is-java-strict; then
1892 if has_version dev-java/java-dep-check; then
1893 [[ -e "${JAVA_PKG_ENV}" ]] || return
1894 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1895 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1896 ewarn "Possibly unneeded dependencies found in package.env:"
1897 for dep in ${output}; do
1898 ewarn "\t${dep}"
1899 done
1900 fi
1901 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1902 ewarn "${output}"
1903 fi
1904 else
1905 eerror "Install dev-java/java-dep-check for dependency checking"
1906 fi
1907 fi
1908}
1800 1909
1801# ------------------------------------------------------------------------------ 1910# ------------------------------------------------------------------------------
1802# @section-begin build 1911# @section-begin build
1803# @section-summary Build functions 1912# @section-summary Build functions
1804# 1913#
1813# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1922# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1814# variables: 1923# variables:
1815# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1924# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1816# gentoo.classpath property. Be sure to call 1925# gentoo.classpath property. Be sure to call
1817# java-ant_rewrite-classpath in src_unpack. 1926# java-ant_rewrite-classpath in src_unpack.
1818# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1927# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1928# for build-time purposes, the dependency is not recorded to
1929# package.env!
1819# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1930# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1820# ------------------------------------------------------------------------------ 1931# ------------------------------------------------------------------------------
1821eant() { 1932eant() {
1822 debug-print-function ${FUNCNAME} $* 1933 debug-print-function ${FUNCNAME} $*
1823 1934
1824 if [[ ${EBUILD_PHASE} = compile ]]; then 1935 if [[ ${EBUILD_PHASE} = compile ]]; then
1825 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1936 java-ant-2_src_configure
1826 # finally get rid of the hooks without breaking stuff 1937 java-utils-2_src_prepare
1827
1828 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1829 && java-ant_ignore-system-classes "${S}/build.xml"
1830
1831 if hasq java-ant-2 ${INHERITED}; then
1832 java-ant_bsfix
1833 fi 1938 fi
1834 1939
1835 # eant can be called multiple times
1836 JAVA_PKG_BSFIX="off"
1837
1838 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1839 echo "Searching for bundled jars:"
1840 java-pkg_find-normal-jars || echo "None found."
1841 echo "Searching for bundled classes (no output if none found):"
1842 find "${WORKDIR}" -name "*.class"
1843 echo "Search done."
1844 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1845 fi
1846 fi
1847
1848 if ! hasq java-ant-2 ${INHERITED}; then 1940 if ! has java-ant-2 ${INHERITED}; then
1849 local msg="You should inherit java-ant-2 when using eant" 1941 local msg="You should inherit java-ant-2 when using eant"
1850 java-pkg_announce-qa-violation "${msg}" 1942 java-pkg_announce-qa-violation "${msg}"
1851 fi 1943 fi
1852 1944
1853 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1945 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1887 echo "more info." 1979 echo "more info."
1888 fi 1980 fi
1889 fi 1981 fi
1890 done 1982 done
1891 1983
1892 # we use this in src_* so we run ant from / 1984 # parse WANT_ANT_TASKS for atoms
1893 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1985 local want_ant_tasks
1894 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1986 for i in ${WANT_ANT_TASKS}; do
1895 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1987 if [[ ${i} = */*:* ]]; then
1896 1988 i=${i#*/}
1897 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1989 i=${i%:0}
1898 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1990 want_ant_tasks+="${i/:/-} "
1899
1900 if is-java-strict; then
1901 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1902 if [[ -z "${ANT_TASKS}" ]]; then
1903 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1904 fi
1905 else 1991 else
1992 want_ant_tasks+="${i} "
1993 fi
1994 done
1995 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1996 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1997
1998 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1999 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
2000
1906 # if ant-tasks is not set by ebuild or forced, activate all of them 2001 # if ant-tasks is not set by ebuild or forced, use none
1907 ANT_TASKS="${ANT_TASKS:-all}" 2002 ANT_TASKS="${ANT_TASKS:-none}"
1908 fi
1909 2003
1910 # at this point, ANT_TASKS should be "all", "none" or explicit list 2004 # at this point, ANT_TASKS should be "all", "none" or explicit list
1911 if [[ "${ANT_TASKS}" == "all" ]]; then 2005 if [[ "${ANT_TASKS}" == "all" ]]; then
1912 einfo "Using all available ANT_TASKS" 2006 einfo "Using all available ANT_TASKS"
1913 elif [[ "${ANT_TASKS}" == "none" ]]; then 2007 elif [[ "${ANT_TASKS}" == "none" ]]; then
1914 einfo "Disabling all optional ANT_TASKS" 2008 einfo "Disabling all optional ANT_TASKS"
1915 else 2009 else
1916 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 2010 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1917 fi 2011 fi
1918 2012
1919 export ANT_TASKS 2013 export ANT_TASKS
1920 fi
1921 2014
1922 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 2015 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1923 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 2016 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1924 2017
1925 local gcp="${EANT_GENTOO_CLASSPATH}" 2018 local gcp="${EANT_GENTOO_CLASSPATH}"
1926 local getjarsarg="" 2019 local getjarsarg=""
1927 2020
1928 if [[ ${EBUILD_PHASE} = "test" ]]; then 2021 if [[ ${EBUILD_PHASE} = "test" ]]; then
1929 antflags="${antflags} -DJunit.present=true" 2022 antflags="${antflags} -DJunit.present=true"
1930 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2023 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1931 getjarsarg="--with-dependencies" 2024 getjarsarg="--with-dependencies"
2025 else
2026 antflags="${antflags} -Dmaven.test.skip=true"
1932 fi 2027 fi
1933 2028
1934 local cp 2029 local cp
1935 2030
1936 for atom in ${gcp}; do 2031 for atom in ${gcp}; do
1937 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2032 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1938 done 2033 done
1939 2034
2035 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2036
1940 if [[ ${cp} ]]; then 2037 if [[ ${cp} ]]; then
1941 # It seems ant does not like single quotes around ${cp} 2038 # It seems ant does not like single quotes around ${cp}
2039 cp=${cp#:}
2040 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2041 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1942 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2042 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1943 fi 2043 fi
1944 2044
1945 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2045 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1946 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2046 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1947 ant ${antflags} "${@}" || die "eant failed" 2047 ant ${antflags} "${@}" || die "eant failed"
2048# call it during each of the phases of the merge process. 2148# call it during each of the phases of the merge process.
2049# 2149#
2050# ----------------------------------------------------------------------------- 2150# -----------------------------------------------------------------------------
2051java-pkg_init() { 2151java-pkg_init() {
2052 debug-print-function ${FUNCNAME} $* 2152 debug-print-function ${FUNCNAME} $*
2153
2154 # Don't set up build environment if installing from binary. #206024 #258423
2155 [[ "${MERGE_TYPE}" == "binary" ]] && return
2156 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2157 # work nothing is lost.
2158 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2159
2053 unset JAVAC 2160 unset JAVAC
2054 unset JAVA_HOME 2161 unset JAVA_HOME
2162
2163 java-config --help >/dev/null || {
2164 eerror ""
2165 eerror "Can't run java-config --help"
2166 eerror "Have you upgraded python recently but haven't"
2167 eerror "run python-updater yet?"
2168 die "Can't run java-config --help"
2169 }
2055 2170
2056 # People do all kinds of weird things. 2171 # People do all kinds of weird things.
2057 # http://forums.gentoo.org/viewtopic-p-3943166.html 2172 # http://forums.gentoo.org/viewtopic-p-3943166.html
2058 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2173 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2059 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2174 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2097 export CLASSPATH= 2212 export CLASSPATH=
2098 2213
2099 # Unset external ANT_ stuff 2214 # Unset external ANT_ stuff
2100 export ANT_TASKS= 2215 export ANT_TASKS=
2101 export ANT_OPTS= 2216 export ANT_OPTS=
2217 export ANT_RESPECT_JAVA_HOME=
2102} 2218}
2103 2219
2104# ------------------------------------------------------------------------------ 2220# ------------------------------------------------------------------------------
2105# @function-internal java-pkg-init-compiler_ 2221# @function-internal java-pkg-init-compiler_
2106# 2222#
2197 done 2313 done
2198 2314
2199 # If it hasn't been defined already, default to javac 2315 # If it hasn't been defined already, default to javac
2200 if [[ -z ${GENTOO_COMPILER} ]]; then 2316 if [[ -z ${GENTOO_COMPILER} ]]; then
2201 if [[ -n ${compilers} ]]; then 2317 if [[ -n ${compilers} ]]; then
2202 einfo "No suitable compiler found: defaulting javac for compilation" 2318 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2203 else 2319 else
2204 # probably don't need to notify users about the default. 2320 # probably don't need to notify users about the default.
2205 :;#einfo "Defaulting to javac for compilation" 2321 :;#einfo "Defaulting to javac for compilation"
2206 fi 2322 fi
2323 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2324 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2325 else
2207 export GENTOO_COMPILER=javac 2326 export GENTOO_COMPILER=javac
2327 fi
2208 else 2328 else
2209 einfo "Using ${GENTOO_COMPILER} for compilation" 2329 einfo "Using ${GENTOO_COMPILER} for compilation"
2210 fi 2330 fi
2211 2331
2212} 2332}
2263 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2383 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2264 # Create package.env 2384 # Create package.env
2265 ( 2385 (
2266 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2386 echo "DESCRIPTION=\"${DESCRIPTION}\""
2267 echo "GENERATION=\"2\"" 2387 echo "GENERATION=\"2\""
2388 echo "SLOT=\"${SLOT}\""
2389 echo "CATEGORY=\"${CATEGORY}\""
2390 echo "PVR=\"${PVR}\""
2268 2391
2269 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2392 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2270 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2393 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2271 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2394 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2272 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2395 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2273 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2396 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2274 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2397 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2275 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2398 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2276 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2399 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2400 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2401 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2277 ) > "${JAVA_PKG_ENV}" 2402 ) > "${JAVA_PKG_ENV}"
2278 2403
2279 # register target/source 2404 # register target/source
2280 local target="$(java-pkg_get-target)" 2405 local target="$(java-pkg_get-target)"
2281 local source="$(java-pkg_get-source)" 2406 local source="$(java-pkg_get-source)"
2314# ------------------------------------------------------------------------------ 2439# ------------------------------------------------------------------------------
2315# @internal-function java-pkg_record-jar_ 2440# @internal-function java-pkg_record-jar_
2316# 2441#
2317# Record an (optional) dependency to the package.env 2442# Record an (optional) dependency to the package.env
2318# @param --optional - record dependency as optional 2443# @param --optional - record dependency as optional
2444# @param --build - record dependency as build_only
2319# @param $1 - package to record 2445# @param $1 - package to record
2320# @param $2 - (optional) jar of package to record 2446# @param $2 - (optional) jar of package to record
2321# ------------------------------------------------------------------------------ 2447# ------------------------------------------------------------------------------
2322JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2448JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2323JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2449JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2450JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2324 2451
2325java-pkg_record-jar_() { 2452java-pkg_record-jar_() {
2326 debug-print-function ${FUNCNAME} $* 2453 debug-print-function ${FUNCNAME} $*
2327 2454
2328 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2455 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2329 if [[ "${1}" == "--optional" ]]; then 2456 case "${1}" in
2330 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2457 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2331 shift 2458 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2332 fi 2459 esac
2333 2460
2334 local pkg=${1} jar=${2} append 2461 local pkg=${1} jar=${2} append
2335 if [[ -z "${jar}" ]]; then 2462 if [[ -z "${jar}" ]]; then
2336 append="${pkg}" 2463 append="${pkg}"
2337 else 2464 else
2390# 2517#
2391# @return 0 - function is declared 2518# @return 0 - function is declared
2392# @return 1 - function is undeclared 2519# @return 1 - function is undeclared
2393# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
2394java-pkg_func-exists() { 2521java-pkg_func-exists() {
2395 if [[ -n "$(declare -f ${1})" ]]; then 2522 declare -F ${1} > /dev/null
2396 return 0
2397 else
2398 return 1
2399 fi
2400} 2523}
2401 2524
2402# ------------------------------------------------------------------------------ 2525# ------------------------------------------------------------------------------
2403# @internal-function java-pkg_setup-vm 2526# @internal-function java-pkg_setup-vm
2404# 2527#
2405# Sets up the environment for a specific VM 2528# Sets up the environment for a specific VM
2406# 2529#
2407# ------------------------------------------------------------------------------ 2530# ------------------------------------------------------------------------------
2408java-pkg_setup-vm() { 2531java-pkg_setup-vm() {
2409 debug-print-function ${FUNCNAME} $* 2532 debug-print-function ${FUNCNAME} $*
2410
2411 export LANG="C" LC_ALL="C"
2412 2533
2413 local vendor="$(java-pkg_get-vm-vendor)" 2534 local vendor="$(java-pkg_get-vm-vendor)"
2414 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2535 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2415 addpredict "/dev/random" 2536 addpredict "/dev/random"
2416 elif [[ "${vendor}" == "ibm" ]]; then 2537 elif [[ "${vendor}" == "ibm" ]]; then
2417 addpredict "/proc/self/maps" 2538 addpredict "/proc/self/maps"
2418 addpredict "/proc/cpuinfo" 2539 addpredict "/proc/cpuinfo"
2540 addpredict "/proc/self/coredump_filter"
2541 elif [[ "${vendor}" == "oracle" ]]; then
2542 addpredict "/dev/random"
2543 addpredict "/proc/self/coredump_filter"
2544 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2545 addpredict "/dev/random"
2546 addpredict "/proc/self/coredump_filter"
2419 elif [[ "${vendor}" == "jrockit" ]]; then 2547 elif [[ "${vendor}" == "jrockit" ]]; then
2420 addpredict "/proc/cpuinfo" 2548 addpredict "/proc/cpuinfo"
2421 fi 2549 fi
2422} 2550}
2423 2551
2424# ------------------------------------------------------------------------------ 2552# ------------------------------------------------------------------------------
2425# @internal-function java-pkg_needs-vm 2553# @internal-function java-pkg_needs-vm
2426# 2554#
2427# Does the current package depend on virtual/jdk? 2555# Does the current package depend on virtual/jdk or does it set
2556# JAVA_PKG_WANT_BUILD_VM?
2428# 2557#
2429# @return 0 - Package depends on virtual/jdk 2558# @return 0 - Package depends on virtual/jdk
2430# @return 1 - Package does not depend on virtual/jdk 2559# @return 1 - Package does not depend on virtual/jdk
2431# ------------------------------------------------------------------------------ 2560# ------------------------------------------------------------------------------
2432java-pkg_needs-vm() { 2561java-pkg_needs-vm() {
2433 debug-print-function ${FUNCNAME} $* 2562 debug-print-function ${FUNCNAME} $*
2434 2563
2435 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2564 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2436 return 0 2565 return 0
2437 fi 2566 fi
2567
2568 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2438 2569
2439 return 1 2570 return 1
2440} 2571}
2441 2572
2442# ------------------------------------------------------------------------------ 2573# ------------------------------------------------------------------------------
2468# ------------------------------------------------------------------------------ 2599# ------------------------------------------------------------------------------
2469java-pkg_get-vm-version() { 2600java-pkg_get-vm-version() {
2470 debug-print-function ${FUNCNAME} $* 2601 debug-print-function ${FUNCNAME} $*
2471 2602
2472 java-config -g PROVIDES_VERSION 2603 java-config -g PROVIDES_VERSION
2604}
2605
2606# ------------------------------------------------------------------------------
2607# @internal-function java-pkg_build-vm-from-handle
2608#
2609# Selects a build vm from a list of vm handles. First checks for the system-vm
2610# beeing usable, then steps through the listed handles till a suitable vm is
2611# found.
2612#
2613# @return - VM handle of an available JDK
2614# ------------------------------------------------------------------------------
2615java-pkg_build-vm-from-handle() {
2616 debug-print-function ${FUNCNAME} "$*"
2617
2618 local vm
2619 vm=$(java-pkg_get-current-vm)
2620 if [[ $? != 0 ]]; then
2621 eerror "${FUNCNAME}: Failed to get active vm"
2622 return 1
2623 fi
2624
2625 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2626 echo ${vm}
2627 return 0
2628 fi
2629
2630 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2631 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2632 echo ${vm}
2633 return 0
2634 fi
2635 done
2636
2637 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2638 return 1
2473} 2639}
2474 2640
2475# ------------------------------------------------------------------------------ 2641# ------------------------------------------------------------------------------
2476# @internal-function java-pkg_switch-vm 2642# @internal-function java-pkg_switch-vm
2477# 2643#
2488 # If you're forcing the VM, I hope you know what your doing... 2654 # If you're forcing the VM, I hope you know what your doing...
2489 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2655 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2490 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2656 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2491 # if we're allowed to switch the vm... 2657 # if we're allowed to switch the vm...
2492 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2658 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2493 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2659 # if there is an explicit list of handles to choose from
2494 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2660 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2495 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2661 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2662 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2663 if [[ $? != 0 ]]; then
2664 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2665 die "${FUNCNAME}: Failed to determine VM for building"
2666 fi
2667 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2668 # they can't be deduced from handles.
2669 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2670 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2671 die "Specify JAVA_PKG_WANT_SOURCE"
2672 fi
2673 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2674 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2675 die "Specify JAVA_PKG_WANT_TARGET"
2676 fi
2677 # otherwise determine a vm from dep string
2496 else 2678 else
2679 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2497 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2680 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2681 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2682 eerror "Unable to determine VM for building from dependencies:"
2683 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2684 die "Failed to determine VM for building."
2685 fi
2498 fi 2686 fi
2499 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2500 eerror "Unable to determine VM for building from dependencies:"
2501 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2502 echo "VNEED: ${JAVA_PKG_VNEED}"
2503 die "Failed to determine VM for building."
2504 else
2505 export GENTOO_VM 2687 export GENTOO_VM
2506 fi
2507 # otherwise just make sure the current VM is sufficient 2688 # otherwise just make sure the current VM is sufficient
2508 else 2689 else
2509 java-pkg_ensure-vm-version-sufficient 2690 java-pkg_ensure-vm-version-sufficient
2510 fi 2691 fi
2511 debug-print "Using: $(java-config -f)" 2692 debug-print "Using: $(java-config -f)"
2546# 2727#
2547# Enhanced die for Java packages, which displays some information that may be 2728# Enhanced die for Java packages, which displays some information that may be
2548# useful for debugging bugs on bugzilla. 2729# useful for debugging bugs on bugzilla.
2549# ------------------------------------------------------------------------------ 2730# ------------------------------------------------------------------------------
2550#register_die_hook java-pkg_die 2731#register_die_hook java-pkg_die
2551if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2732if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2552 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2733 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2553fi 2734fi
2554 2735
2555java-pkg_die() { 2736java-pkg_die() {
2556 echo "!!! When you file a bug report, please include the following information:" >&2 2737 echo "!!! When you file a bug report, please include the following information:" >&2
2580# not. 2761# not.
2581# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2762# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2582# ------------------------------------------------------------------------------ 2763# ------------------------------------------------------------------------------
2583java-pkg_verify-classes() { 2764java-pkg_verify-classes() {
2584 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2765 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2766
2767 local version_verify="/usr/bin/class-version-verify.py"
2768
2769 if [[ ! -x "${version_verify}" ]]; then
2770 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2771 fi
2772
2773 if [[ ! -x "${version_verify}" ]]; then
2774 ewarn "Unable to perform class version checks as"
2775 ewarn "class-version-verify.py is unavailable"
2776 ewarn "Please install dev-java/javatoolkit."
2777 return
2778 fi
2779
2585 local target=$(java-pkg_get-target) 2780 local target=$(java-pkg_get-target)
2586 local result 2781 local result
2587 local log="${T}/class-version-verify.log" 2782 local log="${T}/class-version-verify.log"
2588 if [[ -n "${1}" ]]; then 2783 if [[ -n "${1}" ]]; then
2589 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2784 ${version_verify} -v -t ${target} "${1}" > "${log}"
2590 result=$? 2785 result=$?
2591 else 2786 else
2592 ebegin "Verifying java class versions (target: ${target})" 2787 ebegin "Verifying java class versions (target: ${target})"
2593 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2788 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2594 result=$? 2789 result=$?
2595 eend ${result} 2790 eend ${result}
2596 fi 2791 fi
2597 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2792 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2598 if [[ ${result} != 0 ]]; then 2793 if [[ ${result} != 0 ]]; then
2616 2811
2617 local limit_to="${1}" 2812 local limit_to="${1}"
2618 local target_pkg="${2}" 2813 local target_pkg="${2}"
2619 local dev_error="" 2814 local dev_error=""
2620 2815
2816 # remove the version specification, which may include globbing (* and [123])
2621 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2817 local stripped_pkg=$(echo "${target_pkg}" | sed \
2622 's/-[0-9]*\(\.[0-9]\)*$//') 2818 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2623 2819
2624 debug-print "Matching against: ${stripped_pkg}" 2820 debug-print "Matching against: ${stripped_pkg}"
2625 2821
2626 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2822 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2627 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2823 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2677 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2873 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2678 fi 2874 fi
2679} 2875}
2680 2876
2681java-pkg_check-jikes() { 2877java-pkg_check-jikes() {
2682 if hasq jikes ${IUSE}; then 2878 if has jikes ${IUSE}; then
2683 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2879 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2684 fi 2880 fi
2685} 2881}
2686 2882
2687java-pkg_announce-qa-violation() { 2883java-pkg_announce-qa-violation() {
2703is-java-strict() { 2899is-java-strict() {
2704 [[ -n ${JAVA_PKG_STRICT} ]] 2900 [[ -n ${JAVA_PKG_STRICT} ]]
2705 return $? 2901 return $?
2706} 2902}
2707 2903
2904
2708# ------------------------------------------------------------------------------ 2905# ------------------------------------------------------------------------------
2709# @eclass-end 2906# @eclass-end
2710# ------------------------------------------------------------------------------ 2907# ------------------------------------------------------------------------------

Legend:
Removed from v.1.98  
changed lines
  Added in v.1.150

  ViewVC Help
Powered by ViewVC 1.1.20