/[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.81 Revision 1.106
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.81 2007/04/27 10:14:15 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.106 2008/05/03 21:28:07 betelgeuse 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"
282 fi 290 fi
283 done 291 done
284 292
285 java-pkg_do_write_ 293 java-pkg_do_write_
286} 294}
287
288 295
289# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
290# @internal-function depend-java-query 297# @internal-function depend-java-query
291# 298#
292# Wrapper for the depend-java-query binary to enable passing USE in env. 299# Wrapper for the depend-java-query binary to enable passing USE in env.
549# ------------------------------------------------------------------------------ 556# ------------------------------------------------------------------------------
550# @ebuild-function java-pkg_dojavadoc 557# @ebuild-function java-pkg_dojavadoc
551# 558#
552# Installs javadoc documentation. This should be controlled by the doc use flag. 559# Installs javadoc documentation. This should be controlled by the doc use flag.
553# 560#
561# @param $1: optional --symlink creates to symlink like this for html
562# documentation bundles.
554# @param $1: - The javadoc root directory. 563# @param $2: - The javadoc root directory.
555# 564#
556# @example: 565# @example:
557# java-pkg_dojavadoc docs/api 566# java-pkg_dojavadoc docs/api
567# java-pkg_dojavadoc --symlink apidocs docs/api
558# 568#
559# ------------------------------------------------------------------------------ 569# ------------------------------------------------------------------------------
560java-pkg_dojavadoc() { 570java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $* 571 debug-print-function ${FUNCNAME} $*
572
573 # For html documentation bundles that link to Javadoc
574 local symlink
575 if [[ ${1} = --symlink ]]; then
576 symlink=${2}
577 shift 2
578 fi
579
562 local dir="$1" 580 local dir="$1"
581 local dest=/usr/share/doc/${PF}/html
563 582
564 # QA checks 583 # QA checks
565 584
566 java-pkg_check-phase install 585 java-pkg_check-phase install
567 586
571 local msg="No index.html in javadoc directory" 590 local msg="No index.html in javadoc directory"
572 ewarn "${msg}" 591 ewarn "${msg}"
573 is-java-strict && die "${msg}" 592 is-java-strict && die "${msg}"
574 fi 593 fi
575 594
595 if [[ -e ${D}/${dest}/api ]]; then
596 eerror "${dest} already exists. Will not overwrite."
597 die "${dest}"
598 fi
599
576 # Renaming to match our directory layout 600 # Renaming to match our directory layout
577 601
578 local dir_to_install="${dir}" 602 local dir_to_install="${dir}"
579 if [[ "$(basename "${dir}")" != "api" ]]; then 603 if [[ "$(basename "${dir}")" != "api" ]]; then
580 dir_to_install="${T}/api" 604 dir_to_install="${T}/api"
582 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 606 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
583 fi 607 fi
584 608
585 # Actual installation 609 # Actual installation
586 610
587 java-pkg_dohtml -r ${dir_to_install} 611 java-pkg_dohtml -r "${dir_to_install}"
612
613 # Let's make a symlink to the directory we have everything else under
614 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
615
616 if [[ ${symlink} ]]; then
617 debug-print "symlinking ${dest}/{api,${symlink}}"
618 dosym ${dest}/{api,${symlink}} || die
619 fi
588} 620}
589 621
590# ------------------------------------------------------------------------------ 622# ------------------------------------------------------------------------------
591# @ebuild-function java-pkg_dosrc 623# @ebuild-function java-pkg_dosrc
592# 624#
615 647
616 [[ ${#} -lt 1 ]] && die "At least one argument needed" 648 [[ ${#} -lt 1 ]] && die "At least one argument needed"
617 649
618 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
619 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
620 if is-java-strict; then 652 java-pkg_announce-qa-violation ${msg}
621 eerror "${msg}"
622 die "${msg}"
623 else
624 echo "${msg}"
625 echo "Please report this to http://bugs.gentoo.org."
626 fi
627 fi 653 fi
628 654
629 java-pkg_init_paths_ 655 java-pkg_init_paths_
630 656
631 local zip_name="${PN}-src.zip" 657 local zip_name="${PN}-src.zip"
831# @param $opt 857# @param $opt
832# --build-only - makes the jar(s) not added into package.env DEPEND line. 858# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test) 859# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies 860# --with-dependencies - get jars also from requested package's dependencies
835# transitively. 861# transitively.
862# --virtual - Packages passed to this function are to be handled as virtuals
863# and will not have individual jar dependencies recorded.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of . 864# --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 865# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used. 866# case other parameters are not used.
839# @param $2 - jar from package. If not specified, all jars will be used. 867# @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 868# @param $3 - When a single jar is specified, destination filename of the
845 debug-print-function ${FUNCNAME} $* 873 debug-print-function ${FUNCNAME} $*
846 874
847 local build_only="" 875 local build_only=""
848 local destdir="." 876 local destdir="."
849 local deep="" 877 local deep=""
878 local virtual=""
850 879
851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 880 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
852 881
853 while [[ "${1}" == --* ]]; do 882 while [[ "${1}" == --* ]]; do
854 if [[ "${1}" = "--build-only" ]]; then 883 if [[ "${1}" = "--build-only" ]]; then
855 build_only="build" 884 build_only="build"
856 elif [[ "${1}" = "--with-dependencies" ]]; then 885 elif [[ "${1}" = "--with-dependencies" ]]; then
857 deep="--with-dependencies" 886 deep="--with-dependencies"
887 elif [[ "${1}" = "--virtual" ]]; then
888 virtual="true"
858 elif [[ "${1}" = "--into" ]]; then 889 elif [[ "${1}" = "--into" ]]; then
859 destdir="${2}" 890 destdir="${2}"
860 shift 891 shift
861 else 892 else
862 die "java-pkg_jar-from called with unknown parameter: ${1}" 893 die "java-pkg_jar-from called with unknown parameter: ${1}"
865 done 896 done
866 897
867 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 898 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
868 899
869 [[ -z ${target_pkg} ]] && die "Must specify a package" 900 [[ -z ${target_pkg} ]] && die "Must specify a package"
901
902 if [[ "${EAPI}" == "1" ]]; then
903 target_pkg="${target_pkg//:/-}"
904 fi
870 905
871 # default destjar to the target jar 906 # default destjar to the target jar
872 [[ -z "${destjar}" ]] && destjar="${target_jar}" 907 [[ -z "${destjar}" ]] && destjar="${target_jar}"
873 908
874 local error_msg="There was a problem getting the classpath for ${target_pkg}." 909 local error_msg="There was a problem getting the classpath for ${target_pkg}."
886 done 921 done
887 # setting this disables further record-jar_ calls later 922 # setting this disables further record-jar_ calls later
888 build_only="build" 923 build_only="build"
889 else 924 else
890 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 925 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
926 fi
927
928 # Record the entire virtual as a dependency so that
929 # no jars are missed.
930 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
931 java-pkg_record-jar_ "${target_pkg}"
932 # setting this disables further record-jars_ calls later
933 build_only="build"
891 fi 934 fi
892 935
893 pushd ${destdir} > /dev/null \ 936 pushd ${destdir} > /dev/null \
894 || die "failed to change directory to ${destdir}" 937 || die "failed to change directory to ${destdir}"
895 938
978 done 1021 done
979 1022
980 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1023 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
981 1024
982 1025
983 local classpath pkgs="${1}" 1026 local pkgs="${1}"
1027
1028 if [[ "${EAPI}" == "1" ]]; then
1029 pkgs="${pkgs//:/-}"
1030 fi
1031
984 jars="$(java-config ${deep} --classpath=${pkgs})" 1032 jars="$(java-config ${deep} --classpath=${pkgs})"
985 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1033 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
986 debug-print "${pkgs}:${jars}" 1034 debug-print "${pkgs}:${jars}"
987 1035
988 for pkg in ${pkgs//,/ }; do 1036 for pkg in ${pkgs//,/ }; do
989 java-pkg_ensure-dep "${build_only}" "${pkg}" 1037 java-pkg_ensure-dep "${build_only}" "${pkg}"
990 done 1038 done
991
992 if [[ -z "${classpath}" ]]; then
993 classpath="${jars}"
994 else
995 classpath="${classpath}:${jars}"
996 fi
997 1039
998 # Only record jars that aren't build-only 1040 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 1041 if [[ -z "${build_only}" ]]; then
1000 for pkg in ${pkgs//,/ }; do 1042 for pkg in ${pkgs//,/ }; do
1001 java-pkg_record-jar_ "${pkg}" 1043 java-pkg_record-jar_ "${pkg}"
1002 done 1044 done
1003 fi 1045 fi
1004 1046
1005 echo "${classpath}" 1047 echo "${jars}"
1006} 1048}
1007 1049
1008# ------------------------------------------------------------------------------ 1050# ------------------------------------------------------------------------------
1009# @ebuild-function java-pkg_getjar 1051# @ebuild-function java-pkg_getjar
1010# 1052#
1019# @example-return 1061# @example-return
1020# /usr/share/xerces-2/lib/xml-apis.jar 1062# /usr/share/xerces-2/lib/xml-apis.jar
1021# 1063#
1022# @param $opt 1064# @param $opt
1023# --build-only - makes the jar not added into package.env DEPEND line. 1065# --build-only - makes the jar not added into package.env DEPEND line.
1066# --virtual - Packages passed to this function are to be handled as virtuals
1067# and will not have individual jar dependencies recorded.
1024# @param $1 - package to use 1068# @param $1 - package to use
1025# @param $2 - jar to get 1069# @param $2 - jar to get
1026# ------------------------------------------------------------------------------ 1070# ------------------------------------------------------------------------------
1027java-pkg_getjar() { 1071java-pkg_getjar() {
1028 debug-print-function ${FUNCNAME} $* 1072 debug-print-function ${FUNCNAME} $*
1029 1073
1030 local build_only="" 1074 local build_only=""
1075 local virtual=""
1031 1076
1032 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1033 1078
1034 while [[ "${1}" == --* ]]; do 1079 while [[ "${1}" == --* ]]; do
1035 if [[ "${1}" = "--build-only" ]]; then 1080 if [[ "${1}" = "--build-only" ]]; then
1036 build_only="build" 1081 build_only="build"
1082 elif [[ "${1}" == "--virtual" ]]; then
1083 virtual="true"
1037 else 1084 else
1038 die "java-pkg_jar-from called with unknown parameter: ${1}" 1085 die "java-pkg_getjar called with unknown parameter: ${1}"
1039 fi 1086 fi
1040 shift 1087 shift
1041 done 1088 done
1042 1089
1043 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1090 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1044 1091
1045 local pkg="${1}" target_jar="${2}" jar 1092 local pkg="${1}" target_jar="${2}" jar
1093
1094 if [[ "${EAPI}" == "1" ]]; then
1095 pkg="${pkg//:/-}"
1096 fi
1097
1046 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1098 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1047 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1099 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1048 1100
1049 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1101 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1050 local classpath 1102 local classpath
1051 classpath=$(java-config --classpath=${pkg}) 1103 classpath=$(java-config --classpath=${pkg})
1052 [[ $? != 0 ]] && die ${error_msg} 1104 [[ $? != 0 ]] && die ${error_msg}
1053 1105
1054 java-pkg_ensure-dep "${build_only}" "${pkg}" 1106 java-pkg_ensure-dep "${build_only}" "${pkg}"
1107
1108 # Record the package(Virtual) as a dependency and then set build_only
1109 # So that individual jars are not recorded.
1110 if [[ -n "${virtual}" ]]; then
1111 java-pkg_record-jar_ "${pkg}"
1112 build_only="true"
1113 fi
1055 1114
1056 for jar in ${classpath//:/ }; do 1115 for jar in ${classpath//:/ }; do
1057 if [[ ! -f "${jar}" ]] ; then 1116 if [[ ! -f "${jar}" ]] ; then
1058 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1117 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1059 fi 1118 fi
1077# from a package, into package.env DEPEND line. Can only be called in 1136# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase. 1137# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get 1138# 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 1139# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1140# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083# 1141#
1084# @param $1 - comma-separated list of packages, or a single package 1142# @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 1143# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on 1144# to depend on
1087# 1145#
1105 1163
1106 local pkgs="${1}" 1164 local pkgs="${1}"
1107 local jar="${2}" 1165 local jar="${2}"
1108 1166
1109 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1167 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1168
1169 if [[ "${EAPI}" == "1" ]]; then
1170 pkgs="${pkgs//:/-}"
1171 fi
1110 1172
1111 if [[ -z "${jar}" ]]; then 1173 if [[ -z "${jar}" ]]; then
1112 for pkg in ${pkgs//,/ }; do 1174 for pkg in ${pkgs//,/ }; do
1113 java-pkg_ensure-dep runtime "${pkg}" 1175 java-pkg_ensure-dep runtime "${pkg}"
1114 java-pkg_record-jar_ "${pkg}" 1176 java-pkg_record-jar_ "${pkg}"
1118 die "${FUNCNAME} called with both package list and jar name" 1180 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}" 1181 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}" 1182 java-pkg_record-jar_ "${pkgs}" "${jar}"
1121 fi 1183 fi
1122 1184
1123 java-pkg_do_write_ 1185 java-pkg_do_write_
1186}
1187
1188# ------------------------------------------------------------------------------
1189# @ebuild-function java-pkg_register-optional-dependency
1190#
1191# Registers optional runtime dependency on a package, list of packages, or a
1192# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1193# called in src_install phase.
1194# Intended for packages that can use other packages when those are in classpath.
1195# Will be put on classpath by launcher if they are installed. Typical case is
1196# JDBC implementations for various databases. It's better than having USE flag
1197# for each implementation triggering hard dependency.
1198#
1199# @param $1 - comma-separated list of packages, or a single package
1200# @param $2 - if param $1 is a single package, optionally specify the jar
1201# to depend on
1202#
1203# Example: Record the optional dependency on some jdbc providers
1204# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1205#
1206# Note: Passing both list of packages as the first parameter AND specifying the
1207# jar as the second is not allowed and will cause the function to die. We assume
1208# that there's more chance one passes such combination as a mistake, than that
1209# there are more packages providing identically named jar without class
1210# collisions.
1211# ------------------------------------------------------------------------------
1212java-pkg_register-optional-dependency() {
1213 debug-print-function ${FUNCNAME} $*
1214
1215 java-pkg_check-phase install
1216
1217 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1218
1219 local pkgs="${1}"
1220 local jar="${2}"
1221
1222 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1223
1224 if [[ "${EAPI}" == "1" ]]; then
1225 pkgs="${pkgs//:/-}"
1226 fi
1227
1228 if [[ -z "${jar}" ]]; then
1229 for pkg in ${pkgs//,/ }; do
1230 java-pkg_record-jar_ --optional "${pkg}"
1231 done
1232 else
1233 [[ ${pkgs} == *,* ]] && \
1234 die "${FUNCNAME} called with both package list and jar name"
1235 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1236 fi
1237
1238 java-pkg_do_write_
1239}
1240
1241# ------------------------------------------------------------------------------
1242# @ebuild-function java-pkg_register-environment-variable
1243#
1244# Register an arbitrary environment variable into package.env. The gjl launcher
1245# for this package or any package depending on this will export it into
1246# environement before executing java command.
1247# Must only be called in src_install phase.
1248#
1249# @param $1 - variable name
1250# @param $2 - variable value
1251# ------------------------------------------------------------------------------
1252JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1253JAVA_PKG_EXTRA_ENV_VARS=""
1254java-pkg_register-environment-variable() {
1255 debug-print-function ${FUNCNAME} $*
1256
1257 java-pkg_check-phase install
1258
1259 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1260
1261 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1262 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1263
1264 java-pkg_do_write_
1124} 1265}
1125 1266
1126# This function reads stdin, and based on that input, figures out how to 1267# This function reads stdin, and based on that input, figures out how to
1127# populate jars from the filesystem. 1268# populate jars from the filesystem.
1128# Need to figure out a good way of making use of this, ie be able to use a 1269# Need to figure out a good way of making use of this, ie be able to use a
1591 dodir /usr/share/ant/${TASKS_DIR} 1732 dodir /usr/share/ant/${TASKS_DIR}
1592 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1733 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1593} 1734}
1594 1735
1595# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1596# @internal-function java-pkg_ant-tasks-from-deps
1597#
1598# Function to determine ANT_TASKS from DEPEND variable for backwards
1599# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1600# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1601# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1602# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1603# be a problem, the worst it can do is activace all tasks when not needed.
1604# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1605# insufficient dependencies, otherwise all available tasks are used for
1606# backwards compatilbility.
1607#
1608# @return "all" or "none"
1609# ------------------------------------------------------------------------------
1610java-pkg_ant-tasks-from-deps() {
1611 local found_ant found_ant_tasks
1612
1613 for dep in ${DEPEND}
1614 do
1615 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1616 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1617 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1618 done
1619
1620 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1621 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1622 echo "all"
1623 else
1624 # 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
1626 echo "none"
1627 fi
1628}
1629
1630# ------------------------------------------------------------------------------
1631# @internal-function java-pkg_ant-tasks-depend 1737# @internal-function java-pkg_ant-tasks-depend
1632# 1738#
1633# Translates the WANT_ANT_TASKS variable into valid dependencies. 1739# Translates the WANT_ANT_TASKS variable into valid dependencies.
1634# ------------------------------------------------------------------------------ 1740# ------------------------------------------------------------------------------
1635java-pkg_ant-tasks-depend() { 1741java-pkg_ant-tasks-depend() {
1651 return 0 1757 return 0
1652 fi 1758 fi
1653} 1759}
1654 1760
1655# ------------------------------------------------------------------------------ 1761# ------------------------------------------------------------------------------
1762# @ebuild-function ejunit
1763#
1764# Junit wrapper function. Makes it easier to run the tests and checks for
1765# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1766#
1767# Examples:
1768# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1769# ejunit org.blinkenlights.jid3.test.AllTests
1770#
1771# @param $1 - -cp or -classpath
1772# @param $2 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java
1774# ------------------------------------------------------------------------------
1775ejunit{
1776 debug-print-function ${FUNCNAME} $*
1777
1778 local pkgs
1779 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1780 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1781 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1782 done
1783 fi
1784
1785 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1786 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1787 cp="${2}:${cp}"
1788 shift 2
1789 else
1790 cp=".:${cp}"
1791 fi
1792
1793 local runner=junit.textui.TestRunner
1794 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1795 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1796}
1797
1798# ------------------------------------------------------------------------------
1656# @section-end helper 1799# @section-end helper
1657# ------------------------------------------------------------------------------ 1800# ------------------------------------------------------------------------------
1658 1801
1659# ------------------------------------------------------------------------------ 1802# ------------------------------------------------------------------------------
1660# @section-begin build 1803# @section-begin build
1671# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1814# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1672# variables: 1815# variables:
1673# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1816# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1674# gentoo.classpath property. Be sure to call 1817# gentoo.classpath property. Be sure to call
1675# java-ant_rewrite-classpath in src_unpack. 1818# java-ant_rewrite-classpath in src_unpack.
1819# 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. 1820# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1677# ------------------------------------------------------------------------------ 1821# ------------------------------------------------------------------------------
1678eant() { 1822eant() {
1679 debug-print-function ${FUNCNAME} $* 1823 debug-print-function ${FUNCNAME} $*
1680 1824
1681 # FIXME get this working 1825 if [[ ${EBUILD_PHASE} = compile ]]; then
1682# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1826 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1683# java-pkg_announce-qa-violation \ 1827 # finally get rid of the hooks without breaking stuff
1684# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 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
1685# fi 1847 fi
1686 1848
1687 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1849 if ! hasq java-ant-2 ${INHERITED}; then
1688 local msg="You should inherit java-ant-2 when using eant" 1850 local msg="You should inherit java-ant-2 when using eant"
1689 java-pkg_announce-qa-violation ${msg} 1851 java-pkg_announce-qa-violation "${msg}"
1690 die ${msg}
1691 fi 1852 fi
1692 1853
1693 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1854 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1694 1855
1695 java-pkg_init-compiler_ 1856 java-pkg_init-compiler_
1696 local compiler="${GENTOO_COMPILER}" 1857 local compiler="${GENTOO_COMPILER}"
1697 1858
1698 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1859 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})" 1860 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1701 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1861 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1702 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1862 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1703 fi 1863 fi
1704 1864
1710 # java-config -p 1870 # java-config -p
1711 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1871 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 1872 if [[ -n ${build_compiler_deps} ]]; then
1713 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1873 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1714 fi 1874 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 1875 fi
1721 1876
1722 for arg in "${@}"; do 1877 for arg in "${@}"; do
1723 if [[ ${arg} = -lib ]]; then 1878 if [[ ${arg} = -lib ]]; then
1724 if is-java-strict; then 1879 if is-java-strict; then
1733 echo "more info." 1888 echo "more info."
1734 fi 1889 fi
1735 fi 1890 fi
1736 done 1891 done
1737 1892
1738 if 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 1893 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1740 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1894 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1741 1895
1742 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1896 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1743 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1897 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1744 1898
1745 if is-java-strict; then
1746 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1747 if [[ -z "${ANT_TASKS}" ]]; then
1748 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1749 fi
1750 else
1751 # if ant-tasks is not set by ebuild or forced, activate all of them 1899 # if ant-tasks is not set by ebuild or forced, use none
1752 ANT_TASKS="${ANT_TASKS:-all}" 1900 ANT_TASKS="${ANT_TASKS:-none}"
1753 fi
1754 1901
1755 # at this point, ANT_TASKS should be "all", "none" or explicit list 1902 # at this point, ANT_TASKS should be "all", "none" or explicit list
1756 if [[ "${ANT_TASKS}" == "all" ]]; then 1903 if [[ "${ANT_TASKS}" == "all" ]]; then
1757 einfo "Using all available ANT_TASKS" 1904 einfo "Using all available ANT_TASKS"
1758 elif [[ "${ANT_TASKS}" == "none" ]]; then 1905 elif [[ "${ANT_TASKS}" == "none" ]]; then
1759 einfo "Disabling all optional ANT_TASKS" 1906 einfo "Disabling all optional ANT_TASKS"
1760 else 1907 else
1761 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1908 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1762 fi 1909 fi
1763 1910
1764 export ANT_TASKS 1911 export ANT_TASKS
1765 fi
1766 1912
1767 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1913 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1768 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1914 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1769 1915
1770 local gcp="${EANT_GENTOO_CLASSPATH}" 1916 local gcp="${EANT_GENTOO_CLASSPATH}"
1892# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2038# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1893# call it during each of the phases of the merge process. 2039# call it during each of the phases of the merge process.
1894# 2040#
1895# ----------------------------------------------------------------------------- 2041# -----------------------------------------------------------------------------
1896java-pkg_init() { 2042java-pkg_init() {
2043 debug-print-function ${FUNCNAME} $*
1897 unset JAVAC 2044 unset JAVAC
1898 unset JAVA_HOME 2045 unset JAVA_HOME
1899 2046
1900 # People do all kinds of weird things. 2047 # People do all kinds of weird things.
1901 # http://forums.gentoo.org/viewtopic-p-3943166.html 2048 # http://forums.gentoo.org/viewtopic-p-3943166.html
1909 ewarn "make.conf for example) to silence this warning or" 2056 ewarn "make.conf for example) to silence this warning or"
1910 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2057 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1911 fi 2058 fi
1912 2059
1913 if [[ -z ${accept} ]]; then 2060 if [[ -z ${accept} ]]; then
2061 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2062 # -version output
1914 unset _JAVA_OPTIONS 2063 unset _JAVA_OPTIONS
1915 # phase hooks make this run many times without this 2064 # phase hooks make this run many times without this
1916 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2065 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1917 fi 2066 fi
1918 2067
2068 if java-pkg_func-exists ant_src_unpack; then
2069 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2070 fi
2071
1919 java-pkg_init_paths_ 2072 java-pkg_init_paths_
1920 java-pkg_switch-vm 2073 java-pkg_switch-vm
1921 PATH=${JAVA_HOME}/bin:${PATH} 2074 PATH=${JAVA_HOME}/bin:${PATH}
1922 2075
1923 # TODO we will probably want to set JAVAC and JAVACFLAGS 2076 # TODO we will probably want to set JAVAC and JAVACFLAGS
1924 2077
1925 # Do some QA checks 2078 # Do some QA checks
1926 java-pkg_check-jikes 2079 java-pkg_check-jikes
2080
2081 # Can't use unset here because Portage does not save the unset
2082 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
1927 2083
1928 # When users have crazy classpaths some packages can fail to compile. 2084 # When users have crazy classpaths some packages can fail to compile.
1929 # and everything should work with empty CLASSPATH. 2085 # and everything should work with empty CLASSPATH.
1930 # This also helps prevent unexpected dependencies on random things 2086 # This also helps prevent unexpected dependencies on random things
1931 # from the CLASSPATH. 2087 # from the CLASSPATH.
1932 unset CLASSPATH 2088 export CLASSPATH=
1933 2089
1934 # Unset external ANT_ stuff 2090 # Unset external ANT_ stuff
1935 unset ANT_TASKS 2091 export ANT_TASKS=
1936 unset ANT_OPTS 2092 export ANT_OPTS=
1937} 2093}
1938 2094
1939# ------------------------------------------------------------------------------ 2095# ------------------------------------------------------------------------------
1940# @function-internal java-pkg-init-compiler_ 2096# @function-internal java-pkg-init-compiler_
1941# 2097#
2032 done 2188 done
2033 2189
2034 # If it hasn't been defined already, default to javac 2190 # If it hasn't been defined already, default to javac
2035 if [[ -z ${GENTOO_COMPILER} ]]; then 2191 if [[ -z ${GENTOO_COMPILER} ]]; then
2036 if [[ -n ${compilers} ]]; then 2192 if [[ -n ${compilers} ]]; then
2037 einfo "No suitable compiler found: defaulting javac for compilation" 2193 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2038 else 2194 else
2039 # probably don't need to notify users about the default. 2195 # probably don't need to notify users about the default.
2040 :;#einfo "Defaulting to javac for compilation" 2196 :;#einfo "Defaulting to javac for compilation"
2041 fi 2197 fi
2198 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2199 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2200 else
2042 export GENTOO_COMPILER=javac 2201 export GENTOO_COMPILER=javac
2202 fi
2043 else 2203 else
2044 einfo "Using ${GENTOO_COMPILER} for compilation" 2204 einfo "Using ${GENTOO_COMPILER} for compilation"
2045 fi 2205 fi
2046 2206
2047} 2207}
2063 fi 2223 fi
2064 2224
2065 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2225 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2066 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2226 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2067 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2227 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2228 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2229 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2068 2230
2069 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2231 [[ -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}" 2232 [[ -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" 2233 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2072 2234
2085# Writes the package.env out to disk. 2247# Writes the package.env out to disk.
2086# 2248#
2087# ------------------------------------------------------------------------------ 2249# ------------------------------------------------------------------------------
2088# TODO change to do-write, to match everything else 2250# TODO change to do-write, to match everything else
2089java-pkg_do_write_() { 2251java-pkg_do_write_() {
2252 debug-print-function ${FUNCNAME} $*
2090 java-pkg_init_paths_ 2253 java-pkg_init_paths_
2091 # Create directory for package.env 2254 # Create directory for package.env
2092 dodir "${JAVA_PKG_SHAREPATH}" 2255 dodir "${JAVA_PKG_SHAREPATH}"
2093 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2256 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2257 "${JAVA_PKG_DEPEND_FILE}" || -f \
2258 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2094 # Create package.env 2259 # Create package.env
2095 ( 2260 (
2096 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2261 echo "DESCRIPTION=\"${DESCRIPTION}\""
2097 echo "GENERATION=\"2\"" 2262 echo "GENERATION=\"2\""
2263 echo "SLOT=\"${SLOT}\""
2098 2264
2099 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2265 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2100 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2266 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2101 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2267 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2102 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2268 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2269 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2270 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2271 && 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 ! 2272 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2104 ) > "${JAVA_PKG_ENV}" 2273 ) > "${JAVA_PKG_ENV}"
2105 2274
2106 # register target/source 2275 # register target/source
2107 local target="$(java-pkg_get-target)" 2276 local target="$(java-pkg_get-target)"
2118 2287
2119 2288
2120 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2289 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2121 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2290 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2122 2291
2292 # extra env variables
2293 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2294 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2295 # nested echo to remove leading/trailing spaces
2296 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2297 >> "${JAVA_PKG_ENV}" || die
2298 fi
2299
2123 # Strip unnecessary leading and trailing colons 2300 # Strip unnecessary leading and trailing colons
2124 # TODO try to cleanup if possible 2301 # TODO try to cleanup if possible
2125 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2302 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2303 else
2304 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2305 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2306 debug-print "write package.env."
2126 fi 2307 fi
2127} 2308}
2128 2309
2129# ------------------------------------------------------------------------------ 2310# ------------------------------------------------------------------------------
2130# @internal-function java-pkg_record-jar_ 2311# @internal-function java-pkg_record-jar_
2131# 2312#
2132# Record a dependency to the package.env 2313# Record an (optional) dependency to the package.env
2133# 2314# @param --optional - record dependency as optional
2315# @param $1 - package to record
2316# @param $2 - (optional) jar of package to record
2134# ------------------------------------------------------------------------------ 2317# ------------------------------------------------------------------------------
2135JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2318JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2319JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2136 2320
2137java-pkg_record-jar_() { 2321java-pkg_record-jar_() {
2138 debug-print-function ${FUNCNAME} $* 2322 debug-print-function ${FUNCNAME} $*
2323
2324 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2325 if [[ "${1}" == "--optional" ]]; then
2326 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2327 shift
2328 fi
2139 2329
2140 local pkg=${1} jar=${2} append 2330 local pkg=${1} jar=${2} append
2141 if [[ -z "${jar}" ]]; then 2331 if [[ -z "${jar}" ]]; then
2142 append="${pkg}" 2332 append="${pkg}"
2143 else 2333 else
2144 append="$(basename ${jar})@${pkg}" 2334 append="$(basename ${jar})@${pkg}"
2145 fi 2335 fi
2146 2336
2147 echo ${append} >> ${JAVA_PKG_DEPEND} 2337 echo "${append}" >> "${depend_file}"
2148} 2338}
2149 2339
2150# ------------------------------------------------------------------------------ 2340# ------------------------------------------------------------------------------
2151# @internal-function java-pkg_append_ 2341# @internal-function java-pkg_append_
2152# 2342#
2212# 2402#
2213# ------------------------------------------------------------------------------ 2403# ------------------------------------------------------------------------------
2214java-pkg_setup-vm() { 2404java-pkg_setup-vm() {
2215 debug-print-function ${FUNCNAME} $* 2405 debug-print-function ${FUNCNAME} $*
2216 2406
2407 export LANG="C" LC_ALL="C"
2408
2217 local vendor="$(java-pkg_get-vm-vendor)" 2409 local vendor="$(java-pkg_get-vm-vendor)"
2218 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2410 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2219 addpredict "/dev/random" 2411 addpredict "/dev/random"
2220 elif [[ "${vendor}" == "ibm" ]]; then 2412 elif [[ "${vendor}" == "ibm" ]]; then
2221 addpredict "/proc/self/maps" 2413 addpredict "/proc/self/maps"
2222 addpredict "/proc/cpuinfo" 2414 addpredict "/proc/cpuinfo"
2223 export LANG="C" LC_ALL="C"
2224 elif [[ "${vendor}" == "jrockit" ]]; then 2415 elif [[ "${vendor}" == "jrockit" ]]; then
2225 addpredict "/proc/cpuinfo" 2416 addpredict "/proc/cpuinfo"
2226 fi 2417 fi
2227} 2418}
2228 2419
2332 2523
2333 #TODO If you know a better solution let us know. 2524 #TODO If you know a better solution let us know.
2334 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2525 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2335 2526
2336 local tann="${T}/announced-vm" 2527 local tann="${T}/announced-vm"
2528 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2529 # if people have for example modified eclasses some where
2337 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2530 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)" 2531 einfo "Using: $(java-config -f)"
2343 [[ ! -f "${tann}" ]] && touch "${tann}" 2532 [[ ! -f "${tann}" ]] && touch "${tann}"
2344 fi
2345 fi 2533 fi
2346 2534
2347 else 2535 else
2348 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2536 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2349 fi 2537 fi
2416# Check that a package being used in jarfrom, getjars and getjar is contained 2604# Check that a package being used in jarfrom, getjars and getjar is contained
2417# within DEPEND or RDEPEND. 2605# within DEPEND or RDEPEND.
2418# @param $1 - empty - check both vars; "runtime" or "build" - check only 2606# @param $1 - empty - check both vars; "runtime" or "build" - check only
2419# RDEPEND, resp. DEPEND 2607# RDEPEND, resp. DEPEND
2420# @param $2 - Package name and slot. 2608# @param $2 - Package name and slot.
2609
2421java-pkg_ensure-dep() { 2610java-pkg_ensure-dep() {
2422 debug-print-function ${FUNCNAME} $* 2611 debug-print-function ${FUNCNAME} $*
2423 2612
2424 local limit_to="${1}" 2613 local limit_to="${1}"
2425 local target_pkg="${2}" 2614 local target_pkg="${2}"
2426 local dev_error="" 2615 local dev_error=""
2427 2616
2428 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2617 local stripped_pkg=$(echo "${target_pkg}" | sed \
2429 's/-[0-9]*\(\.[0-9]\)*$//') 2618 's/-[0-9]*\(\.[0-9]\)*$//')
2619
2620 debug-print "Matching against: ${stripped_pkg}"
2430 2621
2431 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2622 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2432 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2623 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2433 dev_error="${dev_error} declared in DEPEND." 2624 dev_error="${dev_error} declared in DEPEND."
2434 if is-java-strict; then 2625 if is-java-strict; then
2626 eerror "${dev_error}"
2435 die "${dev_error}" 2627 die "${dev_error}"
2436 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2628 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2437 eerror "${dev_error}" 2629 eerror "${dev_error}"
2438 elog "Because you have this package installed the package will" 2630 elog "Because you have this package installed the package will"
2439 elog "build without problems, but please report this to" 2631 elog "build without problems, but please report this to"
2440 elog "http://bugs.gentoo.org" 2632 elog "http://bugs.gentoo.org"
2441 fi 2633 fi
2442 fi 2634 fi
2443 2635
2636 if [[ ${limit_to} != build ]]; then
2444 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2637 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2638 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2445 dev_error="The ebuild is attempting to use ${target_pkg}," 2639 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." 2640 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2641 dev_error="${dev_error} or PDEPEND."
2447 if is-java-strict; then 2642 if is-java-strict; then
2643 eerror "${dev_error}"
2448 die "${dev_error}" 2644 die "${dev_error}"
2449 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2645 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2450 eerror "${dev_error}" 2646 eerror "${dev_error}"
2451 elog "The package will build without problems, but may fail to run" 2647 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" 2648 elog "if you don't have ${target_pkg} installed, so please report"
2453 elog "this to http://bugs.gentoo.org" 2649 elog "this to http://bugs.gentoo.org"
2650 fi
2651 fi
2454 fi 2652 fi
2455 fi 2653 fi
2456} 2654}
2457 2655
2458# ------------------------------------------------------------------------------ 2656# ------------------------------------------------------------------------------
2459# @section-end internal 2657# @section-end internal
2460# ------------------------------------------------------------------------------ 2658# ------------------------------------------------------------------------------
2461 2659
2462java-pkg_check-phase() { 2660java-pkg_check-phase() {
2463 local phase=${1} 2661 local phase=${1}
2464 local funcname=${2} 2662 local funcname=${FUNCNAME[1]}
2465 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2663 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2466 java-pkg_announce-qa-violation \
2467 "${funcname} used outside of src_${phase}" 2664 local msg="${funcname} used outside of src_${phase}"
2665 java-pkg_announce-qa-violation "${msg}"
2468 fi 2666 fi
2469} 2667}
2470 2668
2471java-pkg_check-versioned-jar() { 2669java-pkg_check-versioned-jar() {
2472 local jar=${1} 2670 local jar=${1}
2481 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2679 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2482 fi 2680 fi
2483} 2681}
2484 2682
2485java-pkg_announce-qa-violation() { 2683java-pkg_announce-qa-violation() {
2486 if is-java-strict; then 2684 local nodie
2685 if [[ ${1} == "--nodie" ]]; then
2686 nodie="true"
2687 shift
2688 fi
2487 echo "Java QA Notice: $@" >&2 2689 echo "Java QA Notice: $@" >&2
2488 increment-qa-violations 2690 increment-qa-violations
2489 fi 2691 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2490} 2692}
2491 2693
2492increment-qa-violations() { 2694increment-qa-violations() {
2493 let "JAVA_PKG_QA_VIOLATIONS+=1" 2695 let "JAVA_PKG_QA_VIOLATIONS+=1"
2494 export JAVA_PKG_QA_VIOLATIONS 2696 export JAVA_PKG_QA_VIOLATIONS

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

  ViewVC Help
Powered by ViewVC 1.1.20