/[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.88 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.88 2007/05/28 19:28:22 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 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
57#WANT_ANT_TASKS 57#WANT_ANT_TASKS
58 58
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# 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
63# 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.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
66 67
67# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
68# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
69# 70#
70# 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
71# 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
72# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
73# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
74JAVA_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 )"
75 77
76# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 80# @variable-default yes
79# 81#
194# 196#
195# @example 197# @example
196# java-pkg_doexamples demo 198# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/* 199# java-pkg_doexamples demo/* examples/*
198# 200#
201# @param --subdir - If the examples need a certain directory structure
199# @param $* - list of files to install 202# @param $* - list of files to install
200# ------------------------------------------------------------------------------ 203# ------------------------------------------------------------------------------
201java-pkg_doexamples() { 204java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $* 205 debug-print-function ${FUNCNAME} $*
203 206
204 [[ ${#} -lt 1 ]] && die "At least one argument needed" 207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205 208
206 java-pkg_check-phase install 209 java-pkg_check-phase install
207 210
208 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
209 if [[ ${#} = 1 && -d ${1} ]]; then 218 if [[ ${#} = 1 && -d ${1} ]]; then
210 ( # dont want to pollute calling env 219 ( # dont want to pollute calling env
211 insinto "${dest}" 220 insinto "${dest}"
212 doins -r ${1}/* 221 doins -r ${1}/*
213 ) || die "Installing examples failed" 222 ) || die "Installing examples failed"
282 done 291 done
283 292
284 java-pkg_do_write_ 293 java-pkg_do_write_
285} 294}
286 295
287
288# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
289# @internal-function depend-java-query 297# @internal-function depend-java-query
290# 298#
291# 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.
292# 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
357 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
358 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
359 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
360 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
361 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
362 die "${jar} does not exist" 371 die "${jar} does not exist"
363 fi 372 fi
364 done 373 done
365 374
366 java-pkg_do_write_ 375 java-pkg_do_write_
421# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
422# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
423java-pkg_doso() { 432java-pkg_doso() {
424 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
425 434
426 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
427 java-pkg_check-phase install 435 java-pkg_check-phase install
428 436
429 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
430 438
431 java-pkg_init_paths_ 439 java-pkg_init_paths_
432 440
433 local lib 441 local lib
434 # for each lib 442 # for each lib
437 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
438 # install if it isn't a symlink 446 # install if it isn't a symlink
439 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
440 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
441 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
442 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
443 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
444 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
445 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
446 else 454 else
447 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
448 ln -s "$(readlink "${lib}")" \
449 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
450 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
451 fi 457 fi
452 # otherwise die 458 # otherwise die
453 else 459 else
454 die "${lib} does not exist" 460 die "${lib} does not exist"
455 fi 461 fi
471java-pkg_regso() { 477java-pkg_regso() {
472 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
473 479
474 java-pkg_check-phase install 480 java-pkg_check-phase install
475 481
476 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
477 483
478 java-pkg_init_paths_ 484 java-pkg_init_paths_
479 485
480 local lib target_dir 486 local lib target_dir
481 for lib in "$@" ; do 487 for lib in "$@" ; do
548# ------------------------------------------------------------------------------ 554# ------------------------------------------------------------------------------
549# @ebuild-function java-pkg_dojavadoc 555# @ebuild-function java-pkg_dojavadoc
550# 556#
551# 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.
552# 558#
559# @param $1: optional --symlink creates to symlink like this for html
560# documentation bundles.
553# @param $1: - The javadoc root directory. 561# @param $2: - The javadoc root directory.
554# 562#
555# @example: 563# @example:
556# java-pkg_dojavadoc docs/api 564# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api
557# 566#
558# ------------------------------------------------------------------------------ 567# ------------------------------------------------------------------------------
559java-pkg_dojavadoc() { 568java-pkg_dojavadoc() {
560 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
561 local dir="$1" 578 local dir="$1"
579 local dest=/usr/share/doc/${PF}/html
562 580
563 # QA checks 581 # QA checks
564 582
565 java-pkg_check-phase install 583 java-pkg_check-phase install
566 584
570 local msg="No index.html in javadoc directory" 588 local msg="No index.html in javadoc directory"
571 ewarn "${msg}" 589 ewarn "${msg}"
572 is-java-strict && die "${msg}" 590 is-java-strict && die "${msg}"
573 fi 591 fi
574 592
593 if [[ -e ${D}/${dest}/api ]]; then
594 eerror "${dest} already exists. Will not overwrite."
595 die "${dest}"
596 fi
597
575 # Renaming to match our directory layout 598 # Renaming to match our directory layout
576 599
577 local dir_to_install="${dir}" 600 local dir_to_install="${dir}"
578 if [[ "$(basename "${dir}")" != "api" ]]; then 601 if [[ "$(basename "${dir}")" != "api" ]]; then
579 dir_to_install="${T}/api" 602 dir_to_install="${T}/api"
581 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 604 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
582 fi 605 fi
583 606
584 # Actual installation 607 # Actual installation
585 608
586 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
587} 618}
588 619
589# ------------------------------------------------------------------------------ 620# ------------------------------------------------------------------------------
590# @ebuild-function java-pkg_dosrc 621# @ebuild-function java-pkg_dosrc
591# 622#
614 645
615 [[ ${#} -lt 1 ]] && die "At least one argument needed" 646 [[ ${#} -lt 1 ]] && die "At least one argument needed"
616 647
617 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 648 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
618 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 649 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
619 if is-java-strict; then 650 java-pkg_announce-qa-violation ${msg}
620 eerror "${msg}"
621 die "${msg}"
622 else
623 echo "${msg}"
624 echo "Please report this to http://bugs.gentoo.org."
625 fi
626 fi 651 fi
627 652
628 java-pkg_init_paths_ 653 java-pkg_init_paths_
629 654
630 local zip_name="${PN}-src.zip" 655 local zip_name="${PN}-src.zip"
830# @param $opt 855# @param $opt
831# --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.
832# (assumed automatically when called inside src_test) 857# (assumed automatically when called inside src_test)
833# --with-dependencies - get jars also from requested package's dependencies 858# --with-dependencies - get jars also from requested package's dependencies
834# 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.
835# --into $dir - symlink jar(s) into $dir (must exist) instead of . 862# --into $dir - symlink jar(s) into $dir (must exist) instead of .
836# @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
837# case other parameters are not used. 864# case other parameters are not used.
838# @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.
839# @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
844 debug-print-function ${FUNCNAME} $* 871 debug-print-function ${FUNCNAME} $*
845 872
846 local build_only="" 873 local build_only=""
847 local destdir="." 874 local destdir="."
848 local deep="" 875 local deep=""
876 local virtual=""
849 877
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 878 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 879
852 while [[ "${1}" == --* ]]; do 880 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 881 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 882 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 883 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies" 884 deep="--with-dependencies"
885 elif [[ "${1}" = "--virtual" ]]; then
886 virtual="true"
857 elif [[ "${1}" = "--into" ]]; then 887 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}" 888 destdir="${2}"
859 shift 889 shift
860 else 890 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}" 891 die "java-pkg_jar-from called with unknown parameter: ${1}"
864 done 894 done
865 895
866 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 896 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
867 897
868 [[ -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
869 903
870 # default destjar to the target jar 904 # default destjar to the target jar
871 [[ -z "${destjar}" ]] && destjar="${target_jar}" 905 [[ -z "${destjar}" ]] && destjar="${target_jar}"
872 906
873 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}."
885 done 919 done
886 # setting this disables further record-jar_ calls later 920 # setting this disables further record-jar_ calls later
887 build_only="build" 921 build_only="build"
888 else 922 else
889 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"
890 fi 932 fi
891 933
892 pushd ${destdir} > /dev/null \ 934 pushd ${destdir} > /dev/null \
893 || die "failed to change directory to ${destdir}" 935 || die "failed to change directory to ${destdir}"
894 936
977 done 1019 done
978 1020
979 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1021 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
980 1022
981 1023
982 local classpath pkgs="${1}" 1024 local pkgs="${1}"
1025
1026 if [[ "${EAPI}" == "1" ]]; then
1027 pkgs="${pkgs//:/-}"
1028 fi
1029
983 jars="$(java-config ${deep} --classpath=${pkgs})" 1030 jars="$(java-config ${deep} --classpath=${pkgs})"
984 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1031 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
985 debug-print "${pkgs}:${jars}" 1032 debug-print "${pkgs}:${jars}"
986 1033
987 for pkg in ${pkgs//,/ }; do 1034 for pkg in ${pkgs//,/ }; do
988 java-pkg_ensure-dep "${build_only}" "${pkg}" 1035 java-pkg_ensure-dep "${build_only}" "${pkg}"
989 done 1036 done
990
991 if [[ -z "${classpath}" ]]; then
992 classpath="${jars}"
993 else
994 classpath="${classpath}:${jars}"
995 fi
996 1037
997 # Only record jars that aren't build-only 1038 # Only record jars that aren't build-only
998 if [[ -z "${build_only}" ]]; then 1039 if [[ -z "${build_only}" ]]; then
999 for pkg in ${pkgs//,/ }; do 1040 for pkg in ${pkgs//,/ }; do
1000 java-pkg_record-jar_ "${pkg}" 1041 java-pkg_record-jar_ "${pkg}"
1001 done 1042 done
1002 fi 1043 fi
1003 1044
1004 echo "${classpath}" 1045 echo "${jars}"
1005} 1046}
1006 1047
1007# ------------------------------------------------------------------------------ 1048# ------------------------------------------------------------------------------
1008# @ebuild-function java-pkg_getjar 1049# @ebuild-function java-pkg_getjar
1009# 1050#
1018# @example-return 1059# @example-return
1019# /usr/share/xerces-2/lib/xml-apis.jar 1060# /usr/share/xerces-2/lib/xml-apis.jar
1020# 1061#
1021# @param $opt 1062# @param $opt
1022# --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.
1023# @param $1 - package to use 1066# @param $1 - package to use
1024# @param $2 - jar to get 1067# @param $2 - jar to get
1025# ------------------------------------------------------------------------------ 1068# ------------------------------------------------------------------------------
1026java-pkg_getjar() { 1069java-pkg_getjar() {
1027 debug-print-function ${FUNCNAME} $* 1070 debug-print-function ${FUNCNAME} $*
1028 1071
1029 local build_only="" 1072 local build_only=""
1073 local virtual=""
1030 1074
1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1032 1076
1033 while [[ "${1}" == --* ]]; do 1077 while [[ "${1}" == --* ]]; do
1034 if [[ "${1}" = "--build-only" ]]; then 1078 if [[ "${1}" = "--build-only" ]]; then
1035 build_only="build" 1079 build_only="build"
1080 elif [[ "${1}" == "--virtual" ]]; then
1081 virtual="true"
1036 else 1082 else
1037 die "java-pkg_jar-from called with unknown parameter: ${1}" 1083 die "java-pkg_getjar called with unknown parameter: ${1}"
1038 fi 1084 fi
1039 shift 1085 shift
1040 done 1086 done
1041 1087
1042 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1088 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1043 1089
1044 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
1045 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1046 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1097 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1047 1098
1048 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?"
1049 local classpath 1100 local classpath
1050 classpath=$(java-config --classpath=${pkg}) 1101 classpath=$(java-config --classpath=${pkg})
1051 [[ $? != 0 ]] && die ${error_msg} 1102 [[ $? != 0 ]] && die ${error_msg}
1052 1103
1053 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
1054 1112
1055 for jar in ${classpath//:/ }; do 1113 for jar in ${classpath//:/ }; do
1056 if [[ ! -f "${jar}" ]] ; then 1114 if [[ ! -f "${jar}" ]] ; then
1057 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1058 fi 1116 fi
1103 1161
1104 local pkgs="${1}" 1162 local pkgs="${1}"
1105 local jar="${2}" 1163 local jar="${2}"
1106 1164
1107 [[ -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
1108 1170
1109 if [[ -z "${jar}" ]]; then 1171 if [[ -z "${jar}" ]]; then
1110 for pkg in ${pkgs//,/ }; do 1172 for pkg in ${pkgs//,/ }; do
1111 java-pkg_ensure-dep runtime "${pkg}" 1173 java-pkg_ensure-dep runtime "${pkg}"
1112 java-pkg_record-jar_ "${pkg}" 1174 java-pkg_record-jar_ "${pkg}"
1154 1216
1155 local pkgs="${1}" 1217 local pkgs="${1}"
1156 local jar="${2}" 1218 local jar="${2}"
1157 1219
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1220 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1221
1222 if [[ "${EAPI}" == "1" ]]; then
1223 pkgs="${pkgs//:/-}"
1224 fi
1159 1225
1160 if [[ -z "${jar}" ]]; then 1226 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do 1227 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}" 1228 java-pkg_record-jar_ --optional "${pkg}"
1163 done 1229 done
1664 dodir /usr/share/ant/${TASKS_DIR} 1730 dodir /usr/share/ant/${TASKS_DIR}
1665 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1731 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1666} 1732}
1667 1733
1668# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1669# @internal-function java-pkg_ant-tasks-from-deps
1670#
1671# Function to determine ANT_TASKS from DEPEND variable for backwards
1672# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1673# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1674# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1675# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1676# be a problem, the worst it can do is activace all tasks when not needed.
1677# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1678# insufficient dependencies, otherwise all available tasks are used for
1679# backwards compatilbility.
1680#
1681# @return "all" or "none"
1682# ------------------------------------------------------------------------------
1683java-pkg_ant-tasks-from-deps() {
1684 local found_ant found_ant_tasks
1685
1686 for dep in ${DEPEND}
1687 do
1688 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1689 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1690 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1691 done
1692
1693 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1694 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1695 echo "all"
1696 else
1697 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1698 # so we deactivate all tasks that may be installed
1699 echo "none"
1700 fi
1701}
1702
1703# ------------------------------------------------------------------------------
1704# @internal-function java-pkg_ant-tasks-depend 1735# @internal-function java-pkg_ant-tasks-depend
1705# 1736#
1706# Translates the WANT_ANT_TASKS variable into valid dependencies. 1737# Translates the WANT_ANT_TASKS variable into valid dependencies.
1707# ------------------------------------------------------------------------------ 1738# ------------------------------------------------------------------------------
1708java-pkg_ant-tasks-depend() { 1739java-pkg_ant-tasks-depend() {
1710 1741
1711 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1712 local DEP="" 1743 local DEP=""
1713 for i in ${WANT_ANT_TASKS} 1744 for i in ${WANT_ANT_TASKS}
1714 do 1745 do
1715 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
1716 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1751 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1717 return 1 1752 return 1
1718 fi 1753 fi
1719 DEP="${DEP}dev-java/${i} "
1720 done 1754 done
1721 echo ${DEP} 1755 echo ${DEP}
1722 return 0 1756 return 0
1723 else 1757 else
1724 return 0 1758 return 0
1741# ------------------------------------------------------------------------------ 1775# ------------------------------------------------------------------------------
1742ejunit() { 1776ejunit() {
1743 debug-print-function ${FUNCNAME} $* 1777 debug-print-function ${FUNCNAME} $*
1744 1778
1745 local pkgs 1779 local pkgs
1780 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1781 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1782 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done 1783 done
1784 fi
1749 1785
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1786 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1787 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}" 1788 cp="${2}:${cp}"
1753 shift 2 1789 shift 2
1763# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1764# @section-end helper 1800# @section-end helper
1765# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1766 1802
1767# ------------------------------------------------------------------------------ 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}
1851
1852# ------------------------------------------------------------------------------
1768# @section-begin build 1853# @section-begin build
1769# @section-summary Build functions 1854# @section-summary Build functions
1770# 1855#
1771# These are some functions for building a package. In particular, it consists of 1856# These are some functions for building a package. In particular, it consists of
1772# wrappers for javac and ant. 1857# wrappers for javac and ant.
1779# 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,
1780# variables: 1865# variables:
1781# 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
1782# gentoo.classpath property. Be sure to call 1867# gentoo.classpath property. Be sure to call
1783# 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
1784# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1785# ------------------------------------------------------------------------------ 1874# ------------------------------------------------------------------------------
1786eant() { 1875eant() {
1787 debug-print-function ${FUNCNAME} $* 1876 debug-print-function ${FUNCNAME} $*
1877
1878 if [[ ${EBUILD_PHASE} = compile ]]; then
1879 java-ant-2_src_configure
1880 java-utils-2_src_prepare
1881 fi
1788 1882
1789 if ! hasq java-ant-2 ${INHERITED}; then 1883 if ! hasq java-ant-2 ${INHERITED}; then
1790 local msg="You should inherit java-ant-2 when using eant" 1884 local msg="You should inherit java-ant-2 when using eant"
1791 java-pkg_announce-qa-violation "${msg}" 1885 java-pkg_announce-qa-violation "${msg}"
1792 fi 1886 fi
1793 1887
1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1888 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1795 1889
1796 java-pkg_init-compiler_ 1890 java-pkg_init-compiler_
1797 local compiler="${GENTOO_COMPILER}" 1891 local compiler="${GENTOO_COMPILER}"
1798 1892
1799 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1893 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1800
1801 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})"
1802 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1895 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1803 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1896 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1804 fi 1897 fi
1805 1898
1811 # java-config -p 1904 # java-config -p
1812 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})"
1813 if [[ -n ${build_compiler_deps} ]]; then 1906 if [[ -n ${build_compiler_deps} ]]; then
1814 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1907 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1815 fi 1908 fi
1816 fi
1817
1818 if is-java-strict; then
1819 einfo "Disabling system classpath for ant"
1820 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1821 fi 1909 fi
1822 1910
1823 for arg in "${@}"; do 1911 for arg in "${@}"; do
1824 if [[ ${arg} = -lib ]]; then 1912 if [[ ${arg} = -lib ]]; then
1825 if is-java-strict; then 1913 if is-java-strict; then
1834 echo "more info." 1922 echo "more info."
1835 fi 1923 fi
1836 fi 1924 fi
1837 done 1925 done
1838 1926
1839 if has_version ">=dev-java/ant-core-1.7.0"; then 1927 # parse WANT_ANT_TASKS for atoms
1840 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1928 local want_ant_tasks
1841 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1929 for i in ${WANT_ANT_TASKS}; do
1842 1930 if [[ ${i} = */*:* ]]; then
1843 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1931 i=${i#*/}
1844 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1932 i=${i%:0}
1845 1933 want_ant_tasks+="${i/:/-} "
1846 if is-java-strict; then
1847 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1848 if [[ -z "${ANT_TASKS}" ]]; then
1849 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1850 fi
1851 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
1852 # 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
1853 ANT_TASKS="${ANT_TASKS:-all}" 1945 ANT_TASKS="${ANT_TASKS:-none}"
1854 fi
1855 1946
1856 # 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
1857 if [[ "${ANT_TASKS}" == "all" ]]; then 1948 if [[ "${ANT_TASKS}" == "all" ]]; then
1858 einfo "Using all available ANT_TASKS" 1949 einfo "Using all available ANT_TASKS"
1859 elif [[ "${ANT_TASKS}" == "none" ]]; then 1950 elif [[ "${ANT_TASKS}" == "none" ]]; then
1860 einfo "Disabling all optional ANT_TASKS" 1951 einfo "Disabling all optional ANT_TASKS"
1861 else 1952 else
1862 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1953 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1863 fi 1954 fi
1864 1955
1865 export ANT_TASKS 1956 export ANT_TASKS
1866 fi
1867 1957
1868 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1958 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1869 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1959 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1870 1960
1871 local gcp="${EANT_GENTOO_CLASSPATH}" 1961 local gcp="${EANT_GENTOO_CLASSPATH}"
1872 local getjarsarg="" 1962 local getjarsarg=""
1873 1963
1874 if [[ ${EBUILD_PHASE} = "test" ]]; then 1964 if [[ ${EBUILD_PHASE} = "test" ]]; then
1875 antflags="${antflags} -DJunit.present=true" 1965 antflags="${antflags} -DJunit.present=true"
1876 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1877 getjarsarg="--with-dependencies" 1967 getjarsarg="--with-dependencies"
1878 fi 1968 fi
1879 1969
1880 local cp 1970 local cp
1881 1971
1882 for atom in ${gcp}; do 1972 for atom in ${gcp}; do
1883 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1884 done 1974 done
1885 1975
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1977
1886 if [[ ${cp} ]]; then 1978 if [[ ${cp} ]]; then
1887 # 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}"
1888 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1889 fi 1984 fi
1890 1985
1891 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1892 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1893 ant ${antflags} "${@}" || die "eant failed" 1988 ant ${antflags} "${@}" || die "eant failed"
1993# 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
1994# call it during each of the phases of the merge process. 2089# call it during each of the phases of the merge process.
1995# 2090#
1996# ----------------------------------------------------------------------------- 2091# -----------------------------------------------------------------------------
1997java-pkg_init() { 2092java-pkg_init() {
2093 debug-print-function ${FUNCNAME} $*
1998 unset JAVAC 2094 unset JAVAC
1999 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 }
2000 2104
2001 # People do all kinds of weird things. 2105 # People do all kinds of weird things.
2002 # http://forums.gentoo.org/viewtopic-p-3943166.html 2106 # http://forums.gentoo.org/viewtopic-p-3943166.html
2003 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2107 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2004 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2108 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2010 ewarn "make.conf for example) to silence this warning or" 2114 ewarn "make.conf for example) to silence this warning or"
2011 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2115 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2012 fi 2116 fi
2013 2117
2014 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
2015 unset _JAVA_OPTIONS 2121 unset _JAVA_OPTIONS
2016 # phase hooks make this run many times without this 2122 # phase hooks make this run many times without this
2017 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2123 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2018 fi 2124 fi
2019 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
2020 java-pkg_init_paths_ 2130 java-pkg_init_paths_
2021 java-pkg_switch-vm 2131 java-pkg_switch-vm
2022 PATH=${JAVA_HOME}/bin:${PATH} 2132 PATH=${JAVA_HOME}/bin:${PATH}
2023 2133
2024 # TODO we will probably want to set JAVAC and JAVACFLAGS 2134 # TODO we will probably want to set JAVAC and JAVACFLAGS
2025 2135
2026 # Do some QA checks 2136 # Do some QA checks
2027 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
2028 2141
2029 # When users have crazy classpaths some packages can fail to compile. 2142 # When users have crazy classpaths some packages can fail to compile.
2030 # and everything should work with empty CLASSPATH. 2143 # and everything should work with empty CLASSPATH.
2031 # This also helps prevent unexpected dependencies on random things 2144 # This also helps prevent unexpected dependencies on random things
2032 # from the CLASSPATH. 2145 # from the CLASSPATH.
2033 unset CLASSPATH 2146 export CLASSPATH=
2034 2147
2035 # Unset external ANT_ stuff 2148 # Unset external ANT_ stuff
2036 unset ANT_TASKS 2149 export ANT_TASKS=
2037 unset ANT_OPTS 2150 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME=
2038} 2152}
2039 2153
2040# ------------------------------------------------------------------------------ 2154# ------------------------------------------------------------------------------
2041# @function-internal java-pkg-init-compiler_ 2155# @function-internal java-pkg-init-compiler_
2042# 2156#
2133 done 2247 done
2134 2248
2135 # If it hasn't been defined already, default to javac 2249 # If it hasn't been defined already, default to javac
2136 if [[ -z ${GENTOO_COMPILER} ]]; then 2250 if [[ -z ${GENTOO_COMPILER} ]]; then
2137 if [[ -n ${compilers} ]]; then 2251 if [[ -n ${compilers} ]]; then
2138 einfo "No suitable compiler found: defaulting javac for compilation" 2252 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2139 else 2253 else
2140 # probably don't need to notify users about the default. 2254 # probably don't need to notify users about the default.
2141 :;#einfo "Defaulting to javac for compilation" 2255 :;#einfo "Defaulting to javac for compilation"
2142 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
2143 export GENTOO_COMPILER=javac 2260 export GENTOO_COMPILER=javac
2261 fi
2144 else 2262 else
2145 einfo "Using ${GENTOO_COMPILER} for compilation" 2263 einfo "Using ${GENTOO_COMPILER} for compilation"
2146 fi 2264 fi
2147 2265
2148} 2266}
2164 fi 2282 fi
2165 2283
2166 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2284 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2167 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2285 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2168 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}"
2169 2289
2170 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2290 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2171 [[ -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}"
2172 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2292 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2173 2293
2197 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2317 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2198 # Create package.env 2318 # Create package.env
2199 ( 2319 (
2200 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2320 echo "DESCRIPTION=\"${DESCRIPTION}\""
2201 echo "GENERATION=\"2\"" 2321 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\""
2202 2323
2203 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2204 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2205 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2206 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2324# 2445#
2325# @return 0 - function is declared 2446# @return 0 - function is declared
2326# @return 1 - function is undeclared 2447# @return 1 - function is undeclared
2327# ------------------------------------------------------------------------------ 2448# ------------------------------------------------------------------------------
2328java-pkg_func-exists() { 2449java-pkg_func-exists() {
2329 if [[ -n "$(declare -f ${1})" ]]; then 2450 declare -F ${1} > /dev/null
2330 return 0
2331 else
2332 return 1
2333 fi
2334} 2451}
2335 2452
2336# ------------------------------------------------------------------------------ 2453# ------------------------------------------------------------------------------
2337# @internal-function java-pkg_setup-vm 2454# @internal-function java-pkg_setup-vm
2338# 2455#
2461 2578
2462 #TODO If you know a better solution let us know. 2579 #TODO If you know a better solution let us know.
2463 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2580 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2464 2581
2465 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
2466 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2585 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2467 # Add a check for setup/preinst phase... to avoid duplicate outputs
2468 # for when FEATURES=buildpkg
2469 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2470 then
2471 einfo "Using: $(java-config -f)" 2586 einfo "Using: $(java-config -f)"
2472 [[ ! -f "${tann}" ]] && touch "${tann}" 2587 [[ ! -f "${tann}" ]] && touch "${tann}"
2473 fi
2474 fi 2588 fi
2475 2589
2476 else 2590 else
2477 [[ -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!!!"
2478 fi 2592 fi
2517# not. 2631# not.
2518# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2632# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2519# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2520java-pkg_verify-classes() { 2634java-pkg_verify-classes() {
2521 #$(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
2522 local target=$(java-pkg_get-target) 2650 local target=$(java-pkg_get-target)
2523 local result 2651 local result
2524 local log="${T}/class-version-verify.log" 2652 local log="${T}/class-version-verify.log"
2525 if [[ -n "${1}" ]]; then 2653 if [[ -n "${1}" ]]; then
2526 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2654 ${version_verify} -v -t ${target} "${1}" > "${log}"
2527 result=$? 2655 result=$?
2528 else 2656 else
2529 ebegin "Verifying java class versions (target: ${target})" 2657 ebegin "Verifying java class versions (target: ${target})"
2530 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2658 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2531 result=$? 2659 result=$?
2532 eend ${result} 2660 eend ${result}
2533 fi 2661 fi
2534 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2662 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2535 if [[ ${result} != 0 ]]; then 2663 if [[ ${result} != 0 ]]; then
2640is-java-strict() { 2768is-java-strict() {
2641 [[ -n ${JAVA_PKG_STRICT} ]] 2769 [[ -n ${JAVA_PKG_STRICT} ]]
2642 return $? 2770 return $?
2643} 2771}
2644 2772
2773
2645# ------------------------------------------------------------------------------ 2774# ------------------------------------------------------------------------------
2646# @eclass-end 2775# @eclass-end
2647# ------------------------------------------------------------------------------ 2776# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20