/[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.116
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.116 2008/10/10 20:11:46 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
34# Summary of variables which control the behavior of building Java packges. 34# Summary of variables which control the behavior of building Java packges.
35# ----------------------------------------------------------------------------- 35# -----------------------------------------------------------------------------
36 36
37# Make sure we use java-config-2 37# Make sure we use java-config-2
38export WANT_JAVA_CONFIG="2" 38export WANT_JAVA_CONFIG="2"
39
40[[ "${EAPI:-0}" == "2" ]] && EXPORT_FUNCTIONS src_prepare
39 41
40# ----------------------------------------------------------------------------- 42# -----------------------------------------------------------------------------
41# @variable-external WANT_ANT_TASKS 43# @variable-external WANT_ANT_TASKS
42# @variable-default "" 44# @variable-default ""
43# 45#
445 if [[ -e "${lib}" ]] ; then 447 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 448 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 449 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 450 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 451 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 452 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 453 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 454 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 455 # otherwise make a symlink to the symlink's origin
454 else 456 else
455 # TODO use dosym 457 # TODO use dosym
1743 1745
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1746 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1747 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1748 for i in ${WANT_ANT_TASKS}
1747 do 1749 do
1748 if [[ ${i} != ant-* ]]; then 1750 if [[ ${i} = ant-* ]]; then
1751 DEP="${DEP}dev-java/${i} "
1752 elif [[ ${i} = */*:* ]]; then
1753 DEP="${DEP}${i} "
1754 else
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1755 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1756 return 1
1751 fi 1757 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1758 done
1754 echo ${DEP} 1759 echo ${DEP}
1755 return 0 1760 return 0
1756 else 1761 else
1757 return 0 1762 return 0
1796} 1801}
1797 1802
1798# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1799# @section-end helper 1804# @section-end helper
1800# ------------------------------------------------------------------------------ 1805# ------------------------------------------------------------------------------
1806
1807# ------------------------------------------------------------------------------
1808# @eclass-src_prepare
1809#
1810# src_prepare Searches for bundled jars
1811# ------------------------------------------------------------------------------
1812
1813java-utils-2_src_prepare() {
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}
1801 1824
1802# ------------------------------------------------------------------------------ 1825# ------------------------------------------------------------------------------
1803# @section-begin build 1826# @section-begin build
1804# @section-summary Build functions 1827# @section-summary Build functions
1805# 1828#
1821# ------------------------------------------------------------------------------ 1844# ------------------------------------------------------------------------------
1822eant() { 1845eant() {
1823 debug-print-function ${FUNCNAME} $* 1846 debug-print-function ${FUNCNAME} $*
1824 1847
1825 if [[ ${EBUILD_PHASE} = compile ]]; then 1848 if [[ ${EBUILD_PHASE} = compile ]]; then
1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1849 java-ant-2_src_configure
1827 # finally get rid of the hooks without breaking stuff 1850 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 1851 fi
1848 1852
1849 if ! hasq java-ant-2 ${INHERITED}; then 1853 if ! hasq java-ant-2 ${INHERITED}; then
1850 local msg="You should inherit java-ant-2 when using eant" 1854 local msg="You should inherit java-ant-2 when using eant"
1851 java-pkg_announce-qa-violation "${msg}" 1855 java-pkg_announce-qa-violation "${msg}"
1888 echo "more info." 1892 echo "more info."
1889 fi 1893 fi
1890 fi 1894 fi
1891 done 1895 done
1892 1896
1897 # parse WANT_ANT_TASKS for atoms
1898 local want_ant_tasks
1899 for i in ${WANT_ANT_TASKS}; do
1900 if [[ ${i} = */*:* ]]; then
1901 i=${i#*/}
1902 i=${i%:0}
1903 want_ant_tasks+="${i/:/-} "
1904 else
1905 want_ant_tasks+="${i} "
1906 fi
1907 done
1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1908 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1909 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1895 1910
1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1911 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1912 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1898 1913
1899 # if ant-tasks is not set by ebuild or forced, use none 1914 # if ant-tasks is not set by ebuild or forced, use none
1916 local gcp="${EANT_GENTOO_CLASSPATH}" 1931 local gcp="${EANT_GENTOO_CLASSPATH}"
1917 local getjarsarg="" 1932 local getjarsarg=""
1918 1933
1919 if [[ ${EBUILD_PHASE} = "test" ]]; then 1934 if [[ ${EBUILD_PHASE} = "test" ]]; then
1920 antflags="${antflags} -DJunit.present=true" 1935 antflags="${antflags} -DJunit.present=true"
1921 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1936 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1922 getjarsarg="--with-dependencies" 1937 getjarsarg="--with-dependencies"
1923 fi 1938 fi
1924 1939
1925 local cp 1940 local cp
1926 1941
1928 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1943 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1929 done 1944 done
1930 1945
1931 if [[ ${cp} ]]; then 1946 if [[ ${cp} ]]; then
1932 # It seems ant does not like single quotes around ${cp} 1947 # It seems ant does not like single quotes around ${cp}
1948 cp=${cp#:}
1949 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1950 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1933 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1951 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1934 fi 1952 fi
1935 1953
1936 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1954 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1937 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1955 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1938 ant ${antflags} "${@}" || die "eant failed" 1956 ant ${antflags} "${@}" || die "eant failed"
2041# ----------------------------------------------------------------------------- 2059# -----------------------------------------------------------------------------
2042java-pkg_init() { 2060java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $* 2061 debug-print-function ${FUNCNAME} $*
2044 unset JAVAC 2062 unset JAVAC
2045 unset JAVA_HOME 2063 unset JAVA_HOME
2064
2065 java-config --help >/dev/null || {
2066 eerror ""
2067 eerror "Can't run java-config --help"
2068 eerror "Have you upgraded python recently but haven't"
2069 eerror "run python-updater yet?"
2070 die "Can't run java-config --help"
2071 }
2046 2072
2047 # People do all kinds of weird things. 2073 # People do all kinds of weird things.
2048 # http://forums.gentoo.org/viewtopic-p-3943166.html 2074 # http://forums.gentoo.org/viewtopic-p-3943166.html
2049 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2075 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2050 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2076 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2576# not. 2602# not.
2577# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2603# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2578# ------------------------------------------------------------------------------ 2604# ------------------------------------------------------------------------------
2579java-pkg_verify-classes() { 2605java-pkg_verify-classes() {
2580 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2606 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2607
2608 local version_verify="/usr/bin/class-version-verify.py"
2609
2610 if [[ ! -x "${version_verify}" ]]; then
2611 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2612 fi
2613
2614 if [[ ! -x "${version_verify}" ]]; then
2615 ewarn "Unable to perform class version checks as"
2616 ewarn "class-version-verify.py is unavailable"
2617 ewarn "Please install dev-java/javatoolkit."
2618 return
2619 fi
2620
2581 local target=$(java-pkg_get-target) 2621 local target=$(java-pkg_get-target)
2582 local result 2622 local result
2583 local log="${T}/class-version-verify.log" 2623 local log="${T}/class-version-verify.log"
2584 if [[ -n "${1}" ]]; then 2624 if [[ -n "${1}" ]]; then
2585 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2625 ${version_verify} -v -t ${target} "${1}" > "${log}"
2586 result=$? 2626 result=$?
2587 else 2627 else
2588 ebegin "Verifying java class versions (target: ${target})" 2628 ebegin "Verifying java class versions (target: ${target})"
2589 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2629 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2590 result=$? 2630 result=$?
2591 eend ${result} 2631 eend ${result}
2592 fi 2632 fi
2593 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2633 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2594 if [[ ${result} != 0 ]]; then 2634 if [[ ${result} != 0 ]]; then
2699is-java-strict() { 2739is-java-strict() {
2700 [[ -n ${JAVA_PKG_STRICT} ]] 2740 [[ -n ${JAVA_PKG_STRICT} ]]
2701 return $? 2741 return $?
2702} 2742}
2703 2743
2744
2704# ------------------------------------------------------------------------------ 2745# ------------------------------------------------------------------------------
2705# @eclass-end 2746# @eclass-end
2706# ------------------------------------------------------------------------------ 2747# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20