/[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.99 Revision 1.107
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.99 2007/11/28 01:54:13 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.107 2008/05/03 21:28:45 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
290 fi 290 fi
291 done 291 done
292 292
293 java-pkg_do_write_ 293 java-pkg_do_write_
294} 294}
295
296 295
297# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
298# @internal-function depend-java-query 297# @internal-function depend-java-query
299# 298#
300# 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.
610 # Actual installation 609 # Actual installation
611 610
612 java-pkg_dohtml -r "${dir_to_install}" 611 java-pkg_dohtml -r "${dir_to_install}"
613 612
614 # Let's make a symlink to the directory we have everything else under 613 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest} "${JAVA_PKG_SHAREPATH}/api" || die 614 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616 615
617 if [[ ${symlink} ]]; then 616 if [[ ${symlink} ]]; then
617 debug-print "symlinking ${dest}/{api,${symlink}}"
618 dosym ${dest}/{api,${symlink}} || die 618 dosym ${dest}/{api,${symlink}} || die
619 fi 619 fi
620} 620}
621 621
622# ------------------------------------------------------------------------------ 622# ------------------------------------------------------------------------------
647 647
648 [[ ${#} -lt 1 ]] && die "At least one argument needed" 648 [[ ${#} -lt 1 ]] && die "At least one argument needed"
649 649
650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
652 if is-java-strict; then 652 java-pkg_announce-qa-violation ${msg}
653 eerror "${msg}"
654 die "${msg}"
655 else
656 echo "${msg}"
657 echo "Please report this to http://bugs.gentoo.org."
658 fi
659 fi 653 fi
660 654
661 java-pkg_init_paths_ 655 java-pkg_init_paths_
662 656
663 local zip_name="${PN}-src.zip" 657 local zip_name="${PN}-src.zip"
903 897
904 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 898 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
905 899
906 [[ -z ${target_pkg} ]] && die "Must specify a package" 900 [[ -z ${target_pkg} ]] && die "Must specify a package"
907 901
902 if [[ "${EAPI}" == "1" ]]; then
903 target_pkg="${target_pkg//:/-}"
904 fi
905
908 # default destjar to the target jar 906 # default destjar to the target jar
909 [[ -z "${destjar}" ]] && destjar="${target_jar}" 907 [[ -z "${destjar}" ]] && destjar="${target_jar}"
910 908
911 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}."
912 local classpath 910 local classpath
1023 done 1021 done
1024 1022
1025 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1023 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1026 1024
1027 1025
1028 local classpath pkgs="${1}" 1026 local pkgs="${1}"
1027
1028 if [[ "${EAPI}" == "1" ]]; then
1029 pkgs="${pkgs//:/-}"
1030 fi
1031
1029 jars="$(java-config ${deep} --classpath=${pkgs})" 1032 jars="$(java-config ${deep} --classpath=${pkgs})"
1030 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1033 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1031 debug-print "${pkgs}:${jars}" 1034 debug-print "${pkgs}:${jars}"
1032 1035
1033 for pkg in ${pkgs//,/ }; do 1036 for pkg in ${pkgs//,/ }; do
1034 java-pkg_ensure-dep "${build_only}" "${pkg}" 1037 java-pkg_ensure-dep "${build_only}" "${pkg}"
1035 done 1038 done
1036
1037 if [[ -z "${classpath}" ]]; then
1038 classpath="${jars}"
1039 else
1040 classpath="${classpath}:${jars}"
1041 fi
1042 1039
1043 # Only record jars that aren't build-only 1040 # Only record jars that aren't build-only
1044 if [[ -z "${build_only}" ]]; then 1041 if [[ -z "${build_only}" ]]; then
1045 for pkg in ${pkgs//,/ }; do 1042 for pkg in ${pkgs//,/ }; do
1046 java-pkg_record-jar_ "${pkg}" 1043 java-pkg_record-jar_ "${pkg}"
1047 done 1044 done
1048 fi 1045 fi
1049 1046
1050 echo "${classpath}" 1047 echo "${jars}"
1051} 1048}
1052 1049
1053# ------------------------------------------------------------------------------ 1050# ------------------------------------------------------------------------------
1054# @ebuild-function java-pkg_getjar 1051# @ebuild-function java-pkg_getjar
1055# 1052#
1080 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1081 1078
1082 while [[ "${1}" == --* ]]; do 1079 while [[ "${1}" == --* ]]; do
1083 if [[ "${1}" = "--build-only" ]]; then 1080 if [[ "${1}" = "--build-only" ]]; then
1084 build_only="build" 1081 build_only="build"
1085 elif [[ "${1}" == --* ]]; then 1082 elif [[ "${1}" == "--virtual" ]]; then
1086 virtual="true" 1083 virtual="true"
1087 else 1084 else
1088 die "java-pkg_jar-from called with unknown parameter: ${1}" 1085 die "java-pkg_getjar called with unknown parameter: ${1}"
1089 fi 1086 fi
1090 shift 1087 shift
1091 done 1088 done
1092 1089
1093 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1090 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1094 1091
1095 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
1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1098 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1097 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1099 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1098 1100
1099 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?"
1100 local classpath 1102 local classpath
1161 1163
1162 local pkgs="${1}" 1164 local pkgs="${1}"
1163 local jar="${2}" 1165 local jar="${2}"
1164 1166
1165 [[ -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
1166 1172
1167 if [[ -z "${jar}" ]]; then 1173 if [[ -z "${jar}" ]]; then
1168 for pkg in ${pkgs//,/ }; do 1174 for pkg in ${pkgs//,/ }; do
1169 java-pkg_ensure-dep runtime "${pkg}" 1175 java-pkg_ensure-dep runtime "${pkg}"
1170 java-pkg_record-jar_ "${pkg}" 1176 java-pkg_record-jar_ "${pkg}"
1212 1218
1213 local pkgs="${1}" 1219 local pkgs="${1}"
1214 local jar="${2}" 1220 local jar="${2}"
1215 1221
1216 [[ -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
1217 1227
1218 if [[ -z "${jar}" ]]; then 1228 if [[ -z "${jar}" ]]; then
1219 for pkg in ${pkgs//,/ }; do 1229 for pkg in ${pkgs//,/ }; do
1220 java-pkg_record-jar_ --optional "${pkg}" 1230 java-pkg_record-jar_ --optional "${pkg}"
1221 done 1231 done
1722 dodir /usr/share/ant/${TASKS_DIR} 1732 dodir /usr/share/ant/${TASKS_DIR}
1723 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1733 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1724} 1734}
1725 1735
1726# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1727# @internal-function java-pkg_ant-tasks-from-deps
1728#
1729# Function to determine ANT_TASKS from DEPEND variable for backwards
1730# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1731# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1732# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1733# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1734# be a problem, the worst it can do is activace all tasks when not needed.
1735# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1736# insufficient dependencies, otherwise all available tasks are used for
1737# backwards compatilbility.
1738#
1739# @return "all" or "none"
1740# ------------------------------------------------------------------------------
1741java-pkg_ant-tasks-from-deps() {
1742 local found_ant found_ant_tasks
1743
1744 for dep in ${DEPEND}
1745 do
1746 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1747 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1748 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1749 done
1750
1751 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1752 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1753 echo "all"
1754 else
1755 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1756 # so we deactivate all tasks that may be installed
1757 echo "none"
1758 fi
1759}
1760
1761# ------------------------------------------------------------------------------
1762# @internal-function java-pkg_ant-tasks-depend 1737# @internal-function java-pkg_ant-tasks-depend
1763# 1738#
1764# Translates the WANT_ANT_TASKS variable into valid dependencies. 1739# Translates the WANT_ANT_TASKS variable into valid dependencies.
1765# ------------------------------------------------------------------------------ 1740# ------------------------------------------------------------------------------
1766java-pkg_ant-tasks-depend() { 1741java-pkg_ant-tasks-depend() {
1799# ------------------------------------------------------------------------------ 1774# ------------------------------------------------------------------------------
1800ejunit() { 1775ejunit() {
1801 debug-print-function ${FUNCNAME} $* 1776 debug-print-function ${FUNCNAME} $*
1802 1777
1803 local pkgs 1778 local pkgs
1779 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1804 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1805 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1806 done 1782 done
1783 fi
1807 1784
1808 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1785 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1809 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1786 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1810 cp="${2}:${cp}" 1787 cp="${2}:${cp}"
1811 shift 2 1788 shift 2
1911 echo "more info." 1888 echo "more info."
1912 fi 1889 fi
1913 fi 1890 fi
1914 done 1891 done
1915 1892
1916 # we use this in src_* so we run ant from /
1917 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1918 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1919 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1920 1895
1921 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1922 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1923 1898
1924 if is-java-strict; then
1925 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1926 if [[ -z "${ANT_TASKS}" ]]; then
1927 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1928 fi
1929 else
1930 # if ant-tasks is not set by ebuild or forced, activate all of them 1899 # if ant-tasks is not set by ebuild or forced, use none
1931 ANT_TASKS="${ANT_TASKS:-all}" 1900 ANT_TASKS="${ANT_TASKS:-none}"
1932 fi
1933 1901
1934 # at this point, ANT_TASKS should be "all", "none" or explicit list 1902 # at this point, ANT_TASKS should be "all", "none" or explicit list
1935 if [[ "${ANT_TASKS}" == "all" ]]; then 1903 if [[ "${ANT_TASKS}" == "all" ]]; then
1936 einfo "Using all available ANT_TASKS" 1904 einfo "Using all available ANT_TASKS"
1937 elif [[ "${ANT_TASKS}" == "none" ]]; then 1905 elif [[ "${ANT_TASKS}" == "none" ]]; then
1938 einfo "Disabling all optional ANT_TASKS" 1906 einfo "Disabling all optional ANT_TASKS"
1939 else 1907 else
1940 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1908 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1941 fi 1909 fi
1942 1910
1943 export ANT_TASKS 1911 export ANT_TASKS
1944 fi
1945 1912
1946 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1913 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1947 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1914 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1948 1915
1949 local gcp="${EANT_GENTOO_CLASSPATH}" 1916 local gcp="${EANT_GENTOO_CLASSPATH}"
2221 done 2188 done
2222 2189
2223 # If it hasn't been defined already, default to javac 2190 # If it hasn't been defined already, default to javac
2224 if [[ -z ${GENTOO_COMPILER} ]]; then 2191 if [[ -z ${GENTOO_COMPILER} ]]; then
2225 if [[ -n ${compilers} ]]; then 2192 if [[ -n ${compilers} ]]; then
2226 einfo "No suitable compiler found: defaulting javac for compilation" 2193 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2227 else 2194 else
2228 # probably don't need to notify users about the default. 2195 # probably don't need to notify users about the default.
2229 :;#einfo "Defaulting to javac for compilation" 2196 :;#einfo "Defaulting to javac for compilation"
2230 fi 2197 fi
2198 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2199 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2200 else
2231 export GENTOO_COMPILER=javac 2201 export GENTOO_COMPILER=javac
2202 fi
2232 else 2203 else
2233 einfo "Using ${GENTOO_COMPILER} for compilation" 2204 einfo "Using ${GENTOO_COMPILER} for compilation"
2234 fi 2205 fi
2235 2206
2236} 2207}
2287 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2258 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2288 # Create package.env 2259 # Create package.env
2289 ( 2260 (
2290 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2261 echo "DESCRIPTION=\"${DESCRIPTION}\""
2291 echo "GENERATION=\"2\"" 2262 echo "GENERATION=\"2\""
2263 echo "SLOT=\"${SLOT}\""
2292 2264
2293 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2265 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2294 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2266 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2295 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2267 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2296 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2268 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \

Legend:
Removed from v.1.99  
changed lines
  Added in v.1.107

  ViewVC Help
Powered by ViewVC 1.1.20