/[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.79 Revision 1.127
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.79 2007/04/26 14:50:00 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.127 2009/05/19 21:23:32 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. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. 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.1.6 ${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"
283 done 291 done
284 292
285 java-pkg_do_write_ 293 java-pkg_do_write_
286} 294}
287 295
288
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.
293# Using env variables keeps this eclass working with java-config versions that 300# Using env variables keeps this eclass working with java-config versions that
358 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
359 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
360 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
361 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
362 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
363 die "${jar} does not exist" 371 die "${jar} does not exist"
364 fi 372 fi
365 done 373 done
366 374
367 java-pkg_do_write_ 375 java-pkg_do_write_
422# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
423# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
424java-pkg_doso() { 432java-pkg_doso() {
425 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
426 434
427 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
428 java-pkg_check-phase install 435 java-pkg_check-phase install
429 436
430 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
431 438
432 java-pkg_init_paths_ 439 java-pkg_init_paths_
433 440
434 local lib 441 local lib
435 # for each lib 442 # for each lib
438 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
439 # install if it isn't a symlink 446 # install if it isn't a symlink
440 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
441 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
442 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
443 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
446 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
447 else 454 else
448 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
449 ln -s "$(readlink "${lib}")" \
450 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
451 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
452 fi 457 fi
453 # otherwise die 458 # otherwise die
454 else 459 else
455 die "${lib} does not exist" 460 die "${lib} does not exist"
456 fi 461 fi
472java-pkg_regso() { 477java-pkg_regso() {
473 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
474 479
475 java-pkg_check-phase install 480 java-pkg_check-phase install
476 481
477 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
478 483
479 java-pkg_init_paths_ 484 java-pkg_init_paths_
480 485
481 local lib target_dir 486 local lib target_dir
482 for lib in "$@" ; do 487 for lib in "$@" ; do
549# ------------------------------------------------------------------------------ 554# ------------------------------------------------------------------------------
550# @ebuild-function java-pkg_dojavadoc 555# @ebuild-function java-pkg_dojavadoc
551# 556#
552# Installs javadoc documentation. This should be controlled by the doc use flag. 557# Installs javadoc documentation. This should be controlled by the doc use flag.
553# 558#
559# @param $1: optional --symlink creates to symlink like this for html
560# documentation bundles.
554# @param $1: - The javadoc root directory. 561# @param $2: - The javadoc root directory.
555# 562#
556# @example: 563# @example:
557# java-pkg_dojavadoc docs/api 564# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api
558# 566#
559# ------------------------------------------------------------------------------ 567# ------------------------------------------------------------------------------
560java-pkg_dojavadoc() { 568java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $* 569 debug-print-function ${FUNCNAME} $*
570
571 # For html documentation bundles that link to Javadoc
572 local symlink
573 if [[ ${1} = --symlink ]]; then
574 symlink=${2}
575 shift 2
576 fi
577
562 local dir="$1" 578 local dir="$1"
579 local dest=/usr/share/doc/${PF}/html
563 580
564 # QA checks 581 # QA checks
565 582
566 java-pkg_check-phase install 583 java-pkg_check-phase install
567 584
571 local msg="No index.html in javadoc directory" 588 local msg="No index.html in javadoc directory"
572 ewarn "${msg}" 589 ewarn "${msg}"
573 is-java-strict && die "${msg}" 590 is-java-strict && die "${msg}"
574 fi 591 fi
575 592
593 if [[ -e ${D}/${dest}/api ]]; then
594 eerror "${dest} already exists. Will not overwrite."
595 die "${dest}"
596 fi
597
576 # Renaming to match our directory layout 598 # Renaming to match our directory layout
577 599
578 local dir_to_install="${dir}" 600 local dir_to_install="${dir}"
579 if [[ "$(basename "${dir}")" != "api" ]]; then 601 if [[ "$(basename "${dir}")" != "api" ]]; then
580 dir_to_install="${T}/api" 602 dir_to_install="${T}/api"
582 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 604 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
583 fi 605 fi
584 606
585 # Actual installation 607 # Actual installation
586 608
587 java-pkg_dohtml -r ${dir_to_install} 609 java-pkg_dohtml -r "${dir_to_install}"
610
611 # Let's make a symlink to the directory we have everything else under
612 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
613
614 if [[ ${symlink} ]]; then
615 debug-print "symlinking ${dest}/{api,${symlink}}"
616 dosym ${dest}/{api,${symlink}} || die
617 fi
588} 618}
589 619
590# ------------------------------------------------------------------------------ 620# ------------------------------------------------------------------------------
591# @ebuild-function java-pkg_dosrc 621# @ebuild-function java-pkg_dosrc
592# 622#
615 645
616 [[ ${#} -lt 1 ]] && die "At least one argument needed" 646 [[ ${#} -lt 1 ]] && die "At least one argument needed"
617 647
618 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 648 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
619 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 649 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
620 if is-java-strict; then 650 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 651 fi
628 652
629 java-pkg_init_paths_ 653 java-pkg_init_paths_
630 654
631 local zip_name="${PN}-src.zip" 655 local zip_name="${PN}-src.zip"
831# @param $opt 855# @param $opt
832# --build-only - makes the jar(s) not added into package.env DEPEND line. 856# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test) 857# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies 858# --with-dependencies - get jars also from requested package's dependencies
835# transitively. 859# transitively.
860# --virtual - Packages passed to this function are to be handled as virtuals
861# and will not have individual jar dependencies recorded.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of . 862# --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 863# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used. 864# case other parameters are not used.
839# @param $2 - jar from package. If not specified, all jars will be used. 865# @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 866# @param $3 - When a single jar is specified, destination filename of the
845 debug-print-function ${FUNCNAME} $* 871 debug-print-function ${FUNCNAME} $*
846 872
847 local build_only="" 873 local build_only=""
848 local destdir="." 874 local destdir="."
849 local deep="" 875 local deep=""
876 local virtual=""
850 877
851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 878 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
852 879
853 while [[ "${1}" == --* ]]; do 880 while [[ "${1}" == --* ]]; do
854 if [[ "${1}" = "--build-only" ]]; then 881 if [[ "${1}" = "--build-only" ]]; then
855 build_only="build" 882 build_only="build"
856 elif [[ "${1}" = "--with-dependencies" ]]; then 883 elif [[ "${1}" = "--with-dependencies" ]]; then
857 deep="--with-dependencies" 884 deep="--with-dependencies"
885 elif [[ "${1}" = "--virtual" ]]; then
886 virtual="true"
858 elif [[ "${1}" = "--into" ]]; then 887 elif [[ "${1}" = "--into" ]]; then
859 destdir="${2}" 888 destdir="${2}"
860 shift 889 shift
861 else 890 else
862 die "java-pkg_jar-from called with unknown parameter: ${1}" 891 die "java-pkg_jar-from called with unknown parameter: ${1}"
865 done 894 done
866 895
867 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 896 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
868 897
869 [[ -z ${target_pkg} ]] && die "Must specify a package" 898 [[ -z ${target_pkg} ]] && die "Must specify a package"
899
900 if [[ "${EAPI}" == "1" ]]; then
901 target_pkg="${target_pkg//:/-}"
902 fi
870 903
871 # default destjar to the target jar 904 # default destjar to the target jar
872 [[ -z "${destjar}" ]] && destjar="${target_jar}" 905 [[ -z "${destjar}" ]] && destjar="${target_jar}"
873 906
874 local error_msg="There was a problem getting the classpath for ${target_pkg}." 907 local error_msg="There was a problem getting the classpath for ${target_pkg}."
886 done 919 done
887 # setting this disables further record-jar_ calls later 920 # setting this disables further record-jar_ calls later
888 build_only="build" 921 build_only="build"
889 else 922 else
890 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 923 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
924 fi
925
926 # Record the entire virtual as a dependency so that
927 # no jars are missed.
928 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
929 java-pkg_record-jar_ "${target_pkg}"
930 # setting this disables further record-jars_ calls later
931 build_only="build"
891 fi 932 fi
892 933
893 pushd ${destdir} > /dev/null \ 934 pushd ${destdir} > /dev/null \
894 || die "failed to change directory to ${destdir}" 935 || die "failed to change directory to ${destdir}"
895 936
978 done 1019 done
979 1020
980 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1021 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
981 1022
982 1023
983 local classpath pkgs="${1}" 1024 local pkgs="${1}"
1025
1026 if [[ "${EAPI}" == "1" ]]; then
1027 pkgs="${pkgs//:/-}"
1028 fi
1029
984 jars="$(java-config ${deep} --classpath=${pkgs})" 1030 jars="$(java-config ${deep} --classpath=${pkgs})"
985 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1031 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
986 debug-print "${pkgs}:${jars}" 1032 debug-print "${pkgs}:${jars}"
987 1033
988 for pkg in ${pkgs//,/ }; do 1034 for pkg in ${pkgs//,/ }; do
989 java-pkg_ensure-dep "${build_only}" "${pkg}" 1035 java-pkg_ensure-dep "${build_only}" "${pkg}"
990 done 1036 done
991 1037
992 if [[ -z "${classpath}" ]]; then
993 classpath="${jars}"
994 else
995 classpath="${classpath}:${jars}"
996 fi
997
998 # Only record jars that aren't build-only 1038 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 1039 if [[ -z "${build_only}" ]]; then
1000 oldifs="${IFS}"
1001 IFS=","
1002 for pkg in ${pkgs}; do 1040 for pkg in ${pkgs//,/ }; do
1003 java-pkg_record-jar_ "${pkg}" 1041 java-pkg_record-jar_ "${pkg}"
1004 done 1042 done
1005 IFS="${oldifs}"
1006 fi 1043 fi
1007 1044
1008 echo "${classpath}" 1045 echo "${jars}"
1009} 1046}
1010 1047
1011# ------------------------------------------------------------------------------ 1048# ------------------------------------------------------------------------------
1012# @ebuild-function java-pkg_getjar 1049# @ebuild-function java-pkg_getjar
1013# 1050#
1022# @example-return 1059# @example-return
1023# /usr/share/xerces-2/lib/xml-apis.jar 1060# /usr/share/xerces-2/lib/xml-apis.jar
1024# 1061#
1025# @param $opt 1062# @param $opt
1026# --build-only - makes the jar not added into package.env DEPEND line. 1063# --build-only - makes the jar not added into package.env DEPEND line.
1064# --virtual - Packages passed to this function are to be handled as virtuals
1065# and will not have individual jar dependencies recorded.
1027# @param $1 - package to use 1066# @param $1 - package to use
1028# @param $2 - jar to get 1067# @param $2 - jar to get
1029# ------------------------------------------------------------------------------ 1068# ------------------------------------------------------------------------------
1030java-pkg_getjar() { 1069java-pkg_getjar() {
1031 debug-print-function ${FUNCNAME} $* 1070 debug-print-function ${FUNCNAME} $*
1032 1071
1033 local build_only="" 1072 local build_only=""
1073 local virtual=""
1034 1074
1035 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1036 1076
1037 while [[ "${1}" == --* ]]; do 1077 while [[ "${1}" == --* ]]; do
1038 if [[ "${1}" = "--build-only" ]]; then 1078 if [[ "${1}" = "--build-only" ]]; then
1039 build_only="build" 1079 build_only="build"
1080 elif [[ "${1}" == "--virtual" ]]; then
1081 virtual="true"
1040 else 1082 else
1041 die "java-pkg_jar-from called with unknown parameter: ${1}" 1083 die "java-pkg_getjar called with unknown parameter: ${1}"
1042 fi 1084 fi
1043 shift 1085 shift
1044 done 1086 done
1045 1087
1046 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1088 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1047 1089
1048 local pkg="${1}" target_jar="${2}" jar 1090 local pkg="${1}" target_jar="${2}" jar
1091
1092 if [[ "${EAPI}" == "1" ]]; then
1093 pkg="${pkg//:/-}"
1094 fi
1095
1049 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1050 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1097 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1051 1098
1052 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1099 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1053 local classpath 1100 local classpath
1054 classpath=$(java-config --classpath=${pkg}) 1101 classpath=$(java-config --classpath=${pkg})
1055 [[ $? != 0 ]] && die ${error_msg} 1102 [[ $? != 0 ]] && die ${error_msg}
1056 1103
1057 java-pkg_ensure-dep "${build_only}" "${pkg}" 1104 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105
1106 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then
1109 java-pkg_record-jar_ "${pkg}"
1110 build_only="true"
1111 fi
1058 1112
1059 for jar in ${classpath//:/ }; do 1113 for jar in ${classpath//:/ }; do
1060 if [[ ! -f "${jar}" ]] ; then 1114 if [[ ! -f "${jar}" ]] ; then
1061 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1062 fi 1116 fi
1080# from a package, into package.env DEPEND line. Can only be called in 1134# from a package, into package.env DEPEND line. Can only be called in
1081# src_install phase. 1135# src_install phase.
1082# Intended for binary packages where you don't need to symlink the jars or get 1136# Intended for binary packages where you don't need to symlink the jars or get
1083# their classpath during build. As such, the dependencies only need to be 1137# their classpath during build. As such, the dependencies only need to be
1084# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1138# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1085# Get the classpath provided by any number of packages.
1086# 1139#
1087# @param $1 - comma-separated list of packages, or a single package 1140# @param $1 - comma-separated list of packages, or a single package
1088# @param $2 - if param $1 is a single package, optionally specify the jar 1141# @param $2 - if param $1 is a single package, optionally specify the jar
1089# to depend on 1142# to depend on
1090# 1143#
1108 1161
1109 local pkgs="${1}" 1162 local pkgs="${1}"
1110 local jar="${2}" 1163 local jar="${2}"
1111 1164
1112 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1165 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1166
1167 if [[ "${EAPI}" == "1" ]]; then
1168 pkgs="${pkgs//:/-}"
1169 fi
1113 1170
1114 if [[ -z "${jar}" ]]; then 1171 if [[ -z "${jar}" ]]; then
1115 for pkg in ${pkgs//,/ }; do 1172 for pkg in ${pkgs//,/ }; do
1116 java-pkg_ensure-dep runtime "${pkg}" 1173 java-pkg_ensure-dep runtime "${pkg}"
1117 java-pkg_record-jar_ "${pkg}" 1174 java-pkg_record-jar_ "${pkg}"
1121 die "${FUNCNAME} called with both package list and jar name" 1178 die "${FUNCNAME} called with both package list and jar name"
1122 java-pkg_ensure-dep runtime "${pkgs}" 1179 java-pkg_ensure-dep runtime "${pkgs}"
1123 java-pkg_record-jar_ "${pkgs}" "${jar}" 1180 java-pkg_record-jar_ "${pkgs}" "${jar}"
1124 fi 1181 fi
1125 1182
1126 java-pkg_do_write_ 1183 java-pkg_do_write_
1184}
1185
1186# ------------------------------------------------------------------------------
1187# @ebuild-function java-pkg_register-optional-dependency
1188#
1189# Registers optional runtime dependency on a package, list of packages, or a
1190# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1191# called in src_install phase.
1192# Intended for packages that can use other packages when those are in classpath.
1193# Will be put on classpath by launcher if they are installed. Typical case is
1194# JDBC implementations for various databases. It's better than having USE flag
1195# for each implementation triggering hard dependency.
1196#
1197# @param $1 - comma-separated list of packages, or a single package
1198# @param $2 - if param $1 is a single package, optionally specify the jar
1199# to depend on
1200#
1201# Example: Record the optional dependency on some jdbc providers
1202# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1203#
1204# Note: Passing both list of packages as the first parameter AND specifying the
1205# jar as the second is not allowed and will cause the function to die. We assume
1206# that there's more chance one passes such combination as a mistake, than that
1207# there are more packages providing identically named jar without class
1208# collisions.
1209# ------------------------------------------------------------------------------
1210java-pkg_register-optional-dependency() {
1211 debug-print-function ${FUNCNAME} $*
1212
1213 java-pkg_check-phase install
1214
1215 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1216
1217 local pkgs="${1}"
1218 local jar="${2}"
1219
1220 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1221
1222 if [[ "${EAPI}" == "1" ]]; then
1223 pkgs="${pkgs//:/-}"
1224 fi
1225
1226 if [[ -z "${jar}" ]]; then
1227 for pkg in ${pkgs//,/ }; do
1228 java-pkg_record-jar_ --optional "${pkg}"
1229 done
1230 else
1231 [[ ${pkgs} == *,* ]] && \
1232 die "${FUNCNAME} called with both package list and jar name"
1233 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1234 fi
1235
1236 java-pkg_do_write_
1237}
1238
1239# ------------------------------------------------------------------------------
1240# @ebuild-function java-pkg_register-environment-variable
1241#
1242# Register an arbitrary environment variable into package.env. The gjl launcher
1243# for this package or any package depending on this will export it into
1244# environement before executing java command.
1245# Must only be called in src_install phase.
1246#
1247# @param $1 - variable name
1248# @param $2 - variable value
1249# ------------------------------------------------------------------------------
1250JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1251JAVA_PKG_EXTRA_ENV_VARS=""
1252java-pkg_register-environment-variable() {
1253 debug-print-function ${FUNCNAME} $*
1254
1255 java-pkg_check-phase install
1256
1257 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1258
1259 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1260 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1261
1262 java-pkg_do_write_
1127} 1263}
1128 1264
1129# This function reads stdin, and based on that input, figures out how to 1265# This function reads stdin, and based on that input, figures out how to
1130# populate jars from the filesystem. 1266# populate jars from the filesystem.
1131# Need to figure out a good way of making use of this, ie be able to use a 1267# Need to figure out a good way of making use of this, ie be able to use a
1594 dodir /usr/share/ant/${TASKS_DIR} 1730 dodir /usr/share/ant/${TASKS_DIR}
1595 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1731 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1596} 1732}
1597 1733
1598# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1599# @internal-function java-pkg_ant-tasks-from-deps
1600#
1601# Function to determine ANT_TASKS from DEPEND variable for backwards
1602# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1603# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1604# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1605# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1606# be a problem, the worst it can do is activace all tasks when not needed.
1607# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1608# insufficient dependencies, otherwise all available tasks are used for
1609# backwards compatilbility.
1610#
1611# @return "all" or "none"
1612# ------------------------------------------------------------------------------
1613java-pkg_ant-tasks-from-deps() {
1614 local found_ant found_ant_tasks
1615
1616 for dep in ${DEPEND}
1617 do
1618 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1619 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1620 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1621 done
1622
1623 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1624 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1625 echo "all"
1626 else
1627 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1628 # so we deactivate all tasks that may be installed
1629 echo "none"
1630 fi
1631}
1632
1633# ------------------------------------------------------------------------------
1634# @internal-function java-pkg_ant-tasks-depend 1735# @internal-function java-pkg_ant-tasks-depend
1635# 1736#
1636# Translates the WANT_ANT_TASKS variable into valid dependencies. 1737# Translates the WANT_ANT_TASKS variable into valid dependencies.
1637# ------------------------------------------------------------------------------ 1738# ------------------------------------------------------------------------------
1638java-pkg_ant-tasks-depend() { 1739java-pkg_ant-tasks-depend() {
1640 1741
1641 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1642 local DEP="" 1743 local DEP=""
1643 for i in ${WANT_ANT_TASKS} 1744 for i in ${WANT_ANT_TASKS}
1644 do 1745 do
1645 if [[ ${i} != ant-* ]]; then 1746 if [[ ${i} = ant-* ]]; then
1747 DEP="${DEP}dev-java/${i} "
1748 elif [[ ${i} = */*:* ]]; then
1749 DEP="${DEP}${i} "
1750 else
1646 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1751 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1647 return 1 1752 return 1
1648 fi 1753 fi
1649 DEP="${DEP}dev-java/${i} "
1650 done 1754 done
1651 echo ${DEP} 1755 echo ${DEP}
1652 return 0 1756 return 0
1653 else 1757 else
1654 return 0 1758 return 0
1655 fi 1759 fi
1656} 1760}
1657 1761
1658# ------------------------------------------------------------------------------ 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 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1781 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1782 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1783 done
1784 fi
1785
1786 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1787 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1788 cp="${2}:${cp}"
1789 shift 2
1790 else
1791 cp=".:${cp}"
1792 fi
1793
1794 local runner=junit.textui.TestRunner
1795 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1796 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1797}
1798
1799# ------------------------------------------------------------------------------
1659# @section-end helper 1800# @section-end helper
1660# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1802
1803# ------------------------------------------------------------------------------
1804# @eclass-src_prepare
1805#
1806# src_prepare Searches for bundled jars
1807# Don't call directly, but via java-pkg-2_src_prepare!
1808# ------------------------------------------------------------------------------
1809
1810java-utils-2_src_prepare() {
1811 [[ ${EBUILD_PHASE} == prepare ]] &&
1812 java-pkg_func-exists java_prepare && java_prepare
1813
1814 # Remember that eant will call this unless called via Portage
1815 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1816 echo "Searching for bundled jars:"
1817 java-pkg_find-normal-jars || echo "None found."
1818 echo "Searching for bundled classes (no output if none found):"
1819 find "${WORKDIR}" -name "*.class"
1820 echo "Search done."
1821 fi
1822 touch "${T}/java-utils-2_src_prepare-run"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @eclass-pkg_preinst
1827#
1828# pkg_preinst Searches for missing and unneeded dependencies
1829# Don't call directly, but via java-pkg-2_pkg_preinst!
1830# ------------------------------------------------------------------------------
1831
1832java-utils-2_pkg_preinst() {
1833 if is-java-strict; then
1834 if has_version dev-java/java-dep-check; then
1835 [[ -e "${JAVA_PKG_ENV}" ]] || return
1836 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1837 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1838 ewarn "Possibly unneeded dependencies found in package.env:"
1839 for dep in ${output}; do
1840 ewarn "\t${dep}"
1841 done
1842 fi
1843 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1844 ewarn "${output}"
1845 fi
1846 else
1847 eerror "Install dev-java/java-dep-check for dependency checking"
1848 fi
1849 fi
1850}
1661 1851
1662# ------------------------------------------------------------------------------ 1852# ------------------------------------------------------------------------------
1663# @section-begin build 1853# @section-begin build
1664# @section-summary Build functions 1854# @section-summary Build functions
1665# 1855#
1674# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1864# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1675# variables: 1865# variables:
1676# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1866# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1677# gentoo.classpath property. Be sure to call 1867# gentoo.classpath property. Be sure to call
1678# java-ant_rewrite-classpath in src_unpack. 1868# java-ant_rewrite-classpath in src_unpack.
1869# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1870# for build-time purposes, the dependency is not recorded to
1871# package.env!
1872# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1679# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1680# ------------------------------------------------------------------------------ 1874# ------------------------------------------------------------------------------
1681eant() { 1875eant() {
1682 debug-print-function ${FUNCNAME} $* 1876 debug-print-function ${FUNCNAME} $*
1683 1877
1684 # FIXME get this working 1878 if [[ ${EBUILD_PHASE} = compile ]]; then
1685# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1879 java-ant-2_src_configure
1686# java-pkg_announce-qa-violation \ 1880 java-utils-2_src_prepare
1687# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1688# fi 1881 fi
1689 1882
1690 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1883 if ! hasq java-ant-2 ${INHERITED}; then
1691 local msg="You should inherit java-ant-2 when using eant" 1884 local msg="You should inherit java-ant-2 when using eant"
1692 java-pkg_announce-qa-violation ${msg} 1885 java-pkg_announce-qa-violation "${msg}"
1693 die ${msg}
1694 fi 1886 fi
1695 1887
1696 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1888 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1697 1889
1698 java-pkg_init-compiler_ 1890 java-pkg_init-compiler_
1699 local compiler="${GENTOO_COMPILER}" 1891 local compiler="${GENTOO_COMPILER}"
1700 1892
1701 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1893 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1702
1703 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1894 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1704 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1895 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1705 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1896 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1706 fi 1897 fi
1707 1898
1713 # java-config -p 1904 # java-config -p
1714 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1905 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1715 if [[ -n ${build_compiler_deps} ]]; then 1906 if [[ -n ${build_compiler_deps} ]]; then
1716 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1907 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1717 fi 1908 fi
1718 fi
1719
1720 if is-java-strict; then
1721 einfo "Disabling system classpath for ant"
1722 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1723 fi 1909 fi
1724 1910
1725 for arg in "${@}"; do 1911 for arg in "${@}"; do
1726 if [[ ${arg} = -lib ]]; then 1912 if [[ ${arg} = -lib ]]; then
1727 if is-java-strict; then 1913 if is-java-strict; then
1736 echo "more info." 1922 echo "more info."
1737 fi 1923 fi
1738 fi 1924 fi
1739 done 1925 done
1740 1926
1741 if has_version ">=dev-java/ant-core-1.7.0"; then 1927 # parse WANT_ANT_TASKS for atoms
1742 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1928 local want_ant_tasks
1743 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1929 for i in ${WANT_ANT_TASKS}; do
1744 1930 if [[ ${i} = */*:* ]]; then
1745 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1931 i=${i#*/}
1746 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1932 i=${i%:0}
1747 1933 want_ant_tasks+="${i/:/-} "
1748 if is-java-strict; then
1749 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1750 if [[ -z "${ANT_TASKS}" ]]; then
1751 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1752 fi
1753 else 1934 else
1935 want_ant_tasks+="${i} "
1936 fi
1937 done
1938 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1939 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1940
1941 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1942 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1943
1754 # if ant-tasks is not set by ebuild or forced, activate all of them 1944 # if ant-tasks is not set by ebuild or forced, use none
1755 ANT_TASKS="${ANT_TASKS:-all}" 1945 ANT_TASKS="${ANT_TASKS:-none}"
1756 fi
1757 1946
1758 # at this point, ANT_TASKS should be "all", "none" or explicit list 1947 # at this point, ANT_TASKS should be "all", "none" or explicit list
1759 if [[ "${ANT_TASKS}" == "all" ]]; then 1948 if [[ "${ANT_TASKS}" == "all" ]]; then
1760 einfo "Using all available ANT_TASKS" 1949 einfo "Using all available ANT_TASKS"
1761 elif [[ "${ANT_TASKS}" == "none" ]]; then 1950 elif [[ "${ANT_TASKS}" == "none" ]]; then
1762 einfo "Disabling all optional ANT_TASKS" 1951 einfo "Disabling all optional ANT_TASKS"
1763 else 1952 else
1764 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1953 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1765 fi 1954 fi
1766 1955
1767 export ANT_TASKS 1956 export ANT_TASKS
1768 fi
1769 1957
1770 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1958 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1771 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1959 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1772 1960
1773 local gcp="${EANT_GENTOO_CLASSPATH}" 1961 local gcp="${EANT_GENTOO_CLASSPATH}"
1774 local getjarsarg="" 1962 local getjarsarg=""
1775 1963
1776 if [[ ${EBUILD_PHASE} = "test" ]]; then 1964 if [[ ${EBUILD_PHASE} = "test" ]]; then
1777 antflags="${antflags} -DJunit.present=true" 1965 antflags="${antflags} -DJunit.present=true"
1778 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1779 getjarsarg="--with-dependencies" 1967 getjarsarg="--with-dependencies"
1780 fi 1968 fi
1781 1969
1782 local cp 1970 local cp
1783 1971
1784 for atom in ${gcp}; do 1972 for atom in ${gcp}; do
1785 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1786 done 1974 done
1787 1975
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1977
1788 if [[ ${cp} ]]; then 1978 if [[ ${cp} ]]; then
1789 # It seems ant does not like single quotes around ${cp} 1979 # It seems ant does not like single quotes around ${cp}
1980 cp=${cp#:}
1981 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1982 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1790 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1791 fi 1984 fi
1792 1985
1793 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1794 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1795 ant ${antflags} "${@}" || die "eant failed" 1988 ant ${antflags} "${@}" || die "eant failed"
1895# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2088# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1896# call it during each of the phases of the merge process. 2089# call it during each of the phases of the merge process.
1897# 2090#
1898# ----------------------------------------------------------------------------- 2091# -----------------------------------------------------------------------------
1899java-pkg_init() { 2092java-pkg_init() {
2093 debug-print-function ${FUNCNAME} $*
1900 unset JAVAC 2094 unset JAVAC
1901 unset JAVA_HOME 2095 unset JAVA_HOME
2096
2097 java-config --help >/dev/null || {
2098 eerror ""
2099 eerror "Can't run java-config --help"
2100 eerror "Have you upgraded python recently but haven't"
2101 eerror "run python-updater yet?"
2102 die "Can't run java-config --help"
2103 }
1902 2104
1903 # People do all kinds of weird things. 2105 # People do all kinds of weird things.
1904 # http://forums.gentoo.org/viewtopic-p-3943166.html 2106 # http://forums.gentoo.org/viewtopic-p-3943166.html
1905 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2107 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
1906 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2108 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
1912 ewarn "make.conf for example) to silence this warning or" 2114 ewarn "make.conf for example) to silence this warning or"
1913 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2115 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1914 fi 2116 fi
1915 2117
1916 if [[ -z ${accept} ]]; then 2118 if [[ -z ${accept} ]]; then
2119 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2120 # -version output
1917 unset _JAVA_OPTIONS 2121 unset _JAVA_OPTIONS
1918 # phase hooks make this run many times without this 2122 # phase hooks make this run many times without this
1919 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2123 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1920 fi 2124 fi
1921 2125
2126 if java-pkg_func-exists ant_src_unpack; then
2127 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2128 fi
2129
1922 java-pkg_init_paths_ 2130 java-pkg_init_paths_
1923 java-pkg_switch-vm 2131 java-pkg_switch-vm
1924 PATH=${JAVA_HOME}/bin:${PATH} 2132 PATH=${JAVA_HOME}/bin:${PATH}
1925 2133
1926 # TODO we will probably want to set JAVAC and JAVACFLAGS 2134 # TODO we will probably want to set JAVAC and JAVACFLAGS
1927 2135
1928 # Do some QA checks 2136 # Do some QA checks
1929 java-pkg_check-jikes 2137 java-pkg_check-jikes
2138
2139 # Can't use unset here because Portage does not save the unset
2140 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
1930 2141
1931 # When users have crazy classpaths some packages can fail to compile. 2142 # When users have crazy classpaths some packages can fail to compile.
1932 # and everything should work with empty CLASSPATH. 2143 # and everything should work with empty CLASSPATH.
1933 # This also helps prevent unexpected dependencies on random things 2144 # This also helps prevent unexpected dependencies on random things
1934 # from the CLASSPATH. 2145 # from the CLASSPATH.
1935 unset CLASSPATH 2146 export CLASSPATH=
1936 2147
1937 # Unset external ANT_ stuff 2148 # Unset external ANT_ stuff
1938 unset ANT_TASKS 2149 export ANT_TASKS=
1939 unset ANT_OPTS 2150 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME=
1940} 2152}
1941 2153
1942# ------------------------------------------------------------------------------ 2154# ------------------------------------------------------------------------------
1943# @function-internal java-pkg-init-compiler_ 2155# @function-internal java-pkg-init-compiler_
1944# 2156#
2035 done 2247 done
2036 2248
2037 # If it hasn't been defined already, default to javac 2249 # If it hasn't been defined already, default to javac
2038 if [[ -z ${GENTOO_COMPILER} ]]; then 2250 if [[ -z ${GENTOO_COMPILER} ]]; then
2039 if [[ -n ${compilers} ]]; then 2251 if [[ -n ${compilers} ]]; then
2040 einfo "No suitable compiler found: defaulting javac for compilation" 2252 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2041 else 2253 else
2042 # probably don't need to notify users about the default. 2254 # probably don't need to notify users about the default.
2043 :;#einfo "Defaulting to javac for compilation" 2255 :;#einfo "Defaulting to javac for compilation"
2044 fi 2256 fi
2257 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2258 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2259 else
2045 export GENTOO_COMPILER=javac 2260 export GENTOO_COMPILER=javac
2261 fi
2046 else 2262 else
2047 einfo "Using ${GENTOO_COMPILER} for compilation" 2263 einfo "Using ${GENTOO_COMPILER} for compilation"
2048 fi 2264 fi
2049 2265
2050} 2266}
2066 fi 2282 fi
2067 2283
2068 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2284 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2069 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2285 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2070 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2286 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2287 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2288 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2071 2289
2072 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2290 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2073 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2291 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2074 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2292 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2075 2293
2088# Writes the package.env out to disk. 2306# Writes the package.env out to disk.
2089# 2307#
2090# ------------------------------------------------------------------------------ 2308# ------------------------------------------------------------------------------
2091# TODO change to do-write, to match everything else 2309# TODO change to do-write, to match everything else
2092java-pkg_do_write_() { 2310java-pkg_do_write_() {
2311 debug-print-function ${FUNCNAME} $*
2093 java-pkg_init_paths_ 2312 java-pkg_init_paths_
2094 # Create directory for package.env 2313 # Create directory for package.env
2095 dodir "${JAVA_PKG_SHAREPATH}" 2314 dodir "${JAVA_PKG_SHAREPATH}"
2096 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2315 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2316 "${JAVA_PKG_DEPEND_FILE}" || -f \
2317 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2097 # Create package.env 2318 # Create package.env
2098 ( 2319 (
2099 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2320 echo "DESCRIPTION=\"${DESCRIPTION}\""
2100 echo "GENERATION=\"2\"" 2321 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\""
2101 2323
2102 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2103 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2104 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2105 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2328 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2329 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2330 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2106 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2331 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2107 ) > "${JAVA_PKG_ENV}" 2332 ) > "${JAVA_PKG_ENV}"
2108 2333
2109 # register target/source 2334 # register target/source
2110 local target="$(java-pkg_get-target)" 2335 local target="$(java-pkg_get-target)"
2121 2346
2122 2347
2123 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2348 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2124 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2349 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2125 2350
2351 # extra env variables
2352 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2353 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2354 # nested echo to remove leading/trailing spaces
2355 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2356 >> "${JAVA_PKG_ENV}" || die
2357 fi
2358
2126 # Strip unnecessary leading and trailing colons 2359 # Strip unnecessary leading and trailing colons
2127 # TODO try to cleanup if possible 2360 # TODO try to cleanup if possible
2128 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2361 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2362 else
2363 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2364 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2365 debug-print "write package.env."
2129 fi 2366 fi
2130} 2367}
2131 2368
2132# ------------------------------------------------------------------------------ 2369# ------------------------------------------------------------------------------
2133# @internal-function java-pkg_record-jar_ 2370# @internal-function java-pkg_record-jar_
2134# 2371#
2135# Record a dependency to the package.env 2372# Record an (optional) dependency to the package.env
2136# 2373# @param --optional - record dependency as optional
2374# @param $1 - package to record
2375# @param $2 - (optional) jar of package to record
2137# ------------------------------------------------------------------------------ 2376# ------------------------------------------------------------------------------
2138JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2377JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2378JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2139 2379
2140java-pkg_record-jar_() { 2380java-pkg_record-jar_() {
2141 debug-print-function ${FUNCNAME} $* 2381 debug-print-function ${FUNCNAME} $*
2382
2383 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2384 if [[ "${1}" == "--optional" ]]; then
2385 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2386 shift
2387 fi
2142 2388
2143 local pkg=${1} jar=${2} append 2389 local pkg=${1} jar=${2} append
2144 if [[ -z "${jar}" ]]; then 2390 if [[ -z "${jar}" ]]; then
2145 append="${pkg}" 2391 append="${pkg}"
2146 else 2392 else
2147 append="$(basename ${jar})@${pkg}" 2393 append="$(basename ${jar})@${pkg}"
2148 fi 2394 fi
2149 2395
2150 echo ${append} >> ${JAVA_PKG_DEPEND} 2396 echo "${append}" >> "${depend_file}"
2151} 2397}
2152 2398
2153# ------------------------------------------------------------------------------ 2399# ------------------------------------------------------------------------------
2154# @internal-function java-pkg_append_ 2400# @internal-function java-pkg_append_
2155# 2401#
2199# 2445#
2200# @return 0 - function is declared 2446# @return 0 - function is declared
2201# @return 1 - function is undeclared 2447# @return 1 - function is undeclared
2202# ------------------------------------------------------------------------------ 2448# ------------------------------------------------------------------------------
2203java-pkg_func-exists() { 2449java-pkg_func-exists() {
2204 if [[ -n "$(declare -f ${1})" ]]; then 2450 declare -F ${1} > /dev/null
2205 return 0
2206 else
2207 return 1
2208 fi
2209} 2451}
2210 2452
2211# ------------------------------------------------------------------------------ 2453# ------------------------------------------------------------------------------
2212# @internal-function java-pkg_setup-vm 2454# @internal-function java-pkg_setup-vm
2213# 2455#
2214# Sets up the environment for a specific VM 2456# Sets up the environment for a specific VM
2215# 2457#
2216# ------------------------------------------------------------------------------ 2458# ------------------------------------------------------------------------------
2217java-pkg_setup-vm() { 2459java-pkg_setup-vm() {
2218 debug-print-function ${FUNCNAME} $* 2460 debug-print-function ${FUNCNAME} $*
2461
2462 export LANG="C" LC_ALL="C"
2219 2463
2220 local vendor="$(java-pkg_get-vm-vendor)" 2464 local vendor="$(java-pkg_get-vm-vendor)"
2221 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2465 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2222 addpredict "/dev/random" 2466 addpredict "/dev/random"
2223 elif [[ "${vendor}" == "ibm" ]]; then 2467 elif [[ "${vendor}" == "ibm" ]]; then
2224 addpredict "/proc/self/maps" 2468 addpredict "/proc/self/maps"
2225 addpredict "/proc/cpuinfo" 2469 addpredict "/proc/cpuinfo"
2226 export LANG="C" LC_ALL="C"
2227 elif [[ "${vendor}" == "jrockit" ]]; then 2470 elif [[ "${vendor}" == "jrockit" ]]; then
2228 addpredict "/proc/cpuinfo" 2471 addpredict "/proc/cpuinfo"
2229 fi 2472 fi
2230} 2473}
2231 2474
2335 2578
2336 #TODO If you know a better solution let us know. 2579 #TODO If you know a better solution let us know.
2337 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2580 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2338 2581
2339 local tann="${T}/announced-vm" 2582 local tann="${T}/announced-vm"
2583 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2584 # if people have for example modified eclasses some where
2340 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2585 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2341 # Add a check for setup/preinst phase... to avoid duplicate outputs
2342 # for when FEATURES=buildpkg
2343 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2344 then
2345 einfo "Using: $(java-config -f)" 2586 einfo "Using: $(java-config -f)"
2346 [[ ! -f "${tann}" ]] && touch "${tann}" 2587 [[ ! -f "${tann}" ]] && touch "${tann}"
2347 fi
2348 fi 2588 fi
2349 2589
2350 else 2590 else
2351 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2591 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2352 fi 2592 fi
2391# not. 2631# not.
2392# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2632# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2393# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2394java-pkg_verify-classes() { 2634java-pkg_verify-classes() {
2395 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2635 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2636
2637 local version_verify="/usr/bin/class-version-verify.py"
2638
2639 if [[ ! -x "${version_verify}" ]]; then
2640 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2641 fi
2642
2643 if [[ ! -x "${version_verify}" ]]; then
2644 ewarn "Unable to perform class version checks as"
2645 ewarn "class-version-verify.py is unavailable"
2646 ewarn "Please install dev-java/javatoolkit."
2647 return
2648 fi
2649
2396 local target=$(java-pkg_get-target) 2650 local target=$(java-pkg_get-target)
2397 local result 2651 local result
2398 local log="${T}/class-version-verify.log" 2652 local log="${T}/class-version-verify.log"
2399 if [[ -n "${1}" ]]; then 2653 if [[ -n "${1}" ]]; then
2400 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2654 ${version_verify} -v -t ${target} "${1}" > "${log}"
2401 result=$? 2655 result=$?
2402 else 2656 else
2403 ebegin "Verifying java class versions (target: ${target})" 2657 ebegin "Verifying java class versions (target: ${target})"
2404 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2658 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2405 result=$? 2659 result=$?
2406 eend ${result} 2660 eend ${result}
2407 fi 2661 fi
2408 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2662 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2409 if [[ ${result} != 0 ]]; then 2663 if [[ ${result} != 0 ]]; then
2419# Check that a package being used in jarfrom, getjars and getjar is contained 2673# Check that a package being used in jarfrom, getjars and getjar is contained
2420# within DEPEND or RDEPEND. 2674# within DEPEND or RDEPEND.
2421# @param $1 - empty - check both vars; "runtime" or "build" - check only 2675# @param $1 - empty - check both vars; "runtime" or "build" - check only
2422# RDEPEND, resp. DEPEND 2676# RDEPEND, resp. DEPEND
2423# @param $2 - Package name and slot. 2677# @param $2 - Package name and slot.
2678
2424java-pkg_ensure-dep() { 2679java-pkg_ensure-dep() {
2425 debug-print-function ${FUNCNAME} $* 2680 debug-print-function ${FUNCNAME} $*
2426 2681
2427 local limit_to="${1}" 2682 local limit_to="${1}"
2428 local target_pkg="${2}" 2683 local target_pkg="${2}"
2429 local dev_error="" 2684 local dev_error=""
2430 2685
2431 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2686 local stripped_pkg=$(echo "${target_pkg}" | sed \
2432 's/-[0-9]*\(\.[0-9]\)*$//') 2687 's/-[0-9]*\(\.[0-9]\)*$//')
2688
2689 debug-print "Matching against: ${stripped_pkg}"
2433 2690
2434 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2691 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2435 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2692 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2436 dev_error="${dev_error} declared in DEPEND." 2693 dev_error="${dev_error} declared in DEPEND."
2437 if is-java-strict; then 2694 if is-java-strict; then
2695 eerror "${dev_error}"
2438 die "${dev_error}" 2696 die "${dev_error}"
2439 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2697 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2440 eerror "${dev_error}" 2698 eerror "${dev_error}"
2441 elog "Because you have this package installed the package will" 2699 elog "Because you have this package installed the package will"
2442 elog "build without problems, but please report this to" 2700 elog "build without problems, but please report this to"
2443 elog "http://bugs.gentoo.org" 2701 elog "http://bugs.gentoo.org"
2444 fi 2702 fi
2445 fi 2703 fi
2446 2704
2705 if [[ ${limit_to} != build ]]; then
2447 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2706 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2707 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2448 dev_error="The ebuild is attempting to use ${target_pkg}," 2708 dev_error="The ebuild is attempting to use ${target_pkg},"
2449 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2709 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2710 dev_error="${dev_error} or PDEPEND."
2450 if is-java-strict; then 2711 if is-java-strict; then
2712 eerror "${dev_error}"
2451 die "${dev_error}" 2713 die "${dev_error}"
2452 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2714 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2453 eerror "${dev_error}" 2715 eerror "${dev_error}"
2454 elog "The package will build without problems, but may fail to run" 2716 elog "The package will build without problems, but may fail to run"
2455 elog "if you don't have ${target_pkg} installed, so please report" 2717 elog "if you don't have ${target_pkg} installed, so please report"
2456 elog "this to http://bugs.gentoo.org" 2718 elog "this to http://bugs.gentoo.org"
2719 fi
2720 fi
2457 fi 2721 fi
2458 fi 2722 fi
2459} 2723}
2460 2724
2461# ------------------------------------------------------------------------------ 2725# ------------------------------------------------------------------------------
2462# @section-end internal 2726# @section-end internal
2463# ------------------------------------------------------------------------------ 2727# ------------------------------------------------------------------------------
2464 2728
2465java-pkg_check-phase() { 2729java-pkg_check-phase() {
2466 local phase=${1} 2730 local phase=${1}
2467 local funcname=${2} 2731 local funcname=${FUNCNAME[1]}
2468 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2732 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2469 java-pkg_announce-qa-violation \
2470 "${funcname} used outside of src_${phase}" 2733 local msg="${funcname} used outside of src_${phase}"
2734 java-pkg_announce-qa-violation "${msg}"
2471 fi 2735 fi
2472} 2736}
2473 2737
2474java-pkg_check-versioned-jar() { 2738java-pkg_check-versioned-jar() {
2475 local jar=${1} 2739 local jar=${1}
2484 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2748 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2485 fi 2749 fi
2486} 2750}
2487 2751
2488java-pkg_announce-qa-violation() { 2752java-pkg_announce-qa-violation() {
2489 if is-java-strict; then 2753 local nodie
2754 if [[ ${1} == "--nodie" ]]; then
2755 nodie="true"
2756 shift
2757 fi
2490 echo "Java QA Notice: $@" >&2 2758 echo "Java QA Notice: $@" >&2
2491 increment-qa-violations 2759 increment-qa-violations
2492 fi 2760 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2493} 2761}
2494 2762
2495increment-qa-violations() { 2763increment-qa-violations() {
2496 let "JAVA_PKG_QA_VIOLATIONS+=1" 2764 let "JAVA_PKG_QA_VIOLATIONS+=1"
2497 export JAVA_PKG_QA_VIOLATIONS 2765 export JAVA_PKG_QA_VIOLATIONS
2500is-java-strict() { 2768is-java-strict() {
2501 [[ -n ${JAVA_PKG_STRICT} ]] 2769 [[ -n ${JAVA_PKG_STRICT} ]]
2502 return $? 2770 return $?
2503} 2771}
2504 2772
2773
2505# ------------------------------------------------------------------------------ 2774# ------------------------------------------------------------------------------
2506# @eclass-end 2775# @eclass-end
2507# ------------------------------------------------------------------------------ 2776# ------------------------------------------------------------------------------

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.127

  ViewVC Help
Powered by ViewVC 1.1.20