/[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.51 Revision 1.80
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.51 2007/01/28 20:04:59 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.80 2007/04/26 23:32:12 caster Exp $
10 10
11 11
12# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
13# @eclass-begin 13# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
55# 55#
56# @seealso JAVA_PKG_FORCE_ANT_TASKS 56# @seealso JAVA_PKG_FORCE_ANT_TASKS
57# ----------------------------------------------------------------------------- 57# -----------------------------------------------------------------------------
58#WANT_ANT_TASKS 58#WANT_ANT_TASKS
59 59
60# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 61# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 62#
62# The version of portage we need to function properly. At this moment it's 63# The version of portage we need to function properly. At this moment it's
63# portage with phase hooks support. 64# portage with phase hooks support.
64# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
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. We also need a recent version
72# portage, that includes phase hooks. 73# portage, that includes phase hooks.
73# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}"
75 76
76# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
78# @variable-default yes 79# @variable-default yes
79# 80#
183# 184#
184# These are used to install Java-related things, such as jars, Javadocs, JNI 185# These are used to install Java-related things, such as jars, Javadocs, JNI
185# libraries, etc. 186# libraries, etc.
186# ----------------------------------------------------------------------------- 187# -----------------------------------------------------------------------------
187 188
189# -----------------------------------------------------------------------------
190# @ebuild-function java-pkg_doexamples
191#
192# Installs given arguments to /usr/share/doc/${PF}/examples
193# If you give it only one parameter and it is a directory it will install
194# everything in that directory to the examples directory.
195#
196# @example
197# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/*
199#
200# @param $* - list of files to install
201# ------------------------------------------------------------------------------
202java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $*
204
205 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206
207 java-pkg_check-phase install
208
209 local dest=/usr/share/doc/${PF}/examples
210 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env
212 insinto "${dest}"
213 doins -r ${1}/*
214 ) || die "Installing examples failed"
215 else
216 ( # dont want to pollute calling env
217 insinto "${dest}"
218 doins -r "$@"
219 ) || die "Installing examples failed"
220 fi
221}
188 222
189# ----------------------------------------------------------------------------- 223# -----------------------------------------------------------------------------
190# @ebuild-function java-pkg_dojar 224# @ebuild-function java-pkg_dojar
191# 225#
192# Installs any number of jars. 226# Installs any number of jars.
227 ewarn "Overwriting ${dest}" 261 ewarn "Overwriting ${dest}"
228 fi 262 fi
229 263
230 # install it into JARDEST if it's a non-symlink 264 # install it into JARDEST if it's a non-symlink
231 if [[ ! -L "${jar}" ]] ; then 265 if [[ ! -L "${jar}" ]] ; then
266 #but first check class version when in strict mode.
267 is-java-strict && java-pkg_verify-classes "${jar}"
268
232 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 269 INSDESTTREE="${JAVA_PKG_JARDEST}" \
233 doins "${jar}" || die "failed to install ${jar}" 270 doins "${jar}" || die "failed to install ${jar}"
234 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 271 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
235 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 272 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
236 # make a symlink to the original jar if it's symlink 273 # make a symlink to the original jar if it's symlink
256# Using env variables keeps this eclass working with java-config versions that 293# Using env variables keeps this eclass working with java-config versions that
257# do not handle use flags. 294# do not handle use flags.
258# ------------------------------------------------------------------------------ 295# ------------------------------------------------------------------------------
259 296
260depend-java-query() { 297depend-java-query() {
298 # Used to have a which call here but it caused endless loops for some people
299 # that had some weird bashrc voodoo for which.
261 USE="${USE}" $(which depend-java-query) "${@}" 300 USE="${USE}" /usr/bin/depend-java-query "${@}"
262} 301}
263 302
264# ------------------------------------------------------------------------------ 303# ------------------------------------------------------------------------------
265# @ebuild-function java-pkg_regjar 304# @ebuild-function java-pkg_regjar
266# 305#
303 for jar in "${@}"; do 342 for jar in "${@}"; do
304 # TODO use java-pkg_check-versioned-jar 343 # TODO use java-pkg_check-versioned-jar
305 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then 344 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
306 [[ -d "${jar}" || -d "${D}${jar}" ]] \ 345 [[ -d "${jar}" || -d "${D}${jar}" ]] \
307 && die "Called ${FUNCNAME} on a directory $*" 346 && die "Called ${FUNCNAME} on a directory $*"
347
348 #check that class version correct when in strict mode
349 is-java-strict && java-pkg_verify-classes "${jar}"
350
308 # nelchael: we should strip ${D} in this case too, here's why: 351 # nelchael: we should strip ${D} in this case too, here's why:
309 # imagine such call: 352 # imagine such call:
310 # java-pkg_regjar ${D}/opt/java/*.jar 353 # java-pkg_regjar ${D}/opt/java/*.jar
311 # such call will fall into this case (-e ${jar}) and will 354 # such call will fall into this case (-e ${jar}) and will
312 # record paths with ${D} in package.env 355 # record paths with ${D} in package.env
313 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 356 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
314 else 357 else
358 if [[ ${jar} = *\** ]]; then
359 eerror "The argument ${jar} to ${FUNCNAME}"
360 eerror "has * in it. If you want it to glob in"
361 eerror '${D} add ${D} to the argument.'
362 fi
315 die "${jar} does not exist" 363 die "${jar} does not exist"
316 fi 364 fi
317 done 365 done
318 366
319 java-pkg_do_write_ 367 java-pkg_do_write_
396 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
397 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
398 # otherwise make a symlink to the symlink's origin 446 # otherwise make a symlink to the symlink's origin
399 else 447 else
400 # TODO use dosym 448 # TODO use dosym
449 ln -s "$(readlink "${lib}")" \
401 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 450 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
402 debug-print "${lib} is a symlink, linking accordanly" 451 debug-print "${lib} is a symlink, linking accordanly"
403 fi 452 fi
404 # otherwise die 453 # otherwise die
405 else 454 else
406 die "${lib} does not exist" 455 die "${lib} does not exist"
507# @example: 556# @example:
508# java-pkg_dojavadoc docs/api 557# java-pkg_dojavadoc docs/api
509# 558#
510# ------------------------------------------------------------------------------ 559# ------------------------------------------------------------------------------
511java-pkg_dojavadoc() { 560java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $*
512 local dir="$1" 562 local dir="$1"
563
564 # QA checks
513 565
514 java-pkg_check-phase install 566 java-pkg_check-phase install
515 567
516 [[ -z "${dir}" ]] && die "Must specify a directory!" 568 [[ -z "${dir}" ]] && die "Must specify a directory!"
517 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 569 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
570 if [[ ! -e "${dir}/index.html" ]]; then
571 local msg="No index.html in javadoc directory"
572 ewarn "${msg}"
573 is-java-strict && die "${msg}"
574 fi
575
576 # Renaming to match our directory layout
518 577
519 local dir_to_install="${dir}" 578 local dir_to_install="${dir}"
520 if [[ "$(basename "${dir}")" != "api" ]]; then 579 if [[ "$(basename "${dir}")" != "api" ]]; then
521 dir_to_install="${T}/api" 580 dir_to_install="${T}/api"
522 # TODO use doins 581 # TODO use doins
523 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 582 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
524 fi 583 fi
584
585 # Actual installation
525 586
526 java-pkg_dohtml -r ${dir_to_install} 587 java-pkg_dohtml -r ${dir_to_install}
527} 588}
528 589
529# ------------------------------------------------------------------------------ 590# ------------------------------------------------------------------------------
547# FIXME apparently this fails if you give it an empty directories 608# FIXME apparently this fails if you give it an empty directories
548java-pkg_dosrc() { 609java-pkg_dosrc() {
549 debug-print-function ${FUNCNAME} $* 610 debug-print-function ${FUNCNAME} $*
550 611
551 [ ${#} -lt 1 ] && die "At least one argument needed" 612 [ ${#} -lt 1 ] && die "At least one argument needed"
552 if ! hasq source ${IUSE}; then
553 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
554 fi
555 613
556 java-pkg_check-phase install 614 java-pkg_check-phase install
557 615
558 [[ ${#} -lt 1 ]] && die "At least one argument needed" 616 [[ ${#} -lt 1 ]] && die "At least one argument needed"
617
618 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
619 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
620 if is-java-strict; then
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
559 628
560 java-pkg_init_paths_ 629 java-pkg_init_paths_
561 630
562 local zip_name="${PN}-src.zip" 631 local zip_name="${PN}-src.zip"
563 local zip_path="${T}/${zip_name}" 632 local zip_path="${T}/${zip_name}"
757# Example: get a specific jar from xerces slot 2, and name it diffrently 826# Example: get a specific jar from xerces slot 2, and name it diffrently
758# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 827# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
759# Example: get junit.jar which is needed only for building 828# Example: get junit.jar which is needed only for building
760# java-pkg_jar-from --build-only junit junit.jar 829# java-pkg_jar-from --build-only junit junit.jar
761# 830#
762# @param $opt 831# @param $opt
763# --build-only - makes the jar(s) not added into package.env DEPEND line. 832# --build-only - makes the jar(s) not added into package.env DEPEND line.
764# (assumed automatically when called inside src_test) 833# (assumed automatically when called inside src_test)
765# --with-dependencies - get jars also from requested package's dependencies 834# --with-dependencies - get jars also from requested package's dependencies
766# transitively. 835# transitively.
767# --into $dir - symlink jar(s) into $dir (must exist) instead of . 836# --into $dir - symlink jar(s) into $dir (must exist) instead of .
768# @param $1 - Package to get jars from. 837# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used.
769# @param $2 - jar from package. If not specified, all jars will be used. 839# @param $2 - jar from package. If not specified, all jars will be used.
770# @param $3 - When a single jar is specified, destination filename of the 840# @param $3 - When a single jar is specified, destination filename of the
771# symlink. Defaults to the name of the jar. 841# symlink. Defaults to the name of the jar.
772# ------------------------------------------------------------------------------ 842# ------------------------------------------------------------------------------
773# TODO could probably be cleaned up a little 843# TODO could probably be cleaned up a little
775 debug-print-function ${FUNCNAME} $* 845 debug-print-function ${FUNCNAME} $*
776 846
777 local build_only="" 847 local build_only=""
778 local destdir="." 848 local destdir="."
779 local deep="" 849 local deep=""
780 850
781 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
782 852
783 while [[ "${1}" == --* ]]; do 853 while [[ "${1}" == --* ]]; do
784 if [[ "${1}" = "--build-only" ]]; then 854 if [[ "${1}" = "--build-only" ]]; then
785 build_only="true" 855 build_only="build"
786 elif [[ "${1}" = "--with-dependencies" ]]; then 856 elif [[ "${1}" = "--with-dependencies" ]]; then
787 deep="--with-dependencies" 857 deep="--with-dependencies"
788 elif [[ "${1}" = "--into" ]]; then 858 elif [[ "${1}" = "--into" ]]; then
789 destdir="${2}" 859 destdir="${2}"
790 shift 860 shift
804 local error_msg="There was a problem getting the classpath for ${target_pkg}." 874 local error_msg="There was a problem getting the classpath for ${target_pkg}."
805 local classpath 875 local classpath
806 classpath="$(java-config ${deep} --classpath=${target_pkg})" 876 classpath="$(java-config ${deep} --classpath=${target_pkg})"
807 [[ $? != 0 ]] && die ${error_msg} 877 [[ $? != 0 ]] && die ${error_msg}
808 878
879 # When we have commas this functions is called to bring jars from multiple
880 # packages. This affects recording of dependencencies performed later
881 # which expects one package only, so we do it here.
882 if [[ ${target_pkg} = *,* ]]; then
883 for pkg in ${target_pkg//,/ }; do
884 java-pkg_ensure-dep "${build_only}" "${pkg}"
885 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
886 done
887 # setting this disables further record-jar_ calls later
888 build_only="build"
889 else
890 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
891 fi
892
809 pushd ${destdir} > /dev/null \ 893 pushd ${destdir} > /dev/null \
810 || die "failed to change directory to ${destdir}" 894 || die "failed to change directory to ${destdir}"
895
811 local jar 896 local jar
812 for jar in ${classpath//:/ }; do 897 for jar in ${classpath//:/ }; do
813 local jar_name=$(basename "${jar}") 898 local jar_name=$(basename "${jar}")
814 if [[ ! -f "${jar}" ]] ; then 899 if [[ ! -f "${jar}" ]] ; then
815 debug-print "${jar} from ${target_pkg} does not exist" 900 debug-print "${jar} from ${target_pkg} does not exist"
825 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 910 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
826 [[ -f "${destjar}" ]] && rm "${destjar}" 911 [[ -f "${destjar}" ]] && rm "${destjar}"
827 ln -snf "${jar}" "${destjar}" \ 912 ln -snf "${jar}" "${destjar}" \
828 || die "Failed to make symlink from ${jar} to ${destjar}" 913 || die "Failed to make symlink from ${jar} to ${destjar}"
829 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 914 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
915 popd > /dev/null
830 return 0 916 return 0
831 fi 917 fi
832 done 918 done
833 popd > /dev/null 919 popd > /dev/null
834 # if no target was specified, we're ok 920 # if no target was specified, we're ok
862# Example: Get the classpath for xerces-2 and xalan, 948# Example: Get the classpath for xerces-2 and xalan,
863# java-pkg_getjars xerces-2,xalan 949# java-pkg_getjars xerces-2,xalan
864# Example Return: 950# Example Return:
865# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 951# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
866# 952#
867# @param $opt 953# @param $opt
868# --build-only - makes the jar(s) not added into package.env DEPEND line. 954# --build-only - makes the jar(s) not added into package.env DEPEND line.
869# (assumed automatically when called inside src_test) 955# (assumed automatically when called inside src_test)
870# --with-dependencies - get jars also from requested package's dependencies 956# --with-dependencies - get jars also from requested package's dependencies
871# transitively. 957# transitively.
872# @param $1 - list of packages to get jars from 958# @param $1 - list of packages to get jars from
875java-pkg_getjars() { 961java-pkg_getjars() {
876 debug-print-function ${FUNCNAME} $* 962 debug-print-function ${FUNCNAME} $*
877 963
878 local build_only="" 964 local build_only=""
879 local deep="" 965 local deep=""
880 966
881 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 967 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
882 968
883 while [[ "${1}" == --* ]]; do 969 while [[ "${1}" == --* ]]; do
884 if [[ "${1}" = "--build-only" ]]; then 970 if [[ "${1}" = "--build-only" ]]; then
885 build_only="true" 971 build_only="build"
886 elif [[ "${1}" = "--with-dependencies" ]]; then 972 elif [[ "${1}" = "--with-dependencies" ]]; then
887 deep="--with-dependencies" 973 deep="--with-dependencies"
888 else 974 else
889 die "java-pkg_jar-from called with unknown parameter: ${1}" 975 die "java-pkg_jar-from called with unknown parameter: ${1}"
890 fi 976 fi
891 shift 977 shift
892 done 978 done
893 979
894 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 980 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
895 981
982
896 local classpath pkgs="${1}" 983 local classpath pkgs="${1}"
897 jars="$(java-config ${deep} --classpath=${pkgs})" 984 jars="$(java-config ${deep} --classpath=${pkgs})"
898 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 985 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
899 debug-print "${pkgs}:${jars}" 986 debug-print "${pkgs}:${jars}"
987
988 for pkg in ${pkgs//,/ }; do
989 java-pkg_ensure-dep "${build_only}" "${pkg}"
990 done
900 991
901 if [[ -z "${classpath}" ]]; then 992 if [[ -z "${classpath}" ]]; then
902 classpath="${jars}" 993 classpath="${jars}"
903 else 994 else
904 classpath="${classpath}:${jars}" 995 classpath="${classpath}:${jars}"
905 fi 996 fi
906 997
907 # Only record jars that aren't build-only 998 # Only record jars that aren't build-only
908 if [[ -z "${build_only}" ]]; then 999 if [[ -z "${build_only}" ]]; then
909 oldifs="${IFS}"
910 IFS=","
911 for pkg in ${pkgs}; do 1000 for pkg in ${pkgs//:/ }; do
912 java-pkg_record-jar_ "${pkg}" 1001 java-pkg_record-jar_ "${pkg}"
913 done 1002 done
914 IFS="${oldifs}"
915 fi 1003 fi
916 1004
917 echo "${classpath}" 1005 echo "${classpath}"
918} 1006}
919 1007
938# ------------------------------------------------------------------------------ 1026# ------------------------------------------------------------------------------
939java-pkg_getjar() { 1027java-pkg_getjar() {
940 debug-print-function ${FUNCNAME} $* 1028 debug-print-function ${FUNCNAME} $*
941 1029
942 local build_only="" 1030 local build_only=""
943 1031
944 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1032 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
945 1033
946 while [[ "${1}" == --* ]]; do 1034 while [[ "${1}" == --* ]]; do
947 if [[ "${1}" = "--build-only" ]]; then 1035 if [[ "${1}" = "--build-only" ]]; then
948 build_only="true" 1036 build_only="build"
949 else 1037 else
950 die "java-pkg_jar-from called with unknown parameter: ${1}" 1038 die "java-pkg_jar-from called with unknown parameter: ${1}"
951 fi 1039 fi
952 shift 1040 shift
953 done 1041 done
960 1048
961 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1049 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
962 local classpath 1050 local classpath
963 classpath=$(java-config --classpath=${pkg}) 1051 classpath=$(java-config --classpath=${pkg})
964 [[ $? != 0 ]] && die ${error_msg} 1052 [[ $? != 0 ]] && die ${error_msg}
1053
1054 java-pkg_ensure-dep "${build_only}" "${pkg}"
965 1055
966 for jar in ${classpath//:/ }; do 1056 for jar in ${classpath//:/ }; do
967 if [[ ! -f "${jar}" ]] ; then 1057 if [[ ! -f "${jar}" ]] ; then
968 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1058 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
969 fi 1059 fi
976 fi 1066 fi
977 done 1067 done
978 1068
979 die "Could not find ${target_jar} in ${pkg}" 1069 die "Could not find ${target_jar} in ${pkg}"
980 return 1 1070 return 1
1071}
1072
1073# ------------------------------------------------------------------------------
1074# @ebuild-function java-pkg_register-dependency
1075#
1076# Registers runtime dependency on a package, list of packages, or a single jar
1077# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get
1080# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083#
1084# @param $1 - comma-separated list of packages, or a single package
1085# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on
1087#
1088# Example: Record the dependency on whole xerces-2 and xalan,
1089# java-pkg_register-dependency xerces-2,xalan
1090# Example: Record the dependency on ant.jar from ant-core
1091# java-pkg_register-dependency ant-core ant.jar
1092#
1093# Note: Passing both list of packages as the first parameter AND specifying the
1094# jar as the second is not allowed and will cause the function to die. We assume
1095# that there's more chance one passes such combination as a mistake, than that
1096# there are more packages providing identically named jar without class
1097# collisions.
1098# ------------------------------------------------------------------------------
1099java-pkg_register-dependency() {
1100 debug-print-function ${FUNCNAME} $*
1101
1102 java-pkg_check-phase install
1103
1104 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1105
1106 local pkgs="${1}"
1107 local jar="${2}"
1108
1109 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1110
1111 if [[ -z "${jar}" ]]; then
1112 for pkg in ${pkgs//,/ }; do
1113 java-pkg_ensure-dep runtime "${pkg}"
1114 java-pkg_record-jar_ "${pkg}"
1115 done
1116 else
1117 [[ ${pkgs} == *,* ]] && \
1118 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}"
1121 fi
1122
1123 java-pkg_do_write_
981} 1124}
982 1125
983# This function reads stdin, and based on that input, figures out how to 1126# This function reads stdin, and based on that input, figures out how to
984# populate jars from the filesystem. 1127# populate jars from the filesystem.
985# Need to figure out a good way of making use of this, ie be able to use a 1128# Need to figure out a good way of making use of this, ie be able to use a
1540# java-pkg_announce-qa-violation \ 1683# java-pkg_announce-qa-violation \
1541# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1684# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1542# fi 1685# fi
1543 1686
1544 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1687 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1545 msg="You should inherit java-ant-2 when using eant" 1688 local msg="You should inherit java-ant-2 when using eant"
1546 java-pkg_announce-qa-violation ${msg} 1689 java-pkg_announce-qa-violation ${msg}
1547 die ${msg} 1690 die ${msg}
1548 fi 1691 fi
1549 1692
1550 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1693 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1694
1551 java-pkg_init-compiler_ 1695 java-pkg_init-compiler_
1552 local compiler="${GENTOO_COMPILER}" 1696 local compiler="${GENTOO_COMPILER}"
1553 1697
1554 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1698 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1555 1699
1573 if is-java-strict; then 1717 if is-java-strict; then
1574 einfo "Disabling system classpath for ant" 1718 einfo "Disabling system classpath for ant"
1575 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1719 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1576 fi 1720 fi
1577 1721
1722 for arg in "${@}"; do
1723 if [[ ${arg} = -lib ]]; then
1724 if is-java-strict; then
1725 eerror "You should not use the -lib argument to eant because it will fail"
1726 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1727 eerror "or ant properties to make dependencies available."
1728 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1729 eerror "split ant (>=dev-java/ant-core-1.7)."
1730 die "eant -lib is deprecated/forbidden"
1731 else
1732 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1733 echo "more info."
1734 fi
1735 fi
1736 done
1737
1578 if has_version ">=dev-java/ant-core-1.7.0"; then 1738 if has_version ">=dev-java/ant-core-1.7.0"; then
1579 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1739 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1580 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1740 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1581 1741
1582 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1742 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1598 elif [[ "${ANT_TASKS}" == "none" ]]; then 1758 elif [[ "${ANT_TASKS}" == "none" ]]; then
1599 einfo "Disabling all optional ANT_TASKS" 1759 einfo "Disabling all optional ANT_TASKS"
1600 else 1760 else
1601 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1761 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1602 fi 1762 fi
1603 1763
1604 export ANT_TASKS 1764 export ANT_TASKS
1605 fi 1765 fi
1606 1766
1607 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1767 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1608 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1768 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1609 1769
1610 local gcp="${EANT_GENTOO_CLASSPATH}" 1770 local gcp="${EANT_GENTOO_CLASSPATH}"
1771 local getjarsarg=""
1611 1772
1773 if [[ ${EBUILD_PHASE} = "test" ]]; then
1774 antflags="${antflags} -DJunit.present=true"
1775 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1776 getjarsarg="--with-dependencies"
1777 fi
1778
1779 local cp
1780
1781 for atom in ${gcp}; do
1782 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1783 done
1784
1612 if [[ "${gcp}" ]]; then 1785 if [[ ${cp} ]]; then
1613 local cp="$(java-pkg_getjars ${gcp})"
1614 # It seems ant does not like single quotes around ${cp} 1786 # It seems ant does not like single quotes around ${cp}
1615 antflags="${antflags} -Dgentoo.classpath=\"${cp}\"" 1787 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1616 fi 1788 fi
1617 1789
1618 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1790 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1619 debug-print "Calling ant: ${antflags} ${@}" 1791 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1620 ant ${antflags} "${@}" || die "eant failed" 1792 ant ${antflags} "${@}" || die "eant failed"
1621
1622} 1793}
1623 1794
1624# ------------------------------------------------------------------------------ 1795# ------------------------------------------------------------------------------
1625# @ebuild-function ejavac 1796# @ebuild-function ejavac
1626# 1797#
1723# 1894#
1724# ----------------------------------------------------------------------------- 1895# -----------------------------------------------------------------------------
1725java-pkg_init() { 1896java-pkg_init() {
1726 unset JAVAC 1897 unset JAVAC
1727 unset JAVA_HOME 1898 unset JAVA_HOME
1899
1900 # People do all kinds of weird things.
1901 # http://forums.gentoo.org/viewtopic-p-3943166.html
1902 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
1903 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
1904 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
1905 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
1906 ewarn "sun-jdk vms and and as such break configure scripts that"
1907 ewarn "use it (for example app-office/openoffice) so we filter it out."
1908 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
1909 ewarn "make.conf for example) to silence this warning or"
1910 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1911 fi
1912
1913 if [[ -z ${accept} ]]; then
1914 unset _JAVA_OPTIONS
1915 # phase hooks make this run many times without this
1916 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1917 fi
1918
1728 java-pkg_init_paths_ 1919 java-pkg_init_paths_
1729 java-pkg_switch-vm 1920 java-pkg_switch-vm
1730 PATH=${JAVA_HOME}/bin:${PATH} 1921 PATH=${JAVA_HOME}/bin:${PATH}
1731 1922
1732 # TODO we will probably want to set JAVAC and JAVACFLAGS 1923 # TODO we will probably want to set JAVAC and JAVACFLAGS
1737 # When users have crazy classpaths some packages can fail to compile. 1928 # When users have crazy classpaths some packages can fail to compile.
1738 # and everything should work with empty CLASSPATH. 1929 # and everything should work with empty CLASSPATH.
1739 # This also helps prevent unexpected dependencies on random things 1930 # This also helps prevent unexpected dependencies on random things
1740 # from the CLASSPATH. 1931 # from the CLASSPATH.
1741 unset CLASSPATH 1932 unset CLASSPATH
1742 1933
1743 # Unset external ANT_ stuff 1934 # Unset external ANT_ stuff
1744 unset ANT_TASKS 1935 unset ANT_TASKS
1745 unset ANT_OPTS 1936 unset ANT_OPTS
1746} 1937}
1747 1938
2188 einfo "Classes" 2379 einfo "Classes"
2189 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2380 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2190 fi 2381 fi
2191} 2382}
2192 2383
2193# TODO document 2384# ------------------------------------------------------------------------------
2385# @internal-function java-pkg_verify-classes
2386#
2194# Verify that the classes were compiled for the right source / target 2387# Verify that the classes were compiled for the right source / target. Dies if
2388# not.
2389# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2390# ------------------------------------------------------------------------------
2195java-pkg_verify-classes() { 2391java-pkg_verify-classes() {
2196 ebegin "Verifying java class versions"
2197 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2392 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2198 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2393 local target=$(java-pkg_get-target)
2394 local result
2395 local log="${T}/class-version-verify.log"
2396 if [[ -n "${1}" ]]; then
2397 class-version-verify.py -v -t ${target} "${1}" > "${log}"
2199 result=$? 2398 result=$?
2200 eend ${result}
2201 if [[ ${result} == 0 ]]; then
2202 einfo "All good"
2203 else 2399 else
2204 ewarn "Possible problem" 2400 ebegin "Verifying java class versions (target: ${target})"
2205 die "Bad class files found" 2401 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2402 result=$?
2403 eend ${result}
2404 fi
2405 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2406 if [[ ${result} != 0 ]]; then
2407 eerror "Incorrect bytecode version found"
2408 [[ -n "${1}" ]] && eerror "in file: ${1}"
2409 eerror "See ${log} for more details."
2410 die "Incorrect bytecode found"
2411 fi
2412}
2413
2414# ----------------------------------------------------------------------------
2415# @internal-function java-pkg_ensure-dep
2416# Check that a package being used in jarfrom, getjars and getjar is contained
2417# within DEPEND or RDEPEND.
2418# @param $1 - empty - check both vars; "runtime" or "build" - check only
2419# RDEPEND, resp. DEPEND
2420# @param $2 - Package name and slot.
2421java-pkg_ensure-dep() {
2422 debug-print-function ${FUNCNAME} $*
2423
2424 local limit_to="${1}"
2425 local target_pkg="${2}"
2426 local dev_error=""
2427
2428 local stripped_pkg=$(echo "${target_pkg}" | sed \
2429 's/-[0-9]*\(\.[0-9]\)*$//')
2430
2431 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2432 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2433 dev_error="${dev_error} declared in DEPEND."
2434 if is-java-strict; then
2435 die "${dev_error}"
2436 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2437 eerror "${dev_error}"
2438 elog "Because you have this package installed the package will"
2439 elog "build without problems, but please report this to"
2440 elog "http://bugs.gentoo.org"
2441 fi
2442 fi
2443
2444 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2445 dev_error="The ebuild is attempting to use ${target_pkg},"
2446 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND."
2447 if is-java-strict; then
2448 die "${dev_error}"
2449 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2450 eerror "${dev_error}"
2451 elog "The package will build without problems, but may fail to run"
2452 elog "if you don't have ${target_pkg} installed, so please report"
2453 elog "this to http://bugs.gentoo.org"
2454 fi
2206 fi 2455 fi
2207} 2456}
2208 2457
2209# ------------------------------------------------------------------------------ 2458# ------------------------------------------------------------------------------
2210# @section-end internal 2459# @section-end internal

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

  ViewVC Help
Powered by ViewVC 1.1.20