/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.90 Revision 1.129
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2005, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.90 2007/06/19 21:08:57 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.129 2009/06/07 08:22:42 ali_bush Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
57#WANT_ANT_TASKS 57#WANT_ANT_TASKS
58 58
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. At this moment it's 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
66 67
67# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
68# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
69# 70#
70# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
71# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
72# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
73# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.32 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.6 ${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#
194# 196#
195# @example 197# @example
196# java-pkg_doexamples demo 198# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/* 199# java-pkg_doexamples demo/* examples/*
198# 200#
201# @param --subdir - If the examples need a certain directory structure
199# @param $* - list of files to install 202# @param $* - list of files to install
200# ------------------------------------------------------------------------------ 203# ------------------------------------------------------------------------------
201java-pkg_doexamples() { 204java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $* 205 debug-print-function ${FUNCNAME} $*
203 206
204 [[ ${#} -lt 1 ]] && die "At least one argument needed" 207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205 208
206 java-pkg_check-phase install 209 java-pkg_check-phase install
207 210
208 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
209 if [[ ${#} = 1 && -d ${1} ]]; then 218 if [[ ${#} = 1 && -d ${1} ]]; then
210 ( # dont want to pollute calling env 219 ( # dont want to pollute calling env
211 insinto "${dest}" 220 insinto "${dest}"
212 doins -r ${1}/* 221 doins -r ${1}/*
213 ) || die "Installing examples failed" 222 ) || die "Installing examples failed"
282 done 291 done
283 292
284 java-pkg_do_write_ 293 java-pkg_do_write_
285} 294}
286 295
287
288# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
289# @internal-function depend-java-query 297# @internal-function depend-java-query
290# 298#
291# 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.
292# 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
357 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
358 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
359 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
360 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
361 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
362 die "${jar} does not exist" 371 die "${jar} does not exist"
363 fi 372 fi
364 done 373 done
365 374
366 java-pkg_do_write_ 375 java-pkg_do_write_
421# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
422# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
423java-pkg_doso() { 432java-pkg_doso() {
424 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
425 434
426 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
427 java-pkg_check-phase install 435 java-pkg_check-phase install
428 436
429 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
430 438
431 java-pkg_init_paths_ 439 java-pkg_init_paths_
432 440
433 local lib 441 local lib
434 # for each lib 442 # for each lib
437 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
438 # install if it isn't a symlink 446 # install if it isn't a symlink
439 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
440 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
441 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
442 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
443 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
444 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
445 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
446 else 454 else
447 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
448 ln -s "$(readlink "${lib}")" \
449 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
450 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
451 fi 457 fi
452 # otherwise die 458 # otherwise die
453 else 459 else
454 die "${lib} does not exist" 460 die "${lib} does not exist"
455 fi 461 fi
471java-pkg_regso() { 477java-pkg_regso() {
472 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
473 479
474 java-pkg_check-phase install 480 java-pkg_check-phase install
475 481
476 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
477 483
478 java-pkg_init_paths_ 484 java-pkg_init_paths_
479 485
480 local lib target_dir 486 local lib target_dir
481 for lib in "$@" ; do 487 for lib in "$@" ; do
548# ------------------------------------------------------------------------------ 554# ------------------------------------------------------------------------------
549# @ebuild-function java-pkg_dojavadoc 555# @ebuild-function java-pkg_dojavadoc
550# 556#
551# 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.
552# 558#
559# @param $1: optional --symlink creates to symlink like this for html
560# documentation bundles.
553# @param $1: - The javadoc root directory. 561# @param $2: - The javadoc root directory.
554# 562#
555# @example: 563# @example:
556# java-pkg_dojavadoc docs/api 564# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api
557# 566#
558# ------------------------------------------------------------------------------ 567# ------------------------------------------------------------------------------
559java-pkg_dojavadoc() { 568java-pkg_dojavadoc() {
560 debug-print-function ${FUNCNAME} $* 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
562 580
563 # QA checks 581 # QA checks
564 582
565 java-pkg_check-phase install 583 java-pkg_check-phase install
566 584
570 local msg="No index.html in javadoc directory" 588 local msg="No index.html in javadoc directory"
571 ewarn "${msg}" 589 ewarn "${msg}"
572 is-java-strict && die "${msg}" 590 is-java-strict && die "${msg}"
573 fi 591 fi
574 592
593 if [[ -e ${D}/${dest}/api ]]; then
594 eerror "${dest} already exists. Will not overwrite."
595 die "${dest}"
596 fi
597
575 # Renaming to match our directory layout 598 # Renaming to match our directory layout
576 599
577 local dir_to_install="${dir}" 600 local dir_to_install="${dir}"
578 if [[ "$(basename "${dir}")" != "api" ]]; then 601 if [[ "$(basename "${dir}")" != "api" ]]; then
579 dir_to_install="${T}/api" 602 dir_to_install="${T}/api"
581 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 604 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
582 fi 605 fi
583 606
584 # Actual installation 607 # Actual installation
585 608
586 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
587} 618}
588 619
589# ------------------------------------------------------------------------------ 620# ------------------------------------------------------------------------------
590# @ebuild-function java-pkg_dosrc 621# @ebuild-function java-pkg_dosrc
591# 622#
614 645
615 [[ ${#} -lt 1 ]] && die "At least one argument needed" 646 [[ ${#} -lt 1 ]] && die "At least one argument needed"
616 647
617 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 648 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
618 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 649 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
619 if is-java-strict; then 650 java-pkg_announce-qa-violation ${msg}
620 eerror "${msg}"
621 die "${msg}"
622 else
623 echo "${msg}"
624 echo "Please report this to http://bugs.gentoo.org."
625 fi
626 fi 651 fi
627 652
628 java-pkg_init_paths_ 653 java-pkg_init_paths_
629 654
630 local zip_name="${PN}-src.zip" 655 local zip_name="${PN}-src.zip"
830# @param $opt 855# @param $opt
831# --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.
832# (assumed automatically when called inside src_test) 857# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 858# --with-dependencies - get jars also from requested package's dependencies
834# 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.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 862# --into $dir - symlink jar(s) into $dir (must exist) instead of .
836# @param $1 - Package to get jars from, or comma-separated list of packages in 863# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used. 864# case other parameters are not used.
838# @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.
839# @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
844 debug-print-function ${FUNCNAME} $* 871 debug-print-function ${FUNCNAME} $*
845 872
846 local build_only="" 873 local build_only=""
847 local destdir="." 874 local destdir="."
848 local deep="" 875 local deep=""
876 local virtual=""
877 local record_jar=""
849 878
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 879 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 880
852 while [[ "${1}" == --* ]]; do 881 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 882 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 883 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 884 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 885 deep="--with-dependencies"
886 elif [[ "${1}" = "--virtual" ]]; then
887 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 888 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 889 destdir="${2}"
859 shift 890 shift
860 else 891 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 892 die "java-pkg_jar-from called with unknown parameter: ${1}"
864 done 895 done
865 896
866 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 897 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
867 898
868 [[ -z ${target_pkg} ]] && die "Must specify a package" 899 [[ -z ${target_pkg} ]] && die "Must specify a package"
900
901 if [[ "${EAPI}" == "1" ]]; then
902 target_pkg="${target_pkg//:/-}"
903 fi
869 904
870 # default destjar to the target jar 905 # default destjar to the target jar
871 [[ -z "${destjar}" ]] && destjar="${target_jar}" 906 [[ -z "${destjar}" ]] && destjar="${target_jar}"
872 907
873 local error_msg="There was a problem getting the classpath for ${target_pkg}." 908 local error_msg="There was a problem getting the classpath for ${target_pkg}."
882 for pkg in ${target_pkg//,/ }; do 917 for pkg in ${target_pkg//,/ }; do
883 java-pkg_ensure-dep "${build_only}" "${pkg}" 918 java-pkg_ensure-dep "${build_only}" "${pkg}"
884 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 919 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
885 done 920 done
886 # setting this disables further record-jar_ calls later 921 # setting this disables further record-jar_ calls later
887 build_only="build" 922 record_jar="true"
888 else 923 else
889 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 924 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
925 fi
926
927 # Record the entire virtual as a dependency so that
928 # no jars are missed.
929 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
930 java-pkg_record-jar_ "${target_pkg}"
931 # setting this disables further record-jars_ calls later
932 record_jar="true"
890 fi 933 fi
891 934
892 pushd ${destdir} > /dev/null \ 935 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 936 || die "failed to change directory to ${destdir}"
894 937
902 # If no specific target jar was indicated, link it 945 # If no specific target jar was indicated, link it
903 if [[ -z "${target_jar}" ]] ; then 946 if [[ -z "${target_jar}" ]] ; then
904 [[ -f "${target_jar}" ]] && rm "${target_jar}" 947 [[ -f "${target_jar}" ]] && rm "${target_jar}"
905 ln -snf "${jar}" \ 948 ln -snf "${jar}" \
906 || die "Failed to make symlink from ${jar} to ${jar_name}" 949 || die "Failed to make symlink from ${jar} to ${jar_name}"
950 if [[ -z "${record_jar}" ]]; then
951 if [[ -z "${build_only}" ]]; then
907 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 952 java-pkg_record-jar_ "${target_pkg}" "${jar}"
953 else
954 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
955 fi
956 fi
908 # otherwise, if the current jar is the target jar, link it 957 # otherwise, if the current jar is the target jar, link it
909 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 958 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
910 [[ -f "${destjar}" ]] && rm "${destjar}" 959 [[ -f "${destjar}" ]] && rm "${destjar}"
911 ln -snf "${jar}" "${destjar}" \ 960 ln -snf "${jar}" "${destjar}" \
912 || die "Failed to make symlink from ${jar} to ${destjar}" 961 || die "Failed to make symlink from ${jar} to ${destjar}"
962 if [[ -z "${record_jar}" ]]; then
963 if [[ -z "${build_only}" ]]; then
913 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 964 java-pkg_record-jar_ "${target_pkg}" "${jar}"
965 else
966 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
967 fi
968 fi
914 popd > /dev/null 969 popd > /dev/null
915 return 0 970 return 0
916 fi 971 fi
917 done 972 done
918 popd > /dev/null 973 popd > /dev/null
977 done 1032 done
978 1033
979 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1034 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
980 1035
981 1036
982 local classpath pkgs="${1}" 1037 local pkgs="${1}"
1038
1039 if [[ "${EAPI}" == "1" ]]; then
1040 pkgs="${pkgs//:/-}"
1041 fi
1042
983 jars="$(java-config ${deep} --classpath=${pkgs})" 1043 jars="$(java-config ${deep} --classpath=${pkgs})"
984 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1044 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
985 debug-print "${pkgs}:${jars}" 1045 debug-print "${pkgs}:${jars}"
986 1046
987 for pkg in ${pkgs//,/ }; do 1047 for pkg in ${pkgs//,/ }; do
988 java-pkg_ensure-dep "${build_only}" "${pkg}" 1048 java-pkg_ensure-dep "${build_only}" "${pkg}"
989 done 1049 done
990 1050
991 if [[ -z "${classpath}" ]]; then 1051 for pkg in ${pkgs//,/ }; do
992 classpath="${jars}"
993 else
994 classpath="${classpath}:${jars}"
995 fi
996
997 # Only record jars that aren't build-only
998 if [[ -z "${build_only}" ]]; then 1052 if [[ -z "${build_only}" ]]; then
999 for pkg in ${pkgs//,/ }; do
1000 java-pkg_record-jar_ "${pkg}" 1053 java-pkg_record-jar_ "${pkg}"
1054 else
1055 java-pkg_record-jar_ --build-only "${pkg}"
1056 fi
1001 done 1057 done
1002 fi
1003 1058
1004 echo "${classpath}" 1059 echo "${jars}"
1005} 1060}
1006 1061
1007# ------------------------------------------------------------------------------ 1062# ------------------------------------------------------------------------------
1008# @ebuild-function java-pkg_getjar 1063# @ebuild-function java-pkg_getjar
1009# 1064#
1018# @example-return 1073# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1074# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1075#
1021# @param $opt 1076# @param $opt
1022# --build-only - makes the jar not added into package.env DEPEND line. 1077# --build-only - makes the jar not added into package.env DEPEND line.
1078# --virtual - Packages passed to this function are to be handled as virtuals
1079# and will not have individual jar dependencies recorded.
1023# @param $1 - package to use 1080# @param $1 - package to use
1024# @param $2 - jar to get 1081# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1083java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1084 debug-print-function ${FUNCNAME} $*
1028 1085
1029 local build_only="" 1086 local build_only=""
1087 local virtual=""
1088 local record_jar=""
1030 1089
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1090 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1091
1033 while [[ "${1}" == --* ]]; do 1092 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1093 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1094 build_only="build"
1095 elif [[ "${1}" == "--virtual" ]]; then
1096 virtual="true"
1036 else 1097 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1098 die "java-pkg_getjar called with unknown parameter: ${1}"
1038 fi 1099 fi
1039 shift 1100 shift
1040 done 1101 done
1041 1102
1042 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1103 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1043 1104
1044 local pkg="${1}" target_jar="${2}" jar 1105 local pkg="${1}" target_jar="${2}" jar
1106
1107 if [[ "${EAPI}" == "1" ]]; then
1108 pkg="${pkg//:/-}"
1109 fi
1110
1045 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1111 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1046 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1112 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1047 1113
1048 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1114 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1049 local classpath 1115 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1116 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1117 [[ $? != 0 ]] && die ${error_msg}
1052 1118
1053 java-pkg_ensure-dep "${build_only}" "${pkg}" 1119 java-pkg_ensure-dep "${build_only}" "${pkg}"
1054 1120
1121 # Record the package(Virtual) as a dependency and then set build_only
1122 # So that individual jars are not recorded.
1123 if [[ -n "${virtual}" ]]; then
1124 if [[ -z "${build_only}" ]]; then
1125 java-pkg_record-jar_ "${pkg}"
1126 else
1127 java-pkg_record-jar_ --build-only "${pkg}"
1128 fi
1129 record_jar="true"
1130 fi
1131
1055 for jar in ${classpath//:/ }; do 1132 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1133 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1134 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1135 fi
1059 1136
1060 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1137 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1061 # Only record jars that aren't build-only 1138 # Only record jars that aren't build-only
1062 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1139 if [[ -z "${record_jar}" ]]; then
1140 if [[ -z "${build_only}" ]]; then
1141 java-pkg_record-jar_ "${pkg}" "${jar}"
1142 else
1143 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1144 fi
1145 fi
1063 echo "${jar}" 1146 echo "${jar}"
1064 return 0 1147 return 0
1065 fi 1148 fi
1066 done 1149 done
1067 1150
1103 1186
1104 local pkgs="${1}" 1187 local pkgs="${1}"
1105 local jar="${2}" 1188 local jar="${2}"
1106 1189
1107 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1190 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1191
1192 if [[ "${EAPI}" == "1" ]]; then
1193 pkgs="${pkgs//:/-}"
1194 fi
1108 1195
1109 if [[ -z "${jar}" ]]; then 1196 if [[ -z "${jar}" ]]; then
1110 for pkg in ${pkgs//,/ }; do 1197 for pkg in ${pkgs//,/ }; do
1111 java-pkg_ensure-dep runtime "${pkg}" 1198 java-pkg_ensure-dep runtime "${pkg}"
1112 java-pkg_record-jar_ "${pkg}" 1199 java-pkg_record-jar_ "${pkg}"
1154 1241
1155 local pkgs="${1}" 1242 local pkgs="${1}"
1156 local jar="${2}" 1243 local jar="${2}"
1157 1244
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1245 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1246
1247 if [[ "${EAPI}" == "1" ]]; then
1248 pkgs="${pkgs//:/-}"
1249 fi
1159 1250
1160 if [[ -z "${jar}" ]]; then 1251 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do 1252 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}" 1253 java-pkg_record-jar_ --optional "${pkg}"
1163 done 1254 done
1240# @section-begin helper 1331# @section-begin helper
1241# @section-summary Helper functions 1332# @section-summary Helper functions
1242# 1333#
1243# Various other functions to use from an ebuild 1334# Various other functions to use from an ebuild
1244# ------------------------------------------------------------------------------ 1335# ------------------------------------------------------------------------------
1245
1246# ------------------------------------------------------------------------------
1247# @ebuild-function java-pkg_need
1248#
1249# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1250# Currently supported virtuals are:
1251# javamail
1252# jdbc-stdext
1253# jaf
1254# jdbc-rowset
1255# jms
1256#
1257# @param $1 - Optionally indicate that the dependencies are controlled by
1258# a use flag by specifying '--use' Requires $2.
1259# @param $2 - USE flag which will enable the dependencies.
1260# @param $@ - virtual packages to add depenedencies for
1261# ------------------------------------------------------------------------------
1262# TODO rewrite to parse a line based declaration file instead -- karltk
1263#java-pkg_need() {
1264# debug-print-function ${FUNCNAME} $*
1265# local useflag
1266# if [[ ${1} == "--use" ]]; then
1267# useflag="${2}"
1268# shift 2
1269# fi
1270#
1271# if [[ -z ${1} ]]; then
1272# die "Must specify at least one virtual package."
1273# fi
1274#
1275# local depstr newdepstr
1276#
1277# for virtual in ${@}; do
1278# if has ${virtual} ${JAVA_PKG_VNEED}; then
1279# debug-print "Already registered virtual ${virtual}"
1280# continue
1281# fi
1282# case ${virtual} in
1283# javamail)
1284# debug-print "java-pkg_need: adding javamail dependencies"
1285# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1286# ;;
1287# jdbc-stdext)
1288# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1289# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1290# ;;
1291# jaf)
1292# debug-print "java-pkg_need: adding jaf dependencies"
1293# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1294# ;;
1295# jdbc-rowset)
1296# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1297# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1298# ;;
1299# jms)
1300# debug-print "java-pkg_need: adding jms dependencies"
1301# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1302# ;;
1303# *)
1304# die "Invalid virtual: ${virtual}"
1305# esac
1306#
1307# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1308#
1309# if [[ -n ${useflag} ]]; then
1310# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1311# else
1312# depstr="${depstr} ${newdepstr}"
1313# fi
1314# done
1315#
1316# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1317# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1318#
1319# export DEPEND="${DEPEND} ${depstr}"
1320# export RDEPEND="${RDEPEND} ${depstr}"
1321#}
1322 1336
1323# ------------------------------------------------------------------------------ 1337# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_find-normal-jars 1338# @ebuild-function java-pkg_find-normal-jars
1325# 1339#
1326# Find the files with suffix .jar file in the given directory or $WORKDIR 1340# Find the files with suffix .jar file in the given directory or $WORKDIR
1664 dodir /usr/share/ant/${TASKS_DIR} 1678 dodir /usr/share/ant/${TASKS_DIR}
1665 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1679 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1666} 1680}
1667 1681
1668# ------------------------------------------------------------------------------ 1682# ------------------------------------------------------------------------------
1669# @internal-function java-pkg_ant-tasks-from-deps
1670#
1671# Function to determine ANT_TASKS from DEPEND variable for backwards
1672# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1673# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1674# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1675# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1676# be a problem, the worst it can do is activace all tasks when not needed.
1677# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1678# insufficient dependencies, otherwise all available tasks are used for
1679# backwards compatilbility.
1680#
1681# @return "all" or "none"
1682# ------------------------------------------------------------------------------
1683java-pkg_ant-tasks-from-deps() {
1684 local found_ant found_ant_tasks
1685
1686 for dep in ${DEPEND}
1687 do
1688 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1689 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1690 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1691 done
1692
1693 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1694 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1695 echo "all"
1696 else
1697 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1698 # so we deactivate all tasks that may be installed
1699 echo "none"
1700 fi
1701}
1702
1703# ------------------------------------------------------------------------------
1704# @internal-function java-pkg_ant-tasks-depend 1683# @internal-function java-pkg_ant-tasks-depend
1705# 1684#
1706# Translates the WANT_ANT_TASKS variable into valid dependencies. 1685# Translates the WANT_ANT_TASKS variable into valid dependencies.
1707# ------------------------------------------------------------------------------ 1686# ------------------------------------------------------------------------------
1708java-pkg_ant-tasks-depend() { 1687java-pkg_ant-tasks-depend() {
1710 1689
1711 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1690 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1712 local DEP="" 1691 local DEP=""
1713 for i in ${WANT_ANT_TASKS} 1692 for i in ${WANT_ANT_TASKS}
1714 do 1693 do
1715 if [[ ${i} != ant-* ]]; then 1694 if [[ ${i} = ant-* ]]; then
1695 DEP="${DEP}dev-java/${i} "
1696 elif [[ ${i} = */*:* ]]; then
1697 DEP="${DEP}${i} "
1698 else
1716 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1699 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1717 return 1 1700 return 1
1718 fi 1701 fi
1719 DEP="${DEP}dev-java/${i} "
1720 done 1702 done
1721 echo ${DEP} 1703 echo ${DEP}
1722 return 0 1704 return 0
1723 else 1705 else
1724 return 0 1706 return 0
1741# ------------------------------------------------------------------------------ 1723# ------------------------------------------------------------------------------
1742ejunit() { 1724ejunit() {
1743 debug-print-function ${FUNCNAME} $* 1725 debug-print-function ${FUNCNAME} $*
1744 1726
1745 local pkgs 1727 local pkgs
1728 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1729 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1730 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done 1731 done
1732 fi
1749 1733
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1734 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1735 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}" 1736 cp="${2}:${cp}"
1753 shift 2 1737 shift 2
1763# ------------------------------------------------------------------------------ 1747# ------------------------------------------------------------------------------
1764# @section-end helper 1748# @section-end helper
1765# ------------------------------------------------------------------------------ 1749# ------------------------------------------------------------------------------
1766 1750
1767# ------------------------------------------------------------------------------ 1751# ------------------------------------------------------------------------------
1752# @eclass-src_prepare
1753#
1754# src_prepare Searches for bundled jars
1755# Don't call directly, but via java-pkg-2_src_prepare!
1756# ------------------------------------------------------------------------------
1757
1758java-utils-2_src_prepare() {
1759 [[ ${EBUILD_PHASE} == prepare ]] &&
1760 java-pkg_func-exists java_prepare && java_prepare
1761
1762 # Remember that eant will call this unless called via Portage
1763 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1764 echo "Searching for bundled jars:"
1765 java-pkg_find-normal-jars || echo "None found."
1766 echo "Searching for bundled classes (no output if none found):"
1767 find "${WORKDIR}" -name "*.class"
1768 echo "Search done."
1769 fi
1770 touch "${T}/java-utils-2_src_prepare-run"
1771}
1772
1773# ------------------------------------------------------------------------------
1774# @eclass-pkg_preinst
1775#
1776# pkg_preinst Searches for missing and unneeded dependencies
1777# Don't call directly, but via java-pkg-2_pkg_preinst!
1778# ------------------------------------------------------------------------------
1779
1780java-utils-2_pkg_preinst() {
1781 if is-java-strict; then
1782 if has_version dev-java/java-dep-check; then
1783 [[ -e "${JAVA_PKG_ENV}" ]] || return
1784 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1785 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1786 ewarn "Possibly unneeded dependencies found in package.env:"
1787 for dep in ${output}; do
1788 ewarn "\t${dep}"
1789 done
1790 fi
1791 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1792 ewarn "${output}"
1793 fi
1794 else
1795 eerror "Install dev-java/java-dep-check for dependency checking"
1796 fi
1797 fi
1798}
1799
1800# ------------------------------------------------------------------------------
1768# @section-begin build 1801# @section-begin build
1769# @section-summary Build functions 1802# @section-summary Build functions
1770# 1803#
1771# These are some functions for building a package. In particular, it consists of 1804# These are some functions for building a package. In particular, it consists of
1772# wrappers for javac and ant. 1805# wrappers for javac and ant.
1779# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1812# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1780# variables: 1813# variables:
1781# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1814# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1782# gentoo.classpath property. Be sure to call 1815# gentoo.classpath property. Be sure to call
1783# java-ant_rewrite-classpath in src_unpack. 1816# java-ant_rewrite-classpath in src_unpack.
1817# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1818# for build-time purposes, the dependency is not recorded to
1819# package.env!
1820# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1784# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1821# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1822# ------------------------------------------------------------------------------
1786eant() { 1823eant() {
1787 debug-print-function ${FUNCNAME} $* 1824 debug-print-function ${FUNCNAME} $*
1825
1826 if [[ ${EBUILD_PHASE} = compile ]]; then
1827 java-ant-2_src_configure
1828 java-utils-2_src_prepare
1829 fi
1788 1830
1789 if ! hasq java-ant-2 ${INHERITED}; then 1831 if ! hasq java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1832 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1833 java-pkg_announce-qa-violation "${msg}"
1792 fi 1834 fi
1793 1835
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1836 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1837
1796 java-pkg_init-compiler_ 1838 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1839 local compiler="${GENTOO_COMPILER}"
1798 1840
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1841 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1800
1801 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1842 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1843 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1844 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1845 fi
1805 1846
1811 # java-config -p 1852 # java-config -p
1812 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1853 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1813 if [[ -n ${build_compiler_deps} ]]; then 1854 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1855 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1856 fi
1816 fi
1817
1818 if is-java-strict; then
1819 einfo "Disabling system classpath for ant"
1820 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1821 fi 1857 fi
1822 1858
1823 for arg in "${@}"; do 1859 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1860 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1861 if is-java-strict; then
1834 echo "more info." 1870 echo "more info."
1835 fi 1871 fi
1836 fi 1872 fi
1837 done 1873 done
1838 1874
1839 # we use this in src_* so we run ant from / 1875 # parse WANT_ANT_TASKS for atoms
1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1876 local want_ant_tasks
1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1877 for i in ${WANT_ANT_TASKS}; do
1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1878 if [[ ${i} = */*:* ]]; then
1843 1879 i=${i#*/}
1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1880 i=${i%:0}
1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1881 want_ant_tasks+="${i/:/-} "
1846
1847 if is-java-strict; then
1848 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1849 if [[ -z "${ANT_TASKS}" ]]; then
1850 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1851 fi
1852 else 1882 else
1883 want_ant_tasks+="${i} "
1884 fi
1885 done
1886 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1887 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1888
1889 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1890 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1891
1853 # if ant-tasks is not set by ebuild or forced, activate all of them 1892 # if ant-tasks is not set by ebuild or forced, use none
1854 ANT_TASKS="${ANT_TASKS:-all}" 1893 ANT_TASKS="${ANT_TASKS:-none}"
1855 fi
1856 1894
1857 # at this point, ANT_TASKS should be "all", "none" or explicit list 1895 # at this point, ANT_TASKS should be "all", "none" or explicit list
1858 if [[ "${ANT_TASKS}" == "all" ]]; then 1896 if [[ "${ANT_TASKS}" == "all" ]]; then
1859 einfo "Using all available ANT_TASKS" 1897 einfo "Using all available ANT_TASKS"
1860 elif [[ "${ANT_TASKS}" == "none" ]]; then 1898 elif [[ "${ANT_TASKS}" == "none" ]]; then
1861 einfo "Disabling all optional ANT_TASKS" 1899 einfo "Disabling all optional ANT_TASKS"
1862 else 1900 else
1863 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1901 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1864 fi 1902 fi
1865 1903
1866 export ANT_TASKS 1904 export ANT_TASKS
1867 fi
1868 1905
1869 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1906 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1870 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1907 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1871 1908
1872 local gcp="${EANT_GENTOO_CLASSPATH}" 1909 local gcp="${EANT_GENTOO_CLASSPATH}"
1873 local getjarsarg="" 1910 local getjarsarg=""
1874 1911
1875 if [[ ${EBUILD_PHASE} = "test" ]]; then 1912 if [[ ${EBUILD_PHASE} = "test" ]]; then
1876 antflags="${antflags} -DJunit.present=true" 1913 antflags="${antflags} -DJunit.present=true"
1877 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1914 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1878 getjarsarg="--with-dependencies" 1915 getjarsarg="--with-dependencies"
1879 fi 1916 fi
1880 1917
1881 local cp 1918 local cp
1882 1919
1883 for atom in ${gcp}; do 1920 for atom in ${gcp}; do
1884 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1921 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1885 done 1922 done
1886 1923
1924 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1925
1887 if [[ ${cp} ]]; then 1926 if [[ ${cp} ]]; then
1888 # It seems ant does not like single quotes around ${cp} 1927 # It seems ant does not like single quotes around ${cp}
1928 cp=${cp#:}
1929 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1930 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1889 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1931 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1890 fi 1932 fi
1891 1933
1892 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1934 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1893 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1935 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1894 ant ${antflags} "${@}" || die "eant failed" 1936 ant ${antflags} "${@}" || die "eant failed"
1994# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2036# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1995# call it during each of the phases of the merge process. 2037# call it during each of the phases of the merge process.
1996# 2038#
1997# ----------------------------------------------------------------------------- 2039# -----------------------------------------------------------------------------
1998java-pkg_init() { 2040java-pkg_init() {
2041 debug-print-function ${FUNCNAME} $*
1999 unset JAVAC 2042 unset JAVAC
2000 unset JAVA_HOME 2043 unset JAVA_HOME
2044
2045 java-config --help >/dev/null || {
2046 eerror ""
2047 eerror "Can't run java-config --help"
2048 eerror "Have you upgraded python recently but haven't"
2049 eerror "run python-updater yet?"
2050 die "Can't run java-config --help"
2051 }
2001 2052
2002 # People do all kinds of weird things. 2053 # People do all kinds of weird things.
2003 # http://forums.gentoo.org/viewtopic-p-3943166.html 2054 # http://forums.gentoo.org/viewtopic-p-3943166.html
2004 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2055 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2005 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2056 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2011 ewarn "make.conf for example) to silence this warning or" 2062 ewarn "make.conf for example) to silence this warning or"
2012 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2063 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2013 fi 2064 fi
2014 2065
2015 if [[ -z ${accept} ]]; then 2066 if [[ -z ${accept} ]]; then
2067 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2068 # -version output
2016 unset _JAVA_OPTIONS 2069 unset _JAVA_OPTIONS
2017 # phase hooks make this run many times without this 2070 # phase hooks make this run many times without this
2018 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2071 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2019 fi 2072 fi
2020 2073
2074 if java-pkg_func-exists ant_src_unpack; then
2075 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2076 fi
2077
2021 java-pkg_init_paths_ 2078 java-pkg_init_paths_
2022 java-pkg_switch-vm 2079 java-pkg_switch-vm
2023 PATH=${JAVA_HOME}/bin:${PATH} 2080 PATH=${JAVA_HOME}/bin:${PATH}
2024 2081
2025 # TODO we will probably want to set JAVAC and JAVACFLAGS 2082 # TODO we will probably want to set JAVAC and JAVACFLAGS
2026 2083
2027 # Do some QA checks 2084 # Do some QA checks
2028 java-pkg_check-jikes 2085 java-pkg_check-jikes
2086
2087 # Can't use unset here because Portage does not save the unset
2088 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2029 2089
2030 # When users have crazy classpaths some packages can fail to compile. 2090 # When users have crazy classpaths some packages can fail to compile.
2031 # and everything should work with empty CLASSPATH. 2091 # and everything should work with empty CLASSPATH.
2032 # This also helps prevent unexpected dependencies on random things 2092 # This also helps prevent unexpected dependencies on random things
2033 # from the CLASSPATH. 2093 # from the CLASSPATH.
2034 unset CLASSPATH 2094 export CLASSPATH=
2035 2095
2036 # Unset external ANT_ stuff 2096 # Unset external ANT_ stuff
2037 unset ANT_TASKS 2097 export ANT_TASKS=
2038 unset ANT_OPTS 2098 export ANT_OPTS=
2099 export ANT_RESPECT_JAVA_HOME=
2039} 2100}
2040 2101
2041# ------------------------------------------------------------------------------ 2102# ------------------------------------------------------------------------------
2042# @function-internal java-pkg-init-compiler_ 2103# @function-internal java-pkg-init-compiler_
2043# 2104#
2134 done 2195 done
2135 2196
2136 # If it hasn't been defined already, default to javac 2197 # If it hasn't been defined already, default to javac
2137 if [[ -z ${GENTOO_COMPILER} ]]; then 2198 if [[ -z ${GENTOO_COMPILER} ]]; then
2138 if [[ -n ${compilers} ]]; then 2199 if [[ -n ${compilers} ]]; then
2139 einfo "No suitable compiler found: defaulting javac for compilation" 2200 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2140 else 2201 else
2141 # probably don't need to notify users about the default. 2202 # probably don't need to notify users about the default.
2142 :;#einfo "Defaulting to javac for compilation" 2203 :;#einfo "Defaulting to javac for compilation"
2143 fi 2204 fi
2205 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2206 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2207 else
2144 export GENTOO_COMPILER=javac 2208 export GENTOO_COMPILER=javac
2209 fi
2145 else 2210 else
2146 einfo "Using ${GENTOO_COMPILER} for compilation" 2211 einfo "Using ${GENTOO_COMPILER} for compilation"
2147 fi 2212 fi
2148 2213
2149} 2214}
2165 fi 2230 fi
2166 2231
2167 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2232 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2168 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2233 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2169 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2234 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2235 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2236 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2170 2237
2171 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2238 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2172 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2239 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2173 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2240 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2174 2241
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2265 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2199 # Create package.env 2266 # Create package.env
2200 ( 2267 (
2201 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2268 echo "DESCRIPTION=\"${DESCRIPTION}\""
2202 echo "GENERATION=\"2\"" 2269 echo "GENERATION=\"2\""
2270 echo "SLOT=\"${SLOT}\""
2271 echo "CATEGORY=\"${CATEGORY}\""
2272 echo "PVR=\"${PVR}\""
2203 2273
2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2274 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2275 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2276 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2277 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2208 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2278 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2209 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2279 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2210 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2280 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2211 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2281 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2282 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2283 && echo "BUILD_DEPEND=\"$(cat "${JAVA_PKG_BUILD_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2212 ) > "${JAVA_PKG_ENV}" 2284 ) > "${JAVA_PKG_ENV}"
2213 2285
2214 # register target/source 2286 # register target/source
2215 local target="$(java-pkg_get-target)" 2287 local target="$(java-pkg_get-target)"
2216 local source="$(java-pkg_get-source)" 2288 local source="$(java-pkg_get-source)"
2249# ------------------------------------------------------------------------------ 2321# ------------------------------------------------------------------------------
2250# @internal-function java-pkg_record-jar_ 2322# @internal-function java-pkg_record-jar_
2251# 2323#
2252# Record an (optional) dependency to the package.env 2324# Record an (optional) dependency to the package.env
2253# @param --optional - record dependency as optional 2325# @param --optional - record dependency as optional
2326# @param --build - record dependency as build_only
2254# @param $1 - package to record 2327# @param $1 - package to record
2255# @param $2 - (optional) jar of package to record 2328# @param $2 - (optional) jar of package to record
2256# ------------------------------------------------------------------------------ 2329# ------------------------------------------------------------------------------
2257JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2330JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2258JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2331JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2332JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2259 2333
2260java-pkg_record-jar_() { 2334java-pkg_record-jar_() {
2261 debug-print-function ${FUNCNAME} $* 2335 debug-print-function ${FUNCNAME} $*
2262 2336
2263 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2337 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2264 if [[ "${1}" == "--optional" ]]; then 2338 case "${1}" in
2265 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2339 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2266 shift 2340 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2267 fi 2341 esac
2268 2342
2269 local pkg=${1} jar=${2} append 2343 local pkg=${1} jar=${2} append
2270 if [[ -z "${jar}" ]]; then 2344 if [[ -z "${jar}" ]]; then
2271 append="${pkg}" 2345 append="${pkg}"
2272 else 2346 else
2325# 2399#
2326# @return 0 - function is declared 2400# @return 0 - function is declared
2327# @return 1 - function is undeclared 2401# @return 1 - function is undeclared
2328# ------------------------------------------------------------------------------ 2402# ------------------------------------------------------------------------------
2329java-pkg_func-exists() { 2403java-pkg_func-exists() {
2330 if [[ -n "$(declare -f ${1})" ]]; then 2404 declare -F ${1} > /dev/null
2331 return 0
2332 else
2333 return 1
2334 fi
2335} 2405}
2336 2406
2337# ------------------------------------------------------------------------------ 2407# ------------------------------------------------------------------------------
2338# @internal-function java-pkg_setup-vm 2408# @internal-function java-pkg_setup-vm
2339# 2409#
2423 # If you're forcing the VM, I hope you know what your doing... 2493 # If you're forcing the VM, I hope you know what your doing...
2424 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2494 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2425 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2495 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2426 # if we're allowed to switch the vm... 2496 # if we're allowed to switch the vm...
2427 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2497 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2428 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2498 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2429 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2430 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2431 else
2432 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2499 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2433 fi
2434 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2500 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2435 eerror "Unable to determine VM for building from dependencies:" 2501 eerror "Unable to determine VM for building from dependencies:"
2436 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2502 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2437 echo "VNEED: ${JAVA_PKG_VNEED}"
2438 die "Failed to determine VM for building." 2503 die "Failed to determine VM for building."
2439 else 2504 else
2440 export GENTOO_VM 2505 export GENTOO_VM
2441 fi 2506 fi
2442 # otherwise just make sure the current VM is sufficient 2507 # otherwise just make sure the current VM is sufficient
2462 2527
2463 #TODO If you know a better solution let us know. 2528 #TODO If you know a better solution let us know.
2464 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2529 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2465 2530
2466 local tann="${T}/announced-vm" 2531 local tann="${T}/announced-vm"
2532 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2533 # if people have for example modified eclasses some where
2467 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2534 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2468 # Add a check for setup/preinst phase... to avoid duplicate outputs
2469 # for when FEATURES=buildpkg
2470 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2471 then
2472 einfo "Using: $(java-config -f)" 2535 einfo "Using: $(java-config -f)"
2473 [[ ! -f "${tann}" ]] && touch "${tann}" 2536 [[ ! -f "${tann}" ]] && touch "${tann}"
2474 fi
2475 fi 2537 fi
2476 2538
2477 else 2539 else
2478 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2540 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2479 fi 2541 fi
2518# not. 2580# not.
2519# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2581# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2520# ------------------------------------------------------------------------------ 2582# ------------------------------------------------------------------------------
2521java-pkg_verify-classes() { 2583java-pkg_verify-classes() {
2522 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2584 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2585
2586 local version_verify="/usr/bin/class-version-verify.py"
2587
2588 if [[ ! -x "${version_verify}" ]]; then
2589 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2590 fi
2591
2592 if [[ ! -x "${version_verify}" ]]; then
2593 ewarn "Unable to perform class version checks as"
2594 ewarn "class-version-verify.py is unavailable"
2595 ewarn "Please install dev-java/javatoolkit."
2596 return
2597 fi
2598
2523 local target=$(java-pkg_get-target) 2599 local target=$(java-pkg_get-target)
2524 local result 2600 local result
2525 local log="${T}/class-version-verify.log" 2601 local log="${T}/class-version-verify.log"
2526 if [[ -n "${1}" ]]; then 2602 if [[ -n "${1}" ]]; then
2527 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2603 ${version_verify} -v -t ${target} "${1}" > "${log}"
2528 result=$? 2604 result=$?
2529 else 2605 else
2530 ebegin "Verifying java class versions (target: ${target})" 2606 ebegin "Verifying java class versions (target: ${target})"
2531 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2607 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2532 result=$? 2608 result=$?
2533 eend ${result} 2609 eend ${result}
2534 fi 2610 fi
2535 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2611 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2536 if [[ ${result} != 0 ]]; then 2612 if [[ ${result} != 0 ]]; then
2641is-java-strict() { 2717is-java-strict() {
2642 [[ -n ${JAVA_PKG_STRICT} ]] 2718 [[ -n ${JAVA_PKG_STRICT} ]]
2643 return $? 2719 return $?
2644} 2720}
2645 2721
2722
2646# ------------------------------------------------------------------------------ 2723# ------------------------------------------------------------------------------
2647# @eclass-end 2724# @eclass-end
2648# ------------------------------------------------------------------------------ 2725# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20