/[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.80 Revision 1.96
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.80 2007/04/26 23:32:12 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.96 2007/11/25 07:51:41 caster 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
58#WANT_ANT_TASKS 57#WANT_ANT_TASKS
59 58
60# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
61# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
62# 61#
63# The version of portage we need to function properly. At this moment it's 62# The version of portage we need to function properly. Previously it was
64# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_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. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
73# portage, that includes phase hooks. 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.31 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
76 77
77# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 80# @variable-default yes
80# 81#
195# 196#
196# @example 197# @example
197# java-pkg_doexamples demo 198# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/* 199# java-pkg_doexamples demo/* examples/*
199# 200#
201# @param --subdir - If the examples need a certain directory structure
200# @param $* - list of files to install 202# @param $* - list of files to install
201# ------------------------------------------------------------------------------ 203# ------------------------------------------------------------------------------
202java-pkg_doexamples() { 204java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $* 205 debug-print-function ${FUNCNAME} $*
204 206
205 [[ ${#} -lt 1 ]] && die "At least one argument needed" 207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206 208
207 java-pkg_check-phase install 209 java-pkg_check-phase install
208 210
209 local dest=/usr/share/doc/${PF}/examples 211 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2}
214 dodir ${dest}
215 shift 2
216 fi
217
210 if [[ ${#} = 1 && -d ${1} ]]; then 218 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env 219 ( # dont want to pollute calling env
212 insinto "${dest}" 220 insinto "${dest}"
213 doins -r ${1}/* 221 doins -r ${1}/*
214 ) || die "Installing examples failed" 222 ) || die "Installing examples failed"
831# @param $opt 839# @param $opt
832# --build-only - makes the jar(s) not added into package.env DEPEND line. 840# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test) 841# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies 842# --with-dependencies - get jars also from requested package's dependencies
835# transitively. 843# transitively.
844# --virtual - Packages passed to this function are to be handled as virtuals
845# and will not have individual jar dependencies recorded.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of . 846# --into $dir - symlink jar(s) into $dir (must exist) instead of .
837# @param $1 - Package to get jars from, or comma-separated list of packages in 847# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used. 848# case other parameters are not used.
839# @param $2 - jar from package. If not specified, all jars will be used. 849# @param $2 - jar from package. If not specified, all jars will be used.
840# @param $3 - When a single jar is specified, destination filename of the 850# @param $3 - When a single jar is specified, destination filename of the
845 debug-print-function ${FUNCNAME} $* 855 debug-print-function ${FUNCNAME} $*
846 856
847 local build_only="" 857 local build_only=""
848 local destdir="." 858 local destdir="."
849 local deep="" 859 local deep=""
860 local virtual=""
850 861
851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 862 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
852 863
853 while [[ "${1}" == --* ]]; do 864 while [[ "${1}" == --* ]]; do
854 if [[ "${1}" = "--build-only" ]]; then 865 if [[ "${1}" = "--build-only" ]]; then
855 build_only="build" 866 build_only="build"
856 elif [[ "${1}" = "--with-dependencies" ]]; then 867 elif [[ "${1}" = "--with-dependencies" ]]; then
857 deep="--with-dependencies" 868 deep="--with-dependencies"
869 elif [[ "${1}" = "--virtual" ]]; then
870 virtual="true"
858 elif [[ "${1}" = "--into" ]]; then 871 elif [[ "${1}" = "--into" ]]; then
859 destdir="${2}" 872 destdir="${2}"
860 shift 873 shift
861 else 874 else
862 die "java-pkg_jar-from called with unknown parameter: ${1}" 875 die "java-pkg_jar-from called with unknown parameter: ${1}"
886 done 899 done
887 # setting this disables further record-jar_ calls later 900 # setting this disables further record-jar_ calls later
888 build_only="build" 901 build_only="build"
889 else 902 else
890 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 903 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
904 fi
905
906 # Record the entire virtual as a dependency so that
907 # no jars are missed.
908 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
909 java-pkg_record-jar_ "${target_pkg}"
910 # setting this disables further record-jars_ calls later
911 build_only="build"
891 fi 912 fi
892 913
893 pushd ${destdir} > /dev/null \ 914 pushd ${destdir} > /dev/null \
894 || die "failed to change directory to ${destdir}" 915 || die "failed to change directory to ${destdir}"
895 916
995 classpath="${classpath}:${jars}" 1016 classpath="${classpath}:${jars}"
996 fi 1017 fi
997 1018
998 # Only record jars that aren't build-only 1019 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 1020 if [[ -z "${build_only}" ]]; then
1000 for pkg in ${pkgs//:/ }; do 1021 for pkg in ${pkgs//,/ }; do
1001 java-pkg_record-jar_ "${pkg}" 1022 java-pkg_record-jar_ "${pkg}"
1002 done 1023 done
1003 fi 1024 fi
1004 1025
1005 echo "${classpath}" 1026 echo "${classpath}"
1019# @example-return 1040# @example-return
1020# /usr/share/xerces-2/lib/xml-apis.jar 1041# /usr/share/xerces-2/lib/xml-apis.jar
1021# 1042#
1022# @param $opt 1043# @param $opt
1023# --build-only - makes the jar not added into package.env DEPEND line. 1044# --build-only - makes the jar not added into package.env DEPEND line.
1045# --virtual - Packages passed to this function are to be handled as virtuals
1046# and will not have individual jar dependencies recorded.
1024# @param $1 - package to use 1047# @param $1 - package to use
1025# @param $2 - jar to get 1048# @param $2 - jar to get
1026# ------------------------------------------------------------------------------ 1049# ------------------------------------------------------------------------------
1027java-pkg_getjar() { 1050java-pkg_getjar() {
1028 debug-print-function ${FUNCNAME} $* 1051 debug-print-function ${FUNCNAME} $*
1029 1052
1030 local build_only="" 1053 local build_only=""
1054 local virtual=""
1031 1055
1032 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1056 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1033 1057
1034 while [[ "${1}" == --* ]]; do 1058 while [[ "${1}" == --* ]]; do
1035 if [[ "${1}" = "--build-only" ]]; then 1059 if [[ "${1}" = "--build-only" ]]; then
1036 build_only="build" 1060 build_only="build"
1061 elif [[ "${1}" == --* ]]; then
1062 virtual="true"
1037 else 1063 else
1038 die "java-pkg_jar-from called with unknown parameter: ${1}" 1064 die "java-pkg_jar-from called with unknown parameter: ${1}"
1039 fi 1065 fi
1040 shift 1066 shift
1041 done 1067 done
1050 local classpath 1076 local classpath
1051 classpath=$(java-config --classpath=${pkg}) 1077 classpath=$(java-config --classpath=${pkg})
1052 [[ $? != 0 ]] && die ${error_msg} 1078 [[ $? != 0 ]] && die ${error_msg}
1053 1079
1054 java-pkg_ensure-dep "${build_only}" "${pkg}" 1080 java-pkg_ensure-dep "${build_only}" "${pkg}"
1081
1082 # Record the package(Virtual) as a dependency and then set build_only
1083 # So that individual jars are not recorded.
1084 if [[ -n "${virtual}" ]]; then
1085 java-pkg_record-jar_ "${pkg}"
1086 build_only="true"
1087 fi
1055 1088
1056 for jar in ${classpath//:/ }; do 1089 for jar in ${classpath//:/ }; do
1057 if [[ ! -f "${jar}" ]] ; then 1090 if [[ ! -f "${jar}" ]] ; then
1058 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1091 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1059 fi 1092 fi
1077# from a package, into package.env DEPEND line. Can only be called in 1110# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase. 1111# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get 1112# Intended for binary packages where you don't need to symlink the jars or get
1080# their classpath during build. As such, the dependencies only need to be 1113# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1114# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083# 1115#
1084# @param $1 - comma-separated list of packages, or a single package 1116# @param $1 - comma-separated list of packages, or a single package
1085# @param $2 - if param $1 is a single package, optionally specify the jar 1117# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on 1118# to depend on
1087# 1119#
1118 die "${FUNCNAME} called with both package list and jar name" 1150 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}" 1151 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}" 1152 java-pkg_record-jar_ "${pkgs}" "${jar}"
1121 fi 1153 fi
1122 1154
1123 java-pkg_do_write_ 1155 java-pkg_do_write_
1156}
1157
1158# ------------------------------------------------------------------------------
1159# @ebuild-function java-pkg_register-optional-dependency
1160#
1161# Registers optional runtime dependency on a package, list of packages, or a
1162# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1163# called in src_install phase.
1164# Intended for packages that can use other packages when those are in classpath.
1165# Will be put on classpath by launcher if they are installed. Typical case is
1166# JDBC implementations for various databases. It's better than having USE flag
1167# for each implementation triggering hard dependency.
1168#
1169# @param $1 - comma-separated list of packages, or a single package
1170# @param $2 - if param $1 is a single package, optionally specify the jar
1171# to depend on
1172#
1173# Example: Record the optional dependency on some jdbc providers
1174# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1175#
1176# Note: Passing both list of packages as the first parameter AND specifying the
1177# jar as the second is not allowed and will cause the function to die. We assume
1178# that there's more chance one passes such combination as a mistake, than that
1179# there are more packages providing identically named jar without class
1180# collisions.
1181# ------------------------------------------------------------------------------
1182java-pkg_register-optional-dependency() {
1183 debug-print-function ${FUNCNAME} $*
1184
1185 java-pkg_check-phase install
1186
1187 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1188
1189 local pkgs="${1}"
1190 local jar="${2}"
1191
1192 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1193
1194 if [[ -z "${jar}" ]]; then
1195 for pkg in ${pkgs//,/ }; do
1196 java-pkg_record-jar_ --optional "${pkg}"
1197 done
1198 else
1199 [[ ${pkgs} == *,* ]] && \
1200 die "${FUNCNAME} called with both package list and jar name"
1201 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1202 fi
1203
1204 java-pkg_do_write_
1205}
1206
1207# ------------------------------------------------------------------------------
1208# @ebuild-function java-pkg_register-environment-variable
1209#
1210# Register an arbitrary environment variable into package.env. The gjl launcher
1211# for this package or any package depending on this will export it into
1212# environement before executing java command.
1213# Must only be called in src_install phase.
1214#
1215# @param $1 - variable name
1216# @param $2 - variable value
1217# ------------------------------------------------------------------------------
1218JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1219JAVA_PKG_EXTRA_ENV_VARS=""
1220java-pkg_register-environment-variable() {
1221 debug-print-function ${FUNCNAME} $*
1222
1223 java-pkg_check-phase install
1224
1225 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1226
1227 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1228 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1229
1230 java-pkg_do_write_
1124} 1231}
1125 1232
1126# This function reads stdin, and based on that input, figures out how to 1233# This function reads stdin, and based on that input, figures out how to
1127# populate jars from the filesystem. 1234# populate jars from the filesystem.
1128# Need to figure out a good way of making use of this, ie be able to use a 1235# Need to figure out a good way of making use of this, ie be able to use a
1616 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true 1723 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1617 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true 1724 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1618 done 1725 done
1619 1726
1620 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then 1727 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1621 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks" 1728 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1622 echo "all" 1729 echo "all"
1623 else 1730 else
1624 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant 1731 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1625 # so we deactivate all tasks that may be installed 1732 # so we deactivate all tasks that may be installed
1626 echo "none" 1733 echo "none"
1651 return 0 1758 return 0
1652 fi 1759 fi
1653} 1760}
1654 1761
1655# ------------------------------------------------------------------------------ 1762# ------------------------------------------------------------------------------
1763# @ebuild-function ejunit
1764#
1765# Junit wrapper function. Makes it easier to run the tests and checks for
1766# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1767#
1768# Examples:
1769# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1770# ejunit org.blinkenlights.jid3.test.AllTests
1771#
1772# @param $1 - -cp or -classpath
1773# @param $2 - classpath; junit and recorded dependencies get appended
1774# @param $@ - the rest of the parameters are passed to java
1775# ------------------------------------------------------------------------------
1776ejunit() {
1777 debug-print-function ${FUNCNAME} $*
1778
1779 local pkgs
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1782 done
1783
1784 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1785 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1786 cp="${2}:${cp}"
1787 shift 2
1788 else
1789 cp=".:${cp}"
1790 fi
1791
1792 local runner=junit.textui.TestRunner
1793 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1794 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1795}
1796
1797# ------------------------------------------------------------------------------
1656# @section-end helper 1798# @section-end helper
1657# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1658 1800
1659# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1660# @section-begin build 1802# @section-begin build
1671# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1813# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1672# variables: 1814# variables:
1673# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1815# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1674# gentoo.classpath property. Be sure to call 1816# gentoo.classpath property. Be sure to call
1675# java-ant_rewrite-classpath in src_unpack. 1817# java-ant_rewrite-classpath in src_unpack.
1818# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1676# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1819# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1677# ------------------------------------------------------------------------------ 1820# ------------------------------------------------------------------------------
1678eant() { 1821eant() {
1679 debug-print-function ${FUNCNAME} $* 1822 debug-print-function ${FUNCNAME} $*
1680 1823
1681 # FIXME get this working 1824 if [[ ${EBUILD_PHASE} = compile ]]; then
1682# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1825 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1683# java-pkg_announce-qa-violation \ 1826 # finally get rid of the hooks without breaking stuff
1684# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1827
1828 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1829 && java-ant_ignore-system-classes "${S}/build.xml"
1830
1831 if hasq java-ant-2 ${INHERITED}; then
1832 java-ant_bsfix
1833 fi
1834
1835 # eant can be called multiple times
1836 JAVA_PKG_BSFIX="off"
1837
1838 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1839 echo "Searching for bundled jars:"
1840 java-pkg_find-normal-jars || echo "None found."
1841 echo "Searching for bundled classes (no output if none found):"
1842 find "${WORKDIR}" -name "*.class"
1843 echo "Search done."
1844 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1845 fi
1685# fi 1846 fi
1686 1847
1687 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1848 if ! hasq java-ant-2 ${INHERITED}; then
1688 local msg="You should inherit java-ant-2 when using eant" 1849 local msg="You should inherit java-ant-2 when using eant"
1689 java-pkg_announce-qa-violation ${msg} 1850 java-pkg_announce-qa-violation "${msg}"
1690 die ${msg}
1691 fi 1851 fi
1692 1852
1693 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1853 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1694 1854
1695 java-pkg_init-compiler_ 1855 java-pkg_init-compiler_
1696 local compiler="${GENTOO_COMPILER}" 1856 local compiler="${GENTOO_COMPILER}"
1697 1857
1698 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1858 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1699
1700 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1859 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1701 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1860 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1702 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1861 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1703 fi 1862 fi
1704 1863
1710 # java-config -p 1869 # java-config -p
1711 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1870 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1712 if [[ -n ${build_compiler_deps} ]]; then 1871 if [[ -n ${build_compiler_deps} ]]; then
1713 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1872 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1714 fi 1873 fi
1715 fi
1716
1717 if is-java-strict; then
1718 einfo "Disabling system classpath for ant"
1719 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1720 fi 1874 fi
1721 1875
1722 for arg in "${@}"; do 1876 for arg in "${@}"; do
1723 if [[ ${arg} = -lib ]]; then 1877 if [[ ${arg} = -lib ]]; then
1724 if is-java-strict; then 1878 if is-java-strict; then
1733 echo "more info." 1887 echo "more info."
1734 fi 1888 fi
1735 fi 1889 fi
1736 done 1890 done
1737 1891
1892 # we use this in src_* so we run ant from /
1738 if has_version ">=dev-java/ant-core-1.7.0"; then 1893 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1739 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1894 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1740 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1895 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1741 1896
1742 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1897 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1743 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1898 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1914 unset _JAVA_OPTIONS 2069 unset _JAVA_OPTIONS
1915 # phase hooks make this run many times without this 2070 # phase hooks make this run many times without this
1916 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2071 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1917 fi 2072 fi
1918 2073
2074 if java-pkg_func-exists ant_src_unpack; then
2075 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2076 fi
2077
1919 java-pkg_init_paths_ 2078 java-pkg_init_paths_
1920 java-pkg_switch-vm 2079 java-pkg_switch-vm
1921 PATH=${JAVA_HOME}/bin:${PATH} 2080 PATH=${JAVA_HOME}/bin:${PATH}
1922 2081
1923 # TODO we will probably want to set JAVAC and JAVACFLAGS 2082 # TODO we will probably want to set JAVAC and JAVACFLAGS
2063 fi 2222 fi
2064 2223
2065 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2224 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2066 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2225 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2067 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2226 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2227 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2228 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2068 2229
2069 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2230 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2070 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2231 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2071 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2232 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2072 2233
2085# Writes the package.env out to disk. 2246# Writes the package.env out to disk.
2086# 2247#
2087# ------------------------------------------------------------------------------ 2248# ------------------------------------------------------------------------------
2088# TODO change to do-write, to match everything else 2249# TODO change to do-write, to match everything else
2089java-pkg_do_write_() { 2250java-pkg_do_write_() {
2251 debug-print-function ${FUNCNAME} $*
2090 java-pkg_init_paths_ 2252 java-pkg_init_paths_
2091 # Create directory for package.env 2253 # Create directory for package.env
2092 dodir "${JAVA_PKG_SHAREPATH}" 2254 dodir "${JAVA_PKG_SHAREPATH}"
2093 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2255 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2256 "${JAVA_PKG_DEPEND_FILE}" || -f \
2257 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2094 # Create package.env 2258 # Create package.env
2095 ( 2259 (
2096 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2260 echo "DESCRIPTION=\"${DESCRIPTION}\""
2097 echo "GENERATION=\"2\"" 2261 echo "GENERATION=\"2\""
2098 2262
2099 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2263 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2100 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2264 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2101 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2265 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2102 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2266 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2267 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2268 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2269 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2103 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2270 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2104 ) > "${JAVA_PKG_ENV}" 2271 ) > "${JAVA_PKG_ENV}"
2105 2272
2106 # register target/source 2273 # register target/source
2107 local target="$(java-pkg_get-target)" 2274 local target="$(java-pkg_get-target)"
2118 2285
2119 2286
2120 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2287 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2121 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2288 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2122 2289
2290 # extra env variables
2291 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2292 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2293 # nested echo to remove leading/trailing spaces
2294 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2295 >> "${JAVA_PKG_ENV}" || die
2296 fi
2297
2123 # Strip unnecessary leading and trailing colons 2298 # Strip unnecessary leading and trailing colons
2124 # TODO try to cleanup if possible 2299 # TODO try to cleanup if possible
2125 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2300 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2301 else
2302 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2303 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2304 debug-print "write package.env."
2126 fi 2305 fi
2127} 2306}
2128 2307
2129# ------------------------------------------------------------------------------ 2308# ------------------------------------------------------------------------------
2130# @internal-function java-pkg_record-jar_ 2309# @internal-function java-pkg_record-jar_
2131# 2310#
2132# Record a dependency to the package.env 2311# Record an (optional) dependency to the package.env
2133# 2312# @param --optional - record dependency as optional
2313# @param $1 - package to record
2314# @param $2 - (optional) jar of package to record
2134# ------------------------------------------------------------------------------ 2315# ------------------------------------------------------------------------------
2135JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2316JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2317JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2136 2318
2137java-pkg_record-jar_() { 2319java-pkg_record-jar_() {
2138 debug-print-function ${FUNCNAME} $* 2320 debug-print-function ${FUNCNAME} $*
2321
2322 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2323 if [[ "${1}" == "--optional" ]]; then
2324 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2325 shift
2326 fi
2139 2327
2140 local pkg=${1} jar=${2} append 2328 local pkg=${1} jar=${2} append
2141 if [[ -z "${jar}" ]]; then 2329 if [[ -z "${jar}" ]]; then
2142 append="${pkg}" 2330 append="${pkg}"
2143 else 2331 else
2144 append="$(basename ${jar})@${pkg}" 2332 append="$(basename ${jar})@${pkg}"
2145 fi 2333 fi
2146 2334
2147 echo ${append} >> ${JAVA_PKG_DEPEND} 2335 echo "${append}" >> "${depend_file}"
2148} 2336}
2149 2337
2150# ------------------------------------------------------------------------------ 2338# ------------------------------------------------------------------------------
2151# @internal-function java-pkg_append_ 2339# @internal-function java-pkg_append_
2152# 2340#
2212# 2400#
2213# ------------------------------------------------------------------------------ 2401# ------------------------------------------------------------------------------
2214java-pkg_setup-vm() { 2402java-pkg_setup-vm() {
2215 debug-print-function ${FUNCNAME} $* 2403 debug-print-function ${FUNCNAME} $*
2216 2404
2405 export LANG="C" LC_ALL="C"
2406
2217 local vendor="$(java-pkg_get-vm-vendor)" 2407 local vendor="$(java-pkg_get-vm-vendor)"
2218 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2408 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2219 addpredict "/dev/random" 2409 addpredict "/dev/random"
2220 elif [[ "${vendor}" == "ibm" ]]; then 2410 elif [[ "${vendor}" == "ibm" ]]; then
2221 addpredict "/proc/self/maps" 2411 addpredict "/proc/self/maps"
2222 addpredict "/proc/cpuinfo" 2412 addpredict "/proc/cpuinfo"
2223 export LANG="C" LC_ALL="C"
2224 elif [[ "${vendor}" == "jrockit" ]]; then 2413 elif [[ "${vendor}" == "jrockit" ]]; then
2225 addpredict "/proc/cpuinfo" 2414 addpredict "/proc/cpuinfo"
2226 fi 2415 fi
2227} 2416}
2228 2417
2332 2521
2333 #TODO If you know a better solution let us know. 2522 #TODO If you know a better solution let us know.
2334 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2523 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2335 2524
2336 local tann="${T}/announced-vm" 2525 local tann="${T}/announced-vm"
2526 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2527 # if people have for example modified eclasses some where
2337 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2528 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2338 # Add a check for setup/preinst phase... to avoid duplicate outputs
2339 # for when FEATURES=buildpkg
2340 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2341 then
2342 einfo "Using: $(java-config -f)" 2529 einfo "Using: $(java-config -f)"
2343 [[ ! -f "${tann}" ]] && touch "${tann}" 2530 [[ ! -f "${tann}" ]] && touch "${tann}"
2344 fi
2345 fi 2531 fi
2346 2532
2347 else 2533 else
2348 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2534 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2349 fi 2535 fi
2416# Check that a package being used in jarfrom, getjars and getjar is contained 2602# Check that a package being used in jarfrom, getjars and getjar is contained
2417# within DEPEND or RDEPEND. 2603# within DEPEND or RDEPEND.
2418# @param $1 - empty - check both vars; "runtime" or "build" - check only 2604# @param $1 - empty - check both vars; "runtime" or "build" - check only
2419# RDEPEND, resp. DEPEND 2605# RDEPEND, resp. DEPEND
2420# @param $2 - Package name and slot. 2606# @param $2 - Package name and slot.
2607
2421java-pkg_ensure-dep() { 2608java-pkg_ensure-dep() {
2422 debug-print-function ${FUNCNAME} $* 2609 debug-print-function ${FUNCNAME} $*
2423 2610
2424 local limit_to="${1}" 2611 local limit_to="${1}"
2425 local target_pkg="${2}" 2612 local target_pkg="${2}"
2426 local dev_error="" 2613 local dev_error=""
2427 2614
2428 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2615 local stripped_pkg=$(echo "${target_pkg}" | sed \
2429 's/-[0-9]*\(\.[0-9]\)*$//') 2616 's/-[0-9]*\(\.[0-9]\)*$//')
2617
2618 debug-print "Matching against: ${stripped_pkg}"
2430 2619
2431 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2620 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2432 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2621 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2433 dev_error="${dev_error} declared in DEPEND." 2622 dev_error="${dev_error} declared in DEPEND."
2434 if is-java-strict; then 2623 if is-java-strict; then
2624 eerror "${dev_error}"
2435 die "${dev_error}" 2625 die "${dev_error}"
2436 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2626 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2437 eerror "${dev_error}" 2627 eerror "${dev_error}"
2438 elog "Because you have this package installed the package will" 2628 elog "Because you have this package installed the package will"
2439 elog "build without problems, but please report this to" 2629 elog "build without problems, but please report this to"
2440 elog "http://bugs.gentoo.org" 2630 elog "http://bugs.gentoo.org"
2441 fi 2631 fi
2442 fi 2632 fi
2443 2633
2634 if [[ ${limit_to} != build ]]; then
2444 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2635 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2636 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2445 dev_error="The ebuild is attempting to use ${target_pkg}," 2637 dev_error="The ebuild is attempting to use ${target_pkg},"
2446 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2638 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2639 dev_error="${dev_error} or PDEPEND."
2447 if is-java-strict; then 2640 if is-java-strict; then
2641 eerror "${dev_error}"
2448 die "${dev_error}" 2642 die "${dev_error}"
2449 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2643 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2450 eerror "${dev_error}" 2644 eerror "${dev_error}"
2451 elog "The package will build without problems, but may fail to run" 2645 elog "The package will build without problems, but may fail to run"
2452 elog "if you don't have ${target_pkg} installed, so please report" 2646 elog "if you don't have ${target_pkg} installed, so please report"
2453 elog "this to http://bugs.gentoo.org" 2647 elog "this to http://bugs.gentoo.org"
2648 fi
2649 fi
2454 fi 2650 fi
2455 fi 2651 fi
2456} 2652}
2457 2653
2458# ------------------------------------------------------------------------------ 2654# ------------------------------------------------------------------------------
2459# @section-end internal 2655# @section-end internal
2460# ------------------------------------------------------------------------------ 2656# ------------------------------------------------------------------------------
2461 2657
2462java-pkg_check-phase() { 2658java-pkg_check-phase() {
2463 local phase=${1} 2659 local phase=${1}
2464 local funcname=${2} 2660 local funcname=${FUNCNAME[1]}
2465 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2661 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2466 java-pkg_announce-qa-violation \
2467 "${funcname} used outside of src_${phase}" 2662 local msg="${funcname} used outside of src_${phase}"
2663 java-pkg_announce-qa-violation "${msg}"
2468 fi 2664 fi
2469} 2665}
2470 2666
2471java-pkg_check-versioned-jar() { 2667java-pkg_check-versioned-jar() {
2472 local jar=${1} 2668 local jar=${1}
2481 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2677 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2482 fi 2678 fi
2483} 2679}
2484 2680
2485java-pkg_announce-qa-violation() { 2681java-pkg_announce-qa-violation() {
2486 if is-java-strict; then 2682 local nodie
2683 if [[ ${1} == "--nodie" ]]; then
2684 nodie="true"
2685 shift
2686 fi
2487 echo "Java QA Notice: $@" >&2 2687 echo "Java QA Notice: $@" >&2
2488 increment-qa-violations 2688 increment-qa-violations
2489 fi 2689 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2490} 2690}
2491 2691
2492increment-qa-violations() { 2692increment-qa-violations() {
2493 let "JAVA_PKG_QA_VIOLATIONS+=1" 2693 let "JAVA_PKG_QA_VIOLATIONS+=1"
2494 export JAVA_PKG_QA_VIOLATIONS 2694 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.96

  ViewVC Help
Powered by ViewVC 1.1.20