/[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.136
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.136 2011/03/15 19:53:05 serkan Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
57#WANT_ANT_TASKS 57#WANT_ANT_TASKS
58 58
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. At this moment it's 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 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.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
75 94
76# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 97# @variable-default yes
79# 98#
194# 213#
195# @example 214# @example
196# java-pkg_doexamples demo 215# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/* 216# java-pkg_doexamples demo/* examples/*
198# 217#
218# @param --subdir - If the examples need a certain directory structure
199# @param $* - list of files to install 219# @param $* - list of files to install
200# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
201java-pkg_doexamples() { 221java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $* 222 debug-print-function ${FUNCNAME} $*
203 223
204 [[ ${#} -lt 1 ]] && die "At least one argument needed" 224 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205 225
206 java-pkg_check-phase install 226 java-pkg_check-phase install
207 227
208 local dest=/usr/share/doc/${PF}/examples 228 local dest=/usr/share/doc/${PF}/examples
229 if [[ ${1} == --subdir ]]; then
230 local dest=${dest}/${2}
231 dodir ${dest}
232 shift 2
233 fi
234
209 if [[ ${#} = 1 && -d ${1} ]]; then 235 if [[ ${#} = 1 && -d ${1} ]]; then
210 ( # dont want to pollute calling env 236 ( # dont want to pollute calling env
211 insinto "${dest}" 237 insinto "${dest}"
212 doins -r ${1}/* 238 doins -r ${1}/*
213 ) || die "Installing examples failed" 239 ) || die "Installing examples failed"
282 done 308 done
283 309
284 java-pkg_do_write_ 310 java-pkg_do_write_
285} 311}
286 312
287
288# ------------------------------------------------------------------------------ 313# ------------------------------------------------------------------------------
289# @internal-function depend-java-query 314# @internal-function depend-java-query
290# 315#
291# Wrapper for the depend-java-query binary to enable passing USE in env. 316# Wrapper for the depend-java-query binary to enable passing USE in env.
292# Using env variables keeps this eclass working with java-config versions that 317# Using env variables keeps this eclass working with java-config versions that
357 if [[ ${jar} = *\** ]]; then 382 if [[ ${jar} = *\** ]]; then
358 eerror "The argument ${jar} to ${FUNCNAME}" 383 eerror "The argument ${jar} to ${FUNCNAME}"
359 eerror "has * in it. If you want it to glob in" 384 eerror "has * in it. If you want it to glob in"
360 eerror '${D} add ${D} to the argument.' 385 eerror '${D} add ${D} to the argument.'
361 fi 386 fi
387 debug-print "${jar} or ${D}${jar} not found"
362 die "${jar} does not exist" 388 die "${jar} does not exist"
363 fi 389 fi
364 done 390 done
365 391
366 java-pkg_do_write_ 392 java-pkg_do_write_
421# @param $@ - JNI libraries to install 447# @param $@ - JNI libraries to install
422# ------------------------------------------------------------------------------ 448# ------------------------------------------------------------------------------
423java-pkg_doso() { 449java-pkg_doso() {
424 debug-print-function ${FUNCNAME} $* 450 debug-print-function ${FUNCNAME} $*
425 451
426 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
427 java-pkg_check-phase install 452 java-pkg_check-phase install
428 453
429 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 454 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
430 455
431 java-pkg_init_paths_ 456 java-pkg_init_paths_
432 457
433 local lib 458 local lib
434 # for each lib 459 # for each lib
437 if [[ -e "${lib}" ]] ; then 462 if [[ -e "${lib}" ]] ; then
438 # install if it isn't a symlink 463 # install if it isn't a symlink
439 if [[ ! -L "${lib}" ]] ; then 464 if [[ ! -L "${lib}" ]] ; then
440 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 465 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
441 INSOPTIONS="${LIBOPTIONS}" \ 466 INSOPTIONS="${LIBOPTIONS}" \
442 doins "${lib}" || "failed to install ${lib}" 467 doins "${lib}" || die "failed to install ${lib}"
443 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 468 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
444 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 469 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
445 # otherwise make a symlink to the symlink's origin 470 # otherwise make a symlink to the symlink's origin
446 else 471 else
447 # TODO use dosym 472 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" 473 debug-print "${lib} is a symlink, linking accordantly"
451 fi 474 fi
452 # otherwise die 475 # otherwise die
453 else 476 else
454 die "${lib} does not exist" 477 die "${lib} does not exist"
455 fi 478 fi
471java-pkg_regso() { 494java-pkg_regso() {
472 debug-print-function ${FUNCNAME} $* 495 debug-print-function ${FUNCNAME} $*
473 496
474 java-pkg_check-phase install 497 java-pkg_check-phase install
475 498
476 [[ ${#} -lt 1 ]] && "at least one argument needed" 499 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
477 500
478 java-pkg_init_paths_ 501 java-pkg_init_paths_
479 502
480 local lib target_dir 503 local lib target_dir
481 for lib in "$@" ; do 504 for lib in "$@" ; do
548# ------------------------------------------------------------------------------ 571# ------------------------------------------------------------------------------
549# @ebuild-function java-pkg_dojavadoc 572# @ebuild-function java-pkg_dojavadoc
550# 573#
551# Installs javadoc documentation. This should be controlled by the doc use flag. 574# Installs javadoc documentation. This should be controlled by the doc use flag.
552# 575#
576# @param $1: optional --symlink creates to symlink like this for html
577# documentation bundles.
553# @param $1: - The javadoc root directory. 578# @param $2: - The javadoc root directory.
554# 579#
555# @example: 580# @example:
556# java-pkg_dojavadoc docs/api 581# java-pkg_dojavadoc docs/api
582# java-pkg_dojavadoc --symlink apidocs docs/api
557# 583#
558# ------------------------------------------------------------------------------ 584# ------------------------------------------------------------------------------
559java-pkg_dojavadoc() { 585java-pkg_dojavadoc() {
560 debug-print-function ${FUNCNAME} $* 586 debug-print-function ${FUNCNAME} $*
587
588 # For html documentation bundles that link to Javadoc
589 local symlink
590 if [[ ${1} = --symlink ]]; then
591 symlink=${2}
592 shift 2
593 fi
594
561 local dir="$1" 595 local dir="$1"
596 local dest=/usr/share/doc/${PF}/html
562 597
563 # QA checks 598 # QA checks
564 599
565 java-pkg_check-phase install 600 java-pkg_check-phase install
566 601
570 local msg="No index.html in javadoc directory" 605 local msg="No index.html in javadoc directory"
571 ewarn "${msg}" 606 ewarn "${msg}"
572 is-java-strict && die "${msg}" 607 is-java-strict && die "${msg}"
573 fi 608 fi
574 609
610 if [[ -e ${D}/${dest}/api ]]; then
611 eerror "${dest} already exists. Will not overwrite."
612 die "${dest}"
613 fi
614
575 # Renaming to match our directory layout 615 # Renaming to match our directory layout
576 616
577 local dir_to_install="${dir}" 617 local dir_to_install="${dir}"
578 if [[ "$(basename "${dir}")" != "api" ]]; then 618 if [[ "$(basename "${dir}")" != "api" ]]; then
579 dir_to_install="${T}/api" 619 dir_to_install="${T}/api"
581 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 621 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
582 fi 622 fi
583 623
584 # Actual installation 624 # Actual installation
585 625
586 java-pkg_dohtml -r ${dir_to_install} 626 java-pkg_dohtml -r "${dir_to_install}"
627
628 # Let's make a symlink to the directory we have everything else under
629 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
630
631 if [[ ${symlink} ]]; then
632 debug-print "symlinking ${dest}/{api,${symlink}}"
633 dosym ${dest}/{api,${symlink}} || die
634 fi
587} 635}
588 636
589# ------------------------------------------------------------------------------ 637# ------------------------------------------------------------------------------
590# @ebuild-function java-pkg_dosrc 638# @ebuild-function java-pkg_dosrc
591# 639#
614 662
615 [[ ${#} -lt 1 ]] && die "At least one argument needed" 663 [[ ${#} -lt 1 ]] && die "At least one argument needed"
616 664
617 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 665 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
618 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 666 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
619 if is-java-strict; then 667 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 668 fi
627 669
628 java-pkg_init_paths_ 670 java-pkg_init_paths_
629 671
630 local zip_name="${PN}-src.zip" 672 local zip_name="${PN}-src.zip"
830# @param $opt 872# @param $opt
831# --build-only - makes the jar(s) not added into package.env DEPEND line. 873# --build-only - makes the jar(s) not added into package.env DEPEND line.
832# (assumed automatically when called inside src_test) 874# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 875# --with-dependencies - get jars also from requested package's dependencies
834# transitively. 876# transitively.
877# --virtual - Packages passed to this function are to be handled as virtuals
878# and will not have individual jar dependencies recorded.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 879# --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 880# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used. 881# case other parameters are not used.
838# @param $2 - jar from package. If not specified, all jars will be used. 882# @param $2 - jar from package. If not specified, all jars will be used.
839# @param $3 - When a single jar is specified, destination filename of the 883# @param $3 - When a single jar is specified, destination filename of the
844 debug-print-function ${FUNCNAME} $* 888 debug-print-function ${FUNCNAME} $*
845 889
846 local build_only="" 890 local build_only=""
847 local destdir="." 891 local destdir="."
848 local deep="" 892 local deep=""
893 local virtual=""
894 local record_jar=""
849 895
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 896 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 897
852 while [[ "${1}" == --* ]]; do 898 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 899 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 900 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 901 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 902 deep="--with-dependencies"
903 elif [[ "${1}" = "--virtual" ]]; then
904 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 905 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 906 destdir="${2}"
859 shift 907 shift
860 else 908 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 909 die "java-pkg_jar-from called with unknown parameter: ${1}"
864 done 912 done
865 913
866 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 914 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
867 915
868 [[ -z ${target_pkg} ]] && die "Must specify a package" 916 [[ -z ${target_pkg} ]] && die "Must specify a package"
917
918 if [[ "${EAPI}" == "1" ]]; then
919 target_pkg="${target_pkg//:/-}"
920 fi
869 921
870 # default destjar to the target jar 922 # default destjar to the target jar
871 [[ -z "${destjar}" ]] && destjar="${target_jar}" 923 [[ -z "${destjar}" ]] && destjar="${target_jar}"
872 924
873 local error_msg="There was a problem getting the classpath for ${target_pkg}." 925 local error_msg="There was a problem getting the classpath for ${target_pkg}."
882 for pkg in ${target_pkg//,/ }; do 934 for pkg in ${target_pkg//,/ }; do
883 java-pkg_ensure-dep "${build_only}" "${pkg}" 935 java-pkg_ensure-dep "${build_only}" "${pkg}"
884 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 936 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
885 done 937 done
886 # setting this disables further record-jar_ calls later 938 # setting this disables further record-jar_ calls later
887 build_only="build" 939 record_jar="true"
888 else 940 else
889 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 941 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
942 fi
943
944 # Record the entire virtual as a dependency so that
945 # no jars are missed.
946 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
947 java-pkg_record-jar_ "${target_pkg}"
948 # setting this disables further record-jars_ calls later
949 record_jar="true"
890 fi 950 fi
891 951
892 pushd ${destdir} > /dev/null \ 952 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 953 || die "failed to change directory to ${destdir}"
894 954
902 # If no specific target jar was indicated, link it 962 # If no specific target jar was indicated, link it
903 if [[ -z "${target_jar}" ]] ; then 963 if [[ -z "${target_jar}" ]] ; then
904 [[ -f "${target_jar}" ]] && rm "${target_jar}" 964 [[ -f "${target_jar}" ]] && rm "${target_jar}"
905 ln -snf "${jar}" \ 965 ln -snf "${jar}" \
906 || die "Failed to make symlink from ${jar} to ${jar_name}" 966 || die "Failed to make symlink from ${jar} to ${jar_name}"
967 if [[ -z "${record_jar}" ]]; then
968 if [[ -z "${build_only}" ]]; then
907 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 969 java-pkg_record-jar_ "${target_pkg}" "${jar}"
970 else
971 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
972 fi
973 fi
908 # otherwise, if the current jar is the target jar, link it 974 # otherwise, if the current jar is the target jar, link it
909 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 975 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
910 [[ -f "${destjar}" ]] && rm "${destjar}" 976 [[ -f "${destjar}" ]] && rm "${destjar}"
911 ln -snf "${jar}" "${destjar}" \ 977 ln -snf "${jar}" "${destjar}" \
912 || die "Failed to make symlink from ${jar} to ${destjar}" 978 || die "Failed to make symlink from ${jar} to ${destjar}"
979 if [[ -z "${record_jar}" ]]; then
980 if [[ -z "${build_only}" ]]; then
913 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 981 java-pkg_record-jar_ "${target_pkg}" "${jar}"
982 else
983 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
984 fi
985 fi
914 popd > /dev/null 986 popd > /dev/null
915 return 0 987 return 0
916 fi 988 fi
917 done 989 done
918 popd > /dev/null 990 popd > /dev/null
977 done 1049 done
978 1050
979 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1051 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
980 1052
981 1053
982 local classpath pkgs="${1}" 1054 local pkgs="${1}"
1055
1056 if [[ "${EAPI}" == "1" ]]; then
1057 pkgs="${pkgs//:/-}"
1058 fi
1059
983 jars="$(java-config ${deep} --classpath=${pkgs})" 1060 jars="$(java-config ${deep} --classpath=${pkgs})"
984 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1061 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
985 debug-print "${pkgs}:${jars}" 1062 debug-print "${pkgs}:${jars}"
986 1063
987 for pkg in ${pkgs//,/ }; do 1064 for pkg in ${pkgs//,/ }; do
988 java-pkg_ensure-dep "${build_only}" "${pkg}" 1065 java-pkg_ensure-dep "${build_only}" "${pkg}"
989 done 1066 done
990 1067
991 if [[ -z "${classpath}" ]]; then 1068 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 1069 if [[ -z "${build_only}" ]]; then
999 for pkg in ${pkgs//,/ }; do
1000 java-pkg_record-jar_ "${pkg}" 1070 java-pkg_record-jar_ "${pkg}"
1071 else
1072 java-pkg_record-jar_ --build-only "${pkg}"
1073 fi
1001 done 1074 done
1002 fi
1003 1075
1004 echo "${classpath}" 1076 echo "${jars}"
1005} 1077}
1006 1078
1007# ------------------------------------------------------------------------------ 1079# ------------------------------------------------------------------------------
1008# @ebuild-function java-pkg_getjar 1080# @ebuild-function java-pkg_getjar
1009# 1081#
1018# @example-return 1090# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1091# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1092#
1021# @param $opt 1093# @param $opt
1022# --build-only - makes the jar not added into package.env DEPEND line. 1094# --build-only - makes the jar not added into package.env DEPEND line.
1095# --virtual - Packages passed to this function are to be handled as virtuals
1096# and will not have individual jar dependencies recorded.
1023# @param $1 - package to use 1097# @param $1 - package to use
1024# @param $2 - jar to get 1098# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1099# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1100java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1101 debug-print-function ${FUNCNAME} $*
1028 1102
1029 local build_only="" 1103 local build_only=""
1104 local virtual=""
1105 local record_jar=""
1030 1106
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1107 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1108
1033 while [[ "${1}" == --* ]]; do 1109 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1110 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1111 build_only="build"
1112 elif [[ "${1}" == "--virtual" ]]; then
1113 virtual="true"
1036 else 1114 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1115 die "java-pkg_getjar called with unknown parameter: ${1}"
1038 fi 1116 fi
1039 shift 1117 shift
1040 done 1118 done
1041 1119
1042 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1120 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1043 1121
1044 local pkg="${1}" target_jar="${2}" jar 1122 local pkg="${1}" target_jar="${2}" jar
1123
1124 if [[ "${EAPI}" == "1" ]]; then
1125 pkg="${pkg//:/-}"
1126 fi
1127
1045 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1128 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1046 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1129 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1047 1130
1048 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1131 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1049 local classpath 1132 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1133 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1134 [[ $? != 0 ]] && die ${error_msg}
1052 1135
1053 java-pkg_ensure-dep "${build_only}" "${pkg}" 1136 java-pkg_ensure-dep "${build_only}" "${pkg}"
1054 1137
1138 # Record the package(Virtual) as a dependency and then set build_only
1139 # So that individual jars are not recorded.
1140 if [[ -n "${virtual}" ]]; then
1141 if [[ -z "${build_only}" ]]; then
1142 java-pkg_record-jar_ "${pkg}"
1143 else
1144 java-pkg_record-jar_ --build-only "${pkg}"
1145 fi
1146 record_jar="true"
1147 fi
1148
1055 for jar in ${classpath//:/ }; do 1149 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1150 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1151 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1152 fi
1059 1153
1060 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1154 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1061 # Only record jars that aren't build-only 1155 # Only record jars that aren't build-only
1062 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1156 if [[ -z "${record_jar}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}" "${jar}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1161 fi
1162 fi
1063 echo "${jar}" 1163 echo "${jar}"
1064 return 0 1164 return 0
1065 fi 1165 fi
1066 done 1166 done
1067 1167
1103 1203
1104 local pkgs="${1}" 1204 local pkgs="${1}"
1105 local jar="${2}" 1205 local jar="${2}"
1106 1206
1107 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1207 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1208
1209 if [[ "${EAPI}" == "1" ]]; then
1210 pkgs="${pkgs//:/-}"
1211 fi
1108 1212
1109 if [[ -z "${jar}" ]]; then 1213 if [[ -z "${jar}" ]]; then
1110 for pkg in ${pkgs//,/ }; do 1214 for pkg in ${pkgs//,/ }; do
1111 java-pkg_ensure-dep runtime "${pkg}" 1215 java-pkg_ensure-dep runtime "${pkg}"
1112 java-pkg_record-jar_ "${pkg}" 1216 java-pkg_record-jar_ "${pkg}"
1155 local pkgs="${1}" 1259 local pkgs="${1}"
1156 local jar="${2}" 1260 local jar="${2}"
1157 1261
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1262 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159 1263
1264 if [[ "${EAPI}" == "1" ]]; then
1265 pkgs="${pkgs//:/-}"
1266 fi
1267
1160 if [[ -z "${jar}" ]]; then 1268 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do 1269 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}" 1270 java-pkg_record-jar_ --optional "${pkg}"
1163 done 1271 done
1164 else 1272 else
1193 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1301 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1194 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1302 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1195 1303
1196 java-pkg_do_write_ 1304 java-pkg_do_write_
1197} 1305}
1306
1307# ------------------------------------------------------------------------------
1308# @ebuild-function java-pkg_get-bootclasspath
1309#
1310# Returns classpath of a given bootclasspath-providing package version.
1311#
1312# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1313# of the current JDK
1314# ------------------------------------------------------------------------------
1315
1316java-pkg_get-bootclasspath() {
1317 local version="${1}"
1318
1319 local bcp
1320 case "${version}" in
1321 auto)
1322 bcp="$(java-config -g BOOTCLASSPATH)"
1323 ;;
1324 1.5)
1325 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1326 ;;
1327 *)
1328 eerror "unknown parameter of java-pkg_get-bootclasspath"
1329 die "unknown parameter of java-pkg_get-bootclasspath"
1330 ;;
1331 esac
1332
1333 echo "${bcp}"
1334}
1335
1198 1336
1199# This function reads stdin, and based on that input, figures out how to 1337# This function reads stdin, and based on that input, figures out how to
1200# populate jars from the filesystem. 1338# populate jars from the filesystem.
1201# Need to figure out a good way of making use of this, ie be able to use a 1339# Need to figure out a good way of making use of this, ie be able to use a
1202# string that was built instead of stdin 1340# string that was built instead of stdin
1240# @section-begin helper 1378# @section-begin helper
1241# @section-summary Helper functions 1379# @section-summary Helper functions
1242# 1380#
1243# Various other functions to use from an ebuild 1381# Various other functions to use from an ebuild
1244# ------------------------------------------------------------------------------ 1382# ------------------------------------------------------------------------------
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 1383
1323# ------------------------------------------------------------------------------ 1384# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_find-normal-jars 1385# @ebuild-function java-pkg_find-normal-jars
1325# 1386#
1326# Find the files with suffix .jar file in the given directory or $WORKDIR 1387# Find the files with suffix .jar file in the given directory or $WORKDIR
1664 dodir /usr/share/ant/${TASKS_DIR} 1725 dodir /usr/share/ant/${TASKS_DIR}
1665 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1726 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1666} 1727}
1667 1728
1668# ------------------------------------------------------------------------------ 1729# ------------------------------------------------------------------------------
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 1730# @internal-function java-pkg_ant-tasks-depend
1705# 1731#
1706# Translates the WANT_ANT_TASKS variable into valid dependencies. 1732# Translates the WANT_ANT_TASKS variable into valid dependencies.
1707# ------------------------------------------------------------------------------ 1733# ------------------------------------------------------------------------------
1708java-pkg_ant-tasks-depend() { 1734java-pkg_ant-tasks-depend() {
1710 1736
1711 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1737 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1712 local DEP="" 1738 local DEP=""
1713 for i in ${WANT_ANT_TASKS} 1739 for i in ${WANT_ANT_TASKS}
1714 do 1740 do
1715 if [[ ${i} != ant-* ]]; then 1741 if [[ ${i} = ant-* ]]; then
1742 DEP="${DEP}dev-java/${i} "
1743 elif [[ ${i} = */*:* ]]; then
1744 DEP="${DEP}${i} "
1745 else
1716 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1746 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1717 return 1 1747 return 1
1718 fi 1748 fi
1719 DEP="${DEP}dev-java/${i} "
1720 done 1749 done
1721 echo ${DEP} 1750 echo ${DEP}
1722 return 0 1751 return 0
1723 else 1752 else
1724 return 0 1753 return 0
1725 fi 1754 fi
1726} 1755}
1727 1756
1757
1728# ------------------------------------------------------------------------------ 1758# ------------------------------------------------------------------------------
1729# @ebuild-function ejunit 1759# @internal-function ejunit_
1730# 1760#
1731# Junit wrapper function. Makes it easier to run the tests and checks for 1761# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1732# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1762# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1733# 1763#
1734# Examples: 1764# @param $1 - junit package (junit or junit-4)
1735# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1736# ejunit org.blinkenlights.jid3.test.AllTests
1737#
1738# @param $1 - -cp or -classpath 1765# @param $2 - -cp or -classpath
1739# @param $2 - classpath; junit and recorded dependencies get appended 1766# @param $3 - classpath; junit and recorded dependencies get appended
1740# @param $@ - the rest of the parameters are passed to java 1767# @param $@ - the rest of the parameters are passed to java
1741# ------------------------------------------------------------------------------
1742ejunit() { 1768ejunit_() {
1743 debug-print-function ${FUNCNAME} $* 1769 debug-print-function ${FUNCNAME} $*
1744 1770
1745 local pkgs 1771 local pkgs
1772 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1773 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1774 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done 1775 done
1776 fi
1749 1777
1778 local junit=${1}
1779 shift 1
1780
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1781 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1782 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}" 1783 cp="${2}:${cp}"
1753 shift 2 1784 shift 2
1754 else 1785 else
1755 cp=".:${cp}" 1786 cp=".:${cp}"
1759 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1790 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1760 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1791 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1761} 1792}
1762 1793
1763# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1795# @ebuild-function ejunit
1796#
1797# Junit wrapper function. Makes it easier to run the tests and checks for
1798# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1799#
1800# Examples:
1801# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1802# ejunit org.blinkenlights.jid3.test.AllTests
1803#
1804# @param $1 - -cp or -classpath
1805# @param $2 - classpath; junit and recorded dependencies get appended
1806# @param $@ - the rest of the parameters are passed to java
1807# ------------------------------------------------------------------------------
1808ejunit() {
1809 debug-print-function ${FUNCNAME} $*
1810
1811 ejunit_ "junit" "${@}"
1812}
1813
1814# ------------------------------------------------------------------------------
1815# @ebuild-function ejunit4
1816#
1817# Junit4 wrapper function. Makes it easier to run the tests and checks for
1818# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1819#
1820# Examples:
1821# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1822# ejunit org.blinkenlights.jid3.test.AllTests
1823#
1824# @param $1 - -cp or -classpath
1825# @param $2 - classpath; junit and recorded dependencies get appended
1826# @param $@ - the rest of the parameters are passed to java
1827# ------------------------------------------------------------------------------
1828ejunit4() {
1829 debug-print-function ${FUNCNAME} $*
1830
1831 ejunit_ "junit-4" "${@}"
1832}
1833
1834# ------------------------------------------------------------------------------
1764# @section-end helper 1835# @section-end helper
1765# ------------------------------------------------------------------------------ 1836# ------------------------------------------------------------------------------
1837
1838# ------------------------------------------------------------------------------
1839# @eclass-src_prepare
1840#
1841# src_prepare Searches for bundled jars
1842# Don't call directly, but via java-pkg-2_src_prepare!
1843# ------------------------------------------------------------------------------
1844
1845java-utils-2_src_prepare() {
1846 [[ ${EBUILD_PHASE} == prepare ]] &&
1847 java-pkg_func-exists java_prepare && java_prepare
1848
1849 # Remember that eant will call this unless called via Portage
1850 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1851 echo "Searching for bundled jars:"
1852 java-pkg_find-normal-jars || echo "None found."
1853 echo "Searching for bundled classes (no output if none found):"
1854 find "${WORKDIR}" -name "*.class"
1855 echo "Search done."
1856 fi
1857 touch "${T}/java-utils-2_src_prepare-run"
1858}
1859
1860# ------------------------------------------------------------------------------
1861# @eclass-pkg_preinst
1862#
1863# pkg_preinst Searches for missing and unneeded dependencies
1864# Don't call directly, but via java-pkg-2_pkg_preinst!
1865# ------------------------------------------------------------------------------
1866
1867java-utils-2_pkg_preinst() {
1868 if is-java-strict; then
1869 if has_version dev-java/java-dep-check; then
1870 [[ -e "${JAVA_PKG_ENV}" ]] || return
1871 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1872 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1873 ewarn "Possibly unneeded dependencies found in package.env:"
1874 for dep in ${output}; do
1875 ewarn "\t${dep}"
1876 done
1877 fi
1878 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1879 ewarn "${output}"
1880 fi
1881 else
1882 eerror "Install dev-java/java-dep-check for dependency checking"
1883 fi
1884 fi
1885}
1766 1886
1767# ------------------------------------------------------------------------------ 1887# ------------------------------------------------------------------------------
1768# @section-begin build 1888# @section-begin build
1769# @section-summary Build functions 1889# @section-summary Build functions
1770# 1890#
1779# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1899# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1780# variables: 1900# variables:
1781# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1901# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1782# gentoo.classpath property. Be sure to call 1902# gentoo.classpath property. Be sure to call
1783# java-ant_rewrite-classpath in src_unpack. 1903# java-ant_rewrite-classpath in src_unpack.
1904# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1905# for build-time purposes, the dependency is not recorded to
1906# package.env!
1907# 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. 1908# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1909# ------------------------------------------------------------------------------
1786eant() { 1910eant() {
1787 debug-print-function ${FUNCNAME} $* 1911 debug-print-function ${FUNCNAME} $*
1912
1913 if [[ ${EBUILD_PHASE} = compile ]]; then
1914 java-ant-2_src_configure
1915 java-utils-2_src_prepare
1916 fi
1788 1917
1789 if ! hasq java-ant-2 ${INHERITED}; then 1918 if ! hasq java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1919 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1920 java-pkg_announce-qa-violation "${msg}"
1792 fi 1921 fi
1793 1922
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1923 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1924
1796 java-pkg_init-compiler_ 1925 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1926 local compiler="${GENTOO_COMPILER}"
1798 1927
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1928 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})" 1929 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1930 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1931 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1932 fi
1805 1933
1811 # java-config -p 1939 # java-config -p
1812 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1940 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 1941 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1942 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1943 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 1944 fi
1822 1945
1823 for arg in "${@}"; do 1946 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1947 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1948 if is-java-strict; then
1834 echo "more info." 1957 echo "more info."
1835 fi 1958 fi
1836 fi 1959 fi
1837 done 1960 done
1838 1961
1839 # we use this in src_* so we run ant from / 1962 # parse WANT_ANT_TASKS for atoms
1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1963 local want_ant_tasks
1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1964 for i in ${WANT_ANT_TASKS}; do
1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1965 if [[ ${i} = */*:* ]]; then
1843 1966 i=${i#*/}
1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1967 i=${i%:0}
1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1968 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 1969 else
1970 want_ant_tasks+="${i} "
1971 fi
1972 done
1973 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1974 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1975
1976 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1977 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1978
1853 # if ant-tasks is not set by ebuild or forced, activate all of them 1979 # if ant-tasks is not set by ebuild or forced, use none
1854 ANT_TASKS="${ANT_TASKS:-all}" 1980 ANT_TASKS="${ANT_TASKS:-none}"
1855 fi
1856 1981
1857 # at this point, ANT_TASKS should be "all", "none" or explicit list 1982 # at this point, ANT_TASKS should be "all", "none" or explicit list
1858 if [[ "${ANT_TASKS}" == "all" ]]; then 1983 if [[ "${ANT_TASKS}" == "all" ]]; then
1859 einfo "Using all available ANT_TASKS" 1984 einfo "Using all available ANT_TASKS"
1860 elif [[ "${ANT_TASKS}" == "none" ]]; then 1985 elif [[ "${ANT_TASKS}" == "none" ]]; then
1861 einfo "Disabling all optional ANT_TASKS" 1986 einfo "Disabling all optional ANT_TASKS"
1862 else 1987 else
1863 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1988 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1864 fi 1989 fi
1865 1990
1866 export ANT_TASKS 1991 export ANT_TASKS
1867 fi
1868 1992
1869 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1993 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1870 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1994 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1871 1995
1872 local gcp="${EANT_GENTOO_CLASSPATH}" 1996 local gcp="${EANT_GENTOO_CLASSPATH}"
1873 local getjarsarg="" 1997 local getjarsarg=""
1874 1998
1875 if [[ ${EBUILD_PHASE} = "test" ]]; then 1999 if [[ ${EBUILD_PHASE} = "test" ]]; then
1876 antflags="${antflags} -DJunit.present=true" 2000 antflags="${antflags} -DJunit.present=true"
1877 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2001 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1878 getjarsarg="--with-dependencies" 2002 getjarsarg="--with-dependencies"
1879 fi 2003 fi
1880 2004
1881 local cp 2005 local cp
1882 2006
1883 for atom in ${gcp}; do 2007 for atom in ${gcp}; do
1884 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2008 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1885 done 2009 done
1886 2010
2011 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2012
1887 if [[ ${cp} ]]; then 2013 if [[ ${cp} ]]; then
1888 # It seems ant does not like single quotes around ${cp} 2014 # It seems ant does not like single quotes around ${cp}
2015 cp=${cp#:}
2016 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2017 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1889 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2018 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1890 fi 2019 fi
1891 2020
1892 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2021 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1893 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2022 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1894 ant ${antflags} "${@}" || die "eant failed" 2023 ant ${antflags} "${@}" || die "eant failed"
1994# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2123# 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. 2124# call it during each of the phases of the merge process.
1996# 2125#
1997# ----------------------------------------------------------------------------- 2126# -----------------------------------------------------------------------------
1998java-pkg_init() { 2127java-pkg_init() {
2128 debug-print-function ${FUNCNAME} $*
1999 unset JAVAC 2129 unset JAVAC
2000 unset JAVA_HOME 2130 unset JAVA_HOME
2131
2132 java-config --help >/dev/null || {
2133 eerror ""
2134 eerror "Can't run java-config --help"
2135 eerror "Have you upgraded python recently but haven't"
2136 eerror "run python-updater yet?"
2137 die "Can't run java-config --help"
2138 }
2001 2139
2002 # People do all kinds of weird things. 2140 # People do all kinds of weird things.
2003 # http://forums.gentoo.org/viewtopic-p-3943166.html 2141 # http://forums.gentoo.org/viewtopic-p-3943166.html
2004 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2142 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2005 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2143 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2011 ewarn "make.conf for example) to silence this warning or" 2149 ewarn "make.conf for example) to silence this warning or"
2012 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2150 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2013 fi 2151 fi
2014 2152
2015 if [[ -z ${accept} ]]; then 2153 if [[ -z ${accept} ]]; then
2154 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2155 # -version output
2016 unset _JAVA_OPTIONS 2156 unset _JAVA_OPTIONS
2017 # phase hooks make this run many times without this 2157 # phase hooks make this run many times without this
2018 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2158 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2019 fi 2159 fi
2020 2160
2161 if java-pkg_func-exists ant_src_unpack; then
2162 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2163 fi
2164
2021 java-pkg_init_paths_ 2165 java-pkg_init_paths_
2022 java-pkg_switch-vm 2166 java-pkg_switch-vm
2023 PATH=${JAVA_HOME}/bin:${PATH} 2167 PATH=${JAVA_HOME}/bin:${PATH}
2024 2168
2025 # TODO we will probably want to set JAVAC and JAVACFLAGS 2169 # TODO we will probably want to set JAVAC and JAVACFLAGS
2026 2170
2027 # Do some QA checks 2171 # Do some QA checks
2028 java-pkg_check-jikes 2172 java-pkg_check-jikes
2173
2174 # Can't use unset here because Portage does not save the unset
2175 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2029 2176
2030 # When users have crazy classpaths some packages can fail to compile. 2177 # When users have crazy classpaths some packages can fail to compile.
2031 # and everything should work with empty CLASSPATH. 2178 # and everything should work with empty CLASSPATH.
2032 # This also helps prevent unexpected dependencies on random things 2179 # This also helps prevent unexpected dependencies on random things
2033 # from the CLASSPATH. 2180 # from the CLASSPATH.
2034 unset CLASSPATH 2181 export CLASSPATH=
2035 2182
2036 # Unset external ANT_ stuff 2183 # Unset external ANT_ stuff
2037 unset ANT_TASKS 2184 export ANT_TASKS=
2038 unset ANT_OPTS 2185 export ANT_OPTS=
2186 export ANT_RESPECT_JAVA_HOME=
2039} 2187}
2040 2188
2041# ------------------------------------------------------------------------------ 2189# ------------------------------------------------------------------------------
2042# @function-internal java-pkg-init-compiler_ 2190# @function-internal java-pkg-init-compiler_
2043# 2191#
2134 done 2282 done
2135 2283
2136 # If it hasn't been defined already, default to javac 2284 # If it hasn't been defined already, default to javac
2137 if [[ -z ${GENTOO_COMPILER} ]]; then 2285 if [[ -z ${GENTOO_COMPILER} ]]; then
2138 if [[ -n ${compilers} ]]; then 2286 if [[ -n ${compilers} ]]; then
2139 einfo "No suitable compiler found: defaulting javac for compilation" 2287 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2140 else 2288 else
2141 # probably don't need to notify users about the default. 2289 # probably don't need to notify users about the default.
2142 :;#einfo "Defaulting to javac for compilation" 2290 :;#einfo "Defaulting to javac for compilation"
2143 fi 2291 fi
2292 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2293 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2294 else
2144 export GENTOO_COMPILER=javac 2295 export GENTOO_COMPILER=javac
2296 fi
2145 else 2297 else
2146 einfo "Using ${GENTOO_COMPILER} for compilation" 2298 einfo "Using ${GENTOO_COMPILER} for compilation"
2147 fi 2299 fi
2148 2300
2149} 2301}
2165 fi 2317 fi
2166 2318
2167 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2319 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2168 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2320 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2169 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2321 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2322 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2323 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2170 2324
2171 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2325 [[ -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}" 2326 [[ -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" 2327 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2174 2328
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2352 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2199 # Create package.env 2353 # Create package.env
2200 ( 2354 (
2201 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2355 echo "DESCRIPTION=\"${DESCRIPTION}\""
2202 echo "GENERATION=\"2\"" 2356 echo "GENERATION=\"2\""
2357 echo "SLOT=\"${SLOT}\""
2358 echo "CATEGORY=\"${CATEGORY}\""
2359 echo "PVR=\"${PVR}\""
2203 2360
2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2361 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2362 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2363 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2364 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2208 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2365 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2209 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2366 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2210 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2367 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2211 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2368 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2369 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2370 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2212 ) > "${JAVA_PKG_ENV}" 2371 ) > "${JAVA_PKG_ENV}"
2213 2372
2214 # register target/source 2373 # register target/source
2215 local target="$(java-pkg_get-target)" 2374 local target="$(java-pkg_get-target)"
2216 local source="$(java-pkg_get-source)" 2375 local source="$(java-pkg_get-source)"
2249# ------------------------------------------------------------------------------ 2408# ------------------------------------------------------------------------------
2250# @internal-function java-pkg_record-jar_ 2409# @internal-function java-pkg_record-jar_
2251# 2410#
2252# Record an (optional) dependency to the package.env 2411# Record an (optional) dependency to the package.env
2253# @param --optional - record dependency as optional 2412# @param --optional - record dependency as optional
2413# @param --build - record dependency as build_only
2254# @param $1 - package to record 2414# @param $1 - package to record
2255# @param $2 - (optional) jar of package to record 2415# @param $2 - (optional) jar of package to record
2256# ------------------------------------------------------------------------------ 2416# ------------------------------------------------------------------------------
2257JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2417JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2258JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2418JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2419JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2259 2420
2260java-pkg_record-jar_() { 2421java-pkg_record-jar_() {
2261 debug-print-function ${FUNCNAME} $* 2422 debug-print-function ${FUNCNAME} $*
2262 2423
2263 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2424 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2264 if [[ "${1}" == "--optional" ]]; then 2425 case "${1}" in
2265 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2426 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2266 shift 2427 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2267 fi 2428 esac
2268 2429
2269 local pkg=${1} jar=${2} append 2430 local pkg=${1} jar=${2} append
2270 if [[ -z "${jar}" ]]; then 2431 if [[ -z "${jar}" ]]; then
2271 append="${pkg}" 2432 append="${pkg}"
2272 else 2433 else
2325# 2486#
2326# @return 0 - function is declared 2487# @return 0 - function is declared
2327# @return 1 - function is undeclared 2488# @return 1 - function is undeclared
2328# ------------------------------------------------------------------------------ 2489# ------------------------------------------------------------------------------
2329java-pkg_func-exists() { 2490java-pkg_func-exists() {
2330 if [[ -n "$(declare -f ${1})" ]]; then 2491 declare -F ${1} > /dev/null
2331 return 0
2332 else
2333 return 1
2334 fi
2335} 2492}
2336 2493
2337# ------------------------------------------------------------------------------ 2494# ------------------------------------------------------------------------------
2338# @internal-function java-pkg_setup-vm 2495# @internal-function java-pkg_setup-vm
2339# 2496#
2365# @return 1 - Package does not depend on virtual/jdk 2522# @return 1 - Package does not depend on virtual/jdk
2366# ------------------------------------------------------------------------------ 2523# ------------------------------------------------------------------------------
2367java-pkg_needs-vm() { 2524java-pkg_needs-vm() {
2368 debug-print-function ${FUNCNAME} $* 2525 debug-print-function ${FUNCNAME} $*
2369 2526
2370 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2527 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2371 return 0 2528 return 0
2372 fi 2529 fi
2373 2530
2374 return 1 2531 return 1
2375} 2532}
2423 # If you're forcing the VM, I hope you know what your doing... 2580 # 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}" 2581 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2425 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2582 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2426 # if we're allowed to switch the vm... 2583 # if we're allowed to switch the vm...
2427 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2584 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}" 2585 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}}")" 2586 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2433 fi
2434 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2587 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2435 eerror "Unable to determine VM for building from dependencies:" 2588 eerror "Unable to determine VM for building from dependencies:"
2436 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2589 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2437 echo "VNEED: ${JAVA_PKG_VNEED}"
2438 die "Failed to determine VM for building." 2590 die "Failed to determine VM for building."
2439 else 2591 else
2440 export GENTOO_VM 2592 export GENTOO_VM
2441 fi 2593 fi
2442 # otherwise just make sure the current VM is sufficient 2594 # otherwise just make sure the current VM is sufficient
2462 2614
2463 #TODO If you know a better solution let us know. 2615 #TODO If you know a better solution let us know.
2464 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2616 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2465 2617
2466 local tann="${T}/announced-vm" 2618 local tann="${T}/announced-vm"
2619 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2620 # if people have for example modified eclasses some where
2467 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2621 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)" 2622 einfo "Using: $(java-config -f)"
2473 [[ ! -f "${tann}" ]] && touch "${tann}" 2623 [[ ! -f "${tann}" ]] && touch "${tann}"
2474 fi
2475 fi 2624 fi
2476 2625
2477 else 2626 else
2478 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2627 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2479 fi 2628 fi
2518# not. 2667# not.
2519# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2668# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2520# ------------------------------------------------------------------------------ 2669# ------------------------------------------------------------------------------
2521java-pkg_verify-classes() { 2670java-pkg_verify-classes() {
2522 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2671 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2672
2673 local version_verify="/usr/bin/class-version-verify.py"
2674
2675 if [[ ! -x "${version_verify}" ]]; then
2676 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2677 fi
2678
2679 if [[ ! -x "${version_verify}" ]]; then
2680 ewarn "Unable to perform class version checks as"
2681 ewarn "class-version-verify.py is unavailable"
2682 ewarn "Please install dev-java/javatoolkit."
2683 return
2684 fi
2685
2523 local target=$(java-pkg_get-target) 2686 local target=$(java-pkg_get-target)
2524 local result 2687 local result
2525 local log="${T}/class-version-verify.log" 2688 local log="${T}/class-version-verify.log"
2526 if [[ -n "${1}" ]]; then 2689 if [[ -n "${1}" ]]; then
2527 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2690 ${version_verify} -v -t ${target} "${1}" > "${log}"
2528 result=$? 2691 result=$?
2529 else 2692 else
2530 ebegin "Verifying java class versions (target: ${target})" 2693 ebegin "Verifying java class versions (target: ${target})"
2531 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2694 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2532 result=$? 2695 result=$?
2533 eend ${result} 2696 eend ${result}
2534 fi 2697 fi
2535 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2698 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2536 if [[ ${result} != 0 ]]; then 2699 if [[ ${result} != 0 ]]; then
2554 2717
2555 local limit_to="${1}" 2718 local limit_to="${1}"
2556 local target_pkg="${2}" 2719 local target_pkg="${2}"
2557 local dev_error="" 2720 local dev_error=""
2558 2721
2722 # remove the version specification, which may include globbing (* and [123])
2559 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2723 local stripped_pkg=$(echo "${target_pkg}" | sed \
2560 's/-[0-9]*\(\.[0-9]\)*$//') 2724 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2561 2725
2562 debug-print "Matching against: ${stripped_pkg}" 2726 debug-print "Matching against: ${stripped_pkg}"
2563 2727
2564 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2728 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2565 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2729 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2641is-java-strict() { 2805is-java-strict() {
2642 [[ -n ${JAVA_PKG_STRICT} ]] 2806 [[ -n ${JAVA_PKG_STRICT} ]]
2643 return $? 2807 return $?
2644} 2808}
2645 2809
2810
2646# ------------------------------------------------------------------------------ 2811# ------------------------------------------------------------------------------
2647# @eclass-end 2812# @eclass-end
2648# ------------------------------------------------------------------------------ 2813# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20