/[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.126
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.126 2009/03/31 19:19:20 betelgeuse 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_
437 if [[ -e "${lib}" ]] ; then 446 if [[ -e "${lib}" ]] ; then
438 # install if it isn't a symlink 447 # install if it isn't a symlink
439 if [[ ! -L "${lib}" ]] ; then 448 if [[ ! -L "${lib}" ]] ; then
440 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 449 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
441 INSOPTIONS="${LIBOPTIONS}" \ 450 INSOPTIONS="${LIBOPTIONS}" \
442 doins "${lib}" || "failed to install ${lib}" 451 doins "${lib}" || die "failed to install ${lib}"
443 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
444 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
445 # otherwise make a symlink to the symlink's origin 454 # otherwise make a symlink to the symlink's origin
446 else 455 else
447 # TODO use dosym 456 # TODO use dosym
548# ------------------------------------------------------------------------------ 557# ------------------------------------------------------------------------------
549# @ebuild-function java-pkg_dojavadoc 558# @ebuild-function java-pkg_dojavadoc
550# 559#
551# Installs javadoc documentation. This should be controlled by the doc use flag. 560# Installs javadoc documentation. This should be controlled by the doc use flag.
552# 561#
562# @param $1: optional --symlink creates to symlink like this for html
563# documentation bundles.
553# @param $1: - The javadoc root directory. 564# @param $2: - The javadoc root directory.
554# 565#
555# @example: 566# @example:
556# java-pkg_dojavadoc docs/api 567# java-pkg_dojavadoc docs/api
568# java-pkg_dojavadoc --symlink apidocs docs/api
557# 569#
558# ------------------------------------------------------------------------------ 570# ------------------------------------------------------------------------------
559java-pkg_dojavadoc() { 571java-pkg_dojavadoc() {
560 debug-print-function ${FUNCNAME} $* 572 debug-print-function ${FUNCNAME} $*
573
574 # For html documentation bundles that link to Javadoc
575 local symlink
576 if [[ ${1} = --symlink ]]; then
577 symlink=${2}
578 shift 2
579 fi
580
561 local dir="$1" 581 local dir="$1"
582 local dest=/usr/share/doc/${PF}/html
562 583
563 # QA checks 584 # QA checks
564 585
565 java-pkg_check-phase install 586 java-pkg_check-phase install
566 587
570 local msg="No index.html in javadoc directory" 591 local msg="No index.html in javadoc directory"
571 ewarn "${msg}" 592 ewarn "${msg}"
572 is-java-strict && die "${msg}" 593 is-java-strict && die "${msg}"
573 fi 594 fi
574 595
596 if [[ -e ${D}/${dest}/api ]]; then
597 eerror "${dest} already exists. Will not overwrite."
598 die "${dest}"
599 fi
600
575 # Renaming to match our directory layout 601 # Renaming to match our directory layout
576 602
577 local dir_to_install="${dir}" 603 local dir_to_install="${dir}"
578 if [[ "$(basename "${dir}")" != "api" ]]; then 604 if [[ "$(basename "${dir}")" != "api" ]]; then
579 dir_to_install="${T}/api" 605 dir_to_install="${T}/api"
581 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 607 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
582 fi 608 fi
583 609
584 # Actual installation 610 # Actual installation
585 611
586 java-pkg_dohtml -r ${dir_to_install} 612 java-pkg_dohtml -r "${dir_to_install}"
613
614 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616
617 if [[ ${symlink} ]]; then
618 debug-print "symlinking ${dest}/{api,${symlink}}"
619 dosym ${dest}/{api,${symlink}} || die
620 fi
587} 621}
588 622
589# ------------------------------------------------------------------------------ 623# ------------------------------------------------------------------------------
590# @ebuild-function java-pkg_dosrc 624# @ebuild-function java-pkg_dosrc
591# 625#
614 648
615 [[ ${#} -lt 1 ]] && die "At least one argument needed" 649 [[ ${#} -lt 1 ]] && die "At least one argument needed"
616 650
617 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 651 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
618 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 652 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
619 if is-java-strict; then 653 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 654 fi
627 655
628 java-pkg_init_paths_ 656 java-pkg_init_paths_
629 657
630 local zip_name="${PN}-src.zip" 658 local zip_name="${PN}-src.zip"
830# @param $opt 858# @param $opt
831# --build-only - makes the jar(s) not added into package.env DEPEND line. 859# --build-only - makes the jar(s) not added into package.env DEPEND line.
832# (assumed automatically when called inside src_test) 860# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 861# --with-dependencies - get jars also from requested package's dependencies
834# transitively. 862# transitively.
863# --virtual - Packages passed to this function are to be handled as virtuals
864# and will not have individual jar dependencies recorded.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 865# --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 866# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used. 867# case other parameters are not used.
838# @param $2 - jar from package. If not specified, all jars will be used. 868# @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 869# @param $3 - When a single jar is specified, destination filename of the
844 debug-print-function ${FUNCNAME} $* 874 debug-print-function ${FUNCNAME} $*
845 875
846 local build_only="" 876 local build_only=""
847 local destdir="." 877 local destdir="."
848 local deep="" 878 local deep=""
879 local virtual=""
849 880
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 881 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 882
852 while [[ "${1}" == --* ]]; do 883 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 884 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 885 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 886 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 887 deep="--with-dependencies"
888 elif [[ "${1}" = "--virtual" ]]; then
889 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 890 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 891 destdir="${2}"
859 shift 892 shift
860 else 893 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 894 die "java-pkg_jar-from called with unknown parameter: ${1}"
864 done 897 done
865 898
866 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 899 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
867 900
868 [[ -z ${target_pkg} ]] && die "Must specify a package" 901 [[ -z ${target_pkg} ]] && die "Must specify a package"
902
903 if [[ "${EAPI}" == "1" ]]; then
904 target_pkg="${target_pkg//:/-}"
905 fi
869 906
870 # default destjar to the target jar 907 # default destjar to the target jar
871 [[ -z "${destjar}" ]] && destjar="${target_jar}" 908 [[ -z "${destjar}" ]] && destjar="${target_jar}"
872 909
873 local error_msg="There was a problem getting the classpath for ${target_pkg}." 910 local error_msg="There was a problem getting the classpath for ${target_pkg}."
885 done 922 done
886 # setting this disables further record-jar_ calls later 923 # setting this disables further record-jar_ calls later
887 build_only="build" 924 build_only="build"
888 else 925 else
889 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 926 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
927 fi
928
929 # Record the entire virtual as a dependency so that
930 # no jars are missed.
931 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
932 java-pkg_record-jar_ "${target_pkg}"
933 # setting this disables further record-jars_ calls later
934 build_only="build"
890 fi 935 fi
891 936
892 pushd ${destdir} > /dev/null \ 937 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 938 || die "failed to change directory to ${destdir}"
894 939
977 done 1022 done
978 1023
979 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1024 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
980 1025
981 1026
982 local classpath pkgs="${1}" 1027 local pkgs="${1}"
1028
1029 if [[ "${EAPI}" == "1" ]]; then
1030 pkgs="${pkgs//:/-}"
1031 fi
1032
983 jars="$(java-config ${deep} --classpath=${pkgs})" 1033 jars="$(java-config ${deep} --classpath=${pkgs})"
984 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1034 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
985 debug-print "${pkgs}:${jars}" 1035 debug-print "${pkgs}:${jars}"
986 1036
987 for pkg in ${pkgs//,/ }; do 1037 for pkg in ${pkgs//,/ }; do
988 java-pkg_ensure-dep "${build_only}" "${pkg}" 1038 java-pkg_ensure-dep "${build_only}" "${pkg}"
989 done 1039 done
990
991 if [[ -z "${classpath}" ]]; then
992 classpath="${jars}"
993 else
994 classpath="${classpath}:${jars}"
995 fi
996 1040
997 # Only record jars that aren't build-only 1041 # Only record jars that aren't build-only
998 if [[ -z "${build_only}" ]]; then 1042 if [[ -z "${build_only}" ]]; then
999 for pkg in ${pkgs//,/ }; do 1043 for pkg in ${pkgs//,/ }; do
1000 java-pkg_record-jar_ "${pkg}" 1044 java-pkg_record-jar_ "${pkg}"
1001 done 1045 done
1002 fi 1046 fi
1003 1047
1004 echo "${classpath}" 1048 echo "${jars}"
1005} 1049}
1006 1050
1007# ------------------------------------------------------------------------------ 1051# ------------------------------------------------------------------------------
1008# @ebuild-function java-pkg_getjar 1052# @ebuild-function java-pkg_getjar
1009# 1053#
1018# @example-return 1062# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1063# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1064#
1021# @param $opt 1065# @param $opt
1022# --build-only - makes the jar not added into package.env DEPEND line. 1066# --build-only - makes the jar not added into package.env DEPEND line.
1067# --virtual - Packages passed to this function are to be handled as virtuals
1068# and will not have individual jar dependencies recorded.
1023# @param $1 - package to use 1069# @param $1 - package to use
1024# @param $2 - jar to get 1070# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1071# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1072java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1073 debug-print-function ${FUNCNAME} $*
1028 1074
1029 local build_only="" 1075 local build_only=""
1076 local virtual=""
1030 1077
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1078 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1079
1033 while [[ "${1}" == --* ]]; do 1080 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1081 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1082 build_only="build"
1083 elif [[ "${1}" == "--virtual" ]]; then
1084 virtual="true"
1036 else 1085 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1086 die "java-pkg_getjar called with unknown parameter: ${1}"
1038 fi 1087 fi
1039 shift 1088 shift
1040 done 1089 done
1041 1090
1042 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1091 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1043 1092
1044 local pkg="${1}" target_jar="${2}" jar 1093 local pkg="${1}" target_jar="${2}" jar
1094
1095 if [[ "${EAPI}" == "1" ]]; then
1096 pkg="${pkg//:/-}"
1097 fi
1098
1045 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1099 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1046 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1100 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1047 1101
1048 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1102 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1049 local classpath 1103 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1104 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1105 [[ $? != 0 ]] && die ${error_msg}
1052 1106
1053 java-pkg_ensure-dep "${build_only}" "${pkg}" 1107 java-pkg_ensure-dep "${build_only}" "${pkg}"
1108
1109 # Record the package(Virtual) as a dependency and then set build_only
1110 # So that individual jars are not recorded.
1111 if [[ -n "${virtual}" ]]; then
1112 java-pkg_record-jar_ "${pkg}"
1113 build_only="true"
1114 fi
1054 1115
1055 for jar in ${classpath//:/ }; do 1116 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1117 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1118 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1119 fi
1103 1164
1104 local pkgs="${1}" 1165 local pkgs="${1}"
1105 local jar="${2}" 1166 local jar="${2}"
1106 1167
1107 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1168 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1169
1170 if [[ "${EAPI}" == "1" ]]; then
1171 pkgs="${pkgs//:/-}"
1172 fi
1108 1173
1109 if [[ -z "${jar}" ]]; then 1174 if [[ -z "${jar}" ]]; then
1110 for pkg in ${pkgs//,/ }; do 1175 for pkg in ${pkgs//,/ }; do
1111 java-pkg_ensure-dep runtime "${pkg}" 1176 java-pkg_ensure-dep runtime "${pkg}"
1112 java-pkg_record-jar_ "${pkg}" 1177 java-pkg_record-jar_ "${pkg}"
1154 1219
1155 local pkgs="${1}" 1220 local pkgs="${1}"
1156 local jar="${2}" 1221 local jar="${2}"
1157 1222
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1223 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1224
1225 if [[ "${EAPI}" == "1" ]]; then
1226 pkgs="${pkgs//:/-}"
1227 fi
1159 1228
1160 if [[ -z "${jar}" ]]; then 1229 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do 1230 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}" 1231 java-pkg_record-jar_ --optional "${pkg}"
1163 done 1232 done
1664 dodir /usr/share/ant/${TASKS_DIR} 1733 dodir /usr/share/ant/${TASKS_DIR}
1665 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1734 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1666} 1735}
1667 1736
1668# ------------------------------------------------------------------------------ 1737# ------------------------------------------------------------------------------
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 1738# @internal-function java-pkg_ant-tasks-depend
1705# 1739#
1706# Translates the WANT_ANT_TASKS variable into valid dependencies. 1740# Translates the WANT_ANT_TASKS variable into valid dependencies.
1707# ------------------------------------------------------------------------------ 1741# ------------------------------------------------------------------------------
1708java-pkg_ant-tasks-depend() { 1742java-pkg_ant-tasks-depend() {
1710 1744
1711 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1745 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1712 local DEP="" 1746 local DEP=""
1713 for i in ${WANT_ANT_TASKS} 1747 for i in ${WANT_ANT_TASKS}
1714 do 1748 do
1715 if [[ ${i} != ant-* ]]; then 1749 if [[ ${i} = ant-* ]]; then
1750 DEP="${DEP}dev-java/${i} "
1751 elif [[ ${i} = */*:* ]]; then
1752 DEP="${DEP}${i} "
1753 else
1716 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1754 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1717 return 1 1755 return 1
1718 fi 1756 fi
1719 DEP="${DEP}dev-java/${i} "
1720 done 1757 done
1721 echo ${DEP} 1758 echo ${DEP}
1722 return 0 1759 return 0
1723 else 1760 else
1724 return 0 1761 return 0
1741# ------------------------------------------------------------------------------ 1778# ------------------------------------------------------------------------------
1742ejunit() { 1779ejunit() {
1743 debug-print-function ${FUNCNAME} $* 1780 debug-print-function ${FUNCNAME} $*
1744 1781
1745 local pkgs 1782 local pkgs
1783 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1784 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1785 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done 1786 done
1787 fi
1749 1788
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1789 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1790 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}" 1791 cp="${2}:${cp}"
1753 shift 2 1792 shift 2
1763# ------------------------------------------------------------------------------ 1802# ------------------------------------------------------------------------------
1764# @section-end helper 1803# @section-end helper
1765# ------------------------------------------------------------------------------ 1804# ------------------------------------------------------------------------------
1766 1805
1767# ------------------------------------------------------------------------------ 1806# ------------------------------------------------------------------------------
1807# @eclass-src_prepare
1808#
1809# src_prepare Searches for bundled jars
1810# Don't call directly, but via java-pkg-2_src_prepare!
1811# ------------------------------------------------------------------------------
1812
1813java-utils-2_src_prepare() {
1814 [[ ${EBUILD_PHASE} == prepare ]] &&
1815 java-pkg_func-exists java_prepare && java_prepare
1816
1817 # Remember that eant will call this unless called via Portage
1818 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1819 echo "Searching for bundled jars:"
1820 java-pkg_find-normal-jars || echo "None found."
1821 echo "Searching for bundled classes (no output if none found):"
1822 find "${WORKDIR}" -name "*.class"
1823 echo "Search done."
1824 fi
1825 touch "${T}/java-utils-2_src_prepare-run"
1826}
1827
1828# ------------------------------------------------------------------------------
1829# @eclass-pkg_preinst
1830#
1831# pkg_preinst Searches for missing and unneeded dependencies
1832# Don't call directly, but via java-pkg-2_pkg_preinst!
1833# ------------------------------------------------------------------------------
1834
1835java-utils-2_pkg_preinst() {
1836 if is-java-strict; then
1837 if has_version dev-java/java-dep-check; then
1838 [[ -e "${JAVA_PKG_ENV}" ]] || return
1839 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1840 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1841 ewarn "Possibly unneeded dependencies found in package.env:"
1842 for dep in ${output}; do
1843 ewarn "\t${dep}"
1844 done
1845 fi
1846 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1847 ewarn "${output}"
1848 fi
1849 else
1850 eerror "Install dev-java/java-dep-check for dependency checking"
1851 fi
1852 fi
1853}
1854
1855# ------------------------------------------------------------------------------
1768# @section-begin build 1856# @section-begin build
1769# @section-summary Build functions 1857# @section-summary Build functions
1770# 1858#
1771# These are some functions for building a package. In particular, it consists of 1859# These are some functions for building a package. In particular, it consists of
1772# wrappers for javac and ant. 1860# wrappers for javac and ant.
1779# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1867# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1780# variables: 1868# variables:
1781# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1869# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1782# gentoo.classpath property. Be sure to call 1870# gentoo.classpath property. Be sure to call
1783# java-ant_rewrite-classpath in src_unpack. 1871# java-ant_rewrite-classpath in src_unpack.
1872# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1873# for build-time purposes, the dependency is not recorded to
1874# package.env!
1875# 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. 1876# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1877# ------------------------------------------------------------------------------
1786eant() { 1878eant() {
1787 debug-print-function ${FUNCNAME} $* 1879 debug-print-function ${FUNCNAME} $*
1880
1881 if [[ ${EBUILD_PHASE} = compile ]]; then
1882 java-ant-2_src_configure
1883 java-utils-2_src_prepare
1884 fi
1788 1885
1789 if ! hasq java-ant-2 ${INHERITED}; then 1886 if ! hasq java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1887 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1888 java-pkg_announce-qa-violation "${msg}"
1792 fi 1889 fi
1793 1890
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1891 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1892
1796 java-pkg_init-compiler_ 1893 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1894 local compiler="${GENTOO_COMPILER}"
1798 1895
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1896 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})" 1897 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1898 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1899 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1900 fi
1805 1901
1811 # java-config -p 1907 # java-config -p
1812 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1908 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 1909 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1910 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1911 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 1912 fi
1822 1913
1823 for arg in "${@}"; do 1914 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1915 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1916 if is-java-strict; then
1834 echo "more info." 1925 echo "more info."
1835 fi 1926 fi
1836 fi 1927 fi
1837 done 1928 done
1838 1929
1839 # we use this in src_* so we run ant from / 1930 # parse WANT_ANT_TASKS for atoms
1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1931 local want_ant_tasks
1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1932 for i in ${WANT_ANT_TASKS}; do
1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1933 if [[ ${i} = */*:* ]]; then
1843 1934 i=${i#*/}
1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1935 i=${i%:0}
1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1936 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 1937 else
1938 want_ant_tasks+="${i} "
1939 fi
1940 done
1941 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1942 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1943
1944 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1945 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1946
1853 # if ant-tasks is not set by ebuild or forced, activate all of them 1947 # if ant-tasks is not set by ebuild or forced, use none
1854 ANT_TASKS="${ANT_TASKS:-all}" 1948 ANT_TASKS="${ANT_TASKS:-none}"
1855 fi
1856 1949
1857 # at this point, ANT_TASKS should be "all", "none" or explicit list 1950 # at this point, ANT_TASKS should be "all", "none" or explicit list
1858 if [[ "${ANT_TASKS}" == "all" ]]; then 1951 if [[ "${ANT_TASKS}" == "all" ]]; then
1859 einfo "Using all available ANT_TASKS" 1952 einfo "Using all available ANT_TASKS"
1860 elif [[ "${ANT_TASKS}" == "none" ]]; then 1953 elif [[ "${ANT_TASKS}" == "none" ]]; then
1861 einfo "Disabling all optional ANT_TASKS" 1954 einfo "Disabling all optional ANT_TASKS"
1862 else 1955 else
1863 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1956 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1864 fi 1957 fi
1865 1958
1866 export ANT_TASKS 1959 export ANT_TASKS
1867 fi
1868 1960
1869 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1961 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1870 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1962 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1871 1963
1872 local gcp="${EANT_GENTOO_CLASSPATH}" 1964 local gcp="${EANT_GENTOO_CLASSPATH}"
1873 local getjarsarg="" 1965 local getjarsarg=""
1874 1966
1875 if [[ ${EBUILD_PHASE} = "test" ]]; then 1967 if [[ ${EBUILD_PHASE} = "test" ]]; then
1876 antflags="${antflags} -DJunit.present=true" 1968 antflags="${antflags} -DJunit.present=true"
1877 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1969 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1878 getjarsarg="--with-dependencies" 1970 getjarsarg="--with-dependencies"
1879 fi 1971 fi
1880 1972
1881 local cp 1973 local cp
1882 1974
1883 for atom in ${gcp}; do 1975 for atom in ${gcp}; do
1884 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1976 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1885 done 1977 done
1886 1978
1979 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1980
1887 if [[ ${cp} ]]; then 1981 if [[ ${cp} ]]; then
1888 # It seems ant does not like single quotes around ${cp} 1982 # It seems ant does not like single quotes around ${cp}
1983 cp=${cp#:}
1984 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1985 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1889 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1986 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1890 fi 1987 fi
1891 1988
1892 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1989 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1893 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1990 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1894 ant ${antflags} "${@}" || die "eant failed" 1991 ant ${antflags} "${@}" || die "eant failed"
1994# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2091# 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. 2092# call it during each of the phases of the merge process.
1996# 2093#
1997# ----------------------------------------------------------------------------- 2094# -----------------------------------------------------------------------------
1998java-pkg_init() { 2095java-pkg_init() {
2096 debug-print-function ${FUNCNAME} $*
1999 unset JAVAC 2097 unset JAVAC
2000 unset JAVA_HOME 2098 unset JAVA_HOME
2099
2100 java-config --help >/dev/null || {
2101 eerror ""
2102 eerror "Can't run java-config --help"
2103 eerror "Have you upgraded python recently but haven't"
2104 eerror "run python-updater yet?"
2105 die "Can't run java-config --help"
2106 }
2001 2107
2002 # People do all kinds of weird things. 2108 # People do all kinds of weird things.
2003 # http://forums.gentoo.org/viewtopic-p-3943166.html 2109 # http://forums.gentoo.org/viewtopic-p-3943166.html
2004 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2110 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2005 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2111 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2011 ewarn "make.conf for example) to silence this warning or" 2117 ewarn "make.conf for example) to silence this warning or"
2012 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2118 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2013 fi 2119 fi
2014 2120
2015 if [[ -z ${accept} ]]; then 2121 if [[ -z ${accept} ]]; then
2122 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2123 # -version output
2016 unset _JAVA_OPTIONS 2124 unset _JAVA_OPTIONS
2017 # phase hooks make this run many times without this 2125 # phase hooks make this run many times without this
2018 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2126 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2019 fi 2127 fi
2020 2128
2129 if java-pkg_func-exists ant_src_unpack; then
2130 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2131 fi
2132
2021 java-pkg_init_paths_ 2133 java-pkg_init_paths_
2022 java-pkg_switch-vm 2134 java-pkg_switch-vm
2023 PATH=${JAVA_HOME}/bin:${PATH} 2135 PATH=${JAVA_HOME}/bin:${PATH}
2024 2136
2025 # TODO we will probably want to set JAVAC and JAVACFLAGS 2137 # TODO we will probably want to set JAVAC and JAVACFLAGS
2026 2138
2027 # Do some QA checks 2139 # Do some QA checks
2028 java-pkg_check-jikes 2140 java-pkg_check-jikes
2141
2142 # Can't use unset here because Portage does not save the unset
2143 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2029 2144
2030 # When users have crazy classpaths some packages can fail to compile. 2145 # When users have crazy classpaths some packages can fail to compile.
2031 # and everything should work with empty CLASSPATH. 2146 # and everything should work with empty CLASSPATH.
2032 # This also helps prevent unexpected dependencies on random things 2147 # This also helps prevent unexpected dependencies on random things
2033 # from the CLASSPATH. 2148 # from the CLASSPATH.
2034 unset CLASSPATH 2149 export CLASSPATH=
2035 2150
2036 # Unset external ANT_ stuff 2151 # Unset external ANT_ stuff
2037 unset ANT_TASKS 2152 export ANT_TASKS=
2038 unset ANT_OPTS 2153 export ANT_OPTS=
2154 export ANT_RESPECT_JAVA_HOME=
2039} 2155}
2040 2156
2041# ------------------------------------------------------------------------------ 2157# ------------------------------------------------------------------------------
2042# @function-internal java-pkg-init-compiler_ 2158# @function-internal java-pkg-init-compiler_
2043# 2159#
2134 done 2250 done
2135 2251
2136 # If it hasn't been defined already, default to javac 2252 # If it hasn't been defined already, default to javac
2137 if [[ -z ${GENTOO_COMPILER} ]]; then 2253 if [[ -z ${GENTOO_COMPILER} ]]; then
2138 if [[ -n ${compilers} ]]; then 2254 if [[ -n ${compilers} ]]; then
2139 einfo "No suitable compiler found: defaulting javac for compilation" 2255 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2140 else 2256 else
2141 # probably don't need to notify users about the default. 2257 # probably don't need to notify users about the default.
2142 :;#einfo "Defaulting to javac for compilation" 2258 :;#einfo "Defaulting to javac for compilation"
2143 fi 2259 fi
2260 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2261 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2262 else
2144 export GENTOO_COMPILER=javac 2263 export GENTOO_COMPILER=javac
2264 fi
2145 else 2265 else
2146 einfo "Using ${GENTOO_COMPILER} for compilation" 2266 einfo "Using ${GENTOO_COMPILER} for compilation"
2147 fi 2267 fi
2148 2268
2149} 2269}
2165 fi 2285 fi
2166 2286
2167 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2287 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2168 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2288 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2169 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2289 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2290 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2291 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2170 2292
2171 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2293 [[ -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}" 2294 [[ -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" 2295 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2174 2296
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2320 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2199 # Create package.env 2321 # Create package.env
2200 ( 2322 (
2201 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2323 echo "DESCRIPTION=\"${DESCRIPTION}\""
2202 echo "GENERATION=\"2\"" 2324 echo "GENERATION=\"2\""
2325 echo "SLOT=\"${SLOT}\""
2203 2326
2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2327 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2328 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2329 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2330 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2325# 2448#
2326# @return 0 - function is declared 2449# @return 0 - function is declared
2327# @return 1 - function is undeclared 2450# @return 1 - function is undeclared
2328# ------------------------------------------------------------------------------ 2451# ------------------------------------------------------------------------------
2329java-pkg_func-exists() { 2452java-pkg_func-exists() {
2330 if [[ -n "$(declare -f ${1})" ]]; then 2453 declare -F ${1} > /dev/null
2331 return 0
2332 else
2333 return 1
2334 fi
2335} 2454}
2336 2455
2337# ------------------------------------------------------------------------------ 2456# ------------------------------------------------------------------------------
2338# @internal-function java-pkg_setup-vm 2457# @internal-function java-pkg_setup-vm
2339# 2458#
2462 2581
2463 #TODO If you know a better solution let us know. 2582 #TODO If you know a better solution let us know.
2464 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2583 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2465 2584
2466 local tann="${T}/announced-vm" 2585 local tann="${T}/announced-vm"
2586 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2587 # if people have for example modified eclasses some where
2467 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2588 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)" 2589 einfo "Using: $(java-config -f)"
2473 [[ ! -f "${tann}" ]] && touch "${tann}" 2590 [[ ! -f "${tann}" ]] && touch "${tann}"
2474 fi
2475 fi 2591 fi
2476 2592
2477 else 2593 else
2478 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2594 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2479 fi 2595 fi
2518# not. 2634# not.
2519# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2635# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2520# ------------------------------------------------------------------------------ 2636# ------------------------------------------------------------------------------
2521java-pkg_verify-classes() { 2637java-pkg_verify-classes() {
2522 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2638 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2639
2640 local version_verify="/usr/bin/class-version-verify.py"
2641
2642 if [[ ! -x "${version_verify}" ]]; then
2643 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2644 fi
2645
2646 if [[ ! -x "${version_verify}" ]]; then
2647 ewarn "Unable to perform class version checks as"
2648 ewarn "class-version-verify.py is unavailable"
2649 ewarn "Please install dev-java/javatoolkit."
2650 return
2651 fi
2652
2523 local target=$(java-pkg_get-target) 2653 local target=$(java-pkg_get-target)
2524 local result 2654 local result
2525 local log="${T}/class-version-verify.log" 2655 local log="${T}/class-version-verify.log"
2526 if [[ -n "${1}" ]]; then 2656 if [[ -n "${1}" ]]; then
2527 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2657 ${version_verify} -v -t ${target} "${1}" > "${log}"
2528 result=$? 2658 result=$?
2529 else 2659 else
2530 ebegin "Verifying java class versions (target: ${target})" 2660 ebegin "Verifying java class versions (target: ${target})"
2531 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2661 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2532 result=$? 2662 result=$?
2533 eend ${result} 2663 eend ${result}
2534 fi 2664 fi
2535 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2665 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2536 if [[ ${result} != 0 ]]; then 2666 if [[ ${result} != 0 ]]; then
2641is-java-strict() { 2771is-java-strict() {
2642 [[ -n ${JAVA_PKG_STRICT} ]] 2772 [[ -n ${JAVA_PKG_STRICT} ]]
2643 return $? 2773 return $?
2644} 2774}
2645 2775
2776
2646# ------------------------------------------------------------------------------ 2777# ------------------------------------------------------------------------------
2647# @eclass-end 2778# @eclass-end
2648# ------------------------------------------------------------------------------ 2779# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20