/[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.73 Revision 1.127
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.73 2007/04/20 14:38:49 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.127 2009/05/19 21:23:32 caster Exp $
10
11 10
12# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
13# @eclass-begin 12# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
15# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
58#WANT_ANT_TASKS 57#WANT_ANT_TASKS
59 58
60# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
61# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
62# 61#
63# 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
64# 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.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 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. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
73# portage, that includes phase hooks. 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.31 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.6 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
76 77
77# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 80# @variable-default yes
80# 81#
195# 196#
196# @example 197# @example
197# java-pkg_doexamples demo 198# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/* 199# java-pkg_doexamples demo/* examples/*
199# 200#
201# @param --subdir - If the examples need a certain directory structure
200# @param $* - list of files to install 202# @param $* - list of files to install
201# ------------------------------------------------------------------------------ 203# ------------------------------------------------------------------------------
202java-pkg_doexamples() { 204java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $* 205 debug-print-function ${FUNCNAME} $*
204 206
205 [[ ${#} -lt 1 ]] && die "At least one argument needed" 207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206 208
207 java-pkg_check-phase install 209 java-pkg_check-phase install
208 210
209 local dest=/usr/share/doc/${PF}/examples 211 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2}
214 dodir ${dest}
215 shift 2
216 fi
217
210 if [[ ${#} = 1 && -d ${1} ]]; then 218 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env 219 ( # dont want to pollute calling env
212 insinto "${dest}" 220 insinto "${dest}"
213 doins -r ${1}/* 221 doins -r ${1}/*
214 ) || die "Installing examples failed" 222 ) || die "Installing examples failed"
283 done 291 done
284 292
285 java-pkg_do_write_ 293 java-pkg_do_write_
286} 294}
287 295
288
289# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
290# @internal-function depend-java-query 297# @internal-function depend-java-query
291# 298#
292# Wrapper for the depend-java-query binary to enable passing USE in env. 299# Wrapper for the depend-java-query binary to enable passing USE in env.
293# Using env variables keeps this eclass working with java-config versions that 300# Using env variables keeps this eclass working with java-config versions that
358 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
359 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
360 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
361 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
362 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
363 die "${jar} does not exist" 371 die "${jar} does not exist"
364 fi 372 fi
365 done 373 done
366 374
367 java-pkg_do_write_ 375 java-pkg_do_write_
422# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
423# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
424java-pkg_doso() { 432java-pkg_doso() {
425 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
426 434
427 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
428 java-pkg_check-phase install 435 java-pkg_check-phase install
429 436
430 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
431 438
432 java-pkg_init_paths_ 439 java-pkg_init_paths_
433 440
434 local lib 441 local lib
435 # for each lib 442 # for each lib
438 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
439 # install if it isn't a symlink 446 # install if it isn't a symlink
440 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
441 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
442 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
443 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
446 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
447 else 454 else
448 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
449 ln -s "$(readlink "${lib}")" \
450 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
451 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
452 fi 457 fi
453 # otherwise die 458 # otherwise die
454 else 459 else
455 die "${lib} does not exist" 460 die "${lib} does not exist"
456 fi 461 fi
472java-pkg_regso() { 477java-pkg_regso() {
473 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
474 479
475 java-pkg_check-phase install 480 java-pkg_check-phase install
476 481
477 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
478 483
479 java-pkg_init_paths_ 484 java-pkg_init_paths_
480 485
481 local lib target_dir 486 local lib target_dir
482 for lib in "$@" ; do 487 for lib in "$@" ; do
549# ------------------------------------------------------------------------------ 554# ------------------------------------------------------------------------------
550# @ebuild-function java-pkg_dojavadoc 555# @ebuild-function java-pkg_dojavadoc
551# 556#
552# Installs javadoc documentation. This should be controlled by the doc use flag. 557# Installs javadoc documentation. This should be controlled by the doc use flag.
553# 558#
559# @param $1: optional --symlink creates to symlink like this for html
560# documentation bundles.
554# @param $1: - The javadoc root directory. 561# @param $2: - The javadoc root directory.
555# 562#
556# @example: 563# @example:
557# java-pkg_dojavadoc docs/api 564# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api
558# 566#
559# ------------------------------------------------------------------------------ 567# ------------------------------------------------------------------------------
560java-pkg_dojavadoc() { 568java-pkg_dojavadoc() {
569 debug-print-function ${FUNCNAME} $*
570
571 # For html documentation bundles that link to Javadoc
572 local symlink
573 if [[ ${1} = --symlink ]]; then
574 symlink=${2}
575 shift 2
576 fi
577
561 local dir="$1" 578 local dir="$1"
579 local dest=/usr/share/doc/${PF}/html
580
581 # QA checks
562 582
563 java-pkg_check-phase install 583 java-pkg_check-phase install
564 584
565 [[ -z "${dir}" ]] && die "Must specify a directory!" 585 [[ -z "${dir}" ]] && die "Must specify a directory!"
566 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 586 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
587 if [[ ! -e "${dir}/index.html" ]]; then
588 local msg="No index.html in javadoc directory"
589 ewarn "${msg}"
590 is-java-strict && die "${msg}"
591 fi
592
593 if [[ -e ${D}/${dest}/api ]]; then
594 eerror "${dest} already exists. Will not overwrite."
595 die "${dest}"
596 fi
597
598 # Renaming to match our directory layout
567 599
568 local dir_to_install="${dir}" 600 local dir_to_install="${dir}"
569 if [[ "$(basename "${dir}")" != "api" ]]; then 601 if [[ "$(basename "${dir}")" != "api" ]]; then
570 dir_to_install="${T}/api" 602 dir_to_install="${T}/api"
571 # TODO use doins 603 # TODO use doins
572 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 604 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
573 fi 605 fi
574 606
607 # Actual installation
608
575 java-pkg_dohtml -r ${dir_to_install} 609 java-pkg_dohtml -r "${dir_to_install}"
610
611 # Let's make a symlink to the directory we have everything else under
612 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
613
614 if [[ ${symlink} ]]; then
615 debug-print "symlinking ${dest}/{api,${symlink}}"
616 dosym ${dest}/{api,${symlink}} || die
617 fi
576} 618}
577 619
578# ------------------------------------------------------------------------------ 620# ------------------------------------------------------------------------------
579# @ebuild-function java-pkg_dosrc 621# @ebuild-function java-pkg_dosrc
580# 622#
603 645
604 [[ ${#} -lt 1 ]] && die "At least one argument needed" 646 [[ ${#} -lt 1 ]] && die "At least one argument needed"
605 647
606 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 648 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
607 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 649 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
608 if is-java-strict; then 650 java-pkg_announce-qa-violation ${msg}
609 eerror "${msg}"
610 die "${msg}"
611 else
612 echo "${msg}"
613 echo "Please report this to http://bugs.gentoo.org."
614 fi
615 fi 651 fi
616 652
617 java-pkg_init_paths_ 653 java-pkg_init_paths_
618 654
619 local zip_name="${PN}-src.zip" 655 local zip_name="${PN}-src.zip"
819# @param $opt 855# @param $opt
820# --build-only - makes the jar(s) not added into package.env DEPEND line. 856# --build-only - makes the jar(s) not added into package.env DEPEND line.
821# (assumed automatically when called inside src_test) 857# (assumed automatically when called inside src_test)
822# --with-dependencies - get jars also from requested package's dependencies 858# --with-dependencies - get jars also from requested package's dependencies
823# transitively. 859# transitively.
860# --virtual - Packages passed to this function are to be handled as virtuals
861# and will not have individual jar dependencies recorded.
824# --into $dir - symlink jar(s) into $dir (must exist) instead of . 862# --into $dir - symlink jar(s) into $dir (must exist) instead of .
825# @param $1 - Package to get jars from. 863# @param $1 - Package to get jars from, or comma-separated list of packages in
864# case other parameters are not used.
826# @param $2 - jar from package. If not specified, all jars will be used. 865# @param $2 - jar from package. If not specified, all jars will be used.
827# @param $3 - When a single jar is specified, destination filename of the 866# @param $3 - When a single jar is specified, destination filename of the
828# symlink. Defaults to the name of the jar. 867# symlink. Defaults to the name of the jar.
829# ------------------------------------------------------------------------------ 868# ------------------------------------------------------------------------------
830# TODO could probably be cleaned up a little 869# TODO could probably be cleaned up a little
832 debug-print-function ${FUNCNAME} $* 871 debug-print-function ${FUNCNAME} $*
833 872
834 local build_only="" 873 local build_only=""
835 local destdir="." 874 local destdir="."
836 local deep="" 875 local deep=""
876 local virtual=""
837 877
838 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 878 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
839 879
840 while [[ "${1}" == --* ]]; do 880 while [[ "${1}" == --* ]]; do
841 if [[ "${1}" = "--build-only" ]]; then 881 if [[ "${1}" = "--build-only" ]]; then
842 build_only="true" 882 build_only="build"
843 elif [[ "${1}" = "--with-dependencies" ]]; then 883 elif [[ "${1}" = "--with-dependencies" ]]; then
844 deep="--with-dependencies" 884 deep="--with-dependencies"
885 elif [[ "${1}" = "--virtual" ]]; then
886 virtual="true"
845 elif [[ "${1}" = "--into" ]]; then 887 elif [[ "${1}" = "--into" ]]; then
846 destdir="${2}" 888 destdir="${2}"
847 shift 889 shift
848 else 890 else
849 die "java-pkg_jar-from called with unknown parameter: ${1}" 891 die "java-pkg_jar-from called with unknown parameter: ${1}"
853 895
854 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 896 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
855 897
856 [[ -z ${target_pkg} ]] && die "Must specify a package" 898 [[ -z ${target_pkg} ]] && die "Must specify a package"
857 899
900 if [[ "${EAPI}" == "1" ]]; then
901 target_pkg="${target_pkg//:/-}"
902 fi
903
858 # default destjar to the target jar 904 # default destjar to the target jar
859 [[ -z "${destjar}" ]] && destjar="${target_jar}" 905 [[ -z "${destjar}" ]] && destjar="${target_jar}"
860 906
861 local error_msg="There was a problem getting the classpath for ${target_pkg}." 907 local error_msg="There was a problem getting the classpath for ${target_pkg}."
862 local classpath 908 local classpath
863 classpath="$(java-config ${deep} --classpath=${target_pkg})" 909 classpath="$(java-config ${deep} --classpath=${target_pkg})"
864 [[ $? != 0 ]] && die ${error_msg} 910 [[ $? != 0 ]] && die ${error_msg}
865 911
912 # When we have commas this functions is called to bring jars from multiple
913 # packages. This affects recording of dependencencies performed later
914 # which expects one package only, so we do it here.
915 if [[ ${target_pkg} = *,* ]]; then
916 for pkg in ${target_pkg//,/ }; do
917 java-pkg_ensure-dep "${build_only}" "${pkg}"
918 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
919 done
920 # setting this disables further record-jar_ calls later
921 build_only="build"
922 else
866 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 923 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
924 fi
925
926 # Record the entire virtual as a dependency so that
927 # no jars are missed.
928 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
929 java-pkg_record-jar_ "${target_pkg}"
930 # setting this disables further record-jars_ calls later
931 build_only="build"
932 fi
867 933
868 pushd ${destdir} > /dev/null \ 934 pushd ${destdir} > /dev/null \
869 || die "failed to change directory to ${destdir}" 935 || die "failed to change directory to ${destdir}"
870
871 # When we have commas this functions is called to bring jars from multiple
872 # packages. This affects recording of dependencencies because that syntax uses :
873 # if we don't change them to : gjl and java-config -d -p break
874 if [[ ${target_pkg} = *,* ]]; then
875 build_only="true"
876 java-pkg_record-jar_ ${target_pkg//,/:}
877 fi
878 936
879 local jar 937 local jar
880 for jar in ${classpath//:/ }; do 938 for jar in ${classpath//:/ }; do
881 local jar_name=$(basename "${jar}") 939 local jar_name=$(basename "${jar}")
882 if [[ ! -f "${jar}" ]] ; then 940 if [[ ! -f "${jar}" ]] ; then
945 debug-print-function ${FUNCNAME} $* 1003 debug-print-function ${FUNCNAME} $*
946 1004
947 local build_only="" 1005 local build_only=""
948 local deep="" 1006 local deep=""
949 1007
950 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1008 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
951 1009
952 while [[ "${1}" == --* ]]; do 1010 while [[ "${1}" == --* ]]; do
953 if [[ "${1}" = "--build-only" ]]; then 1011 if [[ "${1}" = "--build-only" ]]; then
954 build_only="true" 1012 build_only="build"
955 elif [[ "${1}" = "--with-dependencies" ]]; then 1013 elif [[ "${1}" = "--with-dependencies" ]]; then
956 deep="--with-dependencies" 1014 deep="--with-dependencies"
957 else 1015 else
958 die "java-pkg_jar-from called with unknown parameter: ${1}" 1016 die "java-pkg_jar-from called with unknown parameter: ${1}"
959 fi 1017 fi
961 done 1019 done
962 1020
963 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1021 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
964 1022
965 1023
966 local classpath pkgs="${1}" 1024 local pkgs="${1}"
1025
1026 if [[ "${EAPI}" == "1" ]]; then
1027 pkgs="${pkgs//:/-}"
1028 fi
1029
967 jars="$(java-config ${deep} --classpath=${pkgs})" 1030 jars="$(java-config ${deep} --classpath=${pkgs})"
968 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1031 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
969 debug-print "${pkgs}:${jars}" 1032 debug-print "${pkgs}:${jars}"
970 1033
971 for pkg in ${pkgs//,/ }; do 1034 for pkg in ${pkgs//,/ }; do
972 java-pkg_ensure-dep "${build_only}" "${pkg}" 1035 java-pkg_ensure-dep "${build_only}" "${pkg}"
973 done 1036 done
974 1037
975 if [[ -z "${classpath}" ]]; then
976 classpath="${jars}"
977 else
978 classpath="${classpath}:${jars}"
979 fi
980
981 # Only record jars that aren't build-only 1038 # Only record jars that aren't build-only
982 if [[ -z "${build_only}" ]]; then 1039 if [[ -z "${build_only}" ]]; then
983 oldifs="${IFS}"
984 IFS=","
985 for pkg in ${pkgs}; do 1040 for pkg in ${pkgs//,/ }; do
986 java-pkg_record-jar_ "${pkg}" 1041 java-pkg_record-jar_ "${pkg}"
987 done 1042 done
988 IFS="${oldifs}"
989 fi 1043 fi
990 1044
991 echo "${classpath}" 1045 echo "${jars}"
992} 1046}
993 1047
994# ------------------------------------------------------------------------------ 1048# ------------------------------------------------------------------------------
995# @ebuild-function java-pkg_getjar 1049# @ebuild-function java-pkg_getjar
996# 1050#
1005# @example-return 1059# @example-return
1006# /usr/share/xerces-2/lib/xml-apis.jar 1060# /usr/share/xerces-2/lib/xml-apis.jar
1007# 1061#
1008# @param $opt 1062# @param $opt
1009# --build-only - makes the jar not added into package.env DEPEND line. 1063# --build-only - makes the jar not added into package.env DEPEND line.
1064# --virtual - Packages passed to this function are to be handled as virtuals
1065# and will not have individual jar dependencies recorded.
1010# @param $1 - package to use 1066# @param $1 - package to use
1011# @param $2 - jar to get 1067# @param $2 - jar to get
1012# ------------------------------------------------------------------------------ 1068# ------------------------------------------------------------------------------
1013java-pkg_getjar() { 1069java-pkg_getjar() {
1014 debug-print-function ${FUNCNAME} $* 1070 debug-print-function ${FUNCNAME} $*
1015 1071
1016 local build_only="" 1072 local build_only=""
1073 local virtual=""
1017 1074
1018 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1019 1076
1020 while [[ "${1}" == --* ]]; do 1077 while [[ "${1}" == --* ]]; do
1021 if [[ "${1}" = "--build-only" ]]; then 1078 if [[ "${1}" = "--build-only" ]]; then
1022 build_only="true" 1079 build_only="build"
1080 elif [[ "${1}" == "--virtual" ]]; then
1081 virtual="true"
1023 else 1082 else
1024 die "java-pkg_jar-from called with unknown parameter: ${1}" 1083 die "java-pkg_getjar called with unknown parameter: ${1}"
1025 fi 1084 fi
1026 shift 1085 shift
1027 done 1086 done
1028 1087
1029 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1088 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1030 1089
1031 local pkg="${1}" target_jar="${2}" jar 1090 local pkg="${1}" target_jar="${2}" jar
1091
1092 if [[ "${EAPI}" == "1" ]]; then
1093 pkg="${pkg//:/-}"
1094 fi
1095
1032 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1033 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1097 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1034 1098
1035 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1099 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1036 local classpath 1100 local classpath
1037 classpath=$(java-config --classpath=${pkg}) 1101 classpath=$(java-config --classpath=${pkg})
1038 [[ $? != 0 ]] && die ${error_msg} 1102 [[ $? != 0 ]] && die ${error_msg}
1039 1103
1040 java-pkg_ensure-dep "${build_only}" "${pkg}" 1104 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105
1106 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then
1109 java-pkg_record-jar_ "${pkg}"
1110 build_only="true"
1111 fi
1041 1112
1042 for jar in ${classpath//:/ }; do 1113 for jar in ${classpath//:/ }; do
1043 if [[ ! -f "${jar}" ]] ; then 1114 if [[ ! -f "${jar}" ]] ; then
1044 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1045 fi 1116 fi
1052 fi 1123 fi
1053 done 1124 done
1054 1125
1055 die "Could not find ${target_jar} in ${pkg}" 1126 die "Could not find ${target_jar} in ${pkg}"
1056 return 1 1127 return 1
1128}
1129
1130# ------------------------------------------------------------------------------
1131# @ebuild-function java-pkg_register-dependency
1132#
1133# Registers runtime dependency on a package, list of packages, or a single jar
1134# from a package, into package.env DEPEND line. Can only be called in
1135# src_install phase.
1136# Intended for binary packages where you don't need to symlink the jars or get
1137# their classpath during build. As such, the dependencies only need to be
1138# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1139#
1140# @param $1 - comma-separated list of packages, or a single package
1141# @param $2 - if param $1 is a single package, optionally specify the jar
1142# to depend on
1143#
1144# Example: Record the dependency on whole xerces-2 and xalan,
1145# java-pkg_register-dependency xerces-2,xalan
1146# Example: Record the dependency on ant.jar from ant-core
1147# java-pkg_register-dependency ant-core ant.jar
1148#
1149# Note: Passing both list of packages as the first parameter AND specifying the
1150# jar as the second is not allowed and will cause the function to die. We assume
1151# that there's more chance one passes such combination as a mistake, than that
1152# there are more packages providing identically named jar without class
1153# collisions.
1154# ------------------------------------------------------------------------------
1155java-pkg_register-dependency() {
1156 debug-print-function ${FUNCNAME} $*
1157
1158 java-pkg_check-phase install
1159
1160 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1161
1162 local pkgs="${1}"
1163 local jar="${2}"
1164
1165 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1166
1167 if [[ "${EAPI}" == "1" ]]; then
1168 pkgs="${pkgs//:/-}"
1169 fi
1170
1171 if [[ -z "${jar}" ]]; then
1172 for pkg in ${pkgs//,/ }; do
1173 java-pkg_ensure-dep runtime "${pkg}"
1174 java-pkg_record-jar_ "${pkg}"
1175 done
1176 else
1177 [[ ${pkgs} == *,* ]] && \
1178 die "${FUNCNAME} called with both package list and jar name"
1179 java-pkg_ensure-dep runtime "${pkgs}"
1180 java-pkg_record-jar_ "${pkgs}" "${jar}"
1181 fi
1182
1183 java-pkg_do_write_
1184}
1185
1186# ------------------------------------------------------------------------------
1187# @ebuild-function java-pkg_register-optional-dependency
1188#
1189# Registers optional runtime dependency on a package, list of packages, or a
1190# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1191# called in src_install phase.
1192# Intended for packages that can use other packages when those are in classpath.
1193# Will be put on classpath by launcher if they are installed. Typical case is
1194# JDBC implementations for various databases. It's better than having USE flag
1195# for each implementation triggering hard dependency.
1196#
1197# @param $1 - comma-separated list of packages, or a single package
1198# @param $2 - if param $1 is a single package, optionally specify the jar
1199# to depend on
1200#
1201# Example: Record the optional dependency on some jdbc providers
1202# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1203#
1204# Note: Passing both list of packages as the first parameter AND specifying the
1205# jar as the second is not allowed and will cause the function to die. We assume
1206# that there's more chance one passes such combination as a mistake, than that
1207# there are more packages providing identically named jar without class
1208# collisions.
1209# ------------------------------------------------------------------------------
1210java-pkg_register-optional-dependency() {
1211 debug-print-function ${FUNCNAME} $*
1212
1213 java-pkg_check-phase install
1214
1215 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1216
1217 local pkgs="${1}"
1218 local jar="${2}"
1219
1220 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1221
1222 if [[ "${EAPI}" == "1" ]]; then
1223 pkgs="${pkgs//:/-}"
1224 fi
1225
1226 if [[ -z "${jar}" ]]; then
1227 for pkg in ${pkgs//,/ }; do
1228 java-pkg_record-jar_ --optional "${pkg}"
1229 done
1230 else
1231 [[ ${pkgs} == *,* ]] && \
1232 die "${FUNCNAME} called with both package list and jar name"
1233 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1234 fi
1235
1236 java-pkg_do_write_
1237}
1238
1239# ------------------------------------------------------------------------------
1240# @ebuild-function java-pkg_register-environment-variable
1241#
1242# Register an arbitrary environment variable into package.env. The gjl launcher
1243# for this package or any package depending on this will export it into
1244# environement before executing java command.
1245# Must only be called in src_install phase.
1246#
1247# @param $1 - variable name
1248# @param $2 - variable value
1249# ------------------------------------------------------------------------------
1250JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1251JAVA_PKG_EXTRA_ENV_VARS=""
1252java-pkg_register-environment-variable() {
1253 debug-print-function ${FUNCNAME} $*
1254
1255 java-pkg_check-phase install
1256
1257 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1258
1259 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1260 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1261
1262 java-pkg_do_write_
1057} 1263}
1058 1264
1059# This function reads stdin, and based on that input, figures out how to 1265# This function reads stdin, and based on that input, figures out how to
1060# populate jars from the filesystem. 1266# populate jars from the filesystem.
1061# Need to figure out a good way of making use of this, ie be able to use a 1267# Need to figure out a good way of making use of this, ie be able to use a
1524 dodir /usr/share/ant/${TASKS_DIR} 1730 dodir /usr/share/ant/${TASKS_DIR}
1525 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1731 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1526} 1732}
1527 1733
1528# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1529# @internal-function java-pkg_ant-tasks-from-deps
1530#
1531# Function to determine ANT_TASKS from DEPEND variable for backwards
1532# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1533# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1534# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1535# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1536# be a problem, the worst it can do is activace all tasks when not needed.
1537# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1538# insufficient dependencies, otherwise all available tasks are used for
1539# backwards compatilbility.
1540#
1541# @return "all" or "none"
1542# ------------------------------------------------------------------------------
1543java-pkg_ant-tasks-from-deps() {
1544 local found_ant found_ant_tasks
1545
1546 for dep in ${DEPEND}
1547 do
1548 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1549 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1550 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1551 done
1552
1553 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1554 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1555 echo "all"
1556 else
1557 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1558 # so we deactivate all tasks that may be installed
1559 echo "none"
1560 fi
1561}
1562
1563# ------------------------------------------------------------------------------
1564# @internal-function java-pkg_ant-tasks-depend 1735# @internal-function java-pkg_ant-tasks-depend
1565# 1736#
1566# Translates the WANT_ANT_TASKS variable into valid dependencies. 1737# Translates the WANT_ANT_TASKS variable into valid dependencies.
1567# ------------------------------------------------------------------------------ 1738# ------------------------------------------------------------------------------
1568java-pkg_ant-tasks-depend() { 1739java-pkg_ant-tasks-depend() {
1570 1741
1571 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1572 local DEP="" 1743 local DEP=""
1573 for i in ${WANT_ANT_TASKS} 1744 for i in ${WANT_ANT_TASKS}
1574 do 1745 do
1575 if [[ ${i} != ant-* ]]; then 1746 if [[ ${i} = ant-* ]]; then
1747 DEP="${DEP}dev-java/${i} "
1748 elif [[ ${i} = */*:* ]]; then
1749 DEP="${DEP}${i} "
1750 else
1576 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1751 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1577 return 1 1752 return 1
1578 fi 1753 fi
1579 DEP="${DEP}dev-java/${i} "
1580 done 1754 done
1581 echo ${DEP} 1755 echo ${DEP}
1582 return 0 1756 return 0
1583 else 1757 else
1584 return 0 1758 return 0
1585 fi 1759 fi
1586} 1760}
1587 1761
1588# ------------------------------------------------------------------------------ 1762# ------------------------------------------------------------------------------
1763# @ebuild-function ejunit
1764#
1765# Junit wrapper function. Makes it easier to run the tests and checks for
1766# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1767#
1768# Examples:
1769# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1770# ejunit org.blinkenlights.jid3.test.AllTests
1771#
1772# @param $1 - -cp or -classpath
1773# @param $2 - classpath; junit and recorded dependencies get appended
1774# @param $@ - the rest of the parameters are passed to java
1775# ------------------------------------------------------------------------------
1776ejunit() {
1777 debug-print-function ${FUNCNAME} $*
1778
1779 local pkgs
1780 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1781 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1782 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1783 done
1784 fi
1785
1786 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1787 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1788 cp="${2}:${cp}"
1789 shift 2
1790 else
1791 cp=".:${cp}"
1792 fi
1793
1794 local runner=junit.textui.TestRunner
1795 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1796 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1797}
1798
1799# ------------------------------------------------------------------------------
1589# @section-end helper 1800# @section-end helper
1590# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1802
1803# ------------------------------------------------------------------------------
1804# @eclass-src_prepare
1805#
1806# src_prepare Searches for bundled jars
1807# Don't call directly, but via java-pkg-2_src_prepare!
1808# ------------------------------------------------------------------------------
1809
1810java-utils-2_src_prepare() {
1811 [[ ${EBUILD_PHASE} == prepare ]] &&
1812 java-pkg_func-exists java_prepare && java_prepare
1813
1814 # Remember that eant will call this unless called via Portage
1815 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1816 echo "Searching for bundled jars:"
1817 java-pkg_find-normal-jars || echo "None found."
1818 echo "Searching for bundled classes (no output if none found):"
1819 find "${WORKDIR}" -name "*.class"
1820 echo "Search done."
1821 fi
1822 touch "${T}/java-utils-2_src_prepare-run"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @eclass-pkg_preinst
1827#
1828# pkg_preinst Searches for missing and unneeded dependencies
1829# Don't call directly, but via java-pkg-2_pkg_preinst!
1830# ------------------------------------------------------------------------------
1831
1832java-utils-2_pkg_preinst() {
1833 if is-java-strict; then
1834 if has_version dev-java/java-dep-check; then
1835 [[ -e "${JAVA_PKG_ENV}" ]] || return
1836 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1837 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1838 ewarn "Possibly unneeded dependencies found in package.env:"
1839 for dep in ${output}; do
1840 ewarn "\t${dep}"
1841 done
1842 fi
1843 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1844 ewarn "${output}"
1845 fi
1846 else
1847 eerror "Install dev-java/java-dep-check for dependency checking"
1848 fi
1849 fi
1850}
1591 1851
1592# ------------------------------------------------------------------------------ 1852# ------------------------------------------------------------------------------
1593# @section-begin build 1853# @section-begin build
1594# @section-summary Build functions 1854# @section-summary Build functions
1595# 1855#
1604# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1864# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1605# variables: 1865# variables:
1606# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1866# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1607# gentoo.classpath property. Be sure to call 1867# gentoo.classpath property. Be sure to call
1608# java-ant_rewrite-classpath in src_unpack. 1868# java-ant_rewrite-classpath in src_unpack.
1869# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1870# for build-time purposes, the dependency is not recorded to
1871# package.env!
1872# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1609# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1610# ------------------------------------------------------------------------------ 1874# ------------------------------------------------------------------------------
1611eant() { 1875eant() {
1612 debug-print-function ${FUNCNAME} $* 1876 debug-print-function ${FUNCNAME} $*
1613 1877
1614 # FIXME get this working 1878 if [[ ${EBUILD_PHASE} = compile ]]; then
1615# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1879 java-ant-2_src_configure
1616# java-pkg_announce-qa-violation \ 1880 java-utils-2_src_prepare
1617# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1618# fi 1881 fi
1619 1882
1620 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1883 if ! hasq java-ant-2 ${INHERITED}; then
1621 local msg="You should inherit java-ant-2 when using eant" 1884 local msg="You should inherit java-ant-2 when using eant"
1622 java-pkg_announce-qa-violation ${msg} 1885 java-pkg_announce-qa-violation "${msg}"
1623 die ${msg}
1624 fi 1886 fi
1625 1887
1626 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1888 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1627 1889
1628 java-pkg_init-compiler_ 1890 java-pkg_init-compiler_
1629 local compiler="${GENTOO_COMPILER}" 1891 local compiler="${GENTOO_COMPILER}"
1630 1892
1631 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1893 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1632
1633 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1894 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1634 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1895 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1635 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1896 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1636 fi 1897 fi
1637 1898
1643 # java-config -p 1904 # java-config -p
1644 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1905 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1645 if [[ -n ${build_compiler_deps} ]]; then 1906 if [[ -n ${build_compiler_deps} ]]; then
1646 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1907 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1647 fi 1908 fi
1648 fi
1649
1650 if is-java-strict; then
1651 einfo "Disabling system classpath for ant"
1652 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1653 fi 1909 fi
1654 1910
1655 for arg in "${@}"; do 1911 for arg in "${@}"; do
1656 if [[ ${arg} = -lib ]]; then 1912 if [[ ${arg} = -lib ]]; then
1657 if is-java-strict; then 1913 if is-java-strict; then
1666 echo "more info." 1922 echo "more info."
1667 fi 1923 fi
1668 fi 1924 fi
1669 done 1925 done
1670 1926
1671 if has_version ">=dev-java/ant-core-1.7.0"; then 1927 # parse WANT_ANT_TASKS for atoms
1672 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1928 local want_ant_tasks
1673 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1929 for i in ${WANT_ANT_TASKS}; do
1674 1930 if [[ ${i} = */*:* ]]; then
1675 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1931 i=${i#*/}
1676 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1932 i=${i%:0}
1677 1933 want_ant_tasks+="${i/:/-} "
1678 if is-java-strict; then
1679 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1680 if [[ -z "${ANT_TASKS}" ]]; then
1681 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1682 fi
1683 else 1934 else
1935 want_ant_tasks+="${i} "
1936 fi
1937 done
1938 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1939 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1940
1941 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1942 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1943
1684 # if ant-tasks is not set by ebuild or forced, activate all of them 1944 # if ant-tasks is not set by ebuild or forced, use none
1685 ANT_TASKS="${ANT_TASKS:-all}" 1945 ANT_TASKS="${ANT_TASKS:-none}"
1686 fi
1687 1946
1688 # at this point, ANT_TASKS should be "all", "none" or explicit list 1947 # at this point, ANT_TASKS should be "all", "none" or explicit list
1689 if [[ "${ANT_TASKS}" == "all" ]]; then 1948 if [[ "${ANT_TASKS}" == "all" ]]; then
1690 einfo "Using all available ANT_TASKS" 1949 einfo "Using all available ANT_TASKS"
1691 elif [[ "${ANT_TASKS}" == "none" ]]; then 1950 elif [[ "${ANT_TASKS}" == "none" ]]; then
1692 einfo "Disabling all optional ANT_TASKS" 1951 einfo "Disabling all optional ANT_TASKS"
1693 else 1952 else
1694 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1953 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1695 fi 1954 fi
1696 1955
1697 export ANT_TASKS 1956 export ANT_TASKS
1698 fi
1699 1957
1700 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1958 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1701 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1959 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1702 1960
1703 local gcp="${EANT_GENTOO_CLASSPATH}" 1961 local gcp="${EANT_GENTOO_CLASSPATH}"
1962 local getjarsarg=""
1704 1963
1705 if [[ ${EBUILD_PHASE} = "test" ]]; then 1964 if [[ ${EBUILD_PHASE} = "test" ]]; then
1706 antflags="${antflags} -DJunit.present=true" 1965 antflags="${antflags} -DJunit.present=true"
1707 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1967 getjarsarg="--with-dependencies"
1708 fi 1968 fi
1709 1969
1710 local cp 1970 local cp
1711 1971
1712 for atom in ${gcp}; do 1972 for atom in ${gcp}; do
1713 cp="${cp}:$(java-pkg_getjars ${atom})" 1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1714 done 1974 done
1975
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1715 1977
1716 if [[ ${cp} ]]; then 1978 if [[ ${cp} ]]; then
1717 # It seems ant does not like single quotes around ${cp} 1979 # It seems ant does not like single quotes around ${cp}
1980 cp=${cp#:}
1981 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1982 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1718 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1719 fi 1984 fi
1720 1985
1721 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1722 debug-print "Calling ant: ${antflags} ${@}" 1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1723 ant ${antflags} "${@}" || die "eant failed" 1988 ant ${antflags} "${@}" || die "eant failed"
1724
1725} 1989}
1726 1990
1727# ------------------------------------------------------------------------------ 1991# ------------------------------------------------------------------------------
1728# @ebuild-function ejavac 1992# @ebuild-function ejavac
1729# 1993#
1824# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2088# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1825# call it during each of the phases of the merge process. 2089# call it during each of the phases of the merge process.
1826# 2090#
1827# ----------------------------------------------------------------------------- 2091# -----------------------------------------------------------------------------
1828java-pkg_init() { 2092java-pkg_init() {
2093 debug-print-function ${FUNCNAME} $*
1829 unset JAVAC 2094 unset JAVAC
1830 unset JAVA_HOME 2095 unset JAVA_HOME
2096
2097 java-config --help >/dev/null || {
2098 eerror ""
2099 eerror "Can't run java-config --help"
2100 eerror "Have you upgraded python recently but haven't"
2101 eerror "run python-updater yet?"
2102 die "Can't run java-config --help"
2103 }
1831 2104
1832 # People do all kinds of weird things. 2105 # People do all kinds of weird things.
1833 # http://forums.gentoo.org/viewtopic-p-3943166.html 2106 # http://forums.gentoo.org/viewtopic-p-3943166.html
1834 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2107 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
1835 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2108 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
1841 ewarn "make.conf for example) to silence this warning or" 2114 ewarn "make.conf for example) to silence this warning or"
1842 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2115 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1843 fi 2116 fi
1844 2117
1845 if [[ -z ${accept} ]]; then 2118 if [[ -z ${accept} ]]; then
2119 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2120 # -version output
1846 unset _JAVA_OPTIONS 2121 unset _JAVA_OPTIONS
1847 # phase hooks make this run many times without this 2122 # phase hooks make this run many times without this
1848 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2123 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1849 fi 2124 fi
1850 2125
2126 if java-pkg_func-exists ant_src_unpack; then
2127 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2128 fi
2129
1851 java-pkg_init_paths_ 2130 java-pkg_init_paths_
1852 java-pkg_switch-vm 2131 java-pkg_switch-vm
1853 PATH=${JAVA_HOME}/bin:${PATH} 2132 PATH=${JAVA_HOME}/bin:${PATH}
1854 2133
1855 # TODO we will probably want to set JAVAC and JAVACFLAGS 2134 # TODO we will probably want to set JAVAC and JAVACFLAGS
1856 2135
1857 # Do some QA checks 2136 # Do some QA checks
1858 java-pkg_check-jikes 2137 java-pkg_check-jikes
2138
2139 # Can't use unset here because Portage does not save the unset
2140 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
1859 2141
1860 # When users have crazy classpaths some packages can fail to compile. 2142 # When users have crazy classpaths some packages can fail to compile.
1861 # and everything should work with empty CLASSPATH. 2143 # and everything should work with empty CLASSPATH.
1862 # This also helps prevent unexpected dependencies on random things 2144 # This also helps prevent unexpected dependencies on random things
1863 # from the CLASSPATH. 2145 # from the CLASSPATH.
1864 unset CLASSPATH 2146 export CLASSPATH=
1865 2147
1866 # Unset external ANT_ stuff 2148 # Unset external ANT_ stuff
1867 unset ANT_TASKS 2149 export ANT_TASKS=
1868 unset ANT_OPTS 2150 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME=
1869} 2152}
1870 2153
1871# ------------------------------------------------------------------------------ 2154# ------------------------------------------------------------------------------
1872# @function-internal java-pkg-init-compiler_ 2155# @function-internal java-pkg-init-compiler_
1873# 2156#
1964 done 2247 done
1965 2248
1966 # If it hasn't been defined already, default to javac 2249 # If it hasn't been defined already, default to javac
1967 if [[ -z ${GENTOO_COMPILER} ]]; then 2250 if [[ -z ${GENTOO_COMPILER} ]]; then
1968 if [[ -n ${compilers} ]]; then 2251 if [[ -n ${compilers} ]]; then
1969 einfo "No suitable compiler found: defaulting javac for compilation" 2252 einfo "No suitable compiler found: defaulting to JDK default for compilation"
1970 else 2253 else
1971 # probably don't need to notify users about the default. 2254 # probably don't need to notify users about the default.
1972 :;#einfo "Defaulting to javac for compilation" 2255 :;#einfo "Defaulting to javac for compilation"
1973 fi 2256 fi
2257 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2258 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2259 else
1974 export GENTOO_COMPILER=javac 2260 export GENTOO_COMPILER=javac
2261 fi
1975 else 2262 else
1976 einfo "Using ${GENTOO_COMPILER} for compilation" 2263 einfo "Using ${GENTOO_COMPILER} for compilation"
1977 fi 2264 fi
1978 2265
1979} 2266}
1995 fi 2282 fi
1996 2283
1997 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2284 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1998 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2285 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1999 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2286 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2287 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2288 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2000 2289
2001 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2290 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2002 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2291 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2003 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2292 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2004 2293
2017# Writes the package.env out to disk. 2306# Writes the package.env out to disk.
2018# 2307#
2019# ------------------------------------------------------------------------------ 2308# ------------------------------------------------------------------------------
2020# TODO change to do-write, to match everything else 2309# TODO change to do-write, to match everything else
2021java-pkg_do_write_() { 2310java-pkg_do_write_() {
2311 debug-print-function ${FUNCNAME} $*
2022 java-pkg_init_paths_ 2312 java-pkg_init_paths_
2023 # Create directory for package.env 2313 # Create directory for package.env
2024 dodir "${JAVA_PKG_SHAREPATH}" 2314 dodir "${JAVA_PKG_SHAREPATH}"
2025 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2315 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2316 "${JAVA_PKG_DEPEND_FILE}" || -f \
2317 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2026 # Create package.env 2318 # Create package.env
2027 ( 2319 (
2028 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2320 echo "DESCRIPTION=\"${DESCRIPTION}\""
2029 echo "GENERATION=\"2\"" 2321 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\""
2030 2323
2031 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2032 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2033 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2034 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2328 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2329 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2330 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2035 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2331 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2036 ) > "${JAVA_PKG_ENV}" 2332 ) > "${JAVA_PKG_ENV}"
2037 2333
2038 # register target/source 2334 # register target/source
2039 local target="$(java-pkg_get-target)" 2335 local target="$(java-pkg_get-target)"
2050 2346
2051 2347
2052 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2348 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2053 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2349 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2054 2350
2351 # extra env variables
2352 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2353 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2354 # nested echo to remove leading/trailing spaces
2355 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2356 >> "${JAVA_PKG_ENV}" || die
2357 fi
2358
2055 # Strip unnecessary leading and trailing colons 2359 # Strip unnecessary leading and trailing colons
2056 # TODO try to cleanup if possible 2360 # TODO try to cleanup if possible
2057 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2361 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2362 else
2363 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2364 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2365 debug-print "write package.env."
2058 fi 2366 fi
2059} 2367}
2060 2368
2061# ------------------------------------------------------------------------------ 2369# ------------------------------------------------------------------------------
2062# @internal-function java-pkg_record-jar_ 2370# @internal-function java-pkg_record-jar_
2063# 2371#
2064# Record a dependency to the package.env 2372# Record an (optional) dependency to the package.env
2065# 2373# @param --optional - record dependency as optional
2374# @param $1 - package to record
2375# @param $2 - (optional) jar of package to record
2066# ------------------------------------------------------------------------------ 2376# ------------------------------------------------------------------------------
2067JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2377JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2378JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2068 2379
2069java-pkg_record-jar_() { 2380java-pkg_record-jar_() {
2070 debug-print-function ${FUNCNAME} $* 2381 debug-print-function ${FUNCNAME} $*
2382
2383 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2384 if [[ "${1}" == "--optional" ]]; then
2385 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2386 shift
2387 fi
2071 2388
2072 local pkg=${1} jar=${2} append 2389 local pkg=${1} jar=${2} append
2073 if [[ -z "${jar}" ]]; then 2390 if [[ -z "${jar}" ]]; then
2074 append="${pkg}" 2391 append="${pkg}"
2075 else 2392 else
2076 append="$(basename ${jar})@${pkg}" 2393 append="$(basename ${jar})@${pkg}"
2077 fi 2394 fi
2078 2395
2079 echo ${append} >> ${JAVA_PKG_DEPEND} 2396 echo "${append}" >> "${depend_file}"
2080} 2397}
2081 2398
2082# ------------------------------------------------------------------------------ 2399# ------------------------------------------------------------------------------
2083# @internal-function java-pkg_append_ 2400# @internal-function java-pkg_append_
2084# 2401#
2128# 2445#
2129# @return 0 - function is declared 2446# @return 0 - function is declared
2130# @return 1 - function is undeclared 2447# @return 1 - function is undeclared
2131# ------------------------------------------------------------------------------ 2448# ------------------------------------------------------------------------------
2132java-pkg_func-exists() { 2449java-pkg_func-exists() {
2133 if [[ -n "$(declare -f ${1})" ]]; then 2450 declare -F ${1} > /dev/null
2134 return 0
2135 else
2136 return 1
2137 fi
2138} 2451}
2139 2452
2140# ------------------------------------------------------------------------------ 2453# ------------------------------------------------------------------------------
2141# @internal-function java-pkg_setup-vm 2454# @internal-function java-pkg_setup-vm
2142# 2455#
2143# Sets up the environment for a specific VM 2456# Sets up the environment for a specific VM
2144# 2457#
2145# ------------------------------------------------------------------------------ 2458# ------------------------------------------------------------------------------
2146java-pkg_setup-vm() { 2459java-pkg_setup-vm() {
2147 debug-print-function ${FUNCNAME} $* 2460 debug-print-function ${FUNCNAME} $*
2461
2462 export LANG="C" LC_ALL="C"
2148 2463
2149 local vendor="$(java-pkg_get-vm-vendor)" 2464 local vendor="$(java-pkg_get-vm-vendor)"
2150 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2465 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2151 addpredict "/dev/random" 2466 addpredict "/dev/random"
2152 elif [[ "${vendor}" == "ibm" ]]; then 2467 elif [[ "${vendor}" == "ibm" ]]; then
2153 addpredict "/proc/self/maps" 2468 addpredict "/proc/self/maps"
2154 addpredict "/proc/cpuinfo" 2469 addpredict "/proc/cpuinfo"
2155 export LANG="C" LC_ALL="C"
2156 elif [[ "${vendor}" == "jrockit" ]]; then 2470 elif [[ "${vendor}" == "jrockit" ]]; then
2157 addpredict "/proc/cpuinfo" 2471 addpredict "/proc/cpuinfo"
2158 fi 2472 fi
2159} 2473}
2160 2474
2264 2578
2265 #TODO If you know a better solution let us know. 2579 #TODO If you know a better solution let us know.
2266 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2580 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2267 2581
2268 local tann="${T}/announced-vm" 2582 local tann="${T}/announced-vm"
2583 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2584 # if people have for example modified eclasses some where
2269 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2585 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2270 # Add a check for setup/preinst phase... to avoid duplicate outputs
2271 # for when FEATURES=buildpkg
2272 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2273 then
2274 einfo "Using: $(java-config -f)" 2586 einfo "Using: $(java-config -f)"
2275 [[ ! -f "${tann}" ]] && touch "${tann}" 2587 [[ ! -f "${tann}" ]] && touch "${tann}"
2276 fi
2277 fi 2588 fi
2278 2589
2279 else 2590 else
2280 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2591 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2281 fi 2592 fi
2320# not. 2631# not.
2321# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2632# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2322# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2323java-pkg_verify-classes() { 2634java-pkg_verify-classes() {
2324 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2635 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2636
2637 local version_verify="/usr/bin/class-version-verify.py"
2638
2639 if [[ ! -x "${version_verify}" ]]; then
2640 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2641 fi
2642
2643 if [[ ! -x "${version_verify}" ]]; then
2644 ewarn "Unable to perform class version checks as"
2645 ewarn "class-version-verify.py is unavailable"
2646 ewarn "Please install dev-java/javatoolkit."
2647 return
2648 fi
2649
2325 local target=$(java-pkg_get-target) 2650 local target=$(java-pkg_get-target)
2326 local result 2651 local result
2327 local log="${T}/class-version-verify.log" 2652 local log="${T}/class-version-verify.log"
2328 if [[ -n "${1}" ]]; then 2653 if [[ -n "${1}" ]]; then
2329 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2654 ${version_verify} -v -t ${target} "${1}" > "${log}"
2330 result=$? 2655 result=$?
2331 else 2656 else
2332 ebegin "Verifying java class versions (target: ${target})" 2657 ebegin "Verifying java class versions (target: ${target})"
2333 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2658 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2334 result=$? 2659 result=$?
2335 eend ${result} 2660 eend ${result}
2336 fi 2661 fi
2337 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2662 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2338 if [[ ${result} != 0 ]]; then 2663 if [[ ${result} != 0 ]]; then
2345 2670
2346# ---------------------------------------------------------------------------- 2671# ----------------------------------------------------------------------------
2347# @internal-function java-pkg_ensure-dep 2672# @internal-function java-pkg_ensure-dep
2348# Check that a package being used in jarfrom, getjars and getjar is contained 2673# Check that a package being used in jarfrom, getjars and getjar is contained
2349# within DEPEND or RDEPEND. 2674# within DEPEND or RDEPEND.
2350# @param $1 - Is the package a runtime dependency 2675# @param $1 - empty - check both vars; "runtime" or "build" - check only
2676# RDEPEND, resp. DEPEND
2351# @param $2 - Package name and slot. 2677# @param $2 - Package name and slot.
2352 2678
2353java-pkg_ensure-dep() { 2679java-pkg_ensure-dep() {
2354 debug-print-function ${FUNCNAME} $* 2680 debug-print-function ${FUNCNAME} $*
2355 2681
2356 local build_only="${1}" 2682 local limit_to="${1}"
2357 local target_pkg="${2}" 2683 local target_pkg="${2}"
2358 local dev_error="" 2684 local dev_error=""
2359 2685
2360 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2686 local stripped_pkg=$(echo "${target_pkg}" | sed \
2361 's/-[0-9]*\(\.[0-9]\)*$//') 2687 's/-[0-9]*\(\.[0-9]\)*$//')
2362 2688
2689 debug-print "Matching against: ${stripped_pkg}"
2690
2363 if [[ ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2691 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2364 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2692 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2365 dev_error="${dev_error} declared in DEPEND." 2693 dev_error="${dev_error} declared in DEPEND."
2366 if is-java-strict; then 2694 if is-java-strict; then
2695 eerror "${dev_error}"
2367 die "${dev_error}" 2696 die "${dev_error}"
2368 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2697 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2369 eerror "${dev_error}" 2698 eerror "${dev_error}"
2370 elog "Because you have this package installed the package will" 2699 elog "Because you have this package installed the package will"
2371 elog "build without problems, but please report this to" 2700 elog "build without problems, but please report this to"
2372 elog "http://bugs.gentoo.org" 2701 elog "http://bugs.gentoo.org"
2373 fi 2702 fi
2374 fi 2703 fi
2375 2704
2705 if [[ ${limit_to} != build ]]; then
2376 if [[ -z ${build_only} && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2706 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2707 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2377 dev_error="The ebuild is attempting to use ${target_pkg}," 2708 dev_error="The ebuild is attempting to use ${target_pkg},"
2378 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2709 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2710 dev_error="${dev_error} or PDEPEND."
2379 if is-java-strict; then 2711 if is-java-strict; then
2712 eerror "${dev_error}"
2380 die "${dev_error}" 2713 die "${dev_error}"
2381 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2714 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2382 eerror "${dev_error}" 2715 eerror "${dev_error}"
2383 elog "Because you have this package installed the package will" 2716 elog "The package will build without problems, but may fail to run"
2384 elog "build without problems, but please report this to" 2717 elog "if you don't have ${target_pkg} installed, so please report"
2385 elog "http://bugs.gentoo.org" 2718 elog "this to http://bugs.gentoo.org"
2719 fi
2720 fi
2386 fi 2721 fi
2387 fi 2722 fi
2388} 2723}
2389 2724
2390# ------------------------------------------------------------------------------ 2725# ------------------------------------------------------------------------------
2391# @section-end internal 2726# @section-end internal
2392# ------------------------------------------------------------------------------ 2727# ------------------------------------------------------------------------------
2393 2728
2394java-pkg_check-phase() { 2729java-pkg_check-phase() {
2395 local phase=${1} 2730 local phase=${1}
2396 local funcname=${2} 2731 local funcname=${FUNCNAME[1]}
2397 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2732 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2398 java-pkg_announce-qa-violation \
2399 "${funcname} used outside of src_${phase}" 2733 local msg="${funcname} used outside of src_${phase}"
2734 java-pkg_announce-qa-violation "${msg}"
2400 fi 2735 fi
2401} 2736}
2402 2737
2403java-pkg_check-versioned-jar() { 2738java-pkg_check-versioned-jar() {
2404 local jar=${1} 2739 local jar=${1}
2413 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2748 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2414 fi 2749 fi
2415} 2750}
2416 2751
2417java-pkg_announce-qa-violation() { 2752java-pkg_announce-qa-violation() {
2418 if is-java-strict; then 2753 local nodie
2754 if [[ ${1} == "--nodie" ]]; then
2755 nodie="true"
2756 shift
2757 fi
2419 echo "Java QA Notice: $@" >&2 2758 echo "Java QA Notice: $@" >&2
2420 increment-qa-violations 2759 increment-qa-violations
2421 fi 2760 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2422} 2761}
2423 2762
2424increment-qa-violations() { 2763increment-qa-violations() {
2425 let "JAVA_PKG_QA_VIOLATIONS+=1" 2764 let "JAVA_PKG_QA_VIOLATIONS+=1"
2426 export JAVA_PKG_QA_VIOLATIONS 2765 export JAVA_PKG_QA_VIOLATIONS
2429is-java-strict() { 2768is-java-strict() {
2430 [[ -n ${JAVA_PKG_STRICT} ]] 2769 [[ -n ${JAVA_PKG_STRICT} ]]
2431 return $? 2770 return $?
2432} 2771}
2433 2772
2773
2434# ------------------------------------------------------------------------------ 2774# ------------------------------------------------------------------------------
2435# @eclass-end 2775# @eclass-end
2436# ------------------------------------------------------------------------------ 2776# ------------------------------------------------------------------------------

Legend:
Removed from v.1.73  
changed lines
  Added in v.1.127

  ViewVC Help
Powered by ViewVC 1.1.20