/[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.98
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.98 2007/11/26 21:00:59 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.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_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.0.33-r1 ${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"
830# @param $opt 839# @param $opt
831# --build-only - makes the jar(s) not added into package.env DEPEND line. 840# --build-only - makes the jar(s) not added into package.env DEPEND line.
832# (assumed automatically when called inside src_test) 841# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 842# --with-dependencies - get jars also from requested package's dependencies
834# transitively. 843# transitively.
844# --virtual - Packages passed to this function are to be handled as virtuals
845# and will not have individual jar dependencies recorded.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 846# --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 847# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used. 848# case other parameters are not used.
838# @param $2 - jar from package. If not specified, all jars will be used. 849# @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 850# @param $3 - When a single jar is specified, destination filename of the
844 debug-print-function ${FUNCNAME} $* 855 debug-print-function ${FUNCNAME} $*
845 856
846 local build_only="" 857 local build_only=""
847 local destdir="." 858 local destdir="."
848 local deep="" 859 local deep=""
860 local virtual=""
849 861
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 862 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 863
852 while [[ "${1}" == --* ]]; do 864 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 865 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 866 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 867 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 868 deep="--with-dependencies"
869 elif [[ "${1}" = "--virtual" ]]; then
870 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 871 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 872 destdir="${2}"
859 shift 873 shift
860 else 874 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 875 die "java-pkg_jar-from called with unknown parameter: ${1}"
885 done 899 done
886 # setting this disables further record-jar_ calls later 900 # setting this disables further record-jar_ calls later
887 build_only="build" 901 build_only="build"
888 else 902 else
889 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 903 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
904 fi
905
906 # Record the entire virtual as a dependency so that
907 # no jars are missed.
908 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
909 java-pkg_record-jar_ "${target_pkg}"
910 # setting this disables further record-jars_ calls later
911 build_only="build"
890 fi 912 fi
891 913
892 pushd ${destdir} > /dev/null \ 914 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 915 || die "failed to change directory to ${destdir}"
894 916
1018# @example-return 1040# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1041# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1042#
1021# @param $opt 1043# @param $opt
1022# --build-only - makes the jar not added into package.env DEPEND line. 1044# --build-only - makes the jar not added into package.env DEPEND line.
1045# --virtual - Packages passed to this function are to be handled as virtuals
1046# and will not have individual jar dependencies recorded.
1023# @param $1 - package to use 1047# @param $1 - package to use
1024# @param $2 - jar to get 1048# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1049# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1050java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1051 debug-print-function ${FUNCNAME} $*
1028 1052
1029 local build_only="" 1053 local build_only=""
1054 local virtual=""
1030 1055
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1056 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1057
1033 while [[ "${1}" == --* ]]; do 1058 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1059 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1060 build_only="build"
1061 elif [[ "${1}" == --* ]]; then
1062 virtual="true"
1036 else 1063 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1064 die "java-pkg_jar-from called with unknown parameter: ${1}"
1038 fi 1065 fi
1039 shift 1066 shift
1040 done 1067 done
1049 local classpath 1076 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1077 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1078 [[ $? != 0 ]] && die ${error_msg}
1052 1079
1053 java-pkg_ensure-dep "${build_only}" "${pkg}" 1080 java-pkg_ensure-dep "${build_only}" "${pkg}"
1081
1082 # Record the package(Virtual) as a dependency and then set build_only
1083 # So that individual jars are not recorded.
1084 if [[ -n "${virtual}" ]]; then
1085 java-pkg_record-jar_ "${pkg}"
1086 build_only="true"
1087 fi
1054 1088
1055 for jar in ${classpath//:/ }; do 1089 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1090 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1091 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1092 fi
1779# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1813# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1780# variables: 1814# variables:
1781# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1815# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1782# gentoo.classpath property. Be sure to call 1816# gentoo.classpath property. Be sure to call
1783# java-ant_rewrite-classpath in src_unpack. 1817# java-ant_rewrite-classpath in src_unpack.
1818# 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. 1819# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1820# ------------------------------------------------------------------------------
1786eant() { 1821eant() {
1787 debug-print-function ${FUNCNAME} $* 1822 debug-print-function ${FUNCNAME} $*
1823
1824 if [[ ${EBUILD_PHASE} = compile ]]; then
1825 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1826 # finally get rid of the hooks without breaking stuff
1827
1828 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1829 && java-ant_ignore-system-classes "${S}/build.xml"
1830
1831 if hasq java-ant-2 ${INHERITED}; then
1832 java-ant_bsfix
1833 fi
1834
1835 # eant can be called multiple times
1836 JAVA_PKG_BSFIX="off"
1837
1838 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1839 echo "Searching for bundled jars:"
1840 java-pkg_find-normal-jars || echo "None found."
1841 echo "Searching for bundled classes (no output if none found):"
1842 find "${WORKDIR}" -name "*.class"
1843 echo "Search done."
1844 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1845 fi
1846 fi
1788 1847
1789 if ! hasq java-ant-2 ${INHERITED}; then 1848 if ! hasq java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1849 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1850 java-pkg_announce-qa-violation "${msg}"
1792 fi 1851 fi
1793 1852
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1853 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1854
1796 java-pkg_init-compiler_ 1855 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1856 local compiler="${GENTOO_COMPILER}"
1798 1857
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1858 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})" 1859 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1860 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1861 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1862 fi
1805 1863
1811 # java-config -p 1869 # java-config -p
1812 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1870 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 1871 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1872 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1873 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 1874 fi
1822 1875
1823 for arg in "${@}"; do 1876 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1877 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1878 if is-java-strict; then
1994# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2047# 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. 2048# call it during each of the phases of the merge process.
1996# 2049#
1997# ----------------------------------------------------------------------------- 2050# -----------------------------------------------------------------------------
1998java-pkg_init() { 2051java-pkg_init() {
2052 debug-print-function ${FUNCNAME} $*
1999 unset JAVAC 2053 unset JAVAC
2000 unset JAVA_HOME 2054 unset JAVA_HOME
2001 2055
2002 # People do all kinds of weird things. 2056 # People do all kinds of weird things.
2003 # http://forums.gentoo.org/viewtopic-p-3943166.html 2057 # http://forums.gentoo.org/viewtopic-p-3943166.html
2011 ewarn "make.conf for example) to silence this warning or" 2065 ewarn "make.conf for example) to silence this warning or"
2012 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2066 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2013 fi 2067 fi
2014 2068
2015 if [[ -z ${accept} ]]; then 2069 if [[ -z ${accept} ]]; then
2070 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2071 # -version output
2016 unset _JAVA_OPTIONS 2072 unset _JAVA_OPTIONS
2017 # phase hooks make this run many times without this 2073 # phase hooks make this run many times without this
2018 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2074 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2019 fi 2075 fi
2020 2076
2077 if java-pkg_func-exists ant_src_unpack; then
2078 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2079 fi
2080
2021 java-pkg_init_paths_ 2081 java-pkg_init_paths_
2022 java-pkg_switch-vm 2082 java-pkg_switch-vm
2023 PATH=${JAVA_HOME}/bin:${PATH} 2083 PATH=${JAVA_HOME}/bin:${PATH}
2024 2084
2025 # TODO we will probably want to set JAVAC and JAVACFLAGS 2085 # TODO we will probably want to set JAVAC and JAVACFLAGS
2026 2086
2027 # Do some QA checks 2087 # Do some QA checks
2028 java-pkg_check-jikes 2088 java-pkg_check-jikes
2089
2090 # Can't use unset here because Portage does not save the unset
2091 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2029 2092
2030 # When users have crazy classpaths some packages can fail to compile. 2093 # When users have crazy classpaths some packages can fail to compile.
2031 # and everything should work with empty CLASSPATH. 2094 # and everything should work with empty CLASSPATH.
2032 # This also helps prevent unexpected dependencies on random things 2095 # This also helps prevent unexpected dependencies on random things
2033 # from the CLASSPATH. 2096 # from the CLASSPATH.
2034 unset CLASSPATH 2097 export CLASSPATH=
2035 2098
2036 # Unset external ANT_ stuff 2099 # Unset external ANT_ stuff
2037 unset ANT_TASKS 2100 export ANT_TASKS=
2038 unset ANT_OPTS 2101 export ANT_OPTS=
2039} 2102}
2040 2103
2041# ------------------------------------------------------------------------------ 2104# ------------------------------------------------------------------------------
2042# @function-internal java-pkg-init-compiler_ 2105# @function-internal java-pkg-init-compiler_
2043# 2106#
2165 fi 2228 fi
2166 2229
2167 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2230 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2168 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2231 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2169 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2232 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2233 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2234 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2170 2235
2171 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2236 [[ -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}" 2237 [[ -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" 2238 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2174 2239
2462 2527
2463 #TODO If you know a better solution let us know. 2528 #TODO If you know a better solution let us know.
2464 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2529 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2465 2530
2466 local tann="${T}/announced-vm" 2531 local tann="${T}/announced-vm"
2532 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2533 # if people have for example modified eclasses some where
2467 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2534 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)" 2535 einfo "Using: $(java-config -f)"
2473 [[ ! -f "${tann}" ]] && touch "${tann}" 2536 [[ ! -f "${tann}" ]] && touch "${tann}"
2474 fi
2475 fi 2537 fi
2476 2538
2477 else 2539 else
2478 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2540 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2479 fi 2541 fi

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

  ViewVC Help
Powered by ViewVC 1.1.20