/[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.93 Revision 1.132
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.93 2007/09/27 19:47:08 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.132 2010/02/12 23:51:44 caster Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
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
76 94
77# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 97# @variable-default yes
80# 98#
290 done 308 done
291 309
292 java-pkg_do_write_ 310 java-pkg_do_write_
293} 311}
294 312
295
296# ------------------------------------------------------------------------------ 313# ------------------------------------------------------------------------------
297# @internal-function depend-java-query 314# @internal-function depend-java-query
298# 315#
299# Wrapper for the depend-java-query binary to enable passing USE in env. 316# Wrapper for the depend-java-query binary to enable passing USE in env.
300# Using env variables keeps this eclass working with java-config versions that 317# Using env variables keeps this eclass working with java-config versions that
365 if [[ ${jar} = *\** ]]; then 382 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 383 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 384 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 385 eerror '${D} add ${D} to the argument.'
369 fi 386 fi
387 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 388 die "${jar} does not exist"
371 fi 389 fi
372 done 390 done
373 391
374 java-pkg_do_write_ 392 java-pkg_do_write_
429# @param $@ - JNI libraries to install 447# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 448# ------------------------------------------------------------------------------
431java-pkg_doso() { 449java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 450 debug-print-function ${FUNCNAME} $*
433 451
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 452 java-pkg_check-phase install
436 453
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 454 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 455
439 java-pkg_init_paths_ 456 java-pkg_init_paths_
440 457
441 local lib 458 local lib
442 # for each lib 459 # for each lib
445 if [[ -e "${lib}" ]] ; then 462 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 463 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 464 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 465 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 466 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 467 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 468 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 469 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 470 # otherwise make a symlink to the symlink's origin
454 else 471 else
455 # TODO use dosym 472 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 473 debug-print "${lib} is a symlink, linking accordantly"
459 fi 474 fi
460 # otherwise die 475 # otherwise die
461 else 476 else
462 die "${lib} does not exist" 477 die "${lib} does not exist"
463 fi 478 fi
479java-pkg_regso() { 494java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 495 debug-print-function ${FUNCNAME} $*
481 496
482 java-pkg_check-phase install 497 java-pkg_check-phase install
483 498
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 499 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 500
486 java-pkg_init_paths_ 501 java-pkg_init_paths_
487 502
488 local lib target_dir 503 local lib target_dir
489 for lib in "$@" ; do 504 for lib in "$@" ; do
556# ------------------------------------------------------------------------------ 571# ------------------------------------------------------------------------------
557# @ebuild-function java-pkg_dojavadoc 572# @ebuild-function java-pkg_dojavadoc
558# 573#
559# Installs javadoc documentation. This should be controlled by the doc use flag. 574# Installs javadoc documentation. This should be controlled by the doc use flag.
560# 575#
576# @param $1: optional --symlink creates to symlink like this for html
577# documentation bundles.
561# @param $1: - The javadoc root directory. 578# @param $2: - The javadoc root directory.
562# 579#
563# @example: 580# @example:
564# java-pkg_dojavadoc docs/api 581# java-pkg_dojavadoc docs/api
582# java-pkg_dojavadoc --symlink apidocs docs/api
565# 583#
566# ------------------------------------------------------------------------------ 584# ------------------------------------------------------------------------------
567java-pkg_dojavadoc() { 585java-pkg_dojavadoc() {
568 debug-print-function ${FUNCNAME} $* 586 debug-print-function ${FUNCNAME} $*
587
588 # For html documentation bundles that link to Javadoc
589 local symlink
590 if [[ ${1} = --symlink ]]; then
591 symlink=${2}
592 shift 2
593 fi
594
569 local dir="$1" 595 local dir="$1"
596 local dest=/usr/share/doc/${PF}/html
570 597
571 # QA checks 598 # QA checks
572 599
573 java-pkg_check-phase install 600 java-pkg_check-phase install
574 601
578 local msg="No index.html in javadoc directory" 605 local msg="No index.html in javadoc directory"
579 ewarn "${msg}" 606 ewarn "${msg}"
580 is-java-strict && die "${msg}" 607 is-java-strict && die "${msg}"
581 fi 608 fi
582 609
610 if [[ -e ${D}/${dest}/api ]]; then
611 eerror "${dest} already exists. Will not overwrite."
612 die "${dest}"
613 fi
614
583 # Renaming to match our directory layout 615 # Renaming to match our directory layout
584 616
585 local dir_to_install="${dir}" 617 local dir_to_install="${dir}"
586 if [[ "$(basename "${dir}")" != "api" ]]; then 618 if [[ "$(basename "${dir}")" != "api" ]]; then
587 dir_to_install="${T}/api" 619 dir_to_install="${T}/api"
589 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 621 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
590 fi 622 fi
591 623
592 # Actual installation 624 # Actual installation
593 625
594 java-pkg_dohtml -r ${dir_to_install} 626 java-pkg_dohtml -r "${dir_to_install}"
627
628 # Let's make a symlink to the directory we have everything else under
629 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
630
631 if [[ ${symlink} ]]; then
632 debug-print "symlinking ${dest}/{api,${symlink}}"
633 dosym ${dest}/{api,${symlink}} || die
634 fi
595} 635}
596 636
597# ------------------------------------------------------------------------------ 637# ------------------------------------------------------------------------------
598# @ebuild-function java-pkg_dosrc 638# @ebuild-function java-pkg_dosrc
599# 639#
622 662
623 [[ ${#} -lt 1 ]] && die "At least one argument needed" 663 [[ ${#} -lt 1 ]] && die "At least one argument needed"
624 664
625 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 665 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
626 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 666 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
627 if is-java-strict; then 667 java-pkg_announce-qa-violation ${msg}
628 eerror "${msg}"
629 die "${msg}"
630 else
631 echo "${msg}"
632 echo "Please report this to http://bugs.gentoo.org."
633 fi
634 fi 668 fi
635 669
636 java-pkg_init_paths_ 670 java-pkg_init_paths_
637 671
638 local zip_name="${PN}-src.zip" 672 local zip_name="${PN}-src.zip"
838# @param $opt 872# @param $opt
839# --build-only - makes the jar(s) not added into package.env DEPEND line. 873# --build-only - makes the jar(s) not added into package.env DEPEND line.
840# (assumed automatically when called inside src_test) 874# (assumed automatically when called inside src_test)
841# --with-dependencies - get jars also from requested package's dependencies 875# --with-dependencies - get jars also from requested package's dependencies
842# transitively. 876# transitively.
877# --virtual - Packages passed to this function are to be handled as virtuals
878# and will not have individual jar dependencies recorded.
843# --into $dir - symlink jar(s) into $dir (must exist) instead of . 879# --into $dir - symlink jar(s) into $dir (must exist) instead of .
844# @param $1 - Package to get jars from, or comma-separated list of packages in 880# @param $1 - Package to get jars from, or comma-separated list of packages in
845# case other parameters are not used. 881# case other parameters are not used.
846# @param $2 - jar from package. If not specified, all jars will be used. 882# @param $2 - jar from package. If not specified, all jars will be used.
847# @param $3 - When a single jar is specified, destination filename of the 883# @param $3 - When a single jar is specified, destination filename of the
852 debug-print-function ${FUNCNAME} $* 888 debug-print-function ${FUNCNAME} $*
853 889
854 local build_only="" 890 local build_only=""
855 local destdir="." 891 local destdir="."
856 local deep="" 892 local deep=""
893 local virtual=""
894 local record_jar=""
857 895
858 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 896 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
859 897
860 while [[ "${1}" == --* ]]; do 898 while [[ "${1}" == --* ]]; do
861 if [[ "${1}" = "--build-only" ]]; then 899 if [[ "${1}" = "--build-only" ]]; then
862 build_only="build" 900 build_only="build"
863 elif [[ "${1}" = "--with-dependencies" ]]; then 901 elif [[ "${1}" = "--with-dependencies" ]]; then
864 deep="--with-dependencies" 902 deep="--with-dependencies"
903 elif [[ "${1}" = "--virtual" ]]; then
904 virtual="true"
865 elif [[ "${1}" = "--into" ]]; then 905 elif [[ "${1}" = "--into" ]]; then
866 destdir="${2}" 906 destdir="${2}"
867 shift 907 shift
868 else 908 else
869 die "java-pkg_jar-from called with unknown parameter: ${1}" 909 die "java-pkg_jar-from called with unknown parameter: ${1}"
872 done 912 done
873 913
874 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 914 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
875 915
876 [[ -z ${target_pkg} ]] && die "Must specify a package" 916 [[ -z ${target_pkg} ]] && die "Must specify a package"
917
918 if [[ "${EAPI}" == "1" ]]; then
919 target_pkg="${target_pkg//:/-}"
920 fi
877 921
878 # default destjar to the target jar 922 # default destjar to the target jar
879 [[ -z "${destjar}" ]] && destjar="${target_jar}" 923 [[ -z "${destjar}" ]] && destjar="${target_jar}"
880 924
881 local error_msg="There was a problem getting the classpath for ${target_pkg}." 925 local error_msg="There was a problem getting the classpath for ${target_pkg}."
890 for pkg in ${target_pkg//,/ }; do 934 for pkg in ${target_pkg//,/ }; do
891 java-pkg_ensure-dep "${build_only}" "${pkg}" 935 java-pkg_ensure-dep "${build_only}" "${pkg}"
892 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 936 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
893 done 937 done
894 # setting this disables further record-jar_ calls later 938 # setting this disables further record-jar_ calls later
895 build_only="build" 939 record_jar="true"
896 else 940 else
897 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 941 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
942 fi
943
944 # Record the entire virtual as a dependency so that
945 # no jars are missed.
946 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
947 java-pkg_record-jar_ "${target_pkg}"
948 # setting this disables further record-jars_ calls later
949 record_jar="true"
898 fi 950 fi
899 951
900 pushd ${destdir} > /dev/null \ 952 pushd ${destdir} > /dev/null \
901 || die "failed to change directory to ${destdir}" 953 || die "failed to change directory to ${destdir}"
902 954
910 # If no specific target jar was indicated, link it 962 # If no specific target jar was indicated, link it
911 if [[ -z "${target_jar}" ]] ; then 963 if [[ -z "${target_jar}" ]] ; then
912 [[ -f "${target_jar}" ]] && rm "${target_jar}" 964 [[ -f "${target_jar}" ]] && rm "${target_jar}"
913 ln -snf "${jar}" \ 965 ln -snf "${jar}" \
914 || die "Failed to make symlink from ${jar} to ${jar_name}" 966 || die "Failed to make symlink from ${jar} to ${jar_name}"
967 if [[ -z "${record_jar}" ]]; then
968 if [[ -z "${build_only}" ]]; then
915 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 969 java-pkg_record-jar_ "${target_pkg}" "${jar}"
970 else
971 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
972 fi
973 fi
916 # otherwise, if the current jar is the target jar, link it 974 # otherwise, if the current jar is the target jar, link it
917 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 975 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
918 [[ -f "${destjar}" ]] && rm "${destjar}" 976 [[ -f "${destjar}" ]] && rm "${destjar}"
919 ln -snf "${jar}" "${destjar}" \ 977 ln -snf "${jar}" "${destjar}" \
920 || die "Failed to make symlink from ${jar} to ${destjar}" 978 || die "Failed to make symlink from ${jar} to ${destjar}"
979 if [[ -z "${record_jar}" ]]; then
980 if [[ -z "${build_only}" ]]; then
921 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 981 java-pkg_record-jar_ "${target_pkg}" "${jar}"
982 else
983 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
984 fi
985 fi
922 popd > /dev/null 986 popd > /dev/null
923 return 0 987 return 0
924 fi 988 fi
925 done 989 done
926 popd > /dev/null 990 popd > /dev/null
985 done 1049 done
986 1050
987 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1051 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
988 1052
989 1053
990 local classpath pkgs="${1}" 1054 local pkgs="${1}"
1055
1056 if [[ "${EAPI}" == "1" ]]; then
1057 pkgs="${pkgs//:/-}"
1058 fi
1059
991 jars="$(java-config ${deep} --classpath=${pkgs})" 1060 jars="$(java-config ${deep} --classpath=${pkgs})"
992 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1061 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
993 debug-print "${pkgs}:${jars}" 1062 debug-print "${pkgs}:${jars}"
994 1063
995 for pkg in ${pkgs//,/ }; do 1064 for pkg in ${pkgs//,/ }; do
996 java-pkg_ensure-dep "${build_only}" "${pkg}" 1065 java-pkg_ensure-dep "${build_only}" "${pkg}"
997 done 1066 done
998 1067
999 if [[ -z "${classpath}" ]]; then 1068 for pkg in ${pkgs//,/ }; do
1000 classpath="${jars}"
1001 else
1002 classpath="${classpath}:${jars}"
1003 fi
1004
1005 # Only record jars that aren't build-only
1006 if [[ -z "${build_only}" ]]; then 1069 if [[ -z "${build_only}" ]]; then
1007 for pkg in ${pkgs//,/ }; do
1008 java-pkg_record-jar_ "${pkg}" 1070 java-pkg_record-jar_ "${pkg}"
1071 else
1072 java-pkg_record-jar_ --build-only "${pkg}"
1073 fi
1009 done 1074 done
1010 fi
1011 1075
1012 echo "${classpath}" 1076 echo "${jars}"
1013} 1077}
1014 1078
1015# ------------------------------------------------------------------------------ 1079# ------------------------------------------------------------------------------
1016# @ebuild-function java-pkg_getjar 1080# @ebuild-function java-pkg_getjar
1017# 1081#
1026# @example-return 1090# @example-return
1027# /usr/share/xerces-2/lib/xml-apis.jar 1091# /usr/share/xerces-2/lib/xml-apis.jar
1028# 1092#
1029# @param $opt 1093# @param $opt
1030# --build-only - makes the jar not added into package.env DEPEND line. 1094# --build-only - makes the jar not added into package.env DEPEND line.
1095# --virtual - Packages passed to this function are to be handled as virtuals
1096# and will not have individual jar dependencies recorded.
1031# @param $1 - package to use 1097# @param $1 - package to use
1032# @param $2 - jar to get 1098# @param $2 - jar to get
1033# ------------------------------------------------------------------------------ 1099# ------------------------------------------------------------------------------
1034java-pkg_getjar() { 1100java-pkg_getjar() {
1035 debug-print-function ${FUNCNAME} $* 1101 debug-print-function ${FUNCNAME} $*
1036 1102
1037 local build_only="" 1103 local build_only=""
1104 local virtual=""
1105 local record_jar=""
1038 1106
1039 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1107 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1040 1108
1041 while [[ "${1}" == --* ]]; do 1109 while [[ "${1}" == --* ]]; do
1042 if [[ "${1}" = "--build-only" ]]; then 1110 if [[ "${1}" = "--build-only" ]]; then
1043 build_only="build" 1111 build_only="build"
1112 elif [[ "${1}" == "--virtual" ]]; then
1113 virtual="true"
1044 else 1114 else
1045 die "java-pkg_jar-from called with unknown parameter: ${1}" 1115 die "java-pkg_getjar called with unknown parameter: ${1}"
1046 fi 1116 fi
1047 shift 1117 shift
1048 done 1118 done
1049 1119
1050 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1120 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1051 1121
1052 local pkg="${1}" target_jar="${2}" jar 1122 local pkg="${1}" target_jar="${2}" jar
1123
1124 if [[ "${EAPI}" == "1" ]]; then
1125 pkg="${pkg//:/-}"
1126 fi
1127
1053 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1128 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1054 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1129 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1055 1130
1056 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1131 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1057 local classpath 1132 local classpath
1058 classpath=$(java-config --classpath=${pkg}) 1133 classpath=$(java-config --classpath=${pkg})
1059 [[ $? != 0 ]] && die ${error_msg} 1134 [[ $? != 0 ]] && die ${error_msg}
1060 1135
1061 java-pkg_ensure-dep "${build_only}" "${pkg}" 1136 java-pkg_ensure-dep "${build_only}" "${pkg}"
1062 1137
1138 # Record the package(Virtual) as a dependency and then set build_only
1139 # So that individual jars are not recorded.
1140 if [[ -n "${virtual}" ]]; then
1141 if [[ -z "${build_only}" ]]; then
1142 java-pkg_record-jar_ "${pkg}"
1143 else
1144 java-pkg_record-jar_ --build-only "${pkg}"
1145 fi
1146 record_jar="true"
1147 fi
1148
1063 for jar in ${classpath//:/ }; do 1149 for jar in ${classpath//:/ }; do
1064 if [[ ! -f "${jar}" ]] ; then 1150 if [[ ! -f "${jar}" ]] ; then
1065 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1151 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1066 fi 1152 fi
1067 1153
1068 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1154 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1069 # Only record jars that aren't build-only 1155 # Only record jars that aren't build-only
1070 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1156 if [[ -z "${record_jar}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}" "${jar}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1161 fi
1162 fi
1071 echo "${jar}" 1163 echo "${jar}"
1072 return 0 1164 return 0
1073 fi 1165 fi
1074 done 1166 done
1075 1167
1111 1203
1112 local pkgs="${1}" 1204 local pkgs="${1}"
1113 local jar="${2}" 1205 local jar="${2}"
1114 1206
1115 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1207 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1208
1209 if [[ "${EAPI}" == "1" ]]; then
1210 pkgs="${pkgs//:/-}"
1211 fi
1116 1212
1117 if [[ -z "${jar}" ]]; then 1213 if [[ -z "${jar}" ]]; then
1118 for pkg in ${pkgs//,/ }; do 1214 for pkg in ${pkgs//,/ }; do
1119 java-pkg_ensure-dep runtime "${pkg}" 1215 java-pkg_ensure-dep runtime "${pkg}"
1120 java-pkg_record-jar_ "${pkg}" 1216 java-pkg_record-jar_ "${pkg}"
1163 local pkgs="${1}" 1259 local pkgs="${1}"
1164 local jar="${2}" 1260 local jar="${2}"
1165 1261
1166 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1262 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1167 1263
1264 if [[ "${EAPI}" == "1" ]]; then
1265 pkgs="${pkgs//:/-}"
1266 fi
1267
1168 if [[ -z "${jar}" ]]; then 1268 if [[ -z "${jar}" ]]; then
1169 for pkg in ${pkgs//,/ }; do 1269 for pkg in ${pkgs//,/ }; do
1170 java-pkg_record-jar_ --optional "${pkg}" 1270 java-pkg_record-jar_ --optional "${pkg}"
1171 done 1271 done
1172 else 1272 else
1201 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1301 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1202 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1302 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1203 1303
1204 java-pkg_do_write_ 1304 java-pkg_do_write_
1205} 1305}
1306
1307# ------------------------------------------------------------------------------
1308# @ebuild-function java-pkg_get-bootclasspath
1309#
1310# Returns classpath of a given bootclasspath-providing package version.
1311#
1312# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1313# of the current JDK
1314# ------------------------------------------------------------------------------
1315
1316java-pkg_get-bootclasspath() {
1317 local version="${1}"
1318
1319 local bcp
1320 case "${version}" in
1321 auto)
1322 bcp="$(java-config -g BOOTCLASSPATH)"
1323 ;;
1324 1.5)
1325 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1326 ;;
1327 *)
1328 eerror "unknown parameter of java-pkg_get-bootclasspath"
1329 die "unknown parameter of java-pkg_get-bootclasspath"
1330 ;;
1331 esac
1332
1333 echo "${bcp}"
1334}
1335
1206 1336
1207# This function reads stdin, and based on that input, figures out how to 1337# This function reads stdin, and based on that input, figures out how to
1208# populate jars from the filesystem. 1338# populate jars from the filesystem.
1209# Need to figure out a good way of making use of this, ie be able to use a 1339# Need to figure out a good way of making use of this, ie be able to use a
1210# string that was built instead of stdin 1340# string that was built instead of stdin
1248# @section-begin helper 1378# @section-begin helper
1249# @section-summary Helper functions 1379# @section-summary Helper functions
1250# 1380#
1251# Various other functions to use from an ebuild 1381# Various other functions to use from an ebuild
1252# ------------------------------------------------------------------------------ 1382# ------------------------------------------------------------------------------
1253
1254# ------------------------------------------------------------------------------
1255# @ebuild-function java-pkg_need
1256#
1257# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1258# Currently supported virtuals are:
1259# javamail
1260# jdbc-stdext
1261# jaf
1262# jdbc-rowset
1263# jms
1264#
1265# @param $1 - Optionally indicate that the dependencies are controlled by
1266# a use flag by specifying '--use' Requires $2.
1267# @param $2 - USE flag which will enable the dependencies.
1268# @param $@ - virtual packages to add depenedencies for
1269# ------------------------------------------------------------------------------
1270# TODO rewrite to parse a line based declaration file instead -- karltk
1271#java-pkg_need() {
1272# debug-print-function ${FUNCNAME} $*
1273# local useflag
1274# if [[ ${1} == "--use" ]]; then
1275# useflag="${2}"
1276# shift 2
1277# fi
1278#
1279# if [[ -z ${1} ]]; then
1280# die "Must specify at least one virtual package."
1281# fi
1282#
1283# local depstr newdepstr
1284#
1285# for virtual in ${@}; do
1286# if has ${virtual} ${JAVA_PKG_VNEED}; then
1287# debug-print "Already registered virtual ${virtual}"
1288# continue
1289# fi
1290# case ${virtual} in
1291# javamail)
1292# debug-print "java-pkg_need: adding javamail dependencies"
1293# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1294# ;;
1295# jdbc-stdext)
1296# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1297# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1298# ;;
1299# jaf)
1300# debug-print "java-pkg_need: adding jaf dependencies"
1301# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1302# ;;
1303# jdbc-rowset)
1304# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1305# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1306# ;;
1307# jms)
1308# debug-print "java-pkg_need: adding jms dependencies"
1309# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1310# ;;
1311# *)
1312# die "Invalid virtual: ${virtual}"
1313# esac
1314#
1315# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1316#
1317# if [[ -n ${useflag} ]]; then
1318# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1319# else
1320# depstr="${depstr} ${newdepstr}"
1321# fi
1322# done
1323#
1324# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1325# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1326#
1327# export DEPEND="${DEPEND} ${depstr}"
1328# export RDEPEND="${RDEPEND} ${depstr}"
1329#}
1330 1383
1331# ------------------------------------------------------------------------------ 1384# ------------------------------------------------------------------------------
1332# @ebuild-function java-pkg_find-normal-jars 1385# @ebuild-function java-pkg_find-normal-jars
1333# 1386#
1334# Find the files with suffix .jar file in the given directory or $WORKDIR 1387# Find the files with suffix .jar file in the given directory or $WORKDIR
1672 dodir /usr/share/ant/${TASKS_DIR} 1725 dodir /usr/share/ant/${TASKS_DIR}
1673 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1726 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1674} 1727}
1675 1728
1676# ------------------------------------------------------------------------------ 1729# ------------------------------------------------------------------------------
1677# @internal-function java-pkg_ant-tasks-from-deps
1678#
1679# Function to determine ANT_TASKS from DEPEND variable for backwards
1680# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1681# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1682# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1683# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1684# be a problem, the worst it can do is activace all tasks when not needed.
1685# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1686# insufficient dependencies, otherwise all available tasks are used for
1687# backwards compatilbility.
1688#
1689# @return "all" or "none"
1690# ------------------------------------------------------------------------------
1691java-pkg_ant-tasks-from-deps() {
1692 local found_ant found_ant_tasks
1693
1694 for dep in ${DEPEND}
1695 do
1696 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1697 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1698 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1699 done
1700
1701 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1702 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1703 echo "all"
1704 else
1705 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1706 # so we deactivate all tasks that may be installed
1707 echo "none"
1708 fi
1709}
1710
1711# ------------------------------------------------------------------------------
1712# @internal-function java-pkg_ant-tasks-depend 1730# @internal-function java-pkg_ant-tasks-depend
1713# 1731#
1714# Translates the WANT_ANT_TASKS variable into valid dependencies. 1732# Translates the WANT_ANT_TASKS variable into valid dependencies.
1715# ------------------------------------------------------------------------------ 1733# ------------------------------------------------------------------------------
1716java-pkg_ant-tasks-depend() { 1734java-pkg_ant-tasks-depend() {
1718 1736
1719 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1737 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1720 local DEP="" 1738 local DEP=""
1721 for i in ${WANT_ANT_TASKS} 1739 for i in ${WANT_ANT_TASKS}
1722 do 1740 do
1723 if [[ ${i} != ant-* ]]; then 1741 if [[ ${i} = ant-* ]]; then
1742 DEP="${DEP}dev-java/${i} "
1743 elif [[ ${i} = */*:* ]]; then
1744 DEP="${DEP}${i} "
1745 else
1724 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1746 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1725 return 1 1747 return 1
1726 fi 1748 fi
1727 DEP="${DEP}dev-java/${i} "
1728 done 1749 done
1729 echo ${DEP} 1750 echo ${DEP}
1730 return 0 1751 return 0
1731 else 1752 else
1732 return 0 1753 return 0
1749# ------------------------------------------------------------------------------ 1770# ------------------------------------------------------------------------------
1750ejunit() { 1771ejunit() {
1751 debug-print-function ${FUNCNAME} $* 1772 debug-print-function ${FUNCNAME} $*
1752 1773
1753 local pkgs 1774 local pkgs
1775 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1754 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1776 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1755 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1777 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1756 done 1778 done
1779 fi
1757 1780
1758 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1781 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1759 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1782 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1760 cp="${2}:${cp}" 1783 cp="${2}:${cp}"
1761 shift 2 1784 shift 2
1771# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1772# @section-end helper 1795# @section-end helper
1773# ------------------------------------------------------------------------------ 1796# ------------------------------------------------------------------------------
1774 1797
1775# ------------------------------------------------------------------------------ 1798# ------------------------------------------------------------------------------
1799# @eclass-src_prepare
1800#
1801# src_prepare Searches for bundled jars
1802# Don't call directly, but via java-pkg-2_src_prepare!
1803# ------------------------------------------------------------------------------
1804
1805java-utils-2_src_prepare() {
1806 [[ ${EBUILD_PHASE} == prepare ]] &&
1807 java-pkg_func-exists java_prepare && java_prepare
1808
1809 # Remember that eant will call this unless called via Portage
1810 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1811 echo "Searching for bundled jars:"
1812 java-pkg_find-normal-jars || echo "None found."
1813 echo "Searching for bundled classes (no output if none found):"
1814 find "${WORKDIR}" -name "*.class"
1815 echo "Search done."
1816 fi
1817 touch "${T}/java-utils-2_src_prepare-run"
1818}
1819
1820# ------------------------------------------------------------------------------
1821# @eclass-pkg_preinst
1822#
1823# pkg_preinst Searches for missing and unneeded dependencies
1824# Don't call directly, but via java-pkg-2_pkg_preinst!
1825# ------------------------------------------------------------------------------
1826
1827java-utils-2_pkg_preinst() {
1828 if is-java-strict; then
1829 if has_version dev-java/java-dep-check; then
1830 [[ -e "${JAVA_PKG_ENV}" ]] || return
1831 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1832 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1833 ewarn "Possibly unneeded dependencies found in package.env:"
1834 for dep in ${output}; do
1835 ewarn "\t${dep}"
1836 done
1837 fi
1838 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1839 ewarn "${output}"
1840 fi
1841 else
1842 eerror "Install dev-java/java-dep-check for dependency checking"
1843 fi
1844 fi
1845}
1846
1847# ------------------------------------------------------------------------------
1776# @section-begin build 1848# @section-begin build
1777# @section-summary Build functions 1849# @section-summary Build functions
1778# 1850#
1779# These are some functions for building a package. In particular, it consists of 1851# These are some functions for building a package. In particular, it consists of
1780# wrappers for javac and ant. 1852# wrappers for javac and ant.
1787# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1859# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1788# variables: 1860# variables:
1789# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1861# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1790# gentoo.classpath property. Be sure to call 1862# gentoo.classpath property. Be sure to call
1791# java-ant_rewrite-classpath in src_unpack. 1863# java-ant_rewrite-classpath in src_unpack.
1864# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1865# for build-time purposes, the dependency is not recorded to
1866# package.env!
1792# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1867# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1793# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1868# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1794# ------------------------------------------------------------------------------ 1869# ------------------------------------------------------------------------------
1795eant() { 1870eant() {
1796 debug-print-function ${FUNCNAME} $* 1871 debug-print-function ${FUNCNAME} $*
1797 1872
1798 if [[ ${EBUILD_PHASE} = compile ]]; then 1873 if [[ ${EBUILD_PHASE} = compile ]]; then
1799 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1874 java-ant-2_src_configure
1800 # finally get rid of the hooks without breaking stuff 1875 java-utils-2_src_prepare
1801
1802 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1803 && java-ant_ignore-system-classes "${S}/build.xml"
1804
1805 if hasq java-ant-2 ${INHERITED}; then
1806 java-ant_bsfix
1807 fi
1808
1809 # eant can be called multiple times
1810 JAVA_PKG_BSFIX="off"
1811
1812 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1813 echo "Searching for bundled jars:"
1814 java-pkg_find-normal-jars || echo "None found."
1815 echo "Searching for bundled classes (no output if none found):"
1816 find "${WORKDIR}" -name "*.class"
1817 echo "Search done."
1818 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1819 fi
1820 fi 1876 fi
1821 1877
1822 if ! hasq java-ant-2 ${INHERITED}; then 1878 if ! hasq java-ant-2 ${INHERITED}; then
1823 local msg="You should inherit java-ant-2 when using eant" 1879 local msg="You should inherit java-ant-2 when using eant"
1824 java-pkg_announce-qa-violation "${msg}" 1880 java-pkg_announce-qa-violation "${msg}"
1825 fi 1881 fi
1826 1882
1827 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1883 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1828 1884
1829 java-pkg_init-compiler_ 1885 java-pkg_init-compiler_
1830 local compiler="${GENTOO_COMPILER}" 1886 local compiler="${GENTOO_COMPILER}"
1831 1887
1832 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1888 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1843 # java-config -p 1899 # java-config -p
1844 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1900 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1845 if [[ -n ${build_compiler_deps} ]]; then 1901 if [[ -n ${build_compiler_deps} ]]; then
1846 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1902 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1847 fi 1903 fi
1848 fi
1849
1850 if is-java-strict; then
1851 einfo "Disabling system classpath for ant"
1852 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1853 fi 1904 fi
1854 1905
1855 for arg in "${@}"; do 1906 for arg in "${@}"; do
1856 if [[ ${arg} = -lib ]]; then 1907 if [[ ${arg} = -lib ]]; then
1857 if is-java-strict; then 1908 if is-java-strict; then
1866 echo "more info." 1917 echo "more info."
1867 fi 1918 fi
1868 fi 1919 fi
1869 done 1920 done
1870 1921
1871 # we use this in src_* so we run ant from / 1922 # parse WANT_ANT_TASKS for atoms
1872 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1923 local want_ant_tasks
1873 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1924 for i in ${WANT_ANT_TASKS}; do
1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1925 if [[ ${i} = */*:* ]]; then
1875 1926 i=${i#*/}
1876 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1927 i=${i%:0}
1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1928 want_ant_tasks+="${i/:/-} "
1878
1879 if is-java-strict; then
1880 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1881 if [[ -z "${ANT_TASKS}" ]]; then
1882 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1883 fi
1884 else 1929 else
1930 want_ant_tasks+="${i} "
1931 fi
1932 done
1933 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1934 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1935
1936 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1937 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1938
1885 # if ant-tasks is not set by ebuild or forced, activate all of them 1939 # if ant-tasks is not set by ebuild or forced, use none
1886 ANT_TASKS="${ANT_TASKS:-all}" 1940 ANT_TASKS="${ANT_TASKS:-none}"
1887 fi
1888 1941
1889 # at this point, ANT_TASKS should be "all", "none" or explicit list 1942 # at this point, ANT_TASKS should be "all", "none" or explicit list
1890 if [[ "${ANT_TASKS}" == "all" ]]; then 1943 if [[ "${ANT_TASKS}" == "all" ]]; then
1891 einfo "Using all available ANT_TASKS" 1944 einfo "Using all available ANT_TASKS"
1892 elif [[ "${ANT_TASKS}" == "none" ]]; then 1945 elif [[ "${ANT_TASKS}" == "none" ]]; then
1893 einfo "Disabling all optional ANT_TASKS" 1946 einfo "Disabling all optional ANT_TASKS"
1894 else 1947 else
1895 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1948 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1896 fi 1949 fi
1897 1950
1898 export ANT_TASKS 1951 export ANT_TASKS
1899 fi
1900 1952
1901 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1953 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1902 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1954 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1903 1955
1904 local gcp="${EANT_GENTOO_CLASSPATH}" 1956 local gcp="${EANT_GENTOO_CLASSPATH}"
1905 local getjarsarg="" 1957 local getjarsarg=""
1906 1958
1907 if [[ ${EBUILD_PHASE} = "test" ]]; then 1959 if [[ ${EBUILD_PHASE} = "test" ]]; then
1908 antflags="${antflags} -DJunit.present=true" 1960 antflags="${antflags} -DJunit.present=true"
1909 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1961 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1910 getjarsarg="--with-dependencies" 1962 getjarsarg="--with-dependencies"
1911 fi 1963 fi
1912 1964
1913 local cp 1965 local cp
1914 1966
1915 for atom in ${gcp}; do 1967 for atom in ${gcp}; do
1916 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1968 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1917 done 1969 done
1918 1970
1971 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1972
1919 if [[ ${cp} ]]; then 1973 if [[ ${cp} ]]; then
1920 # It seems ant does not like single quotes around ${cp} 1974 # It seems ant does not like single quotes around ${cp}
1975 cp=${cp#:}
1976 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1977 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1921 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1978 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1922 fi 1979 fi
1923 1980
1924 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1981 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1925 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1982 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1926 ant ${antflags} "${@}" || die "eant failed" 1983 ant ${antflags} "${@}" || die "eant failed"
2026# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2083# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2027# call it during each of the phases of the merge process. 2084# call it during each of the phases of the merge process.
2028# 2085#
2029# ----------------------------------------------------------------------------- 2086# -----------------------------------------------------------------------------
2030java-pkg_init() { 2087java-pkg_init() {
2088 debug-print-function ${FUNCNAME} $*
2031 unset JAVAC 2089 unset JAVAC
2032 unset JAVA_HOME 2090 unset JAVA_HOME
2091
2092 java-config --help >/dev/null || {
2093 eerror ""
2094 eerror "Can't run java-config --help"
2095 eerror "Have you upgraded python recently but haven't"
2096 eerror "run python-updater yet?"
2097 die "Can't run java-config --help"
2098 }
2033 2099
2034 # People do all kinds of weird things. 2100 # People do all kinds of weird things.
2035 # http://forums.gentoo.org/viewtopic-p-3943166.html 2101 # http://forums.gentoo.org/viewtopic-p-3943166.html
2036 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2102 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2037 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2103 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2043 ewarn "make.conf for example) to silence this warning or" 2109 ewarn "make.conf for example) to silence this warning or"
2044 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2110 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2045 fi 2111 fi
2046 2112
2047 if [[ -z ${accept} ]]; then 2113 if [[ -z ${accept} ]]; then
2114 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2115 # -version output
2048 unset _JAVA_OPTIONS 2116 unset _JAVA_OPTIONS
2049 # phase hooks make this run many times without this 2117 # phase hooks make this run many times without this
2050 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2118 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2051 fi 2119 fi
2052 2120
2060 2128
2061 # TODO we will probably want to set JAVAC and JAVACFLAGS 2129 # TODO we will probably want to set JAVAC and JAVACFLAGS
2062 2130
2063 # Do some QA checks 2131 # Do some QA checks
2064 java-pkg_check-jikes 2132 java-pkg_check-jikes
2133
2134 # Can't use unset here because Portage does not save the unset
2135 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2065 2136
2066 # When users have crazy classpaths some packages can fail to compile. 2137 # When users have crazy classpaths some packages can fail to compile.
2067 # and everything should work with empty CLASSPATH. 2138 # and everything should work with empty CLASSPATH.
2068 # This also helps prevent unexpected dependencies on random things 2139 # This also helps prevent unexpected dependencies on random things
2069 # from the CLASSPATH. 2140 # from the CLASSPATH.
2070 unset CLASSPATH 2141 export CLASSPATH=
2071 2142
2072 # Unset external ANT_ stuff 2143 # Unset external ANT_ stuff
2073 unset ANT_TASKS 2144 export ANT_TASKS=
2074 unset ANT_OPTS 2145 export ANT_OPTS=
2146 export ANT_RESPECT_JAVA_HOME=
2075} 2147}
2076 2148
2077# ------------------------------------------------------------------------------ 2149# ------------------------------------------------------------------------------
2078# @function-internal java-pkg-init-compiler_ 2150# @function-internal java-pkg-init-compiler_
2079# 2151#
2170 done 2242 done
2171 2243
2172 # If it hasn't been defined already, default to javac 2244 # If it hasn't been defined already, default to javac
2173 if [[ -z ${GENTOO_COMPILER} ]]; then 2245 if [[ -z ${GENTOO_COMPILER} ]]; then
2174 if [[ -n ${compilers} ]]; then 2246 if [[ -n ${compilers} ]]; then
2175 einfo "No suitable compiler found: defaulting javac for compilation" 2247 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2176 else 2248 else
2177 # probably don't need to notify users about the default. 2249 # probably don't need to notify users about the default.
2178 :;#einfo "Defaulting to javac for compilation" 2250 :;#einfo "Defaulting to javac for compilation"
2179 fi 2251 fi
2252 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2253 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2254 else
2180 export GENTOO_COMPILER=javac 2255 export GENTOO_COMPILER=javac
2256 fi
2181 else 2257 else
2182 einfo "Using ${GENTOO_COMPILER} for compilation" 2258 einfo "Using ${GENTOO_COMPILER} for compilation"
2183 fi 2259 fi
2184 2260
2185} 2261}
2201 fi 2277 fi
2202 2278
2203 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2279 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2204 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2280 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2205 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2281 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2282 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2283 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2206 2284
2207 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2285 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2208 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2286 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2209 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2287 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2210 2288
2234 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2312 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2235 # Create package.env 2313 # Create package.env
2236 ( 2314 (
2237 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2315 echo "DESCRIPTION=\"${DESCRIPTION}\""
2238 echo "GENERATION=\"2\"" 2316 echo "GENERATION=\"2\""
2317 echo "SLOT=\"${SLOT}\""
2318 echo "CATEGORY=\"${CATEGORY}\""
2319 echo "PVR=\"${PVR}\""
2239 2320
2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2321 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2322 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2323 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2243 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2324 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2244 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2325 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2245 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2326 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2246 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2327 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2247 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2328 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2329 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2330 && echo "BUILD_DEPEND=\"$(cat "${JAVA_PKG_BUILD_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2248 ) > "${JAVA_PKG_ENV}" 2331 ) > "${JAVA_PKG_ENV}"
2249 2332
2250 # register target/source 2333 # register target/source
2251 local target="$(java-pkg_get-target)" 2334 local target="$(java-pkg_get-target)"
2252 local source="$(java-pkg_get-source)" 2335 local source="$(java-pkg_get-source)"
2285# ------------------------------------------------------------------------------ 2368# ------------------------------------------------------------------------------
2286# @internal-function java-pkg_record-jar_ 2369# @internal-function java-pkg_record-jar_
2287# 2370#
2288# Record an (optional) dependency to the package.env 2371# Record an (optional) dependency to the package.env
2289# @param --optional - record dependency as optional 2372# @param --optional - record dependency as optional
2373# @param --build - record dependency as build_only
2290# @param $1 - package to record 2374# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record 2375# @param $2 - (optional) jar of package to record
2292# ------------------------------------------------------------------------------ 2376# ------------------------------------------------------------------------------
2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2377JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2378JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2379JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2295 2380
2296java-pkg_record-jar_() { 2381java-pkg_record-jar_() {
2297 debug-print-function ${FUNCNAME} $* 2382 debug-print-function ${FUNCNAME} $*
2298 2383
2299 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2384 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2300 if [[ "${1}" == "--optional" ]]; then 2385 case "${1}" in
2301 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2386 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2302 shift 2387 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2303 fi 2388 esac
2304 2389
2305 local pkg=${1} jar=${2} append 2390 local pkg=${1} jar=${2} append
2306 if [[ -z "${jar}" ]]; then 2391 if [[ -z "${jar}" ]]; then
2307 append="${pkg}" 2392 append="${pkg}"
2308 else 2393 else
2361# 2446#
2362# @return 0 - function is declared 2447# @return 0 - function is declared
2363# @return 1 - function is undeclared 2448# @return 1 - function is undeclared
2364# ------------------------------------------------------------------------------ 2449# ------------------------------------------------------------------------------
2365java-pkg_func-exists() { 2450java-pkg_func-exists() {
2366 if [[ -n "$(declare -f ${1})" ]]; then 2451 declare -F ${1} > /dev/null
2367 return 0
2368 else
2369 return 1
2370 fi
2371} 2452}
2372 2453
2373# ------------------------------------------------------------------------------ 2454# ------------------------------------------------------------------------------
2374# @internal-function java-pkg_setup-vm 2455# @internal-function java-pkg_setup-vm
2375# 2456#
2459 # If you're forcing the VM, I hope you know what your doing... 2540 # If you're forcing the VM, I hope you know what your doing...
2460 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2541 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2461 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2542 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2462 # if we're allowed to switch the vm... 2543 # if we're allowed to switch the vm...
2463 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2544 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2464 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2545 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2465 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2466 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2467 else
2468 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2546 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2469 fi
2470 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2547 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2471 eerror "Unable to determine VM for building from dependencies:" 2548 eerror "Unable to determine VM for building from dependencies:"
2472 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2549 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2473 echo "VNEED: ${JAVA_PKG_VNEED}"
2474 die "Failed to determine VM for building." 2550 die "Failed to determine VM for building."
2475 else 2551 else
2476 export GENTOO_VM 2552 export GENTOO_VM
2477 fi 2553 fi
2478 # otherwise just make sure the current VM is sufficient 2554 # otherwise just make sure the current VM is sufficient
2551# not. 2627# not.
2552# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2628# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2553# ------------------------------------------------------------------------------ 2629# ------------------------------------------------------------------------------
2554java-pkg_verify-classes() { 2630java-pkg_verify-classes() {
2555 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2631 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2632
2633 local version_verify="/usr/bin/class-version-verify.py"
2634
2635 if [[ ! -x "${version_verify}" ]]; then
2636 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2637 fi
2638
2639 if [[ ! -x "${version_verify}" ]]; then
2640 ewarn "Unable to perform class version checks as"
2641 ewarn "class-version-verify.py is unavailable"
2642 ewarn "Please install dev-java/javatoolkit."
2643 return
2644 fi
2645
2556 local target=$(java-pkg_get-target) 2646 local target=$(java-pkg_get-target)
2557 local result 2647 local result
2558 local log="${T}/class-version-verify.log" 2648 local log="${T}/class-version-verify.log"
2559 if [[ -n "${1}" ]]; then 2649 if [[ -n "${1}" ]]; then
2560 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2650 ${version_verify} -v -t ${target} "${1}" > "${log}"
2561 result=$? 2651 result=$?
2562 else 2652 else
2563 ebegin "Verifying java class versions (target: ${target})" 2653 ebegin "Verifying java class versions (target: ${target})"
2564 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2654 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2565 result=$? 2655 result=$?
2566 eend ${result} 2656 eend ${result}
2567 fi 2657 fi
2568 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2658 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2569 if [[ ${result} != 0 ]]; then 2659 if [[ ${result} != 0 ]]; then
2674is-java-strict() { 2764is-java-strict() {
2675 [[ -n ${JAVA_PKG_STRICT} ]] 2765 [[ -n ${JAVA_PKG_STRICT} ]]
2676 return $? 2766 return $?
2677} 2767}
2678 2768
2769
2679# ------------------------------------------------------------------------------ 2770# ------------------------------------------------------------------------------
2680# @eclass-end 2771# @eclass-end
2681# ------------------------------------------------------------------------------ 2772# ------------------------------------------------------------------------------

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.132

  ViewVC Help
Powered by ViewVC 1.1.20