/[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.106 Revision 1.122
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.106 2008/05/03 21:28:07 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.122 2009/02/19 05:10:37 serkan 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
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 # TODO use dosym
1743 1743
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1745 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1746 for i in ${WANT_ANT_TASKS}
1747 do 1747 do
1748 if [[ ${i} != ant-* ]]; then 1748 if [[ ${i} = ant-* ]]; then
1749 DEP="${DEP}dev-java/${i} "
1750 elif [[ ${i} = */*:* ]]; then
1751 DEP="${DEP}${i} "
1752 else
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1753 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1754 return 1
1751 fi 1755 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1756 done
1754 echo ${DEP} 1757 echo ${DEP}
1755 return 0 1758 return 0
1756 else 1759 else
1757 return 0 1760 return 0
1770# 1773#
1771# @param $1 - -cp or -classpath 1774# @param $1 - -cp or -classpath
1772# @param $2 - classpath; junit and recorded dependencies get appended 1775# @param $2 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java 1776# @param $@ - the rest of the parameters are passed to java
1774# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1775ejunit{ 1778ejunit() {
1776 debug-print-function ${FUNCNAME} $* 1779 debug-print-function ${FUNCNAME} $*
1777 1780
1778 local pkgs 1781 local pkgs
1779 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1782 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1783 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1798# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1799# @section-end helper 1802# @section-end helper
1800# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1801 1804
1802# ------------------------------------------------------------------------------ 1805# ------------------------------------------------------------------------------
1806# @eclass-src_prepare
1807#
1808# src_prepare Searches for bundled jars
1809# Don't call directly, but via java-pkg-2_src_prepare!
1810# ------------------------------------------------------------------------------
1811
1812java-utils-2_src_prepare() {
1813 # Remember that eant will call this unless called via Portage
1814 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1815 echo "Searching for bundled jars:"
1816 java-pkg_find-normal-jars || echo "None found."
1817 echo "Searching for bundled classes (no output if none found):"
1818 find "${WORKDIR}" -name "*.class"
1819 echo "Search done."
1820 fi
1821 touch "${T}/java-utils-2_src_prepare-run"
1822}
1823
1824# ------------------------------------------------------------------------------
1825# @eclass-pkg_preinst
1826#
1827# pkg_preinst Searches for missing and unneeded dependencies
1828# Don't call directly, but via java-pkg-2_pkg_preinst!
1829# ------------------------------------------------------------------------------
1830
1831java-utils-2_pkg_preinst() {
1832 if is-java-strict; then
1833 if has_version dev-java/java-dep-check; then
1834 [[ -e "${JAVA_PKG_ENV}" ]] || return
1835 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1836 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1837 ewarn "Possibly unneeded dependencies found in package.env:"
1838 for dep in ${output}; do
1839 ewarn "\t${dep}"
1840 done
1841 fi
1842 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1843 ewarn "${output}"
1844 fi
1845 else
1846 eerror "Install dev-java/java-dep-check for dependency checking"
1847 fi
1848 fi
1849}
1850
1851# ------------------------------------------------------------------------------
1803# @section-begin build 1852# @section-begin build
1804# @section-summary Build functions 1853# @section-summary Build functions
1805# 1854#
1806# These are some functions for building a package. In particular, it consists of 1855# These are some functions for building a package. In particular, it consists of
1807# wrappers for javac and ant. 1856# wrappers for javac and ant.
1814# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1863# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1815# variables: 1864# variables:
1816# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1865# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1817# gentoo.classpath property. Be sure to call 1866# gentoo.classpath property. Be sure to call
1818# java-ant_rewrite-classpath in src_unpack. 1867# java-ant_rewrite-classpath in src_unpack.
1868# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1869# for build-time purposes, the dependency is not recorded to
1870# package.env!
1819# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1871# 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. 1872# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1821# ------------------------------------------------------------------------------ 1873# ------------------------------------------------------------------------------
1822eant() { 1874eant() {
1823 debug-print-function ${FUNCNAME} $* 1875 debug-print-function ${FUNCNAME} $*
1824 1876
1825 if [[ ${EBUILD_PHASE} = compile ]]; then 1877 if [[ ${EBUILD_PHASE} = compile ]]; then
1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1878 java-ant-2_src_configure
1827 # finally get rid of the hooks without breaking stuff 1879 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 1880 fi
1848 1881
1849 if ! hasq java-ant-2 ${INHERITED}; then 1882 if ! hasq java-ant-2 ${INHERITED}; then
1850 local msg="You should inherit java-ant-2 when using eant" 1883 local msg="You should inherit java-ant-2 when using eant"
1851 java-pkg_announce-qa-violation "${msg}" 1884 java-pkg_announce-qa-violation "${msg}"
1888 echo "more info." 1921 echo "more info."
1889 fi 1922 fi
1890 fi 1923 fi
1891 done 1924 done
1892 1925
1926 # parse WANT_ANT_TASKS for atoms
1927 local want_ant_tasks
1928 for i in ${WANT_ANT_TASKS}; do
1929 if [[ ${i} = */*:* ]]; then
1930 i=${i#*/}
1931 i=${i%:0}
1932 want_ant_tasks+="${i/:/-} "
1933 else
1934 want_ant_tasks+="${i} "
1935 fi
1936 done
1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1937 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1938 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1895 1939
1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1940 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1941 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1898 1942
1899 # if ant-tasks is not set by ebuild or forced, use none 1943 # if ant-tasks is not set by ebuild or forced, use none
1916 local gcp="${EANT_GENTOO_CLASSPATH}" 1960 local gcp="${EANT_GENTOO_CLASSPATH}"
1917 local getjarsarg="" 1961 local getjarsarg=""
1918 1962
1919 if [[ ${EBUILD_PHASE} = "test" ]]; then 1963 if [[ ${EBUILD_PHASE} = "test" ]]; then
1920 antflags="${antflags} -DJunit.present=true" 1964 antflags="${antflags} -DJunit.present=true"
1921 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1965 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1922 getjarsarg="--with-dependencies" 1966 getjarsarg="--with-dependencies"
1923 fi 1967 fi
1924 1968
1925 local cp 1969 local cp
1926 1970
1927 for atom in ${gcp}; do 1971 for atom in ${gcp}; do
1928 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1972 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1929 done 1973 done
1930 1974
1975 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1976
1931 if [[ ${cp} ]]; then 1977 if [[ ${cp} ]]; then
1932 # It seems ant does not like single quotes around ${cp} 1978 # It seems ant does not like single quotes around ${cp}
1979 cp=${cp#:}
1980 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1981 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1933 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1982 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1934 fi 1983 fi
1935 1984
1936 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1985 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1937 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1986 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1938 ant ${antflags} "${@}" || die "eant failed" 1987 ant ${antflags} "${@}" || die "eant failed"
2041# ----------------------------------------------------------------------------- 2090# -----------------------------------------------------------------------------
2042java-pkg_init() { 2091java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $* 2092 debug-print-function ${FUNCNAME} $*
2044 unset JAVAC 2093 unset JAVAC
2045 unset JAVA_HOME 2094 unset JAVA_HOME
2095
2096 java-config --help >/dev/null || {
2097 eerror ""
2098 eerror "Can't run java-config --help"
2099 eerror "Have you upgraded python recently but haven't"
2100 eerror "run python-updater yet?"
2101 die "Can't run java-config --help"
2102 }
2046 2103
2047 # People do all kinds of weird things. 2104 # People do all kinds of weird things.
2048 # http://forums.gentoo.org/viewtopic-p-3943166.html 2105 # http://forums.gentoo.org/viewtopic-p-3943166.html
2049 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2106 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2050 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2107 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2088 export CLASSPATH= 2145 export CLASSPATH=
2089 2146
2090 # Unset external ANT_ stuff 2147 # Unset external ANT_ stuff
2091 export ANT_TASKS= 2148 export ANT_TASKS=
2092 export ANT_OPTS= 2149 export ANT_OPTS=
2150 export ANT_RESPECT_JAVA_HOME=
2093} 2151}
2094 2152
2095# ------------------------------------------------------------------------------ 2153# ------------------------------------------------------------------------------
2096# @function-internal java-pkg-init-compiler_ 2154# @function-internal java-pkg-init-compiler_
2097# 2155#
2576# not. 2634# not.
2577# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2635# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2578# ------------------------------------------------------------------------------ 2636# ------------------------------------------------------------------------------
2579java-pkg_verify-classes() { 2637java-pkg_verify-classes() {
2580 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2638 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2639
2640 local version_verify="/usr/bin/class-version-verify.py"
2641
2642 if [[ ! -x "${version_verify}" ]]; then
2643 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2644 fi
2645
2646 if [[ ! -x "${version_verify}" ]]; then
2647 ewarn "Unable to perform class version checks as"
2648 ewarn "class-version-verify.py is unavailable"
2649 ewarn "Please install dev-java/javatoolkit."
2650 return
2651 fi
2652
2581 local target=$(java-pkg_get-target) 2653 local target=$(java-pkg_get-target)
2582 local result 2654 local result
2583 local log="${T}/class-version-verify.log" 2655 local log="${T}/class-version-verify.log"
2584 if [[ -n "${1}" ]]; then 2656 if [[ -n "${1}" ]]; then
2585 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2657 ${version_verify} -v -t ${target} "${1}" > "${log}"
2586 result=$? 2658 result=$?
2587 else 2659 else
2588 ebegin "Verifying java class versions (target: ${target})" 2660 ebegin "Verifying java class versions (target: ${target})"
2589 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2661 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2590 result=$? 2662 result=$?
2591 eend ${result} 2663 eend ${result}
2592 fi 2664 fi
2593 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2665 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2594 if [[ ${result} != 0 ]]; then 2666 if [[ ${result} != 0 ]]; then
2699is-java-strict() { 2771is-java-strict() {
2700 [[ -n ${JAVA_PKG_STRICT} ]] 2772 [[ -n ${JAVA_PKG_STRICT} ]]
2701 return $? 2773 return $?
2702} 2774}
2703 2775
2776
2704# ------------------------------------------------------------------------------ 2777# ------------------------------------------------------------------------------
2705# @eclass-end 2778# @eclass-end
2706# ------------------------------------------------------------------------------ 2779# ------------------------------------------------------------------------------

Legend:
Removed from v.1.106  
changed lines
  Added in v.1.122

  ViewVC Help
Powered by ViewVC 1.1.20