/[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.87 Revision 1.93
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.87 2007/05/27 11:09:11 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.93 2007/09/27 19:47:08 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.31 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
75 76
76# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 79# @variable-default yes
79# 80#
194# 195#
195# @example 196# @example
196# java-pkg_doexamples demo 197# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/* 198# java-pkg_doexamples demo/* examples/*
198# 199#
200# @param --subdir - If the examples need a certain directory structure
199# @param $* - list of files to install 201# @param $* - list of files to install
200# ------------------------------------------------------------------------------ 202# ------------------------------------------------------------------------------
201java-pkg_doexamples() { 203java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $* 204 debug-print-function ${FUNCNAME} $*
203 205
204 [[ ${#} -lt 1 ]] && die "At least one argument needed" 206 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205 207
206 java-pkg_check-phase install 208 java-pkg_check-phase install
207 209
208 local dest=/usr/share/doc/${PF}/examples 210 local dest=/usr/share/doc/${PF}/examples
211 if [[ ${1} == --subdir ]]; then
212 local dest=${dest}/${2}
213 dodir ${dest}
214 shift 2
215 fi
216
209 if [[ ${#} = 1 && -d ${1} ]]; then 217 if [[ ${#} = 1 && -d ${1} ]]; then
210 ( # dont want to pollute calling env 218 ( # dont want to pollute calling env
211 insinto "${dest}" 219 insinto "${dest}"
212 doins -r ${1}/* 220 doins -r ${1}/*
213 ) || die "Installing examples failed" 221 ) || die "Installing examples failed"
1076# from a package, into package.env DEPEND line. Can only be called in 1084# from a package, into package.env DEPEND line. Can only be called in
1077# src_install phase. 1085# src_install phase.
1078# Intended for binary packages where you don't need to symlink the jars or get 1086# Intended for binary packages where you don't need to symlink the jars or get
1079# their classpath during build. As such, the dependencies only need to be 1087# their classpath during build. As such, the dependencies only need to be
1080# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1088# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1081# Get the classpath provided by any number of packages.
1082# 1089#
1083# @param $1 - comma-separated list of packages, or a single package 1090# @param $1 - comma-separated list of packages, or a single package
1084# @param $2 - if param $1 is a single package, optionally specify the jar 1091# @param $2 - if param $1 is a single package, optionally specify the jar
1085# to depend on 1092# to depend on
1086# 1093#
1115 else 1122 else
1116 [[ ${pkgs} == *,* ]] && \ 1123 [[ ${pkgs} == *,* ]] && \
1117 die "${FUNCNAME} called with both package list and jar name" 1124 die "${FUNCNAME} called with both package list and jar name"
1118 java-pkg_ensure-dep runtime "${pkgs}" 1125 java-pkg_ensure-dep runtime "${pkgs}"
1119 java-pkg_record-jar_ "${pkgs}" "${jar}" 1126 java-pkg_record-jar_ "${pkgs}" "${jar}"
1127 fi
1128
1129 java-pkg_do_write_
1130}
1131
1132# ------------------------------------------------------------------------------
1133# @ebuild-function java-pkg_register-optional-dependency
1134#
1135# Registers optional runtime dependency on a package, list of packages, or a
1136# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1137# called in src_install phase.
1138# Intended for packages that can use other packages when those are in classpath.
1139# Will be put on classpath by launcher if they are installed. Typical case is
1140# JDBC implementations for various databases. It's better than having USE flag
1141# for each implementation triggering hard dependency.
1142#
1143# @param $1 - comma-separated list of packages, or a single package
1144# @param $2 - if param $1 is a single package, optionally specify the jar
1145# to depend on
1146#
1147# Example: Record the optional dependency on some jdbc providers
1148# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1149#
1150# Note: Passing both list of packages as the first parameter AND specifying the
1151# jar as the second is not allowed and will cause the function to die. We assume
1152# that there's more chance one passes such combination as a mistake, than that
1153# there are more packages providing identically named jar without class
1154# collisions.
1155# ------------------------------------------------------------------------------
1156java-pkg_register-optional-dependency() {
1157 debug-print-function ${FUNCNAME} $*
1158
1159 java-pkg_check-phase install
1160
1161 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1162
1163 local pkgs="${1}"
1164 local jar="${2}"
1165
1166 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1167
1168 if [[ -z "${jar}" ]]; then
1169 for pkg in ${pkgs//,/ }; do
1170 java-pkg_record-jar_ --optional "${pkg}"
1171 done
1172 else
1173 [[ ${pkgs} == *,* ]] && \
1174 die "${FUNCNAME} called with both package list and jar name"
1175 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1120 fi 1176 fi
1121 1177
1122 java-pkg_do_write_ 1178 java-pkg_do_write_
1123} 1179}
1124 1180
1731# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1787# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1732# variables: 1788# variables:
1733# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1789# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1734# gentoo.classpath property. Be sure to call 1790# gentoo.classpath property. Be sure to call
1735# java-ant_rewrite-classpath in src_unpack. 1791# java-ant_rewrite-classpath in src_unpack.
1792# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1736# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1793# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1737# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1738eant() { 1795eant() {
1739 debug-print-function ${FUNCNAME} $* 1796 debug-print-function ${FUNCNAME} $*
1797
1798 if [[ ${EBUILD_PHASE} = compile ]]; then
1799 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1800 # finally get rid of the hooks without breaking stuff
1801
1802 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1803 && java-ant_ignore-system-classes "${S}/build.xml"
1804
1805 if hasq java-ant-2 ${INHERITED}; then
1806 java-ant_bsfix
1807 fi
1808
1809 # eant can be called multiple times
1810 JAVA_PKG_BSFIX="off"
1811
1812 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1813 echo "Searching for bundled jars:"
1814 java-pkg_find-normal-jars || echo "None found."
1815 echo "Searching for bundled classes (no output if none found):"
1816 find "${WORKDIR}" -name "*.class"
1817 echo "Search done."
1818 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1819 fi
1820 fi
1740 1821
1741 if ! hasq java-ant-2 ${INHERITED}; then 1822 if ! hasq java-ant-2 ${INHERITED}; then
1742 local msg="You should inherit java-ant-2 when using eant" 1823 local msg="You should inherit java-ant-2 when using eant"
1743 java-pkg_announce-qa-violation "${msg}" 1824 java-pkg_announce-qa-violation "${msg}"
1744 fi 1825 fi
1747 1828
1748 java-pkg_init-compiler_ 1829 java-pkg_init-compiler_
1749 local compiler="${GENTOO_COMPILER}" 1830 local compiler="${GENTOO_COMPILER}"
1750 1831
1751 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1832 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1752
1753 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1833 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1754 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1834 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1755 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1835 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1756 fi 1836 fi
1757 1837
1786 echo "more info." 1866 echo "more info."
1787 fi 1867 fi
1788 fi 1868 fi
1789 done 1869 done
1790 1870
1871 # we use this in src_* so we run ant from /
1791 if has_version ">=dev-java/ant-core-1.7.0"; then 1872 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1792 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1873 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1793 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1794 1875
1795 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1876 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1796 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1967 unset _JAVA_OPTIONS 2048 unset _JAVA_OPTIONS
1968 # phase hooks make this run many times without this 2049 # phase hooks make this run many times without this
1969 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2050 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1970 fi 2051 fi
1971 2052
2053 if java-pkg_func-exists ant_src_unpack; then
2054 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2055 fi
2056
1972 java-pkg_init_paths_ 2057 java-pkg_init_paths_
1973 java-pkg_switch-vm 2058 java-pkg_switch-vm
1974 PATH=${JAVA_HOME}/bin:${PATH} 2059 PATH=${JAVA_HOME}/bin:${PATH}
1975 2060
1976 # TODO we will probably want to set JAVAC and JAVACFLAGS 2061 # TODO we will probably want to set JAVAC and JAVACFLAGS
2143 debug-print-function ${FUNCNAME} $* 2228 debug-print-function ${FUNCNAME} $*
2144 java-pkg_init_paths_ 2229 java-pkg_init_paths_
2145 # Create directory for package.env 2230 # Create directory for package.env
2146 dodir "${JAVA_PKG_SHAREPATH}" 2231 dodir "${JAVA_PKG_SHAREPATH}"
2147 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \ 2232 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2233 "${JAVA_PKG_DEPEND_FILE}" || -f \
2148 "${JAVA_PKG_DEPEND_FILE}" ]]; then 2234 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2149 # Create package.env 2235 # Create package.env
2150 ( 2236 (
2151 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2237 echo "DESCRIPTION=\"${DESCRIPTION}\""
2152 echo "GENERATION=\"2\"" 2238 echo "GENERATION=\"2\""
2153 2239
2154 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2155 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2156 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2157 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2243 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2158 && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND_FILE} | uniq | tr '\n' ':')\"" 2244 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2245 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2246 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2159 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2247 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2160 ) > "${JAVA_PKG_ENV}" 2248 ) > "${JAVA_PKG_ENV}"
2161 2249
2162 # register target/source 2250 # register target/source
2163 local target="$(java-pkg_get-target)" 2251 local target="$(java-pkg_get-target)"
2186 2274
2187 # Strip unnecessary leading and trailing colons 2275 # Strip unnecessary leading and trailing colons
2188 # TODO try to cleanup if possible 2276 # TODO try to cleanup if possible
2189 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2277 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2190 else 2278 else
2191 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY or" 2279 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2192 debug-print "JAVA_PKG_DEPEND_FILE not defined so can't" 2280 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2193 debug-print "write package.env." 2281 debug-print "write package.env."
2194 fi 2282 fi
2195} 2283}
2196 2284
2197# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
2198# @internal-function java-pkg_record-jar_ 2286# @internal-function java-pkg_record-jar_
2199# 2287#
2200# Record a dependency to the package.env 2288# Record an (optional) dependency to the package.env
2201# 2289# @param --optional - record dependency as optional
2290# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record
2202# ------------------------------------------------------------------------------ 2292# ------------------------------------------------------------------------------
2203JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2204 2295
2205java-pkg_record-jar_() { 2296java-pkg_record-jar_() {
2206 debug-print-function ${FUNCNAME} $* 2297 debug-print-function ${FUNCNAME} $*
2298
2299 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2300 if [[ "${1}" == "--optional" ]]; then
2301 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2302 shift
2303 fi
2207 2304
2208 local pkg=${1} jar=${2} append 2305 local pkg=${1} jar=${2} append
2209 if [[ -z "${jar}" ]]; then 2306 if [[ -z "${jar}" ]]; then
2210 append="${pkg}" 2307 append="${pkg}"
2211 else 2308 else
2212 append="$(basename ${jar})@${pkg}" 2309 append="$(basename ${jar})@${pkg}"
2213 fi 2310 fi
2214 2311
2215 echo ${append} >> ${JAVA_PKG_DEPEND_FILE} 2312 echo "${append}" >> "${depend_file}"
2216} 2313}
2217 2314
2218# ------------------------------------------------------------------------------ 2315# ------------------------------------------------------------------------------
2219# @internal-function java-pkg_append_ 2316# @internal-function java-pkg_append_
2220# 2317#
2401 2498
2402 #TODO If you know a better solution let us know. 2499 #TODO If you know a better solution let us know.
2403 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2500 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2404 2501
2405 local tann="${T}/announced-vm" 2502 local tann="${T}/announced-vm"
2503 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2504 # if people have for example modified eclasses some where
2406 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2505 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2407 # Add a check for setup/preinst phase... to avoid duplicate outputs
2408 # for when FEATURES=buildpkg
2409 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2410 then
2411 einfo "Using: $(java-config -f)" 2506 einfo "Using: $(java-config -f)"
2412 [[ ! -f "${tann}" ]] && touch "${tann}" 2507 [[ ! -f "${tann}" ]] && touch "${tann}"
2413 fi
2414 fi 2508 fi
2415 2509
2416 else 2510 else
2417 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2511 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2418 fi 2512 fi

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.93

  ViewVC Help
Powered by ViewVC 1.1.20