/[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.92 Revision 1.113
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.92 2007/08/05 08:17:05 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.113 2008/10/01 15:23:17 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
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
76 77
77# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 80# @variable-default yes
80# 81#
195# 196#
196# @example 197# @example
197# java-pkg_doexamples demo 198# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/* 199# java-pkg_doexamples demo/* examples/*
199# 200#
201# @param --subdir - If the examples need a certain directory structure
200# @param $* - list of files to install 202# @param $* - list of files to install
201# ------------------------------------------------------------------------------ 203# ------------------------------------------------------------------------------
202java-pkg_doexamples() { 204java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $* 205 debug-print-function ${FUNCNAME} $*
204 206
205 [[ ${#} -lt 1 ]] && die "At least one argument needed" 207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206 208
207 java-pkg_check-phase install 209 java-pkg_check-phase install
208 210
209 local dest=/usr/share/doc/${PF}/examples 211 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2}
214 dodir ${dest}
215 shift 2
216 fi
217
210 if [[ ${#} = 1 && -d ${1} ]]; then 218 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env 219 ( # dont want to pollute calling env
212 insinto "${dest}" 220 insinto "${dest}"
213 doins -r ${1}/* 221 doins -r ${1}/*
214 ) || die "Installing examples failed" 222 ) || die "Installing examples failed"
283 done 291 done
284 292
285 java-pkg_do_write_ 293 java-pkg_do_write_
286} 294}
287 295
288
289# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
290# @internal-function depend-java-query 297# @internal-function depend-java-query
291# 298#
292# Wrapper for the depend-java-query binary to enable passing USE in env. 299# Wrapper for the depend-java-query binary to enable passing USE in env.
293# Using env variables keeps this eclass working with java-config versions that 300# Using env variables keeps this eclass working with java-config versions that
438 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
439 # install if it isn't a symlink 446 # install if it isn't a symlink
440 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
441 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
442 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
443 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
446 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
447 else 454 else
448 # TODO use dosym 455 # TODO use dosym
549# ------------------------------------------------------------------------------ 556# ------------------------------------------------------------------------------
550# @ebuild-function java-pkg_dojavadoc 557# @ebuild-function java-pkg_dojavadoc
551# 558#
552# Installs javadoc documentation. This should be controlled by the doc use flag. 559# Installs javadoc documentation. This should be controlled by the doc use flag.
553# 560#
561# @param $1: optional --symlink creates to symlink like this for html
562# documentation bundles.
554# @param $1: - The javadoc root directory. 563# @param $2: - The javadoc root directory.
555# 564#
556# @example: 565# @example:
557# java-pkg_dojavadoc docs/api 566# java-pkg_dojavadoc docs/api
567# java-pkg_dojavadoc --symlink apidocs docs/api
558# 568#
559# ------------------------------------------------------------------------------ 569# ------------------------------------------------------------------------------
560java-pkg_dojavadoc() { 570java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $* 571 debug-print-function ${FUNCNAME} $*
572
573 # For html documentation bundles that link to Javadoc
574 local symlink
575 if [[ ${1} = --symlink ]]; then
576 symlink=${2}
577 shift 2
578 fi
579
562 local dir="$1" 580 local dir="$1"
581 local dest=/usr/share/doc/${PF}/html
563 582
564 # QA checks 583 # QA checks
565 584
566 java-pkg_check-phase install 585 java-pkg_check-phase install
567 586
571 local msg="No index.html in javadoc directory" 590 local msg="No index.html in javadoc directory"
572 ewarn "${msg}" 591 ewarn "${msg}"
573 is-java-strict && die "${msg}" 592 is-java-strict && die "${msg}"
574 fi 593 fi
575 594
595 if [[ -e ${D}/${dest}/api ]]; then
596 eerror "${dest} already exists. Will not overwrite."
597 die "${dest}"
598 fi
599
576 # Renaming to match our directory layout 600 # Renaming to match our directory layout
577 601
578 local dir_to_install="${dir}" 602 local dir_to_install="${dir}"
579 if [[ "$(basename "${dir}")" != "api" ]]; then 603 if [[ "$(basename "${dir}")" != "api" ]]; then
580 dir_to_install="${T}/api" 604 dir_to_install="${T}/api"
582 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 606 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
583 fi 607 fi
584 608
585 # Actual installation 609 # Actual installation
586 610
587 java-pkg_dohtml -r ${dir_to_install} 611 java-pkg_dohtml -r "${dir_to_install}"
612
613 # Let's make a symlink to the directory we have everything else under
614 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
615
616 if [[ ${symlink} ]]; then
617 debug-print "symlinking ${dest}/{api,${symlink}}"
618 dosym ${dest}/{api,${symlink}} || die
619 fi
588} 620}
589 621
590# ------------------------------------------------------------------------------ 622# ------------------------------------------------------------------------------
591# @ebuild-function java-pkg_dosrc 623# @ebuild-function java-pkg_dosrc
592# 624#
615 647
616 [[ ${#} -lt 1 ]] && die "At least one argument needed" 648 [[ ${#} -lt 1 ]] && die "At least one argument needed"
617 649
618 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
619 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
620 if is-java-strict; then 652 java-pkg_announce-qa-violation ${msg}
621 eerror "${msg}"
622 die "${msg}"
623 else
624 echo "${msg}"
625 echo "Please report this to http://bugs.gentoo.org."
626 fi
627 fi 653 fi
628 654
629 java-pkg_init_paths_ 655 java-pkg_init_paths_
630 656
631 local zip_name="${PN}-src.zip" 657 local zip_name="${PN}-src.zip"
831# @param $opt 857# @param $opt
832# --build-only - makes the jar(s) not added into package.env DEPEND line. 858# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test) 859# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies 860# --with-dependencies - get jars also from requested package's dependencies
835# transitively. 861# transitively.
862# --virtual - Packages passed to this function are to be handled as virtuals
863# and will not have individual jar dependencies recorded.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of . 864# --into $dir - symlink jar(s) into $dir (must exist) instead of .
837# @param $1 - Package to get jars from, or comma-separated list of packages in 865# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used. 866# case other parameters are not used.
839# @param $2 - jar from package. If not specified, all jars will be used. 867# @param $2 - jar from package. If not specified, all jars will be used.
840# @param $3 - When a single jar is specified, destination filename of the 868# @param $3 - When a single jar is specified, destination filename of the
845 debug-print-function ${FUNCNAME} $* 873 debug-print-function ${FUNCNAME} $*
846 874
847 local build_only="" 875 local build_only=""
848 local destdir="." 876 local destdir="."
849 local deep="" 877 local deep=""
878 local virtual=""
850 879
851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 880 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
852 881
853 while [[ "${1}" == --* ]]; do 882 while [[ "${1}" == --* ]]; do
854 if [[ "${1}" = "--build-only" ]]; then 883 if [[ "${1}" = "--build-only" ]]; then
855 build_only="build" 884 build_only="build"
856 elif [[ "${1}" = "--with-dependencies" ]]; then 885 elif [[ "${1}" = "--with-dependencies" ]]; then
857 deep="--with-dependencies" 886 deep="--with-dependencies"
887 elif [[ "${1}" = "--virtual" ]]; then
888 virtual="true"
858 elif [[ "${1}" = "--into" ]]; then 889 elif [[ "${1}" = "--into" ]]; then
859 destdir="${2}" 890 destdir="${2}"
860 shift 891 shift
861 else 892 else
862 die "java-pkg_jar-from called with unknown parameter: ${1}" 893 die "java-pkg_jar-from called with unknown parameter: ${1}"
865 done 896 done
866 897
867 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 898 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
868 899
869 [[ -z ${target_pkg} ]] && die "Must specify a package" 900 [[ -z ${target_pkg} ]] && die "Must specify a package"
901
902 if [[ "${EAPI}" == "1" ]]; then
903 target_pkg="${target_pkg//:/-}"
904 fi
870 905
871 # default destjar to the target jar 906 # default destjar to the target jar
872 [[ -z "${destjar}" ]] && destjar="${target_jar}" 907 [[ -z "${destjar}" ]] && destjar="${target_jar}"
873 908
874 local error_msg="There was a problem getting the classpath for ${target_pkg}." 909 local error_msg="There was a problem getting the classpath for ${target_pkg}."
886 done 921 done
887 # setting this disables further record-jar_ calls later 922 # setting this disables further record-jar_ calls later
888 build_only="build" 923 build_only="build"
889 else 924 else
890 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 925 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
926 fi
927
928 # Record the entire virtual as a dependency so that
929 # no jars are missed.
930 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
931 java-pkg_record-jar_ "${target_pkg}"
932 # setting this disables further record-jars_ calls later
933 build_only="build"
891 fi 934 fi
892 935
893 pushd ${destdir} > /dev/null \ 936 pushd ${destdir} > /dev/null \
894 || die "failed to change directory to ${destdir}" 937 || die "failed to change directory to ${destdir}"
895 938
978 done 1021 done
979 1022
980 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1023 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
981 1024
982 1025
983 local classpath pkgs="${1}" 1026 local pkgs="${1}"
1027
1028 if [[ "${EAPI}" == "1" ]]; then
1029 pkgs="${pkgs//:/-}"
1030 fi
1031
984 jars="$(java-config ${deep} --classpath=${pkgs})" 1032 jars="$(java-config ${deep} --classpath=${pkgs})"
985 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1033 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
986 debug-print "${pkgs}:${jars}" 1034 debug-print "${pkgs}:${jars}"
987 1035
988 for pkg in ${pkgs//,/ }; do 1036 for pkg in ${pkgs//,/ }; do
989 java-pkg_ensure-dep "${build_only}" "${pkg}" 1037 java-pkg_ensure-dep "${build_only}" "${pkg}"
990 done 1038 done
991
992 if [[ -z "${classpath}" ]]; then
993 classpath="${jars}"
994 else
995 classpath="${classpath}:${jars}"
996 fi
997 1039
998 # Only record jars that aren't build-only 1040 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 1041 if [[ -z "${build_only}" ]]; then
1000 for pkg in ${pkgs//,/ }; do 1042 for pkg in ${pkgs//,/ }; do
1001 java-pkg_record-jar_ "${pkg}" 1043 java-pkg_record-jar_ "${pkg}"
1002 done 1044 done
1003 fi 1045 fi
1004 1046
1005 echo "${classpath}" 1047 echo "${jars}"
1006} 1048}
1007 1049
1008# ------------------------------------------------------------------------------ 1050# ------------------------------------------------------------------------------
1009# @ebuild-function java-pkg_getjar 1051# @ebuild-function java-pkg_getjar
1010# 1052#
1019# @example-return 1061# @example-return
1020# /usr/share/xerces-2/lib/xml-apis.jar 1062# /usr/share/xerces-2/lib/xml-apis.jar
1021# 1063#
1022# @param $opt 1064# @param $opt
1023# --build-only - makes the jar not added into package.env DEPEND line. 1065# --build-only - makes the jar not added into package.env DEPEND line.
1066# --virtual - Packages passed to this function are to be handled as virtuals
1067# and will not have individual jar dependencies recorded.
1024# @param $1 - package to use 1068# @param $1 - package to use
1025# @param $2 - jar to get 1069# @param $2 - jar to get
1026# ------------------------------------------------------------------------------ 1070# ------------------------------------------------------------------------------
1027java-pkg_getjar() { 1071java-pkg_getjar() {
1028 debug-print-function ${FUNCNAME} $* 1072 debug-print-function ${FUNCNAME} $*
1029 1073
1030 local build_only="" 1074 local build_only=""
1075 local virtual=""
1031 1076
1032 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1033 1078
1034 while [[ "${1}" == --* ]]; do 1079 while [[ "${1}" == --* ]]; do
1035 if [[ "${1}" = "--build-only" ]]; then 1080 if [[ "${1}" = "--build-only" ]]; then
1036 build_only="build" 1081 build_only="build"
1082 elif [[ "${1}" == "--virtual" ]]; then
1083 virtual="true"
1037 else 1084 else
1038 die "java-pkg_jar-from called with unknown parameter: ${1}" 1085 die "java-pkg_getjar called with unknown parameter: ${1}"
1039 fi 1086 fi
1040 shift 1087 shift
1041 done 1088 done
1042 1089
1043 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1090 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1044 1091
1045 local pkg="${1}" target_jar="${2}" jar 1092 local pkg="${1}" target_jar="${2}" jar
1093
1094 if [[ "${EAPI}" == "1" ]]; then
1095 pkg="${pkg//:/-}"
1096 fi
1097
1046 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1098 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1047 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1099 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1048 1100
1049 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1101 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1050 local classpath 1102 local classpath
1051 classpath=$(java-config --classpath=${pkg}) 1103 classpath=$(java-config --classpath=${pkg})
1052 [[ $? != 0 ]] && die ${error_msg} 1104 [[ $? != 0 ]] && die ${error_msg}
1053 1105
1054 java-pkg_ensure-dep "${build_only}" "${pkg}" 1106 java-pkg_ensure-dep "${build_only}" "${pkg}"
1107
1108 # Record the package(Virtual) as a dependency and then set build_only
1109 # So that individual jars are not recorded.
1110 if [[ -n "${virtual}" ]]; then
1111 java-pkg_record-jar_ "${pkg}"
1112 build_only="true"
1113 fi
1055 1114
1056 for jar in ${classpath//:/ }; do 1115 for jar in ${classpath//:/ }; do
1057 if [[ ! -f "${jar}" ]] ; then 1116 if [[ ! -f "${jar}" ]] ; then
1058 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1117 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1059 fi 1118 fi
1104 1163
1105 local pkgs="${1}" 1164 local pkgs="${1}"
1106 local jar="${2}" 1165 local jar="${2}"
1107 1166
1108 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1167 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1168
1169 if [[ "${EAPI}" == "1" ]]; then
1170 pkgs="${pkgs//:/-}"
1171 fi
1109 1172
1110 if [[ -z "${jar}" ]]; then 1173 if [[ -z "${jar}" ]]; then
1111 for pkg in ${pkgs//,/ }; do 1174 for pkg in ${pkgs//,/ }; do
1112 java-pkg_ensure-dep runtime "${pkg}" 1175 java-pkg_ensure-dep runtime "${pkg}"
1113 java-pkg_record-jar_ "${pkg}" 1176 java-pkg_record-jar_ "${pkg}"
1155 1218
1156 local pkgs="${1}" 1219 local pkgs="${1}"
1157 local jar="${2}" 1220 local jar="${2}"
1158 1221
1159 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1222 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1223
1224 if [[ "${EAPI}" == "1" ]]; then
1225 pkgs="${pkgs//:/-}"
1226 fi
1160 1227
1161 if [[ -z "${jar}" ]]; then 1228 if [[ -z "${jar}" ]]; then
1162 for pkg in ${pkgs//,/ }; do 1229 for pkg in ${pkgs//,/ }; do
1163 java-pkg_record-jar_ --optional "${pkg}" 1230 java-pkg_record-jar_ --optional "${pkg}"
1164 done 1231 done
1665 dodir /usr/share/ant/${TASKS_DIR} 1732 dodir /usr/share/ant/${TASKS_DIR}
1666 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1733 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1667} 1734}
1668 1735
1669# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1670# @internal-function java-pkg_ant-tasks-from-deps
1671#
1672# Function to determine ANT_TASKS from DEPEND variable for backwards
1673# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1674# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1675# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1676# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1677# be a problem, the worst it can do is activace all tasks when not needed.
1678# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1679# insufficient dependencies, otherwise all available tasks are used for
1680# backwards compatilbility.
1681#
1682# @return "all" or "none"
1683# ------------------------------------------------------------------------------
1684java-pkg_ant-tasks-from-deps() {
1685 local found_ant found_ant_tasks
1686
1687 for dep in ${DEPEND}
1688 do
1689 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1690 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1691 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1692 done
1693
1694 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1695 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1696 echo "all"
1697 else
1698 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1699 # so we deactivate all tasks that may be installed
1700 echo "none"
1701 fi
1702}
1703
1704# ------------------------------------------------------------------------------
1705# @internal-function java-pkg_ant-tasks-depend 1737# @internal-function java-pkg_ant-tasks-depend
1706# 1738#
1707# Translates the WANT_ANT_TASKS variable into valid dependencies. 1739# Translates the WANT_ANT_TASKS variable into valid dependencies.
1708# ------------------------------------------------------------------------------ 1740# ------------------------------------------------------------------------------
1709java-pkg_ant-tasks-depend() { 1741java-pkg_ant-tasks-depend() {
1711 1743
1712 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1713 local DEP="" 1745 local DEP=""
1714 for i in ${WANT_ANT_TASKS} 1746 for i in ${WANT_ANT_TASKS}
1715 do 1747 do
1716 if [[ ${i} != ant-* ]]; then 1748 if [[ ${i} = ant-* ]]; then
1749 DEP="${DEP}dev-java/${i} "
1750 elif [[ ${i} = */*:* ]]; then
1751 DEP="${DEP}${i} "
1752 else
1717 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1753 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1718 return 1 1754 return 1
1719 fi 1755 fi
1720 DEP="${DEP}dev-java/${i} "
1721 done 1756 done
1722 echo ${DEP} 1757 echo ${DEP}
1723 return 0 1758 return 0
1724 else 1759 else
1725 return 0 1760 return 0
1742# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1743ejunit() { 1778ejunit() {
1744 debug-print-function ${FUNCNAME} $* 1779 debug-print-function ${FUNCNAME} $*
1745 1780
1746 local pkgs 1781 local pkgs
1782 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1747 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1783 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1748 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1784 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1749 done 1785 done
1786 fi
1750 1787
1751 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1788 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1752 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1789 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1753 cp="${2}:${cp}" 1790 cp="${2}:${cp}"
1754 shift 2 1791 shift 2
1762} 1799}
1763 1800
1764# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1765# @section-end helper 1802# @section-end helper
1766# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1804
1805# ------------------------------------------------------------------------------
1806# @eclass-src_prepare
1807#
1808# src_prepare Searches for bundled jars
1809# ------------------------------------------------------------------------------
1810
1811java-utils-2_src_prepare() {
1812 # Remember that eant will call this unless called via Portage
1813 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1814 echo "Searching for bundled jars:"
1815 java-pkg_find-normal-jars || echo "None found."
1816 echo "Searching for bundled classes (no output if none found):"
1817 find "${WORKDIR}" -name "*.class"
1818 echo "Search done."
1819 fi
1820 touch "${T}/java-utils-2_src_prepare-run"
1821}
1767 1822
1768# ------------------------------------------------------------------------------ 1823# ------------------------------------------------------------------------------
1769# @section-begin build 1824# @section-begin build
1770# @section-summary Build functions 1825# @section-summary Build functions
1771# 1826#
1787# ------------------------------------------------------------------------------ 1842# ------------------------------------------------------------------------------
1788eant() { 1843eant() {
1789 debug-print-function ${FUNCNAME} $* 1844 debug-print-function ${FUNCNAME} $*
1790 1845
1791 if [[ ${EBUILD_PHASE} = compile ]]; then 1846 if [[ ${EBUILD_PHASE} = compile ]]; then
1792 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1847 java-ant-2_src_configure
1793 # finally get rid of the hooks without breaking stuff 1848 java-utils-2_src_prepare
1794
1795 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1796 && java-ant_ignore-system-classes "${S}/build.xml"
1797
1798 if hasq java-ant-2 ${INHERITED}; then
1799 java-ant_bsfix
1800 fi
1801
1802 # eant can be called multiple times
1803 JAVA_PKG_BSFIX="off"
1804
1805 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1806 echo "Searching for bundled jars:"
1807 java-pkg_find-normal-jars || echo "None found."
1808 echo "Searching for bundled classes (no output if none found):"
1809 find "${WORKDIR}" -name "*.class"
1810 echo "Search done."
1811 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1812 fi
1813 fi 1849 fi
1814 1850
1815 if ! hasq java-ant-2 ${INHERITED}; then 1851 if ! hasq java-ant-2 ${INHERITED}; then
1816 local msg="You should inherit java-ant-2 when using eant" 1852 local msg="You should inherit java-ant-2 when using eant"
1817 java-pkg_announce-qa-violation "${msg}" 1853 java-pkg_announce-qa-violation "${msg}"
1818 fi 1854 fi
1819 1855
1820 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1856 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1821 1857
1822 java-pkg_init-compiler_ 1858 java-pkg_init-compiler_
1823 local compiler="${GENTOO_COMPILER}" 1859 local compiler="${GENTOO_COMPILER}"
1824 1860
1825 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1861 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1836 # java-config -p 1872 # java-config -p
1837 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1873 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1838 if [[ -n ${build_compiler_deps} ]]; then 1874 if [[ -n ${build_compiler_deps} ]]; then
1839 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1875 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1840 fi 1876 fi
1841 fi
1842
1843 if is-java-strict; then
1844 einfo "Disabling system classpath for ant"
1845 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1846 fi 1877 fi
1847 1878
1848 for arg in "${@}"; do 1879 for arg in "${@}"; do
1849 if [[ ${arg} = -lib ]]; then 1880 if [[ ${arg} = -lib ]]; then
1850 if is-java-strict; then 1881 if is-java-strict; then
1859 echo "more info." 1890 echo "more info."
1860 fi 1891 fi
1861 fi 1892 fi
1862 done 1893 done
1863 1894
1864 # we use this in src_* so we run ant from / 1895 # parse WANT_ANT_TASKS for atoms
1865 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1896 local want_ant_tasks
1866 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1897 for i in ${WANT_ANT_TASKS}; do
1867 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1898 if [[ ${i} = */*:* ]]; then
1868 1899 i=${i#*/}
1869 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1900 i=${i%:0}
1870 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1901 want_ant_tasks+="${i/:/-} "
1871
1872 if is-java-strict; then
1873 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1874 if [[ -z "${ANT_TASKS}" ]]; then
1875 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1876 fi
1877 else 1902 else
1903 want_ant_tasks+="${i} "
1904 fi
1905 done
1906 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1907 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1908
1909 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1910 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1911
1878 # if ant-tasks is not set by ebuild or forced, activate all of them 1912 # if ant-tasks is not set by ebuild or forced, use none
1879 ANT_TASKS="${ANT_TASKS:-all}" 1913 ANT_TASKS="${ANT_TASKS:-none}"
1880 fi
1881 1914
1882 # at this point, ANT_TASKS should be "all", "none" or explicit list 1915 # at this point, ANT_TASKS should be "all", "none" or explicit list
1883 if [[ "${ANT_TASKS}" == "all" ]]; then 1916 if [[ "${ANT_TASKS}" == "all" ]]; then
1884 einfo "Using all available ANT_TASKS" 1917 einfo "Using all available ANT_TASKS"
1885 elif [[ "${ANT_TASKS}" == "none" ]]; then 1918 elif [[ "${ANT_TASKS}" == "none" ]]; then
1886 einfo "Disabling all optional ANT_TASKS" 1919 einfo "Disabling all optional ANT_TASKS"
1887 else 1920 else
1888 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1921 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1889 fi 1922 fi
1890 1923
1891 export ANT_TASKS 1924 export ANT_TASKS
1892 fi
1893 1925
1894 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1926 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1895 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1927 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1896 1928
1897 local gcp="${EANT_GENTOO_CLASSPATH}" 1929 local gcp="${EANT_GENTOO_CLASSPATH}"
1898 local getjarsarg="" 1930 local getjarsarg=""
1899 1931
1900 if [[ ${EBUILD_PHASE} = "test" ]]; then 1932 if [[ ${EBUILD_PHASE} = "test" ]]; then
1901 antflags="${antflags} -DJunit.present=true" 1933 antflags="${antflags} -DJunit.present=true"
1902 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1934 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1903 getjarsarg="--with-dependencies" 1935 getjarsarg="--with-dependencies"
1904 fi 1936 fi
1905 1937
1906 local cp 1938 local cp
1907 1939
1909 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1941 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1910 done 1942 done
1911 1943
1912 if [[ ${cp} ]]; then 1944 if [[ ${cp} ]]; then
1913 # It seems ant does not like single quotes around ${cp} 1945 # It seems ant does not like single quotes around ${cp}
1946 cp=${cp#:}
1947 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1948 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1914 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1949 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1915 fi 1950 fi
1916 1951
1917 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1952 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1918 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1953 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1919 ant ${antflags} "${@}" || die "eant failed" 1954 ant ${antflags} "${@}" || die "eant failed"
2019# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2054# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2020# call it during each of the phases of the merge process. 2055# call it during each of the phases of the merge process.
2021# 2056#
2022# ----------------------------------------------------------------------------- 2057# -----------------------------------------------------------------------------
2023java-pkg_init() { 2058java-pkg_init() {
2059 debug-print-function ${FUNCNAME} $*
2024 unset JAVAC 2060 unset JAVAC
2025 unset JAVA_HOME 2061 unset JAVA_HOME
2026 2062
2027 # People do all kinds of weird things. 2063 # People do all kinds of weird things.
2028 # http://forums.gentoo.org/viewtopic-p-3943166.html 2064 # http://forums.gentoo.org/viewtopic-p-3943166.html
2036 ewarn "make.conf for example) to silence this warning or" 2072 ewarn "make.conf for example) to silence this warning or"
2037 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2073 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2038 fi 2074 fi
2039 2075
2040 if [[ -z ${accept} ]]; then 2076 if [[ -z ${accept} ]]; then
2077 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2078 # -version output
2041 unset _JAVA_OPTIONS 2079 unset _JAVA_OPTIONS
2042 # phase hooks make this run many times without this 2080 # phase hooks make this run many times without this
2043 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2081 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2044 fi 2082 fi
2045 2083
2053 2091
2054 # TODO we will probably want to set JAVAC and JAVACFLAGS 2092 # TODO we will probably want to set JAVAC and JAVACFLAGS
2055 2093
2056 # Do some QA checks 2094 # Do some QA checks
2057 java-pkg_check-jikes 2095 java-pkg_check-jikes
2096
2097 # Can't use unset here because Portage does not save the unset
2098 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2058 2099
2059 # When users have crazy classpaths some packages can fail to compile. 2100 # When users have crazy classpaths some packages can fail to compile.
2060 # and everything should work with empty CLASSPATH. 2101 # and everything should work with empty CLASSPATH.
2061 # This also helps prevent unexpected dependencies on random things 2102 # This also helps prevent unexpected dependencies on random things
2062 # from the CLASSPATH. 2103 # from the CLASSPATH.
2063 unset CLASSPATH 2104 export CLASSPATH=
2064 2105
2065 # Unset external ANT_ stuff 2106 # Unset external ANT_ stuff
2066 unset ANT_TASKS 2107 export ANT_TASKS=
2067 unset ANT_OPTS 2108 export ANT_OPTS=
2068} 2109}
2069 2110
2070# ------------------------------------------------------------------------------ 2111# ------------------------------------------------------------------------------
2071# @function-internal java-pkg-init-compiler_ 2112# @function-internal java-pkg-init-compiler_
2072# 2113#
2163 done 2204 done
2164 2205
2165 # If it hasn't been defined already, default to javac 2206 # If it hasn't been defined already, default to javac
2166 if [[ -z ${GENTOO_COMPILER} ]]; then 2207 if [[ -z ${GENTOO_COMPILER} ]]; then
2167 if [[ -n ${compilers} ]]; then 2208 if [[ -n ${compilers} ]]; then
2168 einfo "No suitable compiler found: defaulting javac for compilation" 2209 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2169 else 2210 else
2170 # probably don't need to notify users about the default. 2211 # probably don't need to notify users about the default.
2171 :;#einfo "Defaulting to javac for compilation" 2212 :;#einfo "Defaulting to javac for compilation"
2172 fi 2213 fi
2214 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2215 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2216 else
2173 export GENTOO_COMPILER=javac 2217 export GENTOO_COMPILER=javac
2218 fi
2174 else 2219 else
2175 einfo "Using ${GENTOO_COMPILER} for compilation" 2220 einfo "Using ${GENTOO_COMPILER} for compilation"
2176 fi 2221 fi
2177 2222
2178} 2223}
2194 fi 2239 fi
2195 2240
2196 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2241 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2197 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2242 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2198 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2243 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2244 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2245 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2199 2246
2200 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2247 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2201 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2248 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2202 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2249 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2203 2250
2227 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2274 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2228 # Create package.env 2275 # Create package.env
2229 ( 2276 (
2230 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2277 echo "DESCRIPTION=\"${DESCRIPTION}\""
2231 echo "GENERATION=\"2\"" 2278 echo "GENERATION=\"2\""
2279 echo "SLOT=\"${SLOT}\""
2232 2280
2233 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2281 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2234 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2282 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2235 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2283 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2236 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2284 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2544# not. 2592# not.
2545# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2593# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2546# ------------------------------------------------------------------------------ 2594# ------------------------------------------------------------------------------
2547java-pkg_verify-classes() { 2595java-pkg_verify-classes() {
2548 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2596 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2597
2598 local version_verify="/usr/bin/class-version-verify.py"
2599
2600 if [[ ! -x "${version_verify}" ]]; then
2601 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2602 fi
2603
2604 if [[ ! -x "${version_verify}" ]]; then
2605 ewarn "Unable to perform class version checks as"
2606 ewarn "class-version-verify.py is unavailable"
2607 ewarn "Please install dev-java/javatoolkit."
2608 return
2609 fi
2610
2549 local target=$(java-pkg_get-target) 2611 local target=$(java-pkg_get-target)
2550 local result 2612 local result
2551 local log="${T}/class-version-verify.log" 2613 local log="${T}/class-version-verify.log"
2552 if [[ -n "${1}" ]]; then 2614 if [[ -n "${1}" ]]; then
2553 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2615 ${version_verify} -v -t ${target} "${1}" > "${log}"
2554 result=$? 2616 result=$?
2555 else 2617 else
2556 ebegin "Verifying java class versions (target: ${target})" 2618 ebegin "Verifying java class versions (target: ${target})"
2557 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2619 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2558 result=$? 2620 result=$?
2559 eend ${result} 2621 eend ${result}
2560 fi 2622 fi
2561 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2623 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2562 if [[ ${result} != 0 ]]; then 2624 if [[ ${result} != 0 ]]; then
2667is-java-strict() { 2729is-java-strict() {
2668 [[ -n ${JAVA_PKG_STRICT} ]] 2730 [[ -n ${JAVA_PKG_STRICT} ]]
2669 return $? 2731 return $?
2670} 2732}
2671 2733
2734[[ "${EAPI}" = "2" ]] && EXPORT_FUNCTIONS src_prepare
2735
2672# ------------------------------------------------------------------------------ 2736# ------------------------------------------------------------------------------
2673# @eclass-end 2737# @eclass-end
2674# ------------------------------------------------------------------------------ 2738# ------------------------------------------------------------------------------

Legend:
Removed from v.1.92  
changed lines
  Added in v.1.113

  ViewVC Help
Powered by ViewVC 1.1.20