/[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.58 Revision 1.101
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.58 2007/02/28 10:45:20 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.101 2008/01/12 15:03:13 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
55# 54#
56# @seealso JAVA_PKG_FORCE_ANT_TASKS 55# @seealso JAVA_PKG_FORCE_ANT_TASKS
57# ----------------------------------------------------------------------------- 56# -----------------------------------------------------------------------------
58#WANT_ANT_TASKS 57#WANT_ANT_TASKS
59 58
59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. At this moment it's 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
66 67
67# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
68# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
69# 70#
70# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
71# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
72# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
73# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
75 77
76# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 80# @variable-default yes
79# 81#
183# 185#
184# These are used to install Java-related things, such as jars, Javadocs, JNI 186# These are used to install Java-related things, such as jars, Javadocs, JNI
185# libraries, etc. 187# libraries, etc.
186# ----------------------------------------------------------------------------- 188# -----------------------------------------------------------------------------
187 189
190# -----------------------------------------------------------------------------
191# @ebuild-function java-pkg_doexamples
192#
193# Installs given arguments to /usr/share/doc/${PF}/examples
194# If you give it only one parameter and it is a directory it will install
195# everything in that directory to the examples directory.
196#
197# @example
198# java-pkg_doexamples demo
199# java-pkg_doexamples demo/* examples/*
200#
201# @param --subdir - If the examples need a certain directory structure
202# @param $* - list of files to install
203# ------------------------------------------------------------------------------
204java-pkg_doexamples() {
205 debug-print-function ${FUNCNAME} $*
206
207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
208
209 java-pkg_check-phase install
210
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
218 if [[ ${#} = 1 && -d ${1} ]]; then
219 ( # dont want to pollute calling env
220 insinto "${dest}"
221 doins -r ${1}/*
222 ) || die "Installing examples failed"
223 else
224 ( # dont want to pollute calling env
225 insinto "${dest}"
226 doins -r "$@"
227 ) || die "Installing examples failed"
228 fi
229}
188 230
189# ----------------------------------------------------------------------------- 231# -----------------------------------------------------------------------------
190# @ebuild-function java-pkg_dojar 232# @ebuild-function java-pkg_dojar
191# 233#
192# Installs any number of jars. 234# Installs any number of jars.
259# Using env variables keeps this eclass working with java-config versions that 301# Using env variables keeps this eclass working with java-config versions that
260# do not handle use flags. 302# do not handle use flags.
261# ------------------------------------------------------------------------------ 303# ------------------------------------------------------------------------------
262 304
263depend-java-query() { 305depend-java-query() {
306 # Used to have a which call here but it caused endless loops for some people
307 # that had some weird bashrc voodoo for which.
264 USE="${USE}" $(which depend-java-query) "${@}" 308 USE="${USE}" /usr/bin/depend-java-query "${@}"
265} 309}
266 310
267# ------------------------------------------------------------------------------ 311# ------------------------------------------------------------------------------
268# @ebuild-function java-pkg_regjar 312# @ebuild-function java-pkg_regjar
269# 313#
317 # java-pkg_regjar ${D}/opt/java/*.jar 361 # java-pkg_regjar ${D}/opt/java/*.jar
318 # such call will fall into this case (-e ${jar}) and will 362 # such call will fall into this case (-e ${jar}) and will
319 # record paths with ${D} in package.env 363 # record paths with ${D} in package.env
320 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 364 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
321 else 365 else
366 if [[ ${jar} = *\** ]]; then
367 eerror "The argument ${jar} to ${FUNCNAME}"
368 eerror "has * in it. If you want it to glob in"
369 eerror '${D} add ${D} to the argument.'
370 fi
322 die "${jar} does not exist" 371 die "${jar} does not exist"
323 fi 372 fi
324 done 373 done
325 374
326 java-pkg_do_write_ 375 java-pkg_do_write_
508# ------------------------------------------------------------------------------ 557# ------------------------------------------------------------------------------
509# @ebuild-function java-pkg_dojavadoc 558# @ebuild-function java-pkg_dojavadoc
510# 559#
511# Installs javadoc documentation. This should be controlled by the doc use flag. 560# Installs javadoc documentation. This should be controlled by the doc use flag.
512# 561#
562# @param $1: optional --symlink creates to symlink like this for html
563# documentation bundles.
513# @param $1: - The javadoc root directory. 564# @param $2: - The javadoc root directory.
514# 565#
515# @example: 566# @example:
516# java-pkg_dojavadoc docs/api 567# java-pkg_dojavadoc docs/api
568# java-pkg_dojavadoc --symlink apidocs docs/api
517# 569#
518# ------------------------------------------------------------------------------ 570# ------------------------------------------------------------------------------
519java-pkg_dojavadoc() { 571java-pkg_dojavadoc() {
572 debug-print-function ${FUNCNAME} $*
573
574 # For html documentation bundles that link to Javadoc
575 local symlink
576 if [[ ${1} = --symlink ]]; then
577 symlink=${2}
578 shift 2
579 fi
580
520 local dir="$1" 581 local dir="$1"
582 local dest=/usr/share/doc/${PF}/html
583
584 # QA checks
521 585
522 java-pkg_check-phase install 586 java-pkg_check-phase install
523 587
524 [[ -z "${dir}" ]] && die "Must specify a directory!" 588 [[ -z "${dir}" ]] && die "Must specify a directory!"
525 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 589 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
590 if [[ ! -e "${dir}/index.html" ]]; then
591 local msg="No index.html in javadoc directory"
592 ewarn "${msg}"
593 is-java-strict && die "${msg}"
594 fi
595
596 if [[ -e ${D}/${dest}/api ]]; then
597 eerror "${dest} already exists. Will not overwrite."
598 die "${dest}"
599 fi
600
601 # Renaming to match our directory layout
526 602
527 local dir_to_install="${dir}" 603 local dir_to_install="${dir}"
528 if [[ "$(basename "${dir}")" != "api" ]]; then 604 if [[ "$(basename "${dir}")" != "api" ]]; then
529 dir_to_install="${T}/api" 605 dir_to_install="${T}/api"
530 # TODO use doins 606 # TODO use doins
531 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 607 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
532 fi 608 fi
533 609
610 # Actual installation
611
534 java-pkg_dohtml -r ${dir_to_install} 612 java-pkg_dohtml -r "${dir_to_install}"
613
614 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616
617 if [[ ${symlink} ]]; then
618 dosym ${dest}/{api,${symlink}} || die
619 fi
535} 620}
536 621
537# ------------------------------------------------------------------------------ 622# ------------------------------------------------------------------------------
538# @ebuild-function java-pkg_dosrc 623# @ebuild-function java-pkg_dosrc
539# 624#
555# FIXME apparently this fails if you give it an empty directories 640# FIXME apparently this fails if you give it an empty directories
556java-pkg_dosrc() { 641java-pkg_dosrc() {
557 debug-print-function ${FUNCNAME} $* 642 debug-print-function ${FUNCNAME} $*
558 643
559 [ ${#} -lt 1 ] && die "At least one argument needed" 644 [ ${#} -lt 1 ] && die "At least one argument needed"
560 if ! hasq source ${IUSE}; then
561 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
562 fi
563 645
564 java-pkg_check-phase install 646 java-pkg_check-phase install
565 647
566 [[ ${#} -lt 1 ]] && die "At least one argument needed" 648 [[ ${#} -lt 1 ]] && die "At least one argument needed"
649
650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
652 if is-java-strict; then
653 eerror "${msg}"
654 die "${msg}"
655 else
656 echo "${msg}"
657 echo "Please report this to http://bugs.gentoo.org."
658 fi
659 fi
567 660
568 java-pkg_init_paths_ 661 java-pkg_init_paths_
569 662
570 local zip_name="${PN}-src.zip" 663 local zip_name="${PN}-src.zip"
571 local zip_path="${T}/${zip_name}" 664 local zip_path="${T}/${zip_name}"
765# Example: get a specific jar from xerces slot 2, and name it diffrently 858# Example: get a specific jar from xerces slot 2, and name it diffrently
766# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 859# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
767# Example: get junit.jar which is needed only for building 860# Example: get junit.jar which is needed only for building
768# java-pkg_jar-from --build-only junit junit.jar 861# java-pkg_jar-from --build-only junit junit.jar
769# 862#
770# @param $opt 863# @param $opt
771# --build-only - makes the jar(s) not added into package.env DEPEND line. 864# --build-only - makes the jar(s) not added into package.env DEPEND line.
772# (assumed automatically when called inside src_test) 865# (assumed automatically when called inside src_test)
773# --with-dependencies - get jars also from requested package's dependencies 866# --with-dependencies - get jars also from requested package's dependencies
774# transitively. 867# transitively.
868# --virtual - Packages passed to this function are to be handled as virtuals
869# and will not have individual jar dependencies recorded.
775# --into $dir - symlink jar(s) into $dir (must exist) instead of . 870# --into $dir - symlink jar(s) into $dir (must exist) instead of .
776# @param $1 - Package to get jars from. 871# @param $1 - Package to get jars from, or comma-separated list of packages in
872# case other parameters are not used.
777# @param $2 - jar from package. If not specified, all jars will be used. 873# @param $2 - jar from package. If not specified, all jars will be used.
778# @param $3 - When a single jar is specified, destination filename of the 874# @param $3 - When a single jar is specified, destination filename of the
779# symlink. Defaults to the name of the jar. 875# symlink. Defaults to the name of the jar.
780# ------------------------------------------------------------------------------ 876# ------------------------------------------------------------------------------
781# TODO could probably be cleaned up a little 877# TODO could probably be cleaned up a little
783 debug-print-function ${FUNCNAME} $* 879 debug-print-function ${FUNCNAME} $*
784 880
785 local build_only="" 881 local build_only=""
786 local destdir="." 882 local destdir="."
787 local deep="" 883 local deep=""
788 884 local virtual=""
885
789 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 886 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
790 887
791 while [[ "${1}" == --* ]]; do 888 while [[ "${1}" == --* ]]; do
792 if [[ "${1}" = "--build-only" ]]; then 889 if [[ "${1}" = "--build-only" ]]; then
793 build_only="true" 890 build_only="build"
794 elif [[ "${1}" = "--with-dependencies" ]]; then 891 elif [[ "${1}" = "--with-dependencies" ]]; then
795 deep="--with-dependencies" 892 deep="--with-dependencies"
893 elif [[ "${1}" = "--virtual" ]]; then
894 virtual="true"
796 elif [[ "${1}" = "--into" ]]; then 895 elif [[ "${1}" = "--into" ]]; then
797 destdir="${2}" 896 destdir="${2}"
798 shift 897 shift
799 else 898 else
800 die "java-pkg_jar-from called with unknown parameter: ${1}" 899 die "java-pkg_jar-from called with unknown parameter: ${1}"
812 local error_msg="There was a problem getting the classpath for ${target_pkg}." 911 local error_msg="There was a problem getting the classpath for ${target_pkg}."
813 local classpath 912 local classpath
814 classpath="$(java-config ${deep} --classpath=${target_pkg})" 913 classpath="$(java-config ${deep} --classpath=${target_pkg})"
815 [[ $? != 0 ]] && die ${error_msg} 914 [[ $? != 0 ]] && die ${error_msg}
816 915
916 # When we have commas this functions is called to bring jars from multiple
917 # packages. This affects recording of dependencencies performed later
918 # which expects one package only, so we do it here.
919 if [[ ${target_pkg} = *,* ]]; then
920 for pkg in ${target_pkg//,/ }; do
921 java-pkg_ensure-dep "${build_only}" "${pkg}"
922 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
923 done
924 # setting this disables further record-jar_ calls later
925 build_only="build"
926 else
927 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
928 fi
929
930 # Record the entire virtual as a dependency so that
931 # no jars are missed.
932 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
933 java-pkg_record-jar_ "${target_pkg}"
934 # setting this disables further record-jars_ calls later
935 build_only="build"
936 fi
937
817 pushd ${destdir} > /dev/null \ 938 pushd ${destdir} > /dev/null \
818 || die "failed to change directory to ${destdir}" 939 || die "failed to change directory to ${destdir}"
940
819 local jar 941 local jar
820 for jar in ${classpath//:/ }; do 942 for jar in ${classpath//:/ }; do
821 local jar_name=$(basename "${jar}") 943 local jar_name=$(basename "${jar}")
822 if [[ ! -f "${jar}" ]] ; then 944 if [[ ! -f "${jar}" ]] ; then
823 debug-print "${jar} from ${target_pkg} does not exist" 945 debug-print "${jar} from ${target_pkg} does not exist"
871# Example: Get the classpath for xerces-2 and xalan, 993# Example: Get the classpath for xerces-2 and xalan,
872# java-pkg_getjars xerces-2,xalan 994# java-pkg_getjars xerces-2,xalan
873# Example Return: 995# Example Return:
874# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 996# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
875# 997#
876# @param $opt 998# @param $opt
877# --build-only - makes the jar(s) not added into package.env DEPEND line. 999# --build-only - makes the jar(s) not added into package.env DEPEND line.
878# (assumed automatically when called inside src_test) 1000# (assumed automatically when called inside src_test)
879# --with-dependencies - get jars also from requested package's dependencies 1001# --with-dependencies - get jars also from requested package's dependencies
880# transitively. 1002# transitively.
881# @param $1 - list of packages to get jars from 1003# @param $1 - list of packages to get jars from
884java-pkg_getjars() { 1006java-pkg_getjars() {
885 debug-print-function ${FUNCNAME} $* 1007 debug-print-function ${FUNCNAME} $*
886 1008
887 local build_only="" 1009 local build_only=""
888 local deep="" 1010 local deep=""
889 1011
890 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1012 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
891 1013
892 while [[ "${1}" == --* ]]; do 1014 while [[ "${1}" == --* ]]; do
893 if [[ "${1}" = "--build-only" ]]; then 1015 if [[ "${1}" = "--build-only" ]]; then
894 build_only="true" 1016 build_only="build"
895 elif [[ "${1}" = "--with-dependencies" ]]; then 1017 elif [[ "${1}" = "--with-dependencies" ]]; then
896 deep="--with-dependencies" 1018 deep="--with-dependencies"
897 else 1019 else
898 die "java-pkg_jar-from called with unknown parameter: ${1}" 1020 die "java-pkg_jar-from called with unknown parameter: ${1}"
899 fi 1021 fi
900 shift 1022 shift
901 done 1023 done
902 1024
903 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1025 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
904 1026
1027
905 local classpath pkgs="${1}" 1028 local classpath pkgs="${1}"
906 jars="$(java-config ${deep} --classpath=${pkgs})" 1029 jars="$(java-config ${deep} --classpath=${pkgs})"
907 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1030 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
908 debug-print "${pkgs}:${jars}" 1031 debug-print "${pkgs}:${jars}"
1032
1033 for pkg in ${pkgs//,/ }; do
1034 java-pkg_ensure-dep "${build_only}" "${pkg}"
1035 done
909 1036
910 if [[ -z "${classpath}" ]]; then 1037 if [[ -z "${classpath}" ]]; then
911 classpath="${jars}" 1038 classpath="${jars}"
912 else 1039 else
913 classpath="${classpath}:${jars}" 1040 classpath="${classpath}:${jars}"
914 fi 1041 fi
915 1042
916 # Only record jars that aren't build-only 1043 # Only record jars that aren't build-only
917 if [[ -z "${build_only}" ]]; then 1044 if [[ -z "${build_only}" ]]; then
918 oldifs="${IFS}"
919 IFS=","
920 for pkg in ${pkgs}; do 1045 for pkg in ${pkgs//,/ }; do
921 java-pkg_record-jar_ "${pkg}" 1046 java-pkg_record-jar_ "${pkg}"
922 done 1047 done
923 IFS="${oldifs}"
924 fi 1048 fi
925 1049
926 echo "${classpath}" 1050 echo "${classpath}"
927} 1051}
928 1052
940# @example-return 1064# @example-return
941# /usr/share/xerces-2/lib/xml-apis.jar 1065# /usr/share/xerces-2/lib/xml-apis.jar
942# 1066#
943# @param $opt 1067# @param $opt
944# --build-only - makes the jar not added into package.env DEPEND line. 1068# --build-only - makes the jar not added into package.env DEPEND line.
1069# --virtual - Packages passed to this function are to be handled as virtuals
1070# and will not have individual jar dependencies recorded.
945# @param $1 - package to use 1071# @param $1 - package to use
946# @param $2 - jar to get 1072# @param $2 - jar to get
947# ------------------------------------------------------------------------------ 1073# ------------------------------------------------------------------------------
948java-pkg_getjar() { 1074java-pkg_getjar() {
949 debug-print-function ${FUNCNAME} $* 1075 debug-print-function ${FUNCNAME} $*
950 1076
951 local build_only="" 1077 local build_only=""
952 1078 local virtual=""
1079
953 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1080 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
954 1081
955 while [[ "${1}" == --* ]]; do 1082 while [[ "${1}" == --* ]]; do
956 if [[ "${1}" = "--build-only" ]]; then 1083 if [[ "${1}" = "--build-only" ]]; then
957 build_only="true" 1084 build_only="build"
1085 elif [[ "${1}" == "--virtual" ]]; then
1086 virtual="true"
958 else 1087 else
959 die "java-pkg_jar-from called with unknown parameter: ${1}" 1088 die "java-pkg_jar-from called with unknown parameter: ${1}"
960 fi 1089 fi
961 shift 1090 shift
962 done 1091 done
969 1098
970 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?"
971 local classpath 1100 local classpath
972 classpath=$(java-config --classpath=${pkg}) 1101 classpath=$(java-config --classpath=${pkg})
973 [[ $? != 0 ]] && die ${error_msg} 1102 [[ $? != 0 ]] && die ${error_msg}
1103
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
974 1112
975 for jar in ${classpath//:/ }; do 1113 for jar in ${classpath//:/ }; do
976 if [[ ! -f "${jar}" ]] ; then 1114 if [[ ! -f "${jar}" ]] ; then
977 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
978 fi 1116 fi
985 fi 1123 fi
986 done 1124 done
987 1125
988 die "Could not find ${target_jar} in ${pkg}" 1126 die "Could not find ${target_jar} in ${pkg}"
989 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 [[ -z "${jar}" ]]; then
1168 for pkg in ${pkgs//,/ }; do
1169 java-pkg_ensure-dep runtime "${pkg}"
1170 java-pkg_record-jar_ "${pkg}"
1171 done
1172 else
1173 [[ ${pkgs} == *,* ]] && \
1174 die "${FUNCNAME} called with both package list and jar name"
1175 java-pkg_ensure-dep runtime "${pkgs}"
1176 java-pkg_record-jar_ "${pkgs}" "${jar}"
1177 fi
1178
1179 java-pkg_do_write_
1180}
1181
1182# ------------------------------------------------------------------------------
1183# @ebuild-function java-pkg_register-optional-dependency
1184#
1185# Registers optional runtime dependency on a package, list of packages, or a
1186# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1187# called in src_install phase.
1188# Intended for packages that can use other packages when those are in classpath.
1189# Will be put on classpath by launcher if they are installed. Typical case is
1190# JDBC implementations for various databases. It's better than having USE flag
1191# for each implementation triggering hard dependency.
1192#
1193# @param $1 - comma-separated list of packages, or a single package
1194# @param $2 - if param $1 is a single package, optionally specify the jar
1195# to depend on
1196#
1197# Example: Record the optional dependency on some jdbc providers
1198# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1199#
1200# Note: Passing both list of packages as the first parameter AND specifying the
1201# jar as the second is not allowed and will cause the function to die. We assume
1202# that there's more chance one passes such combination as a mistake, than that
1203# there are more packages providing identically named jar without class
1204# collisions.
1205# ------------------------------------------------------------------------------
1206java-pkg_register-optional-dependency() {
1207 debug-print-function ${FUNCNAME} $*
1208
1209 java-pkg_check-phase install
1210
1211 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1212
1213 local pkgs="${1}"
1214 local jar="${2}"
1215
1216 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1217
1218 if [[ -z "${jar}" ]]; then
1219 for pkg in ${pkgs//,/ }; do
1220 java-pkg_record-jar_ --optional "${pkg}"
1221 done
1222 else
1223 [[ ${pkgs} == *,* ]] && \
1224 die "${FUNCNAME} called with both package list and jar name"
1225 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1226 fi
1227
1228 java-pkg_do_write_
1229}
1230
1231# ------------------------------------------------------------------------------
1232# @ebuild-function java-pkg_register-environment-variable
1233#
1234# Register an arbitrary environment variable into package.env. The gjl launcher
1235# for this package or any package depending on this will export it into
1236# environement before executing java command.
1237# Must only be called in src_install phase.
1238#
1239# @param $1 - variable name
1240# @param $2 - variable value
1241# ------------------------------------------------------------------------------
1242JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1243JAVA_PKG_EXTRA_ENV_VARS=""
1244java-pkg_register-environment-variable() {
1245 debug-print-function ${FUNCNAME} $*
1246
1247 java-pkg_check-phase install
1248
1249 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1250
1251 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1252 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1253
1254 java-pkg_do_write_
990} 1255}
991 1256
992# This function reads stdin, and based on that input, figures out how to 1257# This function reads stdin, and based on that input, figures out how to
993# populate jars from the filesystem. 1258# populate jars from the filesystem.
994# Need to figure out a good way of making use of this, ie be able to use a 1259# Need to figure out a good way of making use of this, ie be able to use a
1482 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true 1747 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1483 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true 1748 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1484 done 1749 done
1485 1750
1486 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then 1751 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1487 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks" 1752 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1488 echo "all" 1753 echo "all"
1489 else 1754 else
1490 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant 1755 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1491 # so we deactivate all tasks that may be installed 1756 # so we deactivate all tasks that may be installed
1492 echo "none" 1757 echo "none"
1517 return 0 1782 return 0
1518 fi 1783 fi
1519} 1784}
1520 1785
1521# ------------------------------------------------------------------------------ 1786# ------------------------------------------------------------------------------
1787# @ebuild-function ejunit
1788#
1789# Junit wrapper function. Makes it easier to run the tests and checks for
1790# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1791#
1792# Examples:
1793# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1794# ejunit org.blinkenlights.jid3.test.AllTests
1795#
1796# @param $1 - -cp or -classpath
1797# @param $2 - classpath; junit and recorded dependencies get appended
1798# @param $@ - the rest of the parameters are passed to java
1799# ------------------------------------------------------------------------------
1800ejunit() {
1801 debug-print-function ${FUNCNAME} $*
1802
1803 local pkgs
1804 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1805 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1806 done
1807
1808 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1809 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1810 cp="${2}:${cp}"
1811 shift 2
1812 else
1813 cp=".:${cp}"
1814 fi
1815
1816 local runner=junit.textui.TestRunner
1817 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1818 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1819}
1820
1821# ------------------------------------------------------------------------------
1522# @section-end helper 1822# @section-end helper
1523# ------------------------------------------------------------------------------ 1823# ------------------------------------------------------------------------------
1524 1824
1525# ------------------------------------------------------------------------------ 1825# ------------------------------------------------------------------------------
1526# @section-begin build 1826# @section-begin build
1537# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1837# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1538# variables: 1838# variables:
1539# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1839# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1540# gentoo.classpath property. Be sure to call 1840# gentoo.classpath property. Be sure to call
1541# java-ant_rewrite-classpath in src_unpack. 1841# java-ant_rewrite-classpath in src_unpack.
1842# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1542# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1843# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1543# ------------------------------------------------------------------------------ 1844# ------------------------------------------------------------------------------
1544eant() { 1845eant() {
1545 debug-print-function ${FUNCNAME} $* 1846 debug-print-function ${FUNCNAME} $*
1546 1847
1547 # FIXME get this working 1848 if [[ ${EBUILD_PHASE} = compile ]]; then
1548# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1849 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1549# java-pkg_announce-qa-violation \ 1850 # finally get rid of the hooks without breaking stuff
1550# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1851
1852 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1853 && java-ant_ignore-system-classes "${S}/build.xml"
1854
1855 if hasq java-ant-2 ${INHERITED}; then
1856 java-ant_bsfix
1857 fi
1858
1859 # eant can be called multiple times
1860 JAVA_PKG_BSFIX="off"
1861
1862 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1863 echo "Searching for bundled jars:"
1864 java-pkg_find-normal-jars || echo "None found."
1865 echo "Searching for bundled classes (no output if none found):"
1866 find "${WORKDIR}" -name "*.class"
1867 echo "Search done."
1868 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1869 fi
1551# fi 1870 fi
1552 1871
1553 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1872 if ! hasq java-ant-2 ${INHERITED}; then
1554 local msg="You should inherit java-ant-2 when using eant" 1873 local msg="You should inherit java-ant-2 when using eant"
1555 java-pkg_announce-qa-violation ${msg} 1874 java-pkg_announce-qa-violation "${msg}"
1556 die ${msg}
1557 fi 1875 fi
1558 1876
1559 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1877 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1560 1878
1561 java-pkg_init-compiler_ 1879 java-pkg_init-compiler_
1562 local compiler="${GENTOO_COMPILER}" 1880 local compiler="${GENTOO_COMPILER}"
1563 1881
1564 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1882 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1565
1566 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1883 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1567 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1884 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1568 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1885 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1569 fi 1886 fi
1570 1887
1576 # java-config -p 1893 # java-config -p
1577 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1894 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1578 if [[ -n ${build_compiler_deps} ]]; then 1895 if [[ -n ${build_compiler_deps} ]]; then
1579 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1896 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1580 fi 1897 fi
1581 fi
1582
1583 if is-java-strict; then
1584 einfo "Disabling system classpath for ant"
1585 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1586 fi 1898 fi
1587 1899
1588 for arg in "${@}"; do 1900 for arg in "${@}"; do
1589 if [[ ${arg} = -lib ]]; then 1901 if [[ ${arg} = -lib ]]; then
1590 if is-java-strict; then 1902 if is-java-strict; then
1599 echo "more info." 1911 echo "more info."
1600 fi 1912 fi
1601 fi 1913 fi
1602 done 1914 done
1603 1915
1916 # we use this in src_* so we run ant from /
1604 if has_version ">=dev-java/ant-core-1.7.0"; then 1917 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1605 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1918 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1606 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1919 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1607 1920
1608 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1921 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1609 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1922 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1632 1945
1633 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1946 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1634 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1947 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1635 1948
1636 local gcp="${EANT_GENTOO_CLASSPATH}" 1949 local gcp="${EANT_GENTOO_CLASSPATH}"
1950 local getjarsarg=""
1637 1951
1638 if [[ ${EBUILD_PHASE} = "test" ]]; then 1952 if [[ ${EBUILD_PHASE} = "test" ]]; then
1639 antflags="${antflags} -DJunit.present=true" 1953 antflags="${antflags} -DJunit.present=true"
1640 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1954 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1955 getjarsarg="--with-dependencies"
1641 fi 1956 fi
1642 1957
1643 local cp 1958 local cp
1644 1959
1645 for atom in ${gcp}; do 1960 for atom in ${gcp}; do
1646 cp="${cp}:$(java-pkg_getjars ${atom})" 1961 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1647 done 1962 done
1648 1963
1649 if [[ ${cp} ]]; then 1964 if [[ ${cp} ]]; then
1650 # It seems ant does not like single quotes around ${cp} 1965 # It seems ant does not like single quotes around ${cp}
1651 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1966 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1652 fi 1967 fi
1653 1968
1654 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1969 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1655 debug-print "Calling ant: ${antflags} ${@}" 1970 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1656 ant ${antflags} "${@}" || die "eant failed" 1971 ant ${antflags} "${@}" || die "eant failed"
1657
1658} 1972}
1659 1973
1660# ------------------------------------------------------------------------------ 1974# ------------------------------------------------------------------------------
1661# @ebuild-function ejavac 1975# @ebuild-function ejavac
1662# 1976#
1757# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2071# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1758# call it during each of the phases of the merge process. 2072# call it during each of the phases of the merge process.
1759# 2073#
1760# ----------------------------------------------------------------------------- 2074# -----------------------------------------------------------------------------
1761java-pkg_init() { 2075java-pkg_init() {
2076 debug-print-function ${FUNCNAME} $*
1762 unset JAVAC 2077 unset JAVAC
1763 unset JAVA_HOME 2078 unset JAVA_HOME
2079
2080 # People do all kinds of weird things.
2081 # http://forums.gentoo.org/viewtopic-p-3943166.html
2082 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2083 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2084 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2085 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2086 ewarn "sun-jdk vms and and as such break configure scripts that"
2087 ewarn "use it (for example app-office/openoffice) so we filter it out."
2088 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2089 ewarn "make.conf for example) to silence this warning or"
2090 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2091 fi
2092
2093 if [[ -z ${accept} ]]; then
2094 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2095 # -version output
2096 unset _JAVA_OPTIONS
2097 # phase hooks make this run many times without this
2098 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2099 fi
2100
2101 if java-pkg_func-exists ant_src_unpack; then
2102 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2103 fi
2104
1764 java-pkg_init_paths_ 2105 java-pkg_init_paths_
1765 java-pkg_switch-vm 2106 java-pkg_switch-vm
1766 PATH=${JAVA_HOME}/bin:${PATH} 2107 PATH=${JAVA_HOME}/bin:${PATH}
1767 2108
1768 # TODO we will probably want to set JAVAC and JAVACFLAGS 2109 # TODO we will probably want to set JAVAC and JAVACFLAGS
1769 2110
1770 # Do some QA checks 2111 # Do some QA checks
1771 java-pkg_check-jikes 2112 java-pkg_check-jikes
2113
2114 # Can't use unset here because Portage does not save the unset
2115 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
1772 2116
1773 # When users have crazy classpaths some packages can fail to compile. 2117 # When users have crazy classpaths some packages can fail to compile.
1774 # and everything should work with empty CLASSPATH. 2118 # and everything should work with empty CLASSPATH.
1775 # This also helps prevent unexpected dependencies on random things 2119 # This also helps prevent unexpected dependencies on random things
1776 # from the CLASSPATH. 2120 # from the CLASSPATH.
1777 unset CLASSPATH 2121 export CLASSPATH=
1778 2122
1779 # Unset external ANT_ stuff 2123 # Unset external ANT_ stuff
1780 unset ANT_TASKS 2124 export ANT_TASKS=
1781 unset ANT_OPTS 2125 export ANT_OPTS=
1782} 2126}
1783 2127
1784# ------------------------------------------------------------------------------ 2128# ------------------------------------------------------------------------------
1785# @function-internal java-pkg-init-compiler_ 2129# @function-internal java-pkg-init-compiler_
1786# 2130#
1908 fi 2252 fi
1909 2253
1910 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2254 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1911 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2255 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1912 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2256 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2257 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2258 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
1913 2259
1914 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2260 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
1915 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2261 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
1916 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2262 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
1917 2263
1930# Writes the package.env out to disk. 2276# Writes the package.env out to disk.
1931# 2277#
1932# ------------------------------------------------------------------------------ 2278# ------------------------------------------------------------------------------
1933# TODO change to do-write, to match everything else 2279# TODO change to do-write, to match everything else
1934java-pkg_do_write_() { 2280java-pkg_do_write_() {
2281 debug-print-function ${FUNCNAME} $*
1935 java-pkg_init_paths_ 2282 java-pkg_init_paths_
1936 # Create directory for package.env 2283 # Create directory for package.env
1937 dodir "${JAVA_PKG_SHAREPATH}" 2284 dodir "${JAVA_PKG_SHAREPATH}"
1938 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2285 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2286 "${JAVA_PKG_DEPEND_FILE}" || -f \
2287 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1939 # Create package.env 2288 # Create package.env
1940 ( 2289 (
1941 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2290 echo "DESCRIPTION=\"${DESCRIPTION}\""
1942 echo "GENERATION=\"2\"" 2291 echo "GENERATION=\"2\""
1943 2292
1944 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2293 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1945 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2294 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1946 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2295 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1947 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2296 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2297 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2298 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2299 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
1948 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2300 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1949 ) > "${JAVA_PKG_ENV}" 2301 ) > "${JAVA_PKG_ENV}"
1950 2302
1951 # register target/source 2303 # register target/source
1952 local target="$(java-pkg_get-target)" 2304 local target="$(java-pkg_get-target)"
1963 2315
1964 2316
1965 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2317 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1966 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2318 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1967 2319
2320 # extra env variables
2321 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2322 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2323 # nested echo to remove leading/trailing spaces
2324 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2325 >> "${JAVA_PKG_ENV}" || die
2326 fi
2327
1968 # Strip unnecessary leading and trailing colons 2328 # Strip unnecessary leading and trailing colons
1969 # TODO try to cleanup if possible 2329 # TODO try to cleanup if possible
1970 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2330 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2331 else
2332 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2333 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2334 debug-print "write package.env."
1971 fi 2335 fi
1972} 2336}
1973 2337
1974# ------------------------------------------------------------------------------ 2338# ------------------------------------------------------------------------------
1975# @internal-function java-pkg_record-jar_ 2339# @internal-function java-pkg_record-jar_
1976# 2340#
1977# Record a dependency to the package.env 2341# Record an (optional) dependency to the package.env
1978# 2342# @param --optional - record dependency as optional
2343# @param $1 - package to record
2344# @param $2 - (optional) jar of package to record
1979# ------------------------------------------------------------------------------ 2345# ------------------------------------------------------------------------------
1980JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2346JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2347JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
1981 2348
1982java-pkg_record-jar_() { 2349java-pkg_record-jar_() {
1983 debug-print-function ${FUNCNAME} $* 2350 debug-print-function ${FUNCNAME} $*
2351
2352 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2353 if [[ "${1}" == "--optional" ]]; then
2354 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2355 shift
2356 fi
1984 2357
1985 local pkg=${1} jar=${2} append 2358 local pkg=${1} jar=${2} append
1986 if [[ -z "${jar}" ]]; then 2359 if [[ -z "${jar}" ]]; then
1987 append="${pkg}" 2360 append="${pkg}"
1988 else 2361 else
1989 append="$(basename ${jar})@${pkg}" 2362 append="$(basename ${jar})@${pkg}"
1990 fi 2363 fi
1991 2364
1992 echo ${append} >> ${JAVA_PKG_DEPEND} 2365 echo "${append}" >> "${depend_file}"
1993} 2366}
1994 2367
1995# ------------------------------------------------------------------------------ 2368# ------------------------------------------------------------------------------
1996# @internal-function java-pkg_append_ 2369# @internal-function java-pkg_append_
1997# 2370#
2057# 2430#
2058# ------------------------------------------------------------------------------ 2431# ------------------------------------------------------------------------------
2059java-pkg_setup-vm() { 2432java-pkg_setup-vm() {
2060 debug-print-function ${FUNCNAME} $* 2433 debug-print-function ${FUNCNAME} $*
2061 2434
2435 export LANG="C" LC_ALL="C"
2436
2062 local vendor="$(java-pkg_get-vm-vendor)" 2437 local vendor="$(java-pkg_get-vm-vendor)"
2063 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2438 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2064 addpredict "/dev/random" 2439 addpredict "/dev/random"
2065 elif [[ "${vendor}" == "ibm" ]]; then 2440 elif [[ "${vendor}" == "ibm" ]]; then
2066 addpredict "/proc/self/maps" 2441 addpredict "/proc/self/maps"
2067 addpredict "/proc/cpuinfo" 2442 addpredict "/proc/cpuinfo"
2068 export LANG="C" LC_ALL="C"
2069 elif [[ "${vendor}" == "jrockit" ]]; then 2443 elif [[ "${vendor}" == "jrockit" ]]; then
2070 addpredict "/proc/cpuinfo" 2444 addpredict "/proc/cpuinfo"
2071 fi 2445 fi
2072} 2446}
2073 2447
2177 2551
2178 #TODO If you know a better solution let us know. 2552 #TODO If you know a better solution let us know.
2179 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2553 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2180 2554
2181 local tann="${T}/announced-vm" 2555 local tann="${T}/announced-vm"
2556 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2557 # if people have for example modified eclasses some where
2182 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2558 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2183 # Add a check for setup/preinst phase... to avoid duplicate outputs
2184 # for when FEATURES=buildpkg
2185 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2186 then
2187 einfo "Using: $(java-config -f)" 2559 einfo "Using: $(java-config -f)"
2188 [[ ! -f "${tann}" ]] && touch "${tann}" 2560 [[ ! -f "${tann}" ]] && touch "${tann}"
2189 fi
2190 fi 2561 fi
2191 2562
2192 else 2563 else
2193 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2564 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2194 fi 2565 fi
2254 eerror "See ${log} for more details." 2625 eerror "See ${log} for more details."
2255 die "Incorrect bytecode found" 2626 die "Incorrect bytecode found"
2256 fi 2627 fi
2257} 2628}
2258 2629
2630# ----------------------------------------------------------------------------
2631# @internal-function java-pkg_ensure-dep
2632# Check that a package being used in jarfrom, getjars and getjar is contained
2633# within DEPEND or RDEPEND.
2634# @param $1 - empty - check both vars; "runtime" or "build" - check only
2635# RDEPEND, resp. DEPEND
2636# @param $2 - Package name and slot.
2637
2638java-pkg_ensure-dep() {
2639 debug-print-function ${FUNCNAME} $*
2640
2641 local limit_to="${1}"
2642 local target_pkg="${2}"
2643 local dev_error=""
2644
2645 local stripped_pkg=$(echo "${target_pkg}" | sed \
2646 's/-[0-9]*\(\.[0-9]\)*$//')
2647
2648 debug-print "Matching against: ${stripped_pkg}"
2649
2650 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2651 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2652 dev_error="${dev_error} declared in DEPEND."
2653 if is-java-strict; then
2654 eerror "${dev_error}"
2655 die "${dev_error}"
2656 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2657 eerror "${dev_error}"
2658 elog "Because you have this package installed the package will"
2659 elog "build without problems, but please report this to"
2660 elog "http://bugs.gentoo.org"
2661 fi
2662 fi
2663
2664 if [[ ${limit_to} != build ]]; then
2665 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2666 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2667 dev_error="The ebuild is attempting to use ${target_pkg},"
2668 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2669 dev_error="${dev_error} or PDEPEND."
2670 if is-java-strict; then
2671 eerror "${dev_error}"
2672 die "${dev_error}"
2673 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2674 eerror "${dev_error}"
2675 elog "The package will build without problems, but may fail to run"
2676 elog "if you don't have ${target_pkg} installed, so please report"
2677 elog "this to http://bugs.gentoo.org"
2678 fi
2679 fi
2680 fi
2681 fi
2682}
2683
2259# ------------------------------------------------------------------------------ 2684# ------------------------------------------------------------------------------
2260# @section-end internal 2685# @section-end internal
2261# ------------------------------------------------------------------------------ 2686# ------------------------------------------------------------------------------
2262 2687
2263java-pkg_check-phase() { 2688java-pkg_check-phase() {
2264 local phase=${1} 2689 local phase=${1}
2265 local funcname=${2} 2690 local funcname=${FUNCNAME[1]}
2266 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2691 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2267 java-pkg_announce-qa-violation \
2268 "${funcname} used outside of src_${phase}" 2692 local msg="${funcname} used outside of src_${phase}"
2693 java-pkg_announce-qa-violation "${msg}"
2269 fi 2694 fi
2270} 2695}
2271 2696
2272java-pkg_check-versioned-jar() { 2697java-pkg_check-versioned-jar() {
2273 local jar=${1} 2698 local jar=${1}
2282 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2707 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2283 fi 2708 fi
2284} 2709}
2285 2710
2286java-pkg_announce-qa-violation() { 2711java-pkg_announce-qa-violation() {
2287 if is-java-strict; then 2712 local nodie
2713 if [[ ${1} == "--nodie" ]]; then
2714 nodie="true"
2715 shift
2716 fi
2288 echo "Java QA Notice: $@" >&2 2717 echo "Java QA Notice: $@" >&2
2289 increment-qa-violations 2718 increment-qa-violations
2290 fi 2719 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2291} 2720}
2292 2721
2293increment-qa-violations() { 2722increment-qa-violations() {
2294 let "JAVA_PKG_QA_VIOLATIONS+=1" 2723 let "JAVA_PKG_QA_VIOLATIONS+=1"
2295 export JAVA_PKG_QA_VIOLATIONS 2724 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.101

  ViewVC Help
Powered by ViewVC 1.1.20