/[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.86 Revision 1.90
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.86 2007/05/26 23:24:52 ali_bush Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.90 2007/06/19 21:08:57 caster Exp $
10
11 10
12# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
13# @eclass-begin 12# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
15# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
70# 69#
71# This is a convience variable to be used from the other java eclasses. This is 70# 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. We also need a recent version 71# the version of java-config we want to use. We also need a recent version
73# portage, that includes phase hooks. 72# portage, that includes phase hooks.
74# ----------------------------------------------------------------------------- 73# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}" 74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.32 ${JAVA_PKG_PORTAGE_DEP}"
76 75
77# ----------------------------------------------------------------------------- 76# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 78# @variable-default yes
80# 79#
1077# from a package, into package.env DEPEND line. Can only be called in 1076# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase. 1077# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get 1078# Intended for binary packages where you don't need to symlink the jars or get
1080# their classpath during build. As such, the dependencies only need to be 1079# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1080# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083# 1081#
1084# @param $1 - comma-separated list of packages, or a single package 1082# @param $1 - comma-separated list of packages, or a single package
1085# @param $2 - if param $1 is a single package, optionally specify the jar 1083# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on 1084# to depend on
1087# 1085#
1116 else 1114 else
1117 [[ ${pkgs} == *,* ]] && \ 1115 [[ ${pkgs} == *,* ]] && \
1118 die "${FUNCNAME} called with both package list and jar name" 1116 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}" 1117 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}" 1118 java-pkg_record-jar_ "${pkgs}" "${jar}"
1119 fi
1120
1121 java-pkg_do_write_
1122}
1123
1124# ------------------------------------------------------------------------------
1125# @ebuild-function java-pkg_register-optional-dependency
1126#
1127# Registers optional runtime dependency on a package, list of packages, or a
1128# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1129# called in src_install phase.
1130# Intended for packages that can use other packages when those are in classpath.
1131# Will be put on classpath by launcher if they are installed. Typical case is
1132# JDBC implementations for various databases. It's better than having USE flag
1133# for each implementation triggering hard dependency.
1134#
1135# @param $1 - comma-separated list of packages, or a single package
1136# @param $2 - if param $1 is a single package, optionally specify the jar
1137# to depend on
1138#
1139# Example: Record the optional dependency on some jdbc providers
1140# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1141#
1142# Note: Passing both list of packages as the first parameter AND specifying the
1143# jar as the second is not allowed and will cause the function to die. We assume
1144# that there's more chance one passes such combination as a mistake, than that
1145# there are more packages providing identically named jar without class
1146# collisions.
1147# ------------------------------------------------------------------------------
1148java-pkg_register-optional-dependency() {
1149 debug-print-function ${FUNCNAME} $*
1150
1151 java-pkg_check-phase install
1152
1153 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1154
1155 local pkgs="${1}"
1156 local jar="${2}"
1157
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159
1160 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}"
1163 done
1164 else
1165 [[ ${pkgs} == *,* ]] && \
1166 die "${FUNCNAME} called with both package list and jar name"
1167 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1121 fi 1168 fi
1122 1169
1123 java-pkg_do_write_ 1170 java-pkg_do_write_
1124} 1171}
1125 1172
1687# Examples: 1734# Examples:
1688# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests 1735# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1689# ejunit org.blinkenlights.jid3.test.AllTests 1736# ejunit org.blinkenlights.jid3.test.AllTests
1690# 1737#
1691# @param $1 - -cp or -classpath 1738# @param $1 - -cp or -classpath
1692# @param $2 - classpath, junit gets appended 1739# @param $2 - classpath; junit and recorded dependencies get appended
1693# @param $@ - the rest of the parameters are passed to java 1740# @param $@ - the rest of the parameters are passed to java
1694# ------------------------------------------------------------------------------ 1741# ------------------------------------------------------------------------------
1695ejunit() { 1742ejunit() {
1696 debug-print-function ${FUNCNAME} $* 1743 debug-print-function ${FUNCNAME} $*
1697 1744
1698 local cp 1745 local pkgs
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done
1749
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1699 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1700 cp=${2}:$(java-pkg_getjars --build-only junit) 1752 cp="${2}:${cp}"
1701 shift 2 1753 shift 2
1702 else 1754 else
1703 cp=$(java-pkg_getjars --build-only junit):. 1755 cp=".:${cp}"
1704 fi 1756 fi
1705 1757
1706 local runner=junit.textui.TestRunner 1758 local runner=junit.textui.TestRunner
1707 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1759 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1708 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1760 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1782 echo "more info." 1834 echo "more info."
1783 fi 1835 fi
1784 fi 1836 fi
1785 done 1837 done
1786 1838
1839 # we use this in src_* so we run ant from /
1787 if has_version ">=dev-java/ant-core-1.7.0"; then 1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1788 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1789 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1790 1843
1791 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1792 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
2134# Writes the package.env out to disk. 2187# Writes the package.env out to disk.
2135# 2188#
2136# ------------------------------------------------------------------------------ 2189# ------------------------------------------------------------------------------
2137# TODO change to do-write, to match everything else 2190# TODO change to do-write, to match everything else
2138java-pkg_do_write_() { 2191java-pkg_do_write_() {
2192 debug-print-function ${FUNCNAME} $*
2139 java-pkg_init_paths_ 2193 java-pkg_init_paths_
2140 # Create directory for package.env 2194 # Create directory for package.env
2141 dodir "${JAVA_PKG_SHAREPATH}" 2195 dodir "${JAVA_PKG_SHAREPATH}"
2142 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2196 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2197 "${JAVA_PKG_DEPEND_FILE}" || -f \
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2143 # Create package.env 2199 # Create package.env
2144 ( 2200 (
2145 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2201 echo "DESCRIPTION=\"${DESCRIPTION}\""
2146 echo "GENERATION=\"2\"" 2202 echo "GENERATION=\"2\""
2147 2203
2148 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2149 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2150 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2151 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2208 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2209 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2210 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2152 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2211 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2153 ) > "${JAVA_PKG_ENV}" 2212 ) > "${JAVA_PKG_ENV}"
2154 2213
2155 # register target/source 2214 # register target/source
2156 local target="$(java-pkg_get-target)" 2215 local target="$(java-pkg_get-target)"
2178 fi 2237 fi
2179 2238
2180 # Strip unnecessary leading and trailing colons 2239 # Strip unnecessary leading and trailing colons
2181 # TODO try to cleanup if possible 2240 # TODO try to cleanup if possible
2182 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2241 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2242 else
2243 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2244 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2245 debug-print "write package.env."
2183 fi 2246 fi
2184} 2247}
2185 2248
2186# ------------------------------------------------------------------------------ 2249# ------------------------------------------------------------------------------
2187# @internal-function java-pkg_record-jar_ 2250# @internal-function java-pkg_record-jar_
2188# 2251#
2189# Record a dependency to the package.env 2252# Record an (optional) dependency to the package.env
2190# 2253# @param --optional - record dependency as optional
2254# @param $1 - package to record
2255# @param $2 - (optional) jar of package to record
2191# ------------------------------------------------------------------------------ 2256# ------------------------------------------------------------------------------
2192JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2257JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2258JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2193 2259
2194java-pkg_record-jar_() { 2260java-pkg_record-jar_() {
2195 debug-print-function ${FUNCNAME} $* 2261 debug-print-function ${FUNCNAME} $*
2262
2263 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2264 if [[ "${1}" == "--optional" ]]; then
2265 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2266 shift
2267 fi
2196 2268
2197 local pkg=${1} jar=${2} append 2269 local pkg=${1} jar=${2} append
2198 if [[ -z "${jar}" ]]; then 2270 if [[ -z "${jar}" ]]; then
2199 append="${pkg}" 2271 append="${pkg}"
2200 else 2272 else
2201 append="$(basename ${jar})@${pkg}" 2273 append="$(basename ${jar})@${pkg}"
2202 fi 2274 fi
2203 2275
2204 echo ${append} >> ${JAVA_PKG_DEPEND} 2276 echo "${append}" >> "${depend_file}"
2205} 2277}
2206 2278
2207# ------------------------------------------------------------------------------ 2279# ------------------------------------------------------------------------------
2208# @internal-function java-pkg_append_ 2280# @internal-function java-pkg_append_
2209# 2281#
2474# Check that a package being used in jarfrom, getjars and getjar is contained 2546# Check that a package being used in jarfrom, getjars and getjar is contained
2475# within DEPEND or RDEPEND. 2547# within DEPEND or RDEPEND.
2476# @param $1 - empty - check both vars; "runtime" or "build" - check only 2548# @param $1 - empty - check both vars; "runtime" or "build" - check only
2477# RDEPEND, resp. DEPEND 2549# RDEPEND, resp. DEPEND
2478# @param $2 - Package name and slot. 2550# @param $2 - Package name and slot.
2551
2479java-pkg_ensure-dep() { 2552java-pkg_ensure-dep() {
2480 debug-print-function ${FUNCNAME} $* 2553 debug-print-function ${FUNCNAME} $*
2481 2554
2482 local limit_to="${1}" 2555 local limit_to="${1}"
2483 local target_pkg="${2}" 2556 local target_pkg="${2}"
2484 local dev_error="" 2557 local dev_error=""
2485 2558
2486 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2559 local stripped_pkg=$(echo "${target_pkg}" | sed \
2487 's/-[0-9]*\(\.[0-9]\)*$//') 2560 's/-[0-9]*\(\.[0-9]\)*$//')
2561
2562 debug-print "Matching against: ${stripped_pkg}"
2488 2563
2489 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2564 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2490 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2565 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2491 dev_error="${dev_error} declared in DEPEND." 2566 dev_error="${dev_error} declared in DEPEND."
2492 if is-java-strict; then 2567 if is-java-strict; then
2568 eerror "${dev_error}"
2493 die "${dev_error}" 2569 die "${dev_error}"
2494 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2570 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2495 eerror "${dev_error}" 2571 eerror "${dev_error}"
2496 elog "Because you have this package installed the package will" 2572 elog "Because you have this package installed the package will"
2497 elog "build without problems, but please report this to" 2573 elog "build without problems, but please report this to"
2504 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then 2580 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2505 dev_error="The ebuild is attempting to use ${target_pkg}," 2581 dev_error="The ebuild is attempting to use ${target_pkg},"
2506 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND" 2582 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2507 dev_error="${dev_error} or PDEPEND." 2583 dev_error="${dev_error} or PDEPEND."
2508 if is-java-strict; then 2584 if is-java-strict; then
2585 eerror "${dev_error}"
2509 die "${dev_error}" 2586 die "${dev_error}"
2510 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2587 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2511 eerror "${dev_error}" 2588 eerror "${dev_error}"
2512 elog "The package will build without problems, but may fail to run" 2589 elog "The package will build without problems, but may fail to run"
2513 elog "if you don't have ${target_pkg} installed, so please report" 2590 elog "if you don't have ${target_pkg} installed, so please report"

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

  ViewVC Help
Powered by ViewVC 1.1.20