/[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.107 Revision 1.127
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.107 2008/05/03 21:28:45 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.127 2009/05/19 21:23:32 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
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. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
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
365 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
369 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 371 die "${jar} does not exist"
371 fi 372 fi
372 done 373 done
373 374
374 java-pkg_do_write_ 375 java-pkg_do_write_
429# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
431java-pkg_doso() { 432java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
433 434
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 435 java-pkg_check-phase install
436 436
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 438
439 java-pkg_init_paths_ 439 java-pkg_init_paths_
440 440
441 local lib 441 local lib
442 # for each lib 442 # for each lib
445 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 446 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
454 else 454 else
455 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
459 fi 457 fi
460 # otherwise die 458 # otherwise die
461 else 459 else
462 die "${lib} does not exist" 460 die "${lib} does not exist"
463 fi 461 fi
479java-pkg_regso() { 477java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
481 479
482 java-pkg_check-phase install 480 java-pkg_check-phase install
483 481
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 483
486 java-pkg_init_paths_ 484 java-pkg_init_paths_
487 485
488 local lib target_dir 486 local lib target_dir
489 for lib in "$@" ; do 487 for lib in "$@" ; do
1743 1741
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1743 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1744 for i in ${WANT_ANT_TASKS}
1747 do 1745 do
1748 if [[ ${i} != ant-* ]]; then 1746 if [[ ${i} = ant-* ]]; then
1747 DEP="${DEP}dev-java/${i} "
1748 elif [[ ${i} = */*:* ]]; then
1749 DEP="${DEP}${i} "
1750 else
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1751 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1752 return 1
1751 fi 1753 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1754 done
1754 echo ${DEP} 1755 echo ${DEP}
1755 return 0 1756 return 0
1756 else 1757 else
1757 return 0 1758 return 0
1798# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1799# @section-end helper 1800# @section-end helper
1800# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1801 1802
1802# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1804# @eclass-src_prepare
1805#
1806# src_prepare Searches for bundled jars
1807# Don't call directly, but via java-pkg-2_src_prepare!
1808# ------------------------------------------------------------------------------
1809
1810java-utils-2_src_prepare() {
1811 [[ ${EBUILD_PHASE} == prepare ]] &&
1812 java-pkg_func-exists java_prepare && java_prepare
1813
1814 # Remember that eant will call this unless called via Portage
1815 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1816 echo "Searching for bundled jars:"
1817 java-pkg_find-normal-jars || echo "None found."
1818 echo "Searching for bundled classes (no output if none found):"
1819 find "${WORKDIR}" -name "*.class"
1820 echo "Search done."
1821 fi
1822 touch "${T}/java-utils-2_src_prepare-run"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @eclass-pkg_preinst
1827#
1828# pkg_preinst Searches for missing and unneeded dependencies
1829# Don't call directly, but via java-pkg-2_pkg_preinst!
1830# ------------------------------------------------------------------------------
1831
1832java-utils-2_pkg_preinst() {
1833 if is-java-strict; then
1834 if has_version dev-java/java-dep-check; then
1835 [[ -e "${JAVA_PKG_ENV}" ]] || return
1836 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1837 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1838 ewarn "Possibly unneeded dependencies found in package.env:"
1839 for dep in ${output}; do
1840 ewarn "\t${dep}"
1841 done
1842 fi
1843 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1844 ewarn "${output}"
1845 fi
1846 else
1847 eerror "Install dev-java/java-dep-check for dependency checking"
1848 fi
1849 fi
1850}
1851
1852# ------------------------------------------------------------------------------
1803# @section-begin build 1853# @section-begin build
1804# @section-summary Build functions 1854# @section-summary Build functions
1805# 1855#
1806# These are some functions for building a package. In particular, it consists of 1856# These are some functions for building a package. In particular, it consists of
1807# wrappers for javac and ant. 1857# wrappers for javac and ant.
1814# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1864# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1815# variables: 1865# variables:
1816# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1866# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1817# gentoo.classpath property. Be sure to call 1867# gentoo.classpath property. Be sure to call
1818# java-ant_rewrite-classpath in src_unpack. 1868# java-ant_rewrite-classpath in src_unpack.
1869# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1870# for build-time purposes, the dependency is not recorded to
1871# package.env!
1819# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1872# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1820# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1821# ------------------------------------------------------------------------------ 1874# ------------------------------------------------------------------------------
1822eant() { 1875eant() {
1823 debug-print-function ${FUNCNAME} $* 1876 debug-print-function ${FUNCNAME} $*
1824 1877
1825 if [[ ${EBUILD_PHASE} = compile ]]; then 1878 if [[ ${EBUILD_PHASE} = compile ]]; then
1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1879 java-ant-2_src_configure
1827 # finally get rid of the hooks without breaking stuff 1880 java-utils-2_src_prepare
1828
1829 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1830 && java-ant_ignore-system-classes "${S}/build.xml"
1831
1832 if hasq java-ant-2 ${INHERITED}; then
1833 java-ant_bsfix
1834 fi
1835
1836 # eant can be called multiple times
1837 JAVA_PKG_BSFIX="off"
1838
1839 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1840 echo "Searching for bundled jars:"
1841 java-pkg_find-normal-jars || echo "None found."
1842 echo "Searching for bundled classes (no output if none found):"
1843 find "${WORKDIR}" -name "*.class"
1844 echo "Search done."
1845 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1846 fi
1847 fi 1881 fi
1848 1882
1849 if ! hasq java-ant-2 ${INHERITED}; then 1883 if ! hasq java-ant-2 ${INHERITED}; then
1850 local msg="You should inherit java-ant-2 when using eant" 1884 local msg="You should inherit java-ant-2 when using eant"
1851 java-pkg_announce-qa-violation "${msg}" 1885 java-pkg_announce-qa-violation "${msg}"
1888 echo "more info." 1922 echo "more info."
1889 fi 1923 fi
1890 fi 1924 fi
1891 done 1925 done
1892 1926
1927 # parse WANT_ANT_TASKS for atoms
1928 local want_ant_tasks
1929 for i in ${WANT_ANT_TASKS}; do
1930 if [[ ${i} = */*:* ]]; then
1931 i=${i#*/}
1932 i=${i%:0}
1933 want_ant_tasks+="${i/:/-} "
1934 else
1935 want_ant_tasks+="${i} "
1936 fi
1937 done
1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1938 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1939 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1895 1940
1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1941 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1942 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1898 1943
1899 # if ant-tasks is not set by ebuild or forced, use none 1944 # if ant-tasks is not set by ebuild or forced, use none
1916 local gcp="${EANT_GENTOO_CLASSPATH}" 1961 local gcp="${EANT_GENTOO_CLASSPATH}"
1917 local getjarsarg="" 1962 local getjarsarg=""
1918 1963
1919 if [[ ${EBUILD_PHASE} = "test" ]]; then 1964 if [[ ${EBUILD_PHASE} = "test" ]]; then
1920 antflags="${antflags} -DJunit.present=true" 1965 antflags="${antflags} -DJunit.present=true"
1921 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1922 getjarsarg="--with-dependencies" 1967 getjarsarg="--with-dependencies"
1923 fi 1968 fi
1924 1969
1925 local cp 1970 local cp
1926 1971
1927 for atom in ${gcp}; do 1972 for atom in ${gcp}; do
1928 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1929 done 1974 done
1930 1975
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1977
1931 if [[ ${cp} ]]; then 1978 if [[ ${cp} ]]; then
1932 # It seems ant does not like single quotes around ${cp} 1979 # It seems ant does not like single quotes around ${cp}
1980 cp=${cp#:}
1981 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1982 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1933 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1934 fi 1984 fi
1935 1985
1936 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1937 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1938 ant ${antflags} "${@}" || die "eant failed" 1988 ant ${antflags} "${@}" || die "eant failed"
2041# ----------------------------------------------------------------------------- 2091# -----------------------------------------------------------------------------
2042java-pkg_init() { 2092java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $* 2093 debug-print-function ${FUNCNAME} $*
2044 unset JAVAC 2094 unset JAVAC
2045 unset JAVA_HOME 2095 unset JAVA_HOME
2096
2097 java-config --help >/dev/null || {
2098 eerror ""
2099 eerror "Can't run java-config --help"
2100 eerror "Have you upgraded python recently but haven't"
2101 eerror "run python-updater yet?"
2102 die "Can't run java-config --help"
2103 }
2046 2104
2047 # People do all kinds of weird things. 2105 # People do all kinds of weird things.
2048 # http://forums.gentoo.org/viewtopic-p-3943166.html 2106 # http://forums.gentoo.org/viewtopic-p-3943166.html
2049 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2107 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2050 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2108 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2088 export CLASSPATH= 2146 export CLASSPATH=
2089 2147
2090 # Unset external ANT_ stuff 2148 # Unset external ANT_ stuff
2091 export ANT_TASKS= 2149 export ANT_TASKS=
2092 export ANT_OPTS= 2150 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME=
2093} 2152}
2094 2153
2095# ------------------------------------------------------------------------------ 2154# ------------------------------------------------------------------------------
2096# @function-internal java-pkg-init-compiler_ 2155# @function-internal java-pkg-init-compiler_
2097# 2156#
2386# 2445#
2387# @return 0 - function is declared 2446# @return 0 - function is declared
2388# @return 1 - function is undeclared 2447# @return 1 - function is undeclared
2389# ------------------------------------------------------------------------------ 2448# ------------------------------------------------------------------------------
2390java-pkg_func-exists() { 2449java-pkg_func-exists() {
2391 if [[ -n "$(declare -f ${1})" ]]; then 2450 declare -F ${1} > /dev/null
2392 return 0
2393 else
2394 return 1
2395 fi
2396} 2451}
2397 2452
2398# ------------------------------------------------------------------------------ 2453# ------------------------------------------------------------------------------
2399# @internal-function java-pkg_setup-vm 2454# @internal-function java-pkg_setup-vm
2400# 2455#
2576# not. 2631# not.
2577# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2632# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2578# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2579java-pkg_verify-classes() { 2634java-pkg_verify-classes() {
2580 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2635 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2636
2637 local version_verify="/usr/bin/class-version-verify.py"
2638
2639 if [[ ! -x "${version_verify}" ]]; then
2640 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2641 fi
2642
2643 if [[ ! -x "${version_verify}" ]]; then
2644 ewarn "Unable to perform class version checks as"
2645 ewarn "class-version-verify.py is unavailable"
2646 ewarn "Please install dev-java/javatoolkit."
2647 return
2648 fi
2649
2581 local target=$(java-pkg_get-target) 2650 local target=$(java-pkg_get-target)
2582 local result 2651 local result
2583 local log="${T}/class-version-verify.log" 2652 local log="${T}/class-version-verify.log"
2584 if [[ -n "${1}" ]]; then 2653 if [[ -n "${1}" ]]; then
2585 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2654 ${version_verify} -v -t ${target} "${1}" > "${log}"
2586 result=$? 2655 result=$?
2587 else 2656 else
2588 ebegin "Verifying java class versions (target: ${target})" 2657 ebegin "Verifying java class versions (target: ${target})"
2589 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2658 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2590 result=$? 2659 result=$?
2591 eend ${result} 2660 eend ${result}
2592 fi 2661 fi
2593 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2662 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2594 if [[ ${result} != 0 ]]; then 2663 if [[ ${result} != 0 ]]; then
2699is-java-strict() { 2768is-java-strict() {
2700 [[ -n ${JAVA_PKG_STRICT} ]] 2769 [[ -n ${JAVA_PKG_STRICT} ]]
2701 return $? 2770 return $?
2702} 2771}
2703 2772
2773
2704# ------------------------------------------------------------------------------ 2774# ------------------------------------------------------------------------------
2705# @eclass-end 2775# @eclass-end
2706# ------------------------------------------------------------------------------ 2776# ------------------------------------------------------------------------------

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.127

  ViewVC Help
Powered by ViewVC 1.1.20