/[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.90 Revision 1.145
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.90 2007/06/19 21:08:57 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.145 2011/10/02 08:10:28 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
57#WANT_ANT_TASKS 57#WANT_ANT_TASKS
58 58
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. At this moment it's 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
66 67
67# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
68# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
69# 70#
70# 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
71# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
72# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
73# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.32 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
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
75 94
76# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 97# @variable-default yes
79# 98#
194# 213#
195# @example 214# @example
196# java-pkg_doexamples demo 215# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/* 216# java-pkg_doexamples demo/* examples/*
198# 217#
218# @param --subdir - If the examples need a certain directory structure
199# @param $* - list of files to install 219# @param $* - list of files to install
200# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
201java-pkg_doexamples() { 221java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $* 222 debug-print-function ${FUNCNAME} $*
203 223
204 [[ ${#} -lt 1 ]] && die "At least one argument needed" 224 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205 225
206 java-pkg_check-phase install 226 java-pkg_check-phase install
207 227
208 local dest=/usr/share/doc/${PF}/examples 228 local dest=/usr/share/doc/${PF}/examples
229 if [[ ${1} == --subdir ]]; then
230 local dest=${dest}/${2}
231 dodir ${dest}
232 shift 2
233 fi
234
209 if [[ ${#} = 1 && -d ${1} ]]; then 235 if [[ ${#} = 1 && -d ${1} ]]; then
210 ( # dont want to pollute calling env 236 ( # dont want to pollute calling env
211 insinto "${dest}" 237 insinto "${dest}"
212 doins -r ${1}/* 238 doins -r ${1}/*
213 ) || die "Installing examples failed" 239 ) || die "Installing examples failed"
215 ( # dont want to pollute calling env 241 ( # dont want to pollute calling env
216 insinto "${dest}" 242 insinto "${dest}"
217 doins -r "$@" 243 doins -r "$@"
218 ) || die "Installing examples failed" 244 ) || die "Installing examples failed"
219 fi 245 fi
246
247 # Let's make a symlink to the directory we have everything else under
248 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
220} 249}
221 250
222# ----------------------------------------------------------------------------- 251# -----------------------------------------------------------------------------
223# @ebuild-function java-pkg_dojar 252# @ebuild-function java-pkg_dojar
224# 253#
282 done 311 done
283 312
284 java-pkg_do_write_ 313 java-pkg_do_write_
285} 314}
286 315
287
288# ------------------------------------------------------------------------------ 316# ------------------------------------------------------------------------------
289# @internal-function depend-java-query 317# @internal-function depend-java-query
290# 318#
291# Wrapper for the depend-java-query binary to enable passing USE in env. 319# Wrapper for the depend-java-query binary to enable passing USE in env.
292# Using env variables keeps this eclass working with java-config versions that 320# Using env variables keeps this eclass working with java-config versions that
357 if [[ ${jar} = *\** ]]; then 385 if [[ ${jar} = *\** ]]; then
358 eerror "The argument ${jar} to ${FUNCNAME}" 386 eerror "The argument ${jar} to ${FUNCNAME}"
359 eerror "has * in it. If you want it to glob in" 387 eerror "has * in it. If you want it to glob in"
360 eerror '${D} add ${D} to the argument.' 388 eerror '${D} add ${D} to the argument.'
361 fi 389 fi
390 debug-print "${jar} or ${D}${jar} not found"
362 die "${jar} does not exist" 391 die "${jar} does not exist"
363 fi 392 fi
364 done 393 done
365 394
366 java-pkg_do_write_ 395 java-pkg_do_write_
421# @param $@ - JNI libraries to install 450# @param $@ - JNI libraries to install
422# ------------------------------------------------------------------------------ 451# ------------------------------------------------------------------------------
423java-pkg_doso() { 452java-pkg_doso() {
424 debug-print-function ${FUNCNAME} $* 453 debug-print-function ${FUNCNAME} $*
425 454
426 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
427 java-pkg_check-phase install 455 java-pkg_check-phase install
428 456
429 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 457 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
430 458
431 java-pkg_init_paths_ 459 java-pkg_init_paths_
432 460
433 local lib 461 local lib
434 # for each lib 462 # for each lib
437 if [[ -e "${lib}" ]] ; then 465 if [[ -e "${lib}" ]] ; then
438 # install if it isn't a symlink 466 # install if it isn't a symlink
439 if [[ ! -L "${lib}" ]] ; then 467 if [[ ! -L "${lib}" ]] ; then
440 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 468 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
441 INSOPTIONS="${LIBOPTIONS}" \ 469 INSOPTIONS="${LIBOPTIONS}" \
442 doins "${lib}" || "failed to install ${lib}" 470 doins "${lib}" || die "failed to install ${lib}"
443 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 471 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
444 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 472 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
445 # otherwise make a symlink to the symlink's origin 473 # otherwise make a symlink to the symlink's origin
446 else 474 else
447 # TODO use dosym 475 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
448 ln -s "$(readlink "${lib}")" \
449 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
450 debug-print "${lib} is a symlink, linking accordanly" 476 debug-print "${lib} is a symlink, linking accordantly"
451 fi 477 fi
452 # otherwise die 478 # otherwise die
453 else 479 else
454 die "${lib} does not exist" 480 die "${lib} does not exist"
455 fi 481 fi
471java-pkg_regso() { 497java-pkg_regso() {
472 debug-print-function ${FUNCNAME} $* 498 debug-print-function ${FUNCNAME} $*
473 499
474 java-pkg_check-phase install 500 java-pkg_check-phase install
475 501
476 [[ ${#} -lt 1 ]] && "at least one argument needed" 502 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
477 503
478 java-pkg_init_paths_ 504 java-pkg_init_paths_
479 505
480 local lib target_dir 506 local lib target_dir
481 for lib in "$@" ; do 507 for lib in "$@" ; do
548# ------------------------------------------------------------------------------ 574# ------------------------------------------------------------------------------
549# @ebuild-function java-pkg_dojavadoc 575# @ebuild-function java-pkg_dojavadoc
550# 576#
551# Installs javadoc documentation. This should be controlled by the doc use flag. 577# Installs javadoc documentation. This should be controlled by the doc use flag.
552# 578#
579# @param $1: optional --symlink creates to symlink like this for html
580# documentation bundles.
553# @param $1: - The javadoc root directory. 581# @param $2: - The javadoc root directory.
554# 582#
555# @example: 583# @example:
556# java-pkg_dojavadoc docs/api 584# java-pkg_dojavadoc docs/api
585# java-pkg_dojavadoc --symlink apidocs docs/api
557# 586#
558# ------------------------------------------------------------------------------ 587# ------------------------------------------------------------------------------
559java-pkg_dojavadoc() { 588java-pkg_dojavadoc() {
560 debug-print-function ${FUNCNAME} $* 589 debug-print-function ${FUNCNAME} $*
590
591 # For html documentation bundles that link to Javadoc
592 local symlink
593 if [[ ${1} = --symlink ]]; then
594 symlink=${2}
595 shift 2
596 fi
597
561 local dir="$1" 598 local dir="$1"
599 local dest=/usr/share/doc/${PF}/html
562 600
563 # QA checks 601 # QA checks
564 602
565 java-pkg_check-phase install 603 java-pkg_check-phase install
566 604
570 local msg="No index.html in javadoc directory" 608 local msg="No index.html in javadoc directory"
571 ewarn "${msg}" 609 ewarn "${msg}"
572 is-java-strict && die "${msg}" 610 is-java-strict && die "${msg}"
573 fi 611 fi
574 612
613 if [[ -e ${D}/${dest}/api ]]; then
614 eerror "${dest} already exists. Will not overwrite."
615 die "${dest}"
616 fi
617
575 # Renaming to match our directory layout 618 # Renaming to match our directory layout
576 619
577 local dir_to_install="${dir}" 620 local dir_to_install="${dir}"
578 if [[ "$(basename "${dir}")" != "api" ]]; then 621 if [[ "$(basename "${dir}")" != "api" ]]; then
579 dir_to_install="${T}/api" 622 dir_to_install="${T}/api"
581 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 624 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
582 fi 625 fi
583 626
584 # Actual installation 627 # Actual installation
585 628
586 java-pkg_dohtml -r ${dir_to_install} 629 java-pkg_dohtml -r "${dir_to_install}"
630
631 # Let's make a symlink to the directory we have everything else under
632 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
633
634 if [[ ${symlink} ]]; then
635 debug-print "symlinking ${dest}/{api,${symlink}}"
636 dosym ${dest}/{api,${symlink}} || die
637 fi
587} 638}
588 639
589# ------------------------------------------------------------------------------ 640# ------------------------------------------------------------------------------
590# @ebuild-function java-pkg_dosrc 641# @ebuild-function java-pkg_dosrc
591# 642#
614 665
615 [[ ${#} -lt 1 ]] && die "At least one argument needed" 666 [[ ${#} -lt 1 ]] && die "At least one argument needed"
616 667
617 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 668 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
618 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 669 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
619 if is-java-strict; then 670 java-pkg_announce-qa-violation ${msg}
620 eerror "${msg}"
621 die "${msg}"
622 else
623 echo "${msg}"
624 echo "Please report this to http://bugs.gentoo.org."
625 fi
626 fi 671 fi
627 672
628 java-pkg_init_paths_ 673 java-pkg_init_paths_
629 674
630 local zip_name="${PN}-src.zip" 675 local zip_name="${PN}-src.zip"
830# @param $opt 875# @param $opt
831# --build-only - makes the jar(s) not added into package.env DEPEND line. 876# --build-only - makes the jar(s) not added into package.env DEPEND line.
832# (assumed automatically when called inside src_test) 877# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 878# --with-dependencies - get jars also from requested package's dependencies
834# transitively. 879# transitively.
880# --virtual - Packages passed to this function are to be handled as virtuals
881# and will not have individual jar dependencies recorded.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 882# --into $dir - symlink jar(s) into $dir (must exist) instead of .
836# @param $1 - Package to get jars from, or comma-separated list of packages in 883# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used. 884# case other parameters are not used.
838# @param $2 - jar from package. If not specified, all jars will be used. 885# @param $2 - jar from package. If not specified, all jars will be used.
839# @param $3 - When a single jar is specified, destination filename of the 886# @param $3 - When a single jar is specified, destination filename of the
844 debug-print-function ${FUNCNAME} $* 891 debug-print-function ${FUNCNAME} $*
845 892
846 local build_only="" 893 local build_only=""
847 local destdir="." 894 local destdir="."
848 local deep="" 895 local deep=""
896 local virtual=""
897 local record_jar=""
849 898
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 899 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 900
852 while [[ "${1}" == --* ]]; do 901 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 902 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 903 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 904 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 905 deep="--with-dependencies"
906 elif [[ "${1}" = "--virtual" ]]; then
907 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 908 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 909 destdir="${2}"
859 shift 910 shift
860 else 911 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 912 die "java-pkg_jar-from called with unknown parameter: ${1}"
864 done 915 done
865 916
866 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 917 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
867 918
868 [[ -z ${target_pkg} ]] && die "Must specify a package" 919 [[ -z ${target_pkg} ]] && die "Must specify a package"
920
921 if [[ "${EAPI}" == "1" ]]; then
922 target_pkg="${target_pkg//:/-}"
923 fi
869 924
870 # default destjar to the target jar 925 # default destjar to the target jar
871 [[ -z "${destjar}" ]] && destjar="${target_jar}" 926 [[ -z "${destjar}" ]] && destjar="${target_jar}"
872 927
873 local error_msg="There was a problem getting the classpath for ${target_pkg}." 928 local error_msg="There was a problem getting the classpath for ${target_pkg}."
882 for pkg in ${target_pkg//,/ }; do 937 for pkg in ${target_pkg//,/ }; do
883 java-pkg_ensure-dep "${build_only}" "${pkg}" 938 java-pkg_ensure-dep "${build_only}" "${pkg}"
884 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 939 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
885 done 940 done
886 # setting this disables further record-jar_ calls later 941 # setting this disables further record-jar_ calls later
887 build_only="build" 942 record_jar="true"
888 else 943 else
889 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 944 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
945 fi
946
947 # Record the entire virtual as a dependency so that
948 # no jars are missed.
949 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
950 java-pkg_record-jar_ "${target_pkg}"
951 # setting this disables further record-jars_ calls later
952 record_jar="true"
890 fi 953 fi
891 954
892 pushd ${destdir} > /dev/null \ 955 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 956 || die "failed to change directory to ${destdir}"
894 957
902 # If no specific target jar was indicated, link it 965 # If no specific target jar was indicated, link it
903 if [[ -z "${target_jar}" ]] ; then 966 if [[ -z "${target_jar}" ]] ; then
904 [[ -f "${target_jar}" ]] && rm "${target_jar}" 967 [[ -f "${target_jar}" ]] && rm "${target_jar}"
905 ln -snf "${jar}" \ 968 ln -snf "${jar}" \
906 || die "Failed to make symlink from ${jar} to ${jar_name}" 969 || die "Failed to make symlink from ${jar} to ${jar_name}"
970 if [[ -z "${record_jar}" ]]; then
971 if [[ -z "${build_only}" ]]; then
907 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 972 java-pkg_record-jar_ "${target_pkg}" "${jar}"
973 else
974 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
975 fi
976 fi
908 # otherwise, if the current jar is the target jar, link it 977 # otherwise, if the current jar is the target jar, link it
909 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 978 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
910 [[ -f "${destjar}" ]] && rm "${destjar}" 979 [[ -f "${destjar}" ]] && rm "${destjar}"
911 ln -snf "${jar}" "${destjar}" \ 980 ln -snf "${jar}" "${destjar}" \
912 || die "Failed to make symlink from ${jar} to ${destjar}" 981 || die "Failed to make symlink from ${jar} to ${destjar}"
982 if [[ -z "${record_jar}" ]]; then
983 if [[ -z "${build_only}" ]]; then
913 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 984 java-pkg_record-jar_ "${target_pkg}" "${jar}"
985 else
986 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
987 fi
988 fi
914 popd > /dev/null 989 popd > /dev/null
915 return 0 990 return 0
916 fi 991 fi
917 done 992 done
918 popd > /dev/null 993 popd > /dev/null
977 done 1052 done
978 1053
979 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1054 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
980 1055
981 1056
982 local classpath pkgs="${1}" 1057 local pkgs="${1}"
1058
1059 if [[ "${EAPI}" == "1" ]]; then
1060 pkgs="${pkgs//:/-}"
1061 fi
1062
983 jars="$(java-config ${deep} --classpath=${pkgs})" 1063 jars="$(java-config ${deep} --classpath=${pkgs})"
984 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1064 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
985 debug-print "${pkgs}:${jars}" 1065 debug-print "${pkgs}:${jars}"
986 1066
987 for pkg in ${pkgs//,/ }; do 1067 for pkg in ${pkgs//,/ }; do
988 java-pkg_ensure-dep "${build_only}" "${pkg}" 1068 java-pkg_ensure-dep "${build_only}" "${pkg}"
989 done 1069 done
990 1070
991 if [[ -z "${classpath}" ]]; then 1071 for pkg in ${pkgs//,/ }; do
992 classpath="${jars}"
993 else
994 classpath="${classpath}:${jars}"
995 fi
996
997 # Only record jars that aren't build-only
998 if [[ -z "${build_only}" ]]; then 1072 if [[ -z "${build_only}" ]]; then
999 for pkg in ${pkgs//,/ }; do
1000 java-pkg_record-jar_ "${pkg}" 1073 java-pkg_record-jar_ "${pkg}"
1074 else
1075 java-pkg_record-jar_ --build-only "${pkg}"
1076 fi
1001 done 1077 done
1002 fi
1003 1078
1004 echo "${classpath}" 1079 echo "${jars}"
1005} 1080}
1006 1081
1007# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1008# @ebuild-function java-pkg_getjar 1083# @ebuild-function java-pkg_getjar
1009# 1084#
1018# @example-return 1093# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1094# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1095#
1021# @param $opt 1096# @param $opt
1022# --build-only - makes the jar not added into package.env DEPEND line. 1097# --build-only - makes the jar not added into package.env DEPEND line.
1098# --virtual - Packages passed to this function are to be handled as virtuals
1099# and will not have individual jar dependencies recorded.
1023# @param $1 - package to use 1100# @param $1 - package to use
1024# @param $2 - jar to get 1101# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1102# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1103java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1104 debug-print-function ${FUNCNAME} $*
1028 1105
1029 local build_only="" 1106 local build_only=""
1107 local virtual=""
1108 local record_jar=""
1030 1109
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1110 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1111
1033 while [[ "${1}" == --* ]]; do 1112 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1113 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1114 build_only="build"
1115 elif [[ "${1}" == "--virtual" ]]; then
1116 virtual="true"
1036 else 1117 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1118 die "java-pkg_getjar called with unknown parameter: ${1}"
1038 fi 1119 fi
1039 shift 1120 shift
1040 done 1121 done
1041 1122
1042 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1123 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1043 1124
1044 local pkg="${1}" target_jar="${2}" jar 1125 local pkg="${1}" target_jar="${2}" jar
1126
1127 if [[ "${EAPI}" == "1" ]]; then
1128 pkg="${pkg//:/-}"
1129 fi
1130
1045 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1131 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1046 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1132 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1047 1133
1048 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1134 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1049 local classpath 1135 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1136 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1137 [[ $? != 0 ]] && die ${error_msg}
1052 1138
1053 java-pkg_ensure-dep "${build_only}" "${pkg}" 1139 java-pkg_ensure-dep "${build_only}" "${pkg}"
1054 1140
1141 # Record the package(Virtual) as a dependency and then set build_only
1142 # So that individual jars are not recorded.
1143 if [[ -n "${virtual}" ]]; then
1144 if [[ -z "${build_only}" ]]; then
1145 java-pkg_record-jar_ "${pkg}"
1146 else
1147 java-pkg_record-jar_ --build-only "${pkg}"
1148 fi
1149 record_jar="true"
1150 fi
1151
1055 for jar in ${classpath//:/ }; do 1152 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1153 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1154 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1155 fi
1059 1156
1060 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1157 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1061 # Only record jars that aren't build-only 1158 # Only record jars that aren't build-only
1062 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1159 if [[ -z "${record_jar}" ]]; then
1160 if [[ -z "${build_only}" ]]; then
1161 java-pkg_record-jar_ "${pkg}" "${jar}"
1162 else
1163 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1164 fi
1165 fi
1063 echo "${jar}" 1166 echo "${jar}"
1064 return 0 1167 return 0
1065 fi 1168 fi
1066 done 1169 done
1067 1170
1103 1206
1104 local pkgs="${1}" 1207 local pkgs="${1}"
1105 local jar="${2}" 1208 local jar="${2}"
1106 1209
1107 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1210 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1211
1212 if [[ "${EAPI}" == "1" ]]; then
1213 pkgs="${pkgs//:/-}"
1214 fi
1108 1215
1109 if [[ -z "${jar}" ]]; then 1216 if [[ -z "${jar}" ]]; then
1110 for pkg in ${pkgs//,/ }; do 1217 for pkg in ${pkgs//,/ }; do
1111 java-pkg_ensure-dep runtime "${pkg}" 1218 java-pkg_ensure-dep runtime "${pkg}"
1112 java-pkg_record-jar_ "${pkg}" 1219 java-pkg_record-jar_ "${pkg}"
1155 local pkgs="${1}" 1262 local pkgs="${1}"
1156 local jar="${2}" 1263 local jar="${2}"
1157 1264
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1265 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159 1266
1267 if [[ "${EAPI}" == "1" ]]; then
1268 pkgs="${pkgs//:/-}"
1269 fi
1270
1160 if [[ -z "${jar}" ]]; then 1271 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do 1272 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}" 1273 java-pkg_record-jar_ --optional "${pkg}"
1163 done 1274 done
1164 else 1275 else
1193 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1304 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1194 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1305 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1195 1306
1196 java-pkg_do_write_ 1307 java-pkg_do_write_
1197} 1308}
1309
1310# ------------------------------------------------------------------------------
1311# @ebuild-function java-pkg_get-bootclasspath
1312#
1313# Returns classpath of a given bootclasspath-providing package version.
1314#
1315# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1316# of the current JDK
1317# ------------------------------------------------------------------------------
1318
1319java-pkg_get-bootclasspath() {
1320 local version="${1}"
1321
1322 local bcp
1323 case "${version}" in
1324 auto)
1325 bcp="$(java-config -g BOOTCLASSPATH)"
1326 ;;
1327 1.5)
1328 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1329 ;;
1330 *)
1331 eerror "unknown parameter of java-pkg_get-bootclasspath"
1332 die "unknown parameter of java-pkg_get-bootclasspath"
1333 ;;
1334 esac
1335
1336 echo "${bcp}"
1337}
1338
1198 1339
1199# This function reads stdin, and based on that input, figures out how to 1340# This function reads stdin, and based on that input, figures out how to
1200# populate jars from the filesystem. 1341# populate jars from the filesystem.
1201# Need to figure out a good way of making use of this, ie be able to use a 1342# Need to figure out a good way of making use of this, ie be able to use a
1202# string that was built instead of stdin 1343# string that was built instead of stdin
1240# @section-begin helper 1381# @section-begin helper
1241# @section-summary Helper functions 1382# @section-summary Helper functions
1242# 1383#
1243# Various other functions to use from an ebuild 1384# Various other functions to use from an ebuild
1244# ------------------------------------------------------------------------------ 1385# ------------------------------------------------------------------------------
1245
1246# ------------------------------------------------------------------------------
1247# @ebuild-function java-pkg_need
1248#
1249# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1250# Currently supported virtuals are:
1251# javamail
1252# jdbc-stdext
1253# jaf
1254# jdbc-rowset
1255# jms
1256#
1257# @param $1 - Optionally indicate that the dependencies are controlled by
1258# a use flag by specifying '--use' Requires $2.
1259# @param $2 - USE flag which will enable the dependencies.
1260# @param $@ - virtual packages to add depenedencies for
1261# ------------------------------------------------------------------------------
1262# TODO rewrite to parse a line based declaration file instead -- karltk
1263#java-pkg_need() {
1264# debug-print-function ${FUNCNAME} $*
1265# local useflag
1266# if [[ ${1} == "--use" ]]; then
1267# useflag="${2}"
1268# shift 2
1269# fi
1270#
1271# if [[ -z ${1} ]]; then
1272# die "Must specify at least one virtual package."
1273# fi
1274#
1275# local depstr newdepstr
1276#
1277# for virtual in ${@}; do
1278# if has ${virtual} ${JAVA_PKG_VNEED}; then
1279# debug-print "Already registered virtual ${virtual}"
1280# continue
1281# fi
1282# case ${virtual} in
1283# javamail)
1284# debug-print "java-pkg_need: adding javamail dependencies"
1285# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1286# ;;
1287# jdbc-stdext)
1288# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1289# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1290# ;;
1291# jaf)
1292# debug-print "java-pkg_need: adding jaf dependencies"
1293# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1294# ;;
1295# jdbc-rowset)
1296# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1297# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1298# ;;
1299# jms)
1300# debug-print "java-pkg_need: adding jms dependencies"
1301# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1302# ;;
1303# *)
1304# die "Invalid virtual: ${virtual}"
1305# esac
1306#
1307# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1308#
1309# if [[ -n ${useflag} ]]; then
1310# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1311# else
1312# depstr="${depstr} ${newdepstr}"
1313# fi
1314# done
1315#
1316# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1317# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1318#
1319# export DEPEND="${DEPEND} ${depstr}"
1320# export RDEPEND="${RDEPEND} ${depstr}"
1321#}
1322 1386
1323# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_find-normal-jars 1388# @ebuild-function java-pkg_find-normal-jars
1325# 1389#
1326# Find the files with suffix .jar file in the given directory or $WORKDIR 1390# Find the files with suffix .jar file in the given directory or $WORKDIR
1492java-pkg_get-current-vm() { 1556java-pkg_get-current-vm() {
1493 echo ${GENTOO_VM} 1557 echo ${GENTOO_VM}
1494} 1558}
1495 1559
1496java-pkg_current-vm-matches() { 1560java-pkg_current-vm-matches() {
1497 hasq $(java-pkg_get-current-vm) ${@} 1561 has $(java-pkg_get-current-vm) ${@}
1498 return $? 1562 return $?
1499} 1563}
1500 1564
1501# ------------------------------------------------------------------------------ 1565# ------------------------------------------------------------------------------
1502# @ebuild-function java-pkg_get-source 1566# @ebuild-function java-pkg_get-source
1617 die "No GCJ support found!" 1681 die "No GCJ support found!"
1618 fi 1682 fi
1619} 1683}
1620 1684
1621java-pkg_ensure-test() { 1685java-pkg_ensure-test() {
1622 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1686 if has test ${FEATURES} && ! has -test ${FEATURES} \
1623 && hasq test ${IUSE} && ! use test; 1687 && has test ${IUSE} && ! use test;
1624 then 1688 then
1625 eerror "You specified FEATURES=test, but USE=test is needed" 1689 eerror "You specified FEATURES=test, but USE=test is needed"
1626 eerror "to pull in the additional dependencies for testing" 1690 eerror "to pull in the additional dependencies for testing"
1627 die "Need USE=test enabled" 1691 die "Need USE=test enabled"
1628 fi 1692 fi
1664 dodir /usr/share/ant/${TASKS_DIR} 1728 dodir /usr/share/ant/${TASKS_DIR}
1665 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1729 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1666} 1730}
1667 1731
1668# ------------------------------------------------------------------------------ 1732# ------------------------------------------------------------------------------
1669# @internal-function java-pkg_ant-tasks-from-deps
1670#
1671# Function to determine ANT_TASKS from DEPEND variable for backwards
1672# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1673# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1674# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1675# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1676# be a problem, the worst it can do is activace all tasks when not needed.
1677# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1678# insufficient dependencies, otherwise all available tasks are used for
1679# backwards compatilbility.
1680#
1681# @return "all" or "none"
1682# ------------------------------------------------------------------------------
1683java-pkg_ant-tasks-from-deps() {
1684 local found_ant found_ant_tasks
1685
1686 for dep in ${DEPEND}
1687 do
1688 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1689 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1690 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1691 done
1692
1693 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1694 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1695 echo "all"
1696 else
1697 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1698 # so we deactivate all tasks that may be installed
1699 echo "none"
1700 fi
1701}
1702
1703# ------------------------------------------------------------------------------
1704# @internal-function java-pkg_ant-tasks-depend 1733# @internal-function java-pkg_ant-tasks-depend
1705# 1734#
1706# Translates the WANT_ANT_TASKS variable into valid dependencies. 1735# Translates the WANT_ANT_TASKS variable into valid dependencies.
1707# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1708java-pkg_ant-tasks-depend() { 1737java-pkg_ant-tasks-depend() {
1710 1739
1711 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1740 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1712 local DEP="" 1741 local DEP=""
1713 for i in ${WANT_ANT_TASKS} 1742 for i in ${WANT_ANT_TASKS}
1714 do 1743 do
1715 if [[ ${i} != ant-* ]]; then 1744 if [[ ${i} = ant-* ]]; then
1745 DEP="${DEP}dev-java/${i} "
1746 elif [[ ${i} = */*:* ]]; then
1747 DEP="${DEP}${i} "
1748 else
1716 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1717 return 1 1750 return 1
1718 fi 1751 fi
1719 DEP="${DEP}dev-java/${i} "
1720 done 1752 done
1721 echo ${DEP} 1753 echo ${DEP}
1722 return 0 1754 return 0
1723 else 1755 else
1724 return 0 1756 return 0
1725 fi 1757 fi
1726} 1758}
1727 1759
1760
1728# ------------------------------------------------------------------------------ 1761# ------------------------------------------------------------------------------
1729# @ebuild-function ejunit 1762# @internal-function ejunit_
1730# 1763#
1731# Junit wrapper function. Makes it easier to run the tests and checks for 1764# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1732# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1765# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1733# 1766#
1734# Examples: 1767# @param $1 - junit package (junit or junit-4)
1735# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1736# ejunit org.blinkenlights.jid3.test.AllTests
1737#
1738# @param $1 - -cp or -classpath 1768# @param $2 - -cp or -classpath
1739# @param $2 - classpath; junit and recorded dependencies get appended 1769# @param $3 - classpath; junit and recorded dependencies get appended
1740# @param $@ - the rest of the parameters are passed to java 1770# @param $@ - the rest of the parameters are passed to java
1741# ------------------------------------------------------------------------------
1742ejunit() { 1771ejunit_() {
1743 debug-print-function ${FUNCNAME} $* 1772 debug-print-function ${FUNCNAME} $*
1744 1773
1745 local pkgs 1774 local pkgs
1775 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1776 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1777 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done 1778 done
1779 fi
1749 1780
1781 local junit=${1}
1782 shift 1
1783
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1784 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}" 1786 cp="${2}:${cp}"
1753 shift 2 1787 shift 2
1754 else 1788 else
1755 cp=".:${cp}" 1789 cp=".:${cp}"
1756 fi 1790 fi
1757 1791
1758 local runner=junit.textui.TestRunner 1792 local runner=junit.textui.TestRunner
1793 if [[ "${junit}" == "junit-4" ]] ; then
1794 runner=org.junit.runner.JUnitCore
1795 fi
1759 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1796 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1760 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1797 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1761} 1798}
1762 1799
1763# ------------------------------------------------------------------------------ 1800# ------------------------------------------------------------------------------
1801# @ebuild-function ejunit
1802#
1803# Junit wrapper function. Makes it easier to run the tests and checks for
1804# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1805#
1806# Examples:
1807# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1808# ejunit org.blinkenlights.jid3.test.AllTests
1809# ejunit org.blinkenlights.jid3.test.FirstTest \
1810# org.blinkenlights.jid3.test.SecondTest
1811#
1812# @param $1 - -cp or -classpath
1813# @param $2 - classpath; junit and recorded dependencies get appended
1814# @param $@ - the rest of the parameters are passed to java
1815# ------------------------------------------------------------------------------
1816ejunit() {
1817 debug-print-function ${FUNCNAME} $*
1818
1819 ejunit_ "junit" "${@}"
1820}
1821
1822# ------------------------------------------------------------------------------
1823# @ebuild-function ejunit4
1824#
1825# Junit4 wrapper function. Makes it easier to run the tests and checks for
1826# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1827#
1828# Examples:
1829# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1830# ejunit4 org.blinkenlights.jid3.test.AllTests
1831# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1832# org.blinkenlights.jid3.test.SecondTest
1833#
1834# @param $1 - -cp or -classpath
1835# @param $2 - classpath; junit and recorded dependencies get appended
1836# @param $@ - the rest of the parameters are passed to java
1837# ------------------------------------------------------------------------------
1838ejunit4() {
1839 debug-print-function ${FUNCNAME} $*
1840
1841 ejunit_ "junit-4" "${@}"
1842}
1843
1844# ------------------------------------------------------------------------------
1764# @section-end helper 1845# @section-end helper
1765# ------------------------------------------------------------------------------ 1846# ------------------------------------------------------------------------------
1847
1848# ------------------------------------------------------------------------------
1849# @eclass-src_prepare
1850#
1851# src_prepare Searches for bundled jars
1852# Don't call directly, but via java-pkg-2_src_prepare!
1853# ------------------------------------------------------------------------------
1854
1855java-utils-2_src_prepare() {
1856 [[ ${EBUILD_PHASE} == prepare ]] &&
1857 java-pkg_func-exists java_prepare && java_prepare
1858
1859 # Remember that eant will call this unless called via Portage
1860 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1861 echo "Searching for bundled jars:"
1862 java-pkg_find-normal-jars || echo "None found."
1863 echo "Searching for bundled classes (no output if none found):"
1864 find "${WORKDIR}" -name "*.class"
1865 echo "Search done."
1866 fi
1867 touch "${T}/java-utils-2_src_prepare-run"
1868}
1869
1870# ------------------------------------------------------------------------------
1871# @eclass-pkg_preinst
1872#
1873# pkg_preinst Searches for missing and unneeded dependencies
1874# Don't call directly, but via java-pkg-2_pkg_preinst!
1875# ------------------------------------------------------------------------------
1876
1877java-utils-2_pkg_preinst() {
1878 if is-java-strict; then
1879 if has_version dev-java/java-dep-check; then
1880 [[ -e "${JAVA_PKG_ENV}" ]] || return
1881 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1882 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1883 ewarn "Possibly unneeded dependencies found in package.env:"
1884 for dep in ${output}; do
1885 ewarn "\t${dep}"
1886 done
1887 fi
1888 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1889 ewarn "${output}"
1890 fi
1891 else
1892 eerror "Install dev-java/java-dep-check for dependency checking"
1893 fi
1894 fi
1895}
1766 1896
1767# ------------------------------------------------------------------------------ 1897# ------------------------------------------------------------------------------
1768# @section-begin build 1898# @section-begin build
1769# @section-summary Build functions 1899# @section-summary Build functions
1770# 1900#
1779# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1909# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1780# variables: 1910# variables:
1781# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1911# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1782# gentoo.classpath property. Be sure to call 1912# gentoo.classpath property. Be sure to call
1783# java-ant_rewrite-classpath in src_unpack. 1913# java-ant_rewrite-classpath in src_unpack.
1914# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1915# for build-time purposes, the dependency is not recorded to
1916# package.env!
1784# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1917# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1918# ------------------------------------------------------------------------------
1786eant() { 1919eant() {
1787 debug-print-function ${FUNCNAME} $* 1920 debug-print-function ${FUNCNAME} $*
1788 1921
1922 if [[ ${EBUILD_PHASE} = compile ]]; then
1923 java-ant-2_src_configure
1924 java-utils-2_src_prepare
1925 fi
1926
1789 if ! hasq java-ant-2 ${INHERITED}; then 1927 if ! has java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1928 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1929 java-pkg_announce-qa-violation "${msg}"
1792 fi 1930 fi
1793 1931
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1932 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1933
1796 java-pkg_init-compiler_ 1934 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1935 local compiler="${GENTOO_COMPILER}"
1798 1936
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1937 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1800
1801 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1938 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1939 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1940 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1941 fi
1805 1942
1811 # java-config -p 1948 # java-config -p
1812 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1949 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1813 if [[ -n ${build_compiler_deps} ]]; then 1950 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1951 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1952 fi
1816 fi
1817
1818 if is-java-strict; then
1819 einfo "Disabling system classpath for ant"
1820 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1821 fi 1953 fi
1822 1954
1823 for arg in "${@}"; do 1955 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1956 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1957 if is-java-strict; then
1834 echo "more info." 1966 echo "more info."
1835 fi 1967 fi
1836 fi 1968 fi
1837 done 1969 done
1838 1970
1839 # we use this in src_* so we run ant from / 1971 # parse WANT_ANT_TASKS for atoms
1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1972 local want_ant_tasks
1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1973 for i in ${WANT_ANT_TASKS}; do
1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1974 if [[ ${i} = */*:* ]]; then
1843 1975 i=${i#*/}
1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1976 i=${i%:0}
1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1977 want_ant_tasks+="${i/:/-} "
1846
1847 if is-java-strict; then
1848 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1849 if [[ -z "${ANT_TASKS}" ]]; then
1850 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1851 fi
1852 else 1978 else
1979 want_ant_tasks+="${i} "
1980 fi
1981 done
1982 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1983 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1984
1985 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1986 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1987
1853 # if ant-tasks is not set by ebuild or forced, activate all of them 1988 # if ant-tasks is not set by ebuild or forced, use none
1854 ANT_TASKS="${ANT_TASKS:-all}" 1989 ANT_TASKS="${ANT_TASKS:-none}"
1855 fi
1856 1990
1857 # at this point, ANT_TASKS should be "all", "none" or explicit list 1991 # at this point, ANT_TASKS should be "all", "none" or explicit list
1858 if [[ "${ANT_TASKS}" == "all" ]]; then 1992 if [[ "${ANT_TASKS}" == "all" ]]; then
1859 einfo "Using all available ANT_TASKS" 1993 einfo "Using all available ANT_TASKS"
1860 elif [[ "${ANT_TASKS}" == "none" ]]; then 1994 elif [[ "${ANT_TASKS}" == "none" ]]; then
1861 einfo "Disabling all optional ANT_TASKS" 1995 einfo "Disabling all optional ANT_TASKS"
1862 else 1996 else
1863 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1997 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1864 fi 1998 fi
1865 1999
1866 export ANT_TASKS 2000 export ANT_TASKS
1867 fi
1868 2001
1869 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 2002 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1870 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 2003 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1871 2004
1872 local gcp="${EANT_GENTOO_CLASSPATH}" 2005 local gcp="${EANT_GENTOO_CLASSPATH}"
1873 local getjarsarg="" 2006 local getjarsarg=""
1874 2007
1875 if [[ ${EBUILD_PHASE} = "test" ]]; then 2008 if [[ ${EBUILD_PHASE} = "test" ]]; then
1876 antflags="${antflags} -DJunit.present=true" 2009 antflags="${antflags} -DJunit.present=true"
1877 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2010 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1878 getjarsarg="--with-dependencies" 2011 getjarsarg="--with-dependencies"
1879 fi 2012 fi
1880 2013
1881 local cp 2014 local cp
1882 2015
1883 for atom in ${gcp}; do 2016 for atom in ${gcp}; do
1884 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2017 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1885 done 2018 done
1886 2019
2020 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2021
1887 if [[ ${cp} ]]; then 2022 if [[ ${cp} ]]; then
1888 # It seems ant does not like single quotes around ${cp} 2023 # It seems ant does not like single quotes around ${cp}
2024 cp=${cp#:}
2025 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2026 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1889 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2027 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1890 fi 2028 fi
1891 2029
1892 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2030 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1893 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2031 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1894 ant ${antflags} "${@}" || die "eant failed" 2032 ant ${antflags} "${@}" || die "eant failed"
1994# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2132# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1995# call it during each of the phases of the merge process. 2133# call it during each of the phases of the merge process.
1996# 2134#
1997# ----------------------------------------------------------------------------- 2135# -----------------------------------------------------------------------------
1998java-pkg_init() { 2136java-pkg_init() {
2137 debug-print-function ${FUNCNAME} $*
1999 unset JAVAC 2138 unset JAVAC
2000 unset JAVA_HOME 2139 unset JAVA_HOME
2140
2141 java-config --help >/dev/null || {
2142 eerror ""
2143 eerror "Can't run java-config --help"
2144 eerror "Have you upgraded python recently but haven't"
2145 eerror "run python-updater yet?"
2146 die "Can't run java-config --help"
2147 }
2001 2148
2002 # People do all kinds of weird things. 2149 # People do all kinds of weird things.
2003 # http://forums.gentoo.org/viewtopic-p-3943166.html 2150 # http://forums.gentoo.org/viewtopic-p-3943166.html
2004 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2151 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2005 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2152 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2011 ewarn "make.conf for example) to silence this warning or" 2158 ewarn "make.conf for example) to silence this warning or"
2012 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2159 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2013 fi 2160 fi
2014 2161
2015 if [[ -z ${accept} ]]; then 2162 if [[ -z ${accept} ]]; then
2163 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2164 # -version output
2016 unset _JAVA_OPTIONS 2165 unset _JAVA_OPTIONS
2017 # phase hooks make this run many times without this 2166 # phase hooks make this run many times without this
2018 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2167 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2019 fi 2168 fi
2020 2169
2170 if java-pkg_func-exists ant_src_unpack; then
2171 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2172 fi
2173
2021 java-pkg_init_paths_ 2174 java-pkg_init_paths_
2022 java-pkg_switch-vm 2175 java-pkg_switch-vm
2023 PATH=${JAVA_HOME}/bin:${PATH} 2176 PATH=${JAVA_HOME}/bin:${PATH}
2024 2177
2025 # TODO we will probably want to set JAVAC and JAVACFLAGS 2178 # TODO we will probably want to set JAVAC and JAVACFLAGS
2026 2179
2027 # Do some QA checks 2180 # Do some QA checks
2028 java-pkg_check-jikes 2181 java-pkg_check-jikes
2182
2183 # Can't use unset here because Portage does not save the unset
2184 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2029 2185
2030 # When users have crazy classpaths some packages can fail to compile. 2186 # When users have crazy classpaths some packages can fail to compile.
2031 # and everything should work with empty CLASSPATH. 2187 # and everything should work with empty CLASSPATH.
2032 # This also helps prevent unexpected dependencies on random things 2188 # This also helps prevent unexpected dependencies on random things
2033 # from the CLASSPATH. 2189 # from the CLASSPATH.
2034 unset CLASSPATH 2190 export CLASSPATH=
2035 2191
2036 # Unset external ANT_ stuff 2192 # Unset external ANT_ stuff
2037 unset ANT_TASKS 2193 export ANT_TASKS=
2038 unset ANT_OPTS 2194 export ANT_OPTS=
2195 export ANT_RESPECT_JAVA_HOME=
2039} 2196}
2040 2197
2041# ------------------------------------------------------------------------------ 2198# ------------------------------------------------------------------------------
2042# @function-internal java-pkg-init-compiler_ 2199# @function-internal java-pkg-init-compiler_
2043# 2200#
2134 done 2291 done
2135 2292
2136 # If it hasn't been defined already, default to javac 2293 # If it hasn't been defined already, default to javac
2137 if [[ -z ${GENTOO_COMPILER} ]]; then 2294 if [[ -z ${GENTOO_COMPILER} ]]; then
2138 if [[ -n ${compilers} ]]; then 2295 if [[ -n ${compilers} ]]; then
2139 einfo "No suitable compiler found: defaulting javac for compilation" 2296 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2140 else 2297 else
2141 # probably don't need to notify users about the default. 2298 # probably don't need to notify users about the default.
2142 :;#einfo "Defaulting to javac for compilation" 2299 :;#einfo "Defaulting to javac for compilation"
2143 fi 2300 fi
2301 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2302 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2303 else
2144 export GENTOO_COMPILER=javac 2304 export GENTOO_COMPILER=javac
2305 fi
2145 else 2306 else
2146 einfo "Using ${GENTOO_COMPILER} for compilation" 2307 einfo "Using ${GENTOO_COMPILER} for compilation"
2147 fi 2308 fi
2148 2309
2149} 2310}
2165 fi 2326 fi
2166 2327
2167 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2328 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2168 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2329 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2169 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2330 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2331 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2332 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2170 2333
2171 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2334 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2172 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2335 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2173 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2336 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2174 2337
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2361 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2199 # Create package.env 2362 # Create package.env
2200 ( 2363 (
2201 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2364 echo "DESCRIPTION=\"${DESCRIPTION}\""
2202 echo "GENERATION=\"2\"" 2365 echo "GENERATION=\"2\""
2366 echo "SLOT=\"${SLOT}\""
2367 echo "CATEGORY=\"${CATEGORY}\""
2368 echo "PVR=\"${PVR}\""
2203 2369
2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2370 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2371 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2372 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2373 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2208 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2374 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2209 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2375 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2210 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2376 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2211 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2377 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2378 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2379 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2212 ) > "${JAVA_PKG_ENV}" 2380 ) > "${JAVA_PKG_ENV}"
2213 2381
2214 # register target/source 2382 # register target/source
2215 local target="$(java-pkg_get-target)" 2383 local target="$(java-pkg_get-target)"
2216 local source="$(java-pkg_get-source)" 2384 local source="$(java-pkg_get-source)"
2249# ------------------------------------------------------------------------------ 2417# ------------------------------------------------------------------------------
2250# @internal-function java-pkg_record-jar_ 2418# @internal-function java-pkg_record-jar_
2251# 2419#
2252# Record an (optional) dependency to the package.env 2420# Record an (optional) dependency to the package.env
2253# @param --optional - record dependency as optional 2421# @param --optional - record dependency as optional
2422# @param --build - record dependency as build_only
2254# @param $1 - package to record 2423# @param $1 - package to record
2255# @param $2 - (optional) jar of package to record 2424# @param $2 - (optional) jar of package to record
2256# ------------------------------------------------------------------------------ 2425# ------------------------------------------------------------------------------
2257JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2426JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2258JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2427JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2428JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2259 2429
2260java-pkg_record-jar_() { 2430java-pkg_record-jar_() {
2261 debug-print-function ${FUNCNAME} $* 2431 debug-print-function ${FUNCNAME} $*
2262 2432
2263 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2433 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2264 if [[ "${1}" == "--optional" ]]; then 2434 case "${1}" in
2265 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2435 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2266 shift 2436 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2267 fi 2437 esac
2268 2438
2269 local pkg=${1} jar=${2} append 2439 local pkg=${1} jar=${2} append
2270 if [[ -z "${jar}" ]]; then 2440 if [[ -z "${jar}" ]]; then
2271 append="${pkg}" 2441 append="${pkg}"
2272 else 2442 else
2325# 2495#
2326# @return 0 - function is declared 2496# @return 0 - function is declared
2327# @return 1 - function is undeclared 2497# @return 1 - function is undeclared
2328# ------------------------------------------------------------------------------ 2498# ------------------------------------------------------------------------------
2329java-pkg_func-exists() { 2499java-pkg_func-exists() {
2330 if [[ -n "$(declare -f ${1})" ]]; then 2500 declare -F ${1} > /dev/null
2331 return 0
2332 else
2333 return 1
2334 fi
2335} 2501}
2336 2502
2337# ------------------------------------------------------------------------------ 2503# ------------------------------------------------------------------------------
2338# @internal-function java-pkg_setup-vm 2504# @internal-function java-pkg_setup-vm
2339# 2505#
2349 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2515 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2350 addpredict "/dev/random" 2516 addpredict "/dev/random"
2351 elif [[ "${vendor}" == "ibm" ]]; then 2517 elif [[ "${vendor}" == "ibm" ]]; then
2352 addpredict "/proc/self/maps" 2518 addpredict "/proc/self/maps"
2353 addpredict "/proc/cpuinfo" 2519 addpredict "/proc/cpuinfo"
2520 addpredict "/proc/self/coredump_filter"
2521 elif [[ "${vendor}" == "oracle" ]]; then
2522 addpredict "/dev/random"
2523 addpredict "/proc/self/coredump_filter"
2524 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2525 addpredict "/dev/random"
2526 addpredict "/proc/self/coredump_filter"
2354 elif [[ "${vendor}" == "jrockit" ]]; then 2527 elif [[ "${vendor}" == "jrockit" ]]; then
2355 addpredict "/proc/cpuinfo" 2528 addpredict "/proc/cpuinfo"
2356 fi 2529 fi
2357} 2530}
2358 2531
2365# @return 1 - Package does not depend on virtual/jdk 2538# @return 1 - Package does not depend on virtual/jdk
2366# ------------------------------------------------------------------------------ 2539# ------------------------------------------------------------------------------
2367java-pkg_needs-vm() { 2540java-pkg_needs-vm() {
2368 debug-print-function ${FUNCNAME} $* 2541 debug-print-function ${FUNCNAME} $*
2369 2542
2370 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2543 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2371 return 0 2544 return 0
2372 fi 2545 fi
2373 2546
2374 return 1 2547 return 1
2375} 2548}
2423 # If you're forcing the VM, I hope you know what your doing... 2596 # If you're forcing the VM, I hope you know what your doing...
2424 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2597 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2425 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2598 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2426 # if we're allowed to switch the vm... 2599 # if we're allowed to switch the vm...
2427 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2600 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2428 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2601 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2429 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2430 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2431 else
2432 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2602 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2433 fi
2434 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2603 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2435 eerror "Unable to determine VM for building from dependencies:" 2604 eerror "Unable to determine VM for building from dependencies:"
2436 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2605 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2437 echo "VNEED: ${JAVA_PKG_VNEED}"
2438 die "Failed to determine VM for building." 2606 die "Failed to determine VM for building."
2439 else 2607 else
2440 export GENTOO_VM 2608 export GENTOO_VM
2441 fi 2609 fi
2442 # otherwise just make sure the current VM is sufficient 2610 # otherwise just make sure the current VM is sufficient
2462 2630
2463 #TODO If you know a better solution let us know. 2631 #TODO If you know a better solution let us know.
2464 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2632 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2465 2633
2466 local tann="${T}/announced-vm" 2634 local tann="${T}/announced-vm"
2635 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2636 # if people have for example modified eclasses some where
2467 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2637 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2468 # Add a check for setup/preinst phase... to avoid duplicate outputs
2469 # for when FEATURES=buildpkg
2470 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2471 then
2472 einfo "Using: $(java-config -f)" 2638 einfo "Using: $(java-config -f)"
2473 [[ ! -f "${tann}" ]] && touch "${tann}" 2639 [[ ! -f "${tann}" ]] && touch "${tann}"
2474 fi
2475 fi 2640 fi
2476 2641
2477 else 2642 else
2478 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2643 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2479 fi 2644 fi
2484# 2649#
2485# Enhanced die for Java packages, which displays some information that may be 2650# Enhanced die for Java packages, which displays some information that may be
2486# useful for debugging bugs on bugzilla. 2651# useful for debugging bugs on bugzilla.
2487# ------------------------------------------------------------------------------ 2652# ------------------------------------------------------------------------------
2488#register_die_hook java-pkg_die 2653#register_die_hook java-pkg_die
2489if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2654if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2490 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2655 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2491fi 2656fi
2492 2657
2493java-pkg_die() { 2658java-pkg_die() {
2494 echo "!!! When you file a bug report, please include the following information:" >&2 2659 echo "!!! When you file a bug report, please include the following information:" >&2
2518# not. 2683# not.
2519# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2684# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2520# ------------------------------------------------------------------------------ 2685# ------------------------------------------------------------------------------
2521java-pkg_verify-classes() { 2686java-pkg_verify-classes() {
2522 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2687 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2688
2689 local version_verify="/usr/bin/class-version-verify.py"
2690
2691 if [[ ! -x "${version_verify}" ]]; then
2692 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2693 fi
2694
2695 if [[ ! -x "${version_verify}" ]]; then
2696 ewarn "Unable to perform class version checks as"
2697 ewarn "class-version-verify.py is unavailable"
2698 ewarn "Please install dev-java/javatoolkit."
2699 return
2700 fi
2701
2523 local target=$(java-pkg_get-target) 2702 local target=$(java-pkg_get-target)
2524 local result 2703 local result
2525 local log="${T}/class-version-verify.log" 2704 local log="${T}/class-version-verify.log"
2526 if [[ -n "${1}" ]]; then 2705 if [[ -n "${1}" ]]; then
2527 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2706 ${version_verify} -v -t ${target} "${1}" > "${log}"
2528 result=$? 2707 result=$?
2529 else 2708 else
2530 ebegin "Verifying java class versions (target: ${target})" 2709 ebegin "Verifying java class versions (target: ${target})"
2531 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2710 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2532 result=$? 2711 result=$?
2533 eend ${result} 2712 eend ${result}
2534 fi 2713 fi
2535 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2714 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2536 if [[ ${result} != 0 ]]; then 2715 if [[ ${result} != 0 ]]; then
2554 2733
2555 local limit_to="${1}" 2734 local limit_to="${1}"
2556 local target_pkg="${2}" 2735 local target_pkg="${2}"
2557 local dev_error="" 2736 local dev_error=""
2558 2737
2738 # remove the version specification, which may include globbing (* and [123])
2559 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2739 local stripped_pkg=$(echo "${target_pkg}" | sed \
2560 's/-[0-9]*\(\.[0-9]\)*$//') 2740 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2561 2741
2562 debug-print "Matching against: ${stripped_pkg}" 2742 debug-print "Matching against: ${stripped_pkg}"
2563 2743
2564 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2744 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2565 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2745 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2615 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2795 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2616 fi 2796 fi
2617} 2797}
2618 2798
2619java-pkg_check-jikes() { 2799java-pkg_check-jikes() {
2620 if hasq jikes ${IUSE}; then 2800 if has jikes ${IUSE}; then
2621 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2801 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2622 fi 2802 fi
2623} 2803}
2624 2804
2625java-pkg_announce-qa-violation() { 2805java-pkg_announce-qa-violation() {
2641is-java-strict() { 2821is-java-strict() {
2642 [[ -n ${JAVA_PKG_STRICT} ]] 2822 [[ -n ${JAVA_PKG_STRICT} ]]
2643 return $? 2823 return $?
2644} 2824}
2645 2825
2826
2646# ------------------------------------------------------------------------------ 2827# ------------------------------------------------------------------------------
2647# @eclass-end 2828# @eclass-end
2648# ------------------------------------------------------------------------------ 2829# ------------------------------------------------------------------------------

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.145

  ViewVC Help
Powered by ViewVC 1.1.20