/[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.87
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.87 2007/05/27 11:09:11 betelgeuse 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
1687# Examples: 1686# Examples:
1688# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests 1687# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1689# ejunit org.blinkenlights.jid3.test.AllTests 1688# ejunit org.blinkenlights.jid3.test.AllTests
1690# 1689#
1691# @param $1 - -cp or -classpath 1690# @param $1 - -cp or -classpath
1692# @param $2 - classpath, junit gets appended 1691# @param $2 - classpath; junit and recorded dependencies get appended
1693# @param $@ - the rest of the parameters are passed to java 1692# @param $@ - the rest of the parameters are passed to java
1694# ------------------------------------------------------------------------------ 1693# ------------------------------------------------------------------------------
1695ejunit() { 1694ejunit() {
1696 debug-print-function ${FUNCNAME} $* 1695 debug-print-function ${FUNCNAME} $*
1697 1696
1698 local cp 1697 local pkgs
1698 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1699 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1700 done
1701
1702 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1699 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1703 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1700 cp=${2}:$(java-pkg_getjars --build-only junit) 1704 cp="${2}:${cp}"
1701 shift 2 1705 shift 2
1702 else 1706 else
1703 cp=$(java-pkg_getjars --build-only junit):. 1707 cp=".:${cp}"
1704 fi 1708 fi
1705 1709
1706 local runner=junit.textui.TestRunner 1710 local runner=junit.textui.TestRunner
1707 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1711 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1708 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1712 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
2134# Writes the package.env out to disk. 2138# Writes the package.env out to disk.
2135# 2139#
2136# ------------------------------------------------------------------------------ 2140# ------------------------------------------------------------------------------
2137# TODO change to do-write, to match everything else 2141# TODO change to do-write, to match everything else
2138java-pkg_do_write_() { 2142java-pkg_do_write_() {
2143 debug-print-function ${FUNCNAME} $*
2139 java-pkg_init_paths_ 2144 java-pkg_init_paths_
2140 # Create directory for package.env 2145 # Create directory for package.env
2141 dodir "${JAVA_PKG_SHAREPATH}" 2146 dodir "${JAVA_PKG_SHAREPATH}"
2142 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2147 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2148 "${JAVA_PKG_DEPEND_FILE}" ]]; then
2143 # Create package.env 2149 # Create package.env
2144 ( 2150 (
2145 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2151 echo "DESCRIPTION=\"${DESCRIPTION}\""
2146 echo "GENERATION=\"2\"" 2152 echo "GENERATION=\"2\""
2147 2153
2148 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2154 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2149 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2155 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2150 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2156 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2151 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2157 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2158 && echo "DEPEND=\"$(cat ${JAVA_PKG_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 ! 2159 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2153 ) > "${JAVA_PKG_ENV}" 2160 ) > "${JAVA_PKG_ENV}"
2154 2161
2155 # register target/source 2162 # register target/source
2156 local target="$(java-pkg_get-target)" 2163 local target="$(java-pkg_get-target)"
2178 fi 2185 fi
2179 2186
2180 # Strip unnecessary leading and trailing colons 2187 # Strip unnecessary leading and trailing colons
2181 # TODO try to cleanup if possible 2188 # TODO try to cleanup if possible
2182 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2189 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2190 else
2191 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY or"
2192 debug-print "JAVA_PKG_DEPEND_FILE not defined so can't"
2193 debug-print "write package.env."
2183 fi 2194 fi
2184} 2195}
2185 2196
2186# ------------------------------------------------------------------------------ 2197# ------------------------------------------------------------------------------
2187# @internal-function java-pkg_record-jar_ 2198# @internal-function java-pkg_record-jar_
2188# 2199#
2189# Record a dependency to the package.env 2200# Record a dependency to the package.env
2190# 2201#
2191# ------------------------------------------------------------------------------ 2202# ------------------------------------------------------------------------------
2192JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2203JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2193 2204
2194java-pkg_record-jar_() { 2205java-pkg_record-jar_() {
2195 debug-print-function ${FUNCNAME} $* 2206 debug-print-function ${FUNCNAME} $*
2196 2207
2197 local pkg=${1} jar=${2} append 2208 local pkg=${1} jar=${2} append
2199 append="${pkg}" 2210 append="${pkg}"
2200 else 2211 else
2201 append="$(basename ${jar})@${pkg}" 2212 append="$(basename ${jar})@${pkg}"
2202 fi 2213 fi
2203 2214
2204 echo ${append} >> ${JAVA_PKG_DEPEND} 2215 echo ${append} >> ${JAVA_PKG_DEPEND_FILE}
2205} 2216}
2206 2217
2207# ------------------------------------------------------------------------------ 2218# ------------------------------------------------------------------------------
2208# @internal-function java-pkg_append_ 2219# @internal-function java-pkg_append_
2209# 2220#
2474# Check that a package being used in jarfrom, getjars and getjar is contained 2485# Check that a package being used in jarfrom, getjars and getjar is contained
2475# within DEPEND or RDEPEND. 2486# within DEPEND or RDEPEND.
2476# @param $1 - empty - check both vars; "runtime" or "build" - check only 2487# @param $1 - empty - check both vars; "runtime" or "build" - check only
2477# RDEPEND, resp. DEPEND 2488# RDEPEND, resp. DEPEND
2478# @param $2 - Package name and slot. 2489# @param $2 - Package name and slot.
2490
2479java-pkg_ensure-dep() { 2491java-pkg_ensure-dep() {
2480 debug-print-function ${FUNCNAME} $* 2492 debug-print-function ${FUNCNAME} $*
2481 2493
2482 local limit_to="${1}" 2494 local limit_to="${1}"
2483 local target_pkg="${2}" 2495 local target_pkg="${2}"
2484 local dev_error="" 2496 local dev_error=""
2485 2497
2486 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2498 local stripped_pkg=$(echo "${target_pkg}" | sed \
2487 's/-[0-9]*\(\.[0-9]\)*$//') 2499 's/-[0-9]*\(\.[0-9]\)*$//')
2500
2501 debug-print "Matching against: ${stripped_pkg}"
2488 2502
2489 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2503 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2490 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2504 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2491 dev_error="${dev_error} declared in DEPEND." 2505 dev_error="${dev_error} declared in DEPEND."
2492 if is-java-strict; then 2506 if is-java-strict; then
2507 eerror "${dev_error}"
2493 die "${dev_error}" 2508 die "${dev_error}"
2494 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2509 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2495 eerror "${dev_error}" 2510 eerror "${dev_error}"
2496 elog "Because you have this package installed the package will" 2511 elog "Because you have this package installed the package will"
2497 elog "build without problems, but please report this to" 2512 elog "build without problems, but please report this to"
2504 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then 2519 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2505 dev_error="The ebuild is attempting to use ${target_pkg}," 2520 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" 2521 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2507 dev_error="${dev_error} or PDEPEND." 2522 dev_error="${dev_error} or PDEPEND."
2508 if is-java-strict; then 2523 if is-java-strict; then
2524 eerror "${dev_error}"
2509 die "${dev_error}" 2525 die "${dev_error}"
2510 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2526 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2511 eerror "${dev_error}" 2527 eerror "${dev_error}"
2512 elog "The package will build without problems, but may fail to run" 2528 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" 2529 elog "if you don't have ${target_pkg} installed, so please report"

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

  ViewVC Help
Powered by ViewVC 1.1.20