/[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.139 Revision 1.150
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
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-2011, 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.139 2011/03/26 00:43:12 serkan Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.150 2012/03/13 10:05:46 sera 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
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. For EAPI 2 we have new enough stuff so let's have cleaner deps. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66has "${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.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77 77
78# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH 79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80# 80#
81# The version of bootclasspath the package needs to work. Translates to a proper 81# The version of bootclasspath the package needs to work. Translates to a proper
111# Should only be used for testing and debugging. 111# Should only be used for testing and debugging.
112# 112#
113# @example Use sun-jdk-1.5 to emerge foo 113# @example Use sun-jdk-1.5 to emerge foo
114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
115# 115#
116# -----------------------------------------------------------------------------
117
118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
116# ----------------------------------------------------------------------------- 129# -----------------------------------------------------------------------------
117 130
118# ----------------------------------------------------------------------------- 131# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
120# 133#
1318 1331
1319java-pkg_get-bootclasspath() { 1332java-pkg_get-bootclasspath() {
1320 local version="${1}" 1333 local version="${1}"
1321 1334
1322 local bcp 1335 local bcp
1323 case "${version}" in 1336 case "${version}" in
1324 auto) 1337 auto)
1325 bcp="$(java-config -g BOOTCLASSPATH)" 1338 bcp="$(java-config -g BOOTCLASSPATH)"
1326 ;; 1339 ;;
1327 1.5) 1340 1.5)
1328 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)" 1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1556java-pkg_get-current-vm() { 1569java-pkg_get-current-vm() {
1557 echo ${GENTOO_VM} 1570 echo ${GENTOO_VM}
1558} 1571}
1559 1572
1560java-pkg_current-vm-matches() { 1573java-pkg_current-vm-matches() {
1561 hasq $(java-pkg_get-current-vm) ${@} 1574 has $(java-pkg_get-current-vm) ${@}
1562 return $? 1575 return $?
1563} 1576}
1564 1577
1565# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1566# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1681 die "No GCJ support found!" 1694 die "No GCJ support found!"
1682 fi 1695 fi
1683} 1696}
1684 1697
1685java-pkg_ensure-test() { 1698java-pkg_ensure-test() {
1686 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1699 if has test ${FEATURES} && ! has -test ${FEATURES} \
1687 && hasq test ${IUSE} && ! use test; 1700 && has test ${IUSE} && ! use test;
1688 then 1701 then
1689 eerror "You specified FEATURES=test, but USE=test is needed" 1702 eerror "You specified FEATURES=test, but USE=test is needed"
1690 eerror "to pull in the additional dependencies for testing" 1703 eerror "to pull in the additional dependencies for testing"
1691 die "Need USE=test enabled" 1704 die "Need USE=test enabled"
1692 fi 1705 fi
1912# gentoo.classpath property. Be sure to call 1925# gentoo.classpath property. Be sure to call
1913# java-ant_rewrite-classpath in src_unpack. 1926# java-ant_rewrite-classpath in src_unpack.
1914# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used 1927# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1915# for build-time purposes, the dependency is not recorded to 1928# for build-time purposes, the dependency is not recorded to
1916# package.env! 1929# package.env!
1917# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1918# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1930# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1919# ------------------------------------------------------------------------------ 1931# ------------------------------------------------------------------------------
1920eant() { 1932eant() {
1921 debug-print-function ${FUNCNAME} $* 1933 debug-print-function ${FUNCNAME} $*
1922 1934
1923 if [[ ${EBUILD_PHASE} = compile ]]; then 1935 if [[ ${EBUILD_PHASE} = compile ]]; then
1924 java-ant-2_src_configure 1936 java-ant-2_src_configure
1925 java-utils-2_src_prepare 1937 java-utils-2_src_prepare
1926 fi 1938 fi
1927 1939
1928 if ! hasq java-ant-2 ${INHERITED}; then 1940 if ! has java-ant-2 ${INHERITED}; then
1929 local msg="You should inherit java-ant-2 when using eant" 1941 local msg="You should inherit java-ant-2 when using eant"
1930 java-pkg_announce-qa-violation "${msg}" 1942 java-pkg_announce-qa-violation "${msg}"
1931 fi 1943 fi
1932 1944
1933 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1945 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
2008 2020
2009 if [[ ${EBUILD_PHASE} = "test" ]]; then 2021 if [[ ${EBUILD_PHASE} = "test" ]]; then
2010 antflags="${antflags} -DJunit.present=true" 2022 antflags="${antflags} -DJunit.present=true"
2011 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2023 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
2012 getjarsarg="--with-dependencies" 2024 getjarsarg="--with-dependencies"
2025 else
2026 antflags="${antflags} -Dmaven.test.skip=true"
2013 fi 2027 fi
2014 2028
2015 local cp 2029 local cp
2016 2030
2017 for atom in ${gcp}; do 2031 for atom in ${gcp}; do
2134# call it during each of the phases of the merge process. 2148# call it during each of the phases of the merge process.
2135# 2149#
2136# ----------------------------------------------------------------------------- 2150# -----------------------------------------------------------------------------
2137java-pkg_init() { 2151java-pkg_init() {
2138 debug-print-function ${FUNCNAME} $* 2152 debug-print-function ${FUNCNAME} $*
2153
2154 # Don't set up build environment if installing from binary. #206024 #258423
2155 [[ "${MERGE_TYPE}" == "binary" ]] && return
2156 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2157 # work nothing is lost.
2158 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2159
2139 unset JAVAC 2160 unset JAVAC
2140 unset JAVA_HOME 2161 unset JAVA_HOME
2141 2162
2142 java-config --help >/dev/null || { 2163 java-config --help >/dev/null || {
2143 eerror "" 2164 eerror ""
2508# 2529#
2509# ------------------------------------------------------------------------------ 2530# ------------------------------------------------------------------------------
2510java-pkg_setup-vm() { 2531java-pkg_setup-vm() {
2511 debug-print-function ${FUNCNAME} $* 2532 debug-print-function ${FUNCNAME} $*
2512 2533
2513 export LANG="C" LC_ALL="C"
2514
2515 local vendor="$(java-pkg_get-vm-vendor)" 2534 local vendor="$(java-pkg_get-vm-vendor)"
2516 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2535 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2517 addpredict "/dev/random" 2536 addpredict "/dev/random"
2518 elif [[ "${vendor}" == "ibm" ]]; then 2537 elif [[ "${vendor}" == "ibm" ]]; then
2519 addpredict "/proc/self/maps" 2538 addpredict "/proc/self/maps"
2520 addpredict "/proc/cpuinfo" 2539 addpredict "/proc/cpuinfo"
2540 addpredict "/proc/self/coredump_filter"
2541 elif [[ "${vendor}" == "oracle" ]]; then
2542 addpredict "/dev/random"
2543 addpredict "/proc/self/coredump_filter"
2544 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2545 addpredict "/dev/random"
2546 addpredict "/proc/self/coredump_filter"
2521 elif [[ "${vendor}" == "jrockit" ]]; then 2547 elif [[ "${vendor}" == "jrockit" ]]; then
2522 addpredict "/proc/cpuinfo" 2548 addpredict "/proc/cpuinfo"
2523 fi 2549 fi
2524} 2550}
2525 2551
2526# ------------------------------------------------------------------------------ 2552# ------------------------------------------------------------------------------
2527# @internal-function java-pkg_needs-vm 2553# @internal-function java-pkg_needs-vm
2528# 2554#
2529# Does the current package depend on virtual/jdk? 2555# Does the current package depend on virtual/jdk or does it set
2556# JAVA_PKG_WANT_BUILD_VM?
2530# 2557#
2531# @return 0 - Package depends on virtual/jdk 2558# @return 0 - Package depends on virtual/jdk
2532# @return 1 - Package does not depend on virtual/jdk 2559# @return 1 - Package does not depend on virtual/jdk
2533# ------------------------------------------------------------------------------ 2560# ------------------------------------------------------------------------------
2534java-pkg_needs-vm() { 2561java-pkg_needs-vm() {
2535 debug-print-function ${FUNCNAME} $* 2562 debug-print-function ${FUNCNAME} $*
2536 2563
2537 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then 2564 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2538 return 0 2565 return 0
2539 fi 2566 fi
2567
2568 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2540 2569
2541 return 1 2570 return 1
2542} 2571}
2543 2572
2544# ------------------------------------------------------------------------------ 2573# ------------------------------------------------------------------------------
2570# ------------------------------------------------------------------------------ 2599# ------------------------------------------------------------------------------
2571java-pkg_get-vm-version() { 2600java-pkg_get-vm-version() {
2572 debug-print-function ${FUNCNAME} $* 2601 debug-print-function ${FUNCNAME} $*
2573 2602
2574 java-config -g PROVIDES_VERSION 2603 java-config -g PROVIDES_VERSION
2604}
2605
2606# ------------------------------------------------------------------------------
2607# @internal-function java-pkg_build-vm-from-handle
2608#
2609# Selects a build vm from a list of vm handles. First checks for the system-vm
2610# beeing usable, then steps through the listed handles till a suitable vm is
2611# found.
2612#
2613# @return - VM handle of an available JDK
2614# ------------------------------------------------------------------------------
2615java-pkg_build-vm-from-handle() {
2616 debug-print-function ${FUNCNAME} "$*"
2617
2618 local vm
2619 vm=$(java-pkg_get-current-vm)
2620 if [[ $? != 0 ]]; then
2621 eerror "${FUNCNAME}: Failed to get active vm"
2622 return 1
2623 fi
2624
2625 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2626 echo ${vm}
2627 return 0
2628 fi
2629
2630 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2631 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2632 echo ${vm}
2633 return 0
2634 fi
2635 done
2636
2637 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2638 return 1
2575} 2639}
2576 2640
2577# ------------------------------------------------------------------------------ 2641# ------------------------------------------------------------------------------
2578# @internal-function java-pkg_switch-vm 2642# @internal-function java-pkg_switch-vm
2579# 2643#
2590 # If you're forcing the VM, I hope you know what your doing... 2654 # If you're forcing the VM, I hope you know what your doing...
2591 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2655 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2592 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2656 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2593 # if we're allowed to switch the vm... 2657 # if we're allowed to switch the vm...
2594 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2658 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2595 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2659 # if there is an explicit list of handles to choose from
2596 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2660 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2597 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2661 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2598 eerror "Unable to determine VM for building from dependencies:" 2662 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2599 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2663 if [[ $? != 0 ]]; then
2664 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2600 die "Failed to determine VM for building." 2665 die "${FUNCNAME}: Failed to determine VM for building"
2666 fi
2667 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2668 # they can't be deduced from handles.
2669 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2670 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2671 die "Specify JAVA_PKG_WANT_SOURCE"
2672 fi
2673 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2674 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2675 die "Specify JAVA_PKG_WANT_TARGET"
2676 fi
2677 # otherwise determine a vm from dep string
2601 else 2678 else
2602 export GENTOO_VM 2679 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2680 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2681 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2682 eerror "Unable to determine VM for building from dependencies:"
2683 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2684 die "Failed to determine VM for building."
2685 fi
2603 fi 2686 fi
2687 export GENTOO_VM
2604 # otherwise just make sure the current VM is sufficient 2688 # otherwise just make sure the current VM is sufficient
2605 else 2689 else
2606 java-pkg_ensure-vm-version-sufficient 2690 java-pkg_ensure-vm-version-sufficient
2607 fi 2691 fi
2608 debug-print "Using: $(java-config -f)" 2692 debug-print "Using: $(java-config -f)"
2643# 2727#
2644# Enhanced die for Java packages, which displays some information that may be 2728# Enhanced die for Java packages, which displays some information that may be
2645# useful for debugging bugs on bugzilla. 2729# useful for debugging bugs on bugzilla.
2646# ------------------------------------------------------------------------------ 2730# ------------------------------------------------------------------------------
2647#register_die_hook java-pkg_die 2731#register_die_hook java-pkg_die
2648if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2732if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2649 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2733 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2650fi 2734fi
2651 2735
2652java-pkg_die() { 2736java-pkg_die() {
2653 echo "!!! When you file a bug report, please include the following information:" >&2 2737 echo "!!! When you file a bug report, please include the following information:" >&2
2727 2811
2728 local limit_to="${1}" 2812 local limit_to="${1}"
2729 local target_pkg="${2}" 2813 local target_pkg="${2}"
2730 local dev_error="" 2814 local dev_error=""
2731 2815
2732 # remove the version specification, which may include globbing (* and [123]) 2816 # remove the version specification, which may include globbing (* and [123])
2733 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2817 local stripped_pkg=$(echo "${target_pkg}" | sed \
2734 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//') 2818 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2735 2819
2736 debug-print "Matching against: ${stripped_pkg}" 2820 debug-print "Matching against: ${stripped_pkg}"
2737 2821
2789 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2873 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2790 fi 2874 fi
2791} 2875}
2792 2876
2793java-pkg_check-jikes() { 2877java-pkg_check-jikes() {
2794 if hasq jikes ${IUSE}; then 2878 if has jikes ${IUSE}; then
2795 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2879 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2796 fi 2880 fi
2797} 2881}
2798 2882
2799java-pkg_announce-qa-violation() { 2883java-pkg_announce-qa-violation() {

Legend:
Removed from v.1.139  
changed lines
  Added in v.1.150

  ViewVC Help
Powered by ViewVC 1.1.20