/[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.101 Revision 1.120
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.101 2008/01/12 15:03:13 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.120 2008/12/29 00:16:40 caster 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
70# 70#
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.1.6 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77 77
78# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
80# @variable-default yes 80# @variable-default yes
291 done 291 done
292 292
293 java-pkg_do_write_ 293 java-pkg_do_write_
294} 294}
295 295
296
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.
301# 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
446 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
447 # install if it isn't a symlink 446 # install if it isn't a symlink
448 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
449 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
450 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
451 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
454 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
455 else 454 else
456 # TODO use dosym 455 # TODO use dosym
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}/api "${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#
1083 if [[ "${1}" = "--build-only" ]]; then 1080 if [[ "${1}" = "--build-only" ]]; then
1084 build_only="build" 1081 build_only="build"
1085 elif [[ "${1}" == "--virtual" ]]; 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() {
1768 1743
1769 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1770 local DEP="" 1745 local DEP=""
1771 for i in ${WANT_ANT_TASKS} 1746 for i in ${WANT_ANT_TASKS}
1772 do 1747 do
1773 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
1774 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1753 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1775 return 1 1754 return 1
1776 fi 1755 fi
1777 DEP="${DEP}dev-java/${i} "
1778 done 1756 done
1779 echo ${DEP} 1757 echo ${DEP}
1780 return 0 1758 return 0
1781 else 1759 else
1782 return 0 1760 return 0
1799# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1800ejunit() { 1778ejunit() {
1801 debug-print-function ${FUNCNAME} $* 1779 debug-print-function ${FUNCNAME} $*
1802 1780
1803 local pkgs 1781 local pkgs
1782 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1804 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1783 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1805 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1784 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1806 done 1785 done
1786 fi
1807 1787
1808 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1788 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1809 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1789 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1810 cp="${2}:${cp}" 1790 cp="${2}:${cp}"
1811 shift 2 1791 shift 2
1821# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1822# @section-end helper 1802# @section-end helper
1823# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1824 1804
1825# ------------------------------------------------------------------------------ 1805# ------------------------------------------------------------------------------
1806# @eclass-src_prepare
1807#
1808# src_prepare Searches for bundled jars
1809# Don't call directly, but via java-pkg-2_src_prepare!
1810# ------------------------------------------------------------------------------
1811
1812java-utils-2_src_prepare() {
1813 # Remember that eant will call this unless called via Portage
1814 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1815 echo "Searching for bundled jars:"
1816 java-pkg_find-normal-jars || echo "None found."
1817 echo "Searching for bundled classes (no output if none found):"
1818 find "${WORKDIR}" -name "*.class"
1819 echo "Search done."
1820 fi
1821 touch "${T}/java-utils-2_src_prepare-run"
1822}
1823
1824# ------------------------------------------------------------------------------
1826# @section-begin build 1825# @section-begin build
1827# @section-summary Build functions 1826# @section-summary Build functions
1828# 1827#
1829# These are some functions for building a package. In particular, it consists of 1828# These are some functions for building a package. In particular, it consists of
1830# wrappers for javac and ant. 1829# wrappers for javac and ant.
1837# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1836# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1838# variables: 1837# variables:
1839# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1838# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1840# gentoo.classpath property. Be sure to call 1839# gentoo.classpath property. Be sure to call
1841# java-ant_rewrite-classpath in src_unpack. 1840# java-ant_rewrite-classpath in src_unpack.
1841# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1842# for build-time purposes, the dependency is not recorded to
1843# package.env!
1842# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1844# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1843# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1845# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1844# ------------------------------------------------------------------------------ 1846# ------------------------------------------------------------------------------
1845eant() { 1847eant() {
1846 debug-print-function ${FUNCNAME} $* 1848 debug-print-function ${FUNCNAME} $*
1847 1849
1848 if [[ ${EBUILD_PHASE} = compile ]]; then 1850 if [[ ${EBUILD_PHASE} = compile ]]; then
1849 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1851 java-ant-2_src_configure
1850 # finally get rid of the hooks without breaking stuff 1852 java-utils-2_src_prepare
1851
1852 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1853 && java-ant_ignore-system-classes "${S}/build.xml"
1854
1855 if hasq java-ant-2 ${INHERITED}; then
1856 java-ant_bsfix
1857 fi
1858
1859 # eant can be called multiple times
1860 JAVA_PKG_BSFIX="off"
1861
1862 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1863 echo "Searching for bundled jars:"
1864 java-pkg_find-normal-jars || echo "None found."
1865 echo "Searching for bundled classes (no output if none found):"
1866 find "${WORKDIR}" -name "*.class"
1867 echo "Search done."
1868 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1869 fi
1870 fi 1853 fi
1871 1854
1872 if ! hasq java-ant-2 ${INHERITED}; then 1855 if ! hasq java-ant-2 ${INHERITED}; then
1873 local msg="You should inherit java-ant-2 when using eant" 1856 local msg="You should inherit java-ant-2 when using eant"
1874 java-pkg_announce-qa-violation "${msg}" 1857 java-pkg_announce-qa-violation "${msg}"
1911 echo "more info." 1894 echo "more info."
1912 fi 1895 fi
1913 fi 1896 fi
1914 done 1897 done
1915 1898
1916 # we use this in src_* so we run ant from / 1899 # parse WANT_ANT_TASKS for atoms
1917 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1900 local want_ant_tasks
1918 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1901 for i in ${WANT_ANT_TASKS}; do
1919 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1902 if [[ ${i} = */*:* ]]; then
1920 1903 i=${i#*/}
1921 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1904 i=${i%:0}
1922 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1905 want_ant_tasks+="${i/:/-} "
1923
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 1906 else
1907 want_ant_tasks+="${i} "
1908 fi
1909 done
1910 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1911 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1912
1913 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1914 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1915
1930 # if ant-tasks is not set by ebuild or forced, activate all of them 1916 # if ant-tasks is not set by ebuild or forced, use none
1931 ANT_TASKS="${ANT_TASKS:-all}" 1917 ANT_TASKS="${ANT_TASKS:-none}"
1932 fi
1933 1918
1934 # at this point, ANT_TASKS should be "all", "none" or explicit list 1919 # at this point, ANT_TASKS should be "all", "none" or explicit list
1935 if [[ "${ANT_TASKS}" == "all" ]]; then 1920 if [[ "${ANT_TASKS}" == "all" ]]; then
1936 einfo "Using all available ANT_TASKS" 1921 einfo "Using all available ANT_TASKS"
1937 elif [[ "${ANT_TASKS}" == "none" ]]; then 1922 elif [[ "${ANT_TASKS}" == "none" ]]; then
1938 einfo "Disabling all optional ANT_TASKS" 1923 einfo "Disabling all optional ANT_TASKS"
1939 else 1924 else
1940 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1925 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1941 fi 1926 fi
1942 1927
1943 export ANT_TASKS 1928 export ANT_TASKS
1944 fi
1945 1929
1946 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1930 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1947 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1931 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1948 1932
1949 local gcp="${EANT_GENTOO_CLASSPATH}" 1933 local gcp="${EANT_GENTOO_CLASSPATH}"
1950 local getjarsarg="" 1934 local getjarsarg=""
1951 1935
1952 if [[ ${EBUILD_PHASE} = "test" ]]; then 1936 if [[ ${EBUILD_PHASE} = "test" ]]; then
1953 antflags="${antflags} -DJunit.present=true" 1937 antflags="${antflags} -DJunit.present=true"
1954 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1938 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1955 getjarsarg="--with-dependencies" 1939 getjarsarg="--with-dependencies"
1956 fi 1940 fi
1957 1941
1958 local cp 1942 local cp
1959 1943
1960 for atom in ${gcp}; do 1944 for atom in ${gcp}; do
1961 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1945 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1962 done 1946 done
1963 1947
1948 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1949
1964 if [[ ${cp} ]]; then 1950 if [[ ${cp} ]]; then
1965 # It seems ant does not like single quotes around ${cp} 1951 # It seems ant does not like single quotes around ${cp}
1952 cp=${cp#:}
1953 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1954 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1966 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1955 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1967 fi 1956 fi
1968 1957
1969 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1958 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1970 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1959 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1971 ant ${antflags} "${@}" || die "eant failed" 1960 ant ${antflags} "${@}" || die "eant failed"
2074# ----------------------------------------------------------------------------- 2063# -----------------------------------------------------------------------------
2075java-pkg_init() { 2064java-pkg_init() {
2076 debug-print-function ${FUNCNAME} $* 2065 debug-print-function ${FUNCNAME} $*
2077 unset JAVAC 2066 unset JAVAC
2078 unset JAVA_HOME 2067 unset JAVA_HOME
2068
2069 java-config --help >/dev/null || {
2070 eerror ""
2071 eerror "Can't run java-config --help"
2072 eerror "Have you upgraded python recently but haven't"
2073 eerror "run python-updater yet?"
2074 die "Can't run java-config --help"
2075 }
2079 2076
2080 # People do all kinds of weird things. 2077 # People do all kinds of weird things.
2081 # http://forums.gentoo.org/viewtopic-p-3943166.html 2078 # http://forums.gentoo.org/viewtopic-p-3943166.html
2082 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2079 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2083 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2080 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2121 export CLASSPATH= 2118 export CLASSPATH=
2122 2119
2123 # Unset external ANT_ stuff 2120 # Unset external ANT_ stuff
2124 export ANT_TASKS= 2121 export ANT_TASKS=
2125 export ANT_OPTS= 2122 export ANT_OPTS=
2123 export ANT_RESPECT_JAVA_HOME=
2126} 2124}
2127 2125
2128# ------------------------------------------------------------------------------ 2126# ------------------------------------------------------------------------------
2129# @function-internal java-pkg-init-compiler_ 2127# @function-internal java-pkg-init-compiler_
2130# 2128#
2221 done 2219 done
2222 2220
2223 # If it hasn't been defined already, default to javac 2221 # If it hasn't been defined already, default to javac
2224 if [[ -z ${GENTOO_COMPILER} ]]; then 2222 if [[ -z ${GENTOO_COMPILER} ]]; then
2225 if [[ -n ${compilers} ]]; then 2223 if [[ -n ${compilers} ]]; then
2226 einfo "No suitable compiler found: defaulting javac for compilation" 2224 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2227 else 2225 else
2228 # probably don't need to notify users about the default. 2226 # probably don't need to notify users about the default.
2229 :;#einfo "Defaulting to javac for compilation" 2227 :;#einfo "Defaulting to javac for compilation"
2230 fi 2228 fi
2229 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2230 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2231 else
2231 export GENTOO_COMPILER=javac 2232 export GENTOO_COMPILER=javac
2233 fi
2232 else 2234 else
2233 einfo "Using ${GENTOO_COMPILER} for compilation" 2235 einfo "Using ${GENTOO_COMPILER} for compilation"
2234 fi 2236 fi
2235 2237
2236} 2238}
2287 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2289 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2288 # Create package.env 2290 # Create package.env
2289 ( 2291 (
2290 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2292 echo "DESCRIPTION=\"${DESCRIPTION}\""
2291 echo "GENERATION=\"2\"" 2293 echo "GENERATION=\"2\""
2294 echo "SLOT=\"${SLOT}\""
2292 2295
2293 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2296 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2294 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2297 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2295 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2298 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2296 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2299 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2604# not. 2607# not.
2605# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2608# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2606# ------------------------------------------------------------------------------ 2609# ------------------------------------------------------------------------------
2607java-pkg_verify-classes() { 2610java-pkg_verify-classes() {
2608 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2611 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2612
2613 local version_verify="/usr/bin/class-version-verify.py"
2614
2615 if [[ ! -x "${version_verify}" ]]; then
2616 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2617 fi
2618
2619 if [[ ! -x "${version_verify}" ]]; then
2620 ewarn "Unable to perform class version checks as"
2621 ewarn "class-version-verify.py is unavailable"
2622 ewarn "Please install dev-java/javatoolkit."
2623 return
2624 fi
2625
2609 local target=$(java-pkg_get-target) 2626 local target=$(java-pkg_get-target)
2610 local result 2627 local result
2611 local log="${T}/class-version-verify.log" 2628 local log="${T}/class-version-verify.log"
2612 if [[ -n "${1}" ]]; then 2629 if [[ -n "${1}" ]]; then
2613 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2630 ${version_verify} -v -t ${target} "${1}" > "${log}"
2614 result=$? 2631 result=$?
2615 else 2632 else
2616 ebegin "Verifying java class versions (target: ${target})" 2633 ebegin "Verifying java class versions (target: ${target})"
2617 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2634 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2618 result=$? 2635 result=$?
2619 eend ${result} 2636 eend ${result}
2620 fi 2637 fi
2621 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2638 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2622 if [[ ${result} != 0 ]]; then 2639 if [[ ${result} != 0 ]]; then
2727is-java-strict() { 2744is-java-strict() {
2728 [[ -n ${JAVA_PKG_STRICT} ]] 2745 [[ -n ${JAVA_PKG_STRICT} ]]
2729 return $? 2746 return $?
2730} 2747}
2731 2748
2749
2732# ------------------------------------------------------------------------------ 2750# ------------------------------------------------------------------------------
2733# @eclass-end 2751# @eclass-end
2734# ------------------------------------------------------------------------------ 2752# ------------------------------------------------------------------------------

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.120

  ViewVC Help
Powered by ViewVC 1.1.20