/[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.22 Revision 1.51
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 10
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
27 28
29IUSE="elibc_FreeBSD"
30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
32# Summary of variables which control the behavior of building Java packges. 35# Summary of variables which control the behavior of building Java packges.
33# ----------------------------------------------------------------------------- 36# -----------------------------------------------------------------------------
34 37
35# Make sure we use java-config-2 38# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 39export WANT_JAVA_CONFIG="2"
37 40
38# TODO document 41# -----------------------------------------------------------------------------
42# @variable-external WANT_ANT_TASKS
43# @variable-default ""
44#
45# An $IFS separated list of ant tasks.
46# Ebuild can specify this variable before inheriting java-ant-2 eclass to
47# determine ANT_TASKS it needs. They will be automatically translated to
48# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
49# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
50# Ebuilds that need to depend conditionally on certain tasks and specify them
51# differently for different eant calls can't use this simplified approach.
52# You also cannot specify version or anything else than ant-*.
53#
54# @example WANT_ANT_TASKS="ant-junit ant-trax"
55#
56# @seealso JAVA_PKG_FORCE_ANT_TASKS
57# -----------------------------------------------------------------------------
58#WANT_ANT_TASKS
59
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. At this moment it's
63# portage with phase hooks support.
64# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40 66
41# ----------------------------------------------------------------------------- 67# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 68# @variable-internal JAVA_PKG_E_DEPEND
43# 69#
125# JAVA_PKG_COMPILERS_CONF. 151# JAVA_PKG_COMPILERS_CONF.
126# 152#
127# @note This should only be used internally or for testing. 153# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 154# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 155# JAVA_PKG_FORCE_COMPILER="jikes javac"
156# -----------------------------------------------------------------------------
157
158# -----------------------------------------------------------------------------
159# @variable-external JAVA_PKG_FORCE_ANT_TASKS
160#
161# An $IFS separated list of ant tasks. Can be set in environment before calling
162# emerge/ebuild to override variables set in ebuild, mainly for testing before
163# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
164# eant() call, not the dependencies specified in WANT_ANT_TASKS.
165#
166# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
167# ebuild foo.ebuild compile
168#
169# @seealso WANT_ANT_TASKS
130# ----------------------------------------------------------------------------- 170# -----------------------------------------------------------------------------
131 171
132# TODO document me 172# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 173JAVA_PKG_QA_VIOLATIONS=0
134 174
171 # Create JARDEST if it doesn't exist 211 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 212 dodir ${JAVA_PKG_JARDEST}
173 213
174 local jar 214 local jar
175 # for each jar 215 # for each jar
176 for jar in "$@"; do 216 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 217 local jar_basename=$(basename "${jar}")
178 218
179 java-pkg_check-versioned-jar ${jar_basename} 219 java-pkg_check-versioned-jar ${jar_basename}
180 220
181 # check if it exists 221 # check if it exists
182 if [[ -e "${jar}" ]] ; then 222 if [[ -e "${jar}" ]] ; then
223 # Don't overwrite if jar has already been installed with the same
224 # name
225 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
226 if [[ -e "${dest}" ]]; then
227 ewarn "Overwriting ${dest}"
228 fi
229
183 # install it into JARDEST if it's a non-symlink 230 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 231 if [[ ! -L "${jar}" ]] ; then
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 232 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 233 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 234 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
200 247
201 java-pkg_do_write_ 248 java-pkg_do_write_
202} 249}
203 250
204 251
252# ------------------------------------------------------------------------------
253# @internal-function depend-java-query
254#
255# Wrapper for the depend-java-query binary to enable passing USE in env.
256# Using env variables keeps this eclass working with java-config versions that
257# do not handle use flags.
258# ------------------------------------------------------------------------------
259
260depend-java-query() {
261 USE="${USE}" $(which depend-java-query) "${@}"
262}
205 263
206# ------------------------------------------------------------------------------ 264# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 265# @ebuild-function java-pkg_regjar
208# 266#
209# Records an already installed jar in the package.env 267# Records an already installed jar in the package.env
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 298 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 299
242 java-pkg_init_paths_ 300 java-pkg_init_paths_
243 301
244 local jar jar_dir jar_file 302 local jar jar_dir jar_file
245 for jar in "$@"; do 303 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 304 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 305 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
306 [[ -d "${jar}" || -d "${D}${jar}" ]] \
307 && die "Called ${FUNCNAME} on a directory $*"
248 # nelchael: we should strip ${D} in this case too, here's why: 308 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 309 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 310 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 311 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 312 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 313 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 314 else
257 die "${jar} does not exist" 315 die "${jar} does not exist"
258 fi 316 fi
259 done 317 done
260 318
261 java-pkg_do_write_ 319 java-pkg_do_write_
262} 320}
263
264 321
265# ------------------------------------------------------------------------------ 322# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 323# @ebuild-function java-pkg_newjar
267# 324#
268# Installs a jar with a new name 325# Installs a jar with a new name
279 local original_jar="${1}" 336 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 337 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 338 local new_jar_dest="${T}/${new_jar}"
282 339
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 340 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 341 [[ ! -f ${original_jar} ]] \
342 && die "${original_jar} does not exist or is not a file!"
285 343
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 344 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 345 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 346 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 347 java-pkg_dojar "${new_jar_dest}"
290} 348}
291 349
292
293# ------------------------------------------------------------------------------ 350# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 351# @ebuild-function java-pkg_addcp
295# 352#
296# Add something to the package's classpath. For jars, you should use dojar, 353# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 354# newjar, or regjar. This is typically used to add directories to the classpath.
301# ------------------------------------------------------------------------------ 358# ------------------------------------------------------------------------------
302java-pkg_addcp() { 359java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 360 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 361 java-pkg_do_write_
305} 362}
306
307 363
308# ------------------------------------------------------------------------------ 364# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 365# @ebuild-function java-pkg_doso
310# 366#
311# Installs any number of JNI libraries 367# Installs any number of JNI libraries
428# ------------------------------------------------------------------------------ 484# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 485java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 486 debug-print-function ${FUNCNAME} $*
431 487
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 488 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 489
490 # from /usr/lib/portage/bin/dohtml -h
491 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 492 dohtml -f package-list "$@"
493
435 # this probably shouldn't be here but it provides 494 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 495 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 496 # old ebuilds.
438 java-pkg_recordjavadoc 497 java-pkg_recordjavadoc
439} 498}
440 499
441# TODO document 500# ------------------------------------------------------------------------------
501# @ebuild-function java-pkg_dojavadoc
502#
503# Installs javadoc documentation. This should be controlled by the doc use flag.
504#
505# @param $1: - The javadoc root directory.
506#
507# @example:
508# java-pkg_dojavadoc docs/api
509#
510# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 511java-pkg_dojavadoc() {
443 local dir="$1" 512 local dir="$1"
444 513
445 java-pkg_check-phase install 514 java-pkg_check-phase install
446 515
491 java-pkg_init_paths_ 560 java-pkg_init_paths_
492 561
493 local zip_name="${PN}-src.zip" 562 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 563 local zip_path="${T}/${zip_name}"
495 local dir 564 local dir
496 for dir in ${@}; do 565 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 566 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 567 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 568 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 569 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 570 local result=$?
518# @ebuild-function java-pkg_dolauncher 587# @ebuild-function java-pkg_dolauncher
519# 588#
520# Make a wrapper script to lauch/start this package 589# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 590# If necessary, the wrapper will switch to the appropriate VM.
522# 591#
592# Can be called without parameters if the package installs only one jar
593# that has the Main-class attribute set. The wrapper will be named ${PN}.
594#
523# @param $1 - filename of launcher to create 595# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 596# @param $2 - options, as follows:
525# --main the.main.class.too.start 597# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 598# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 599# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 600# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 601# --pwd Directory the launcher changes to before executing java
530# -into 602# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 603# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 604# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 605java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 606 debug-print-function ${FUNCNAME} $*
535 607
536 java-pkg_check-phase install 608 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 609 java-pkg_init_paths_
541 610
611 if [[ ${#} = 0 ]]; then
612 local name="${PN}"
613 else
542 local name="${1}" 614 local name="${1}"
615 shift
616 fi
617
543 # TODO rename to launcher 618 # TODO rename to launcher
544 local target="${T}/${name}" 619 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 620 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 621 local target_dir pre
547 shift
548 622
549 # Process the other the rest of the arguments 623 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 624 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 625 local var="${1}" value="${2}"
552 if [[ "${var:0:2}" == "--" ]]; then 626 if [[ "${var:0:2}" == "--" ]]; then
627 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 628 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
629 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 630 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 631 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 632 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 633 pre="${value}"
558 fi 634 fi
559 shift 2 635 shift 2
560 done 636 done
561 637
638 # Test if no --jar and --main arguments were given and
639 # in that case check if the package only installs one jar
640 # and use that jar.
641 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
642 local cp="${JAVA_PKG_CLASSPATH}"
643 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
644 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
645 else
646 local msg="Not enough information to create a launcher given."
647 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
648 die "${msg}"
649 fi
650 fi
651
562 # Write the actual script 652 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 653 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 654 if [[ -n "${pre}" ]]; then
655 if [[ -f "${pre}" ]]; then
656 cat "${pre}" >> "${target}"
657 else
658 die "-pre specified file '${pre}' does not exist"
659 fi
660 fi
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 661 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
566 cat "${var_tmp}" >> "${target}" 662 cat "${var_tmp}" >> "${target}"
567 rm -f "${var_tmp}" 663 rm -f "${var_tmp}"
568 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 664 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
569 665
661# Example: get a specific jar from xerces slot 2, and name it diffrently 757# Example: get a specific jar from xerces slot 2, and name it diffrently
662# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 758# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
663# Example: get junit.jar which is needed only for building 759# Example: get junit.jar which is needed only for building
664# java-pkg_jar-from --build-only junit junit.jar 760# java-pkg_jar-from --build-only junit junit.jar
665# 761#
666# @param $1 - (optional) "--build-only" makes the jar(s) not added into 762# @param $opt
667# package.env DEPEND line. 763# --build-only - makes the jar(s) not added into package.env DEPEND line.
764# (assumed automatically when called inside src_test)
765# --with-dependencies - get jars also from requested package's dependencies
766# transitively.
767# --into $dir - symlink jar(s) into $dir (must exist) instead of .
668# @param $1 - Package to get jars from. 768# @param $1 - Package to get jars from.
669# @param $2 - jar from package. If not specified, all jars will be used. 769# @param $2 - jar from package. If not specified, all jars will be used.
670# @param $3 - When a single jar is specified, destination filename of the 770# @param $3 - When a single jar is specified, destination filename of the
671# symlink. Defaults to the name of the jar. 771# symlink. Defaults to the name of the jar.
672# ------------------------------------------------------------------------------ 772# ------------------------------------------------------------------------------
673# TODO could probably be cleaned up a little 773# TODO could probably be cleaned up a little
674java-pkg_jar-from() { 774java-pkg_jar-from() {
675 debug-print-function ${FUNCNAME} $* 775 debug-print-function ${FUNCNAME} $*
676 776
677 local build_only="" 777 local build_only=""
778 local destdir="."
779 local deep=""
780
781 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
678 782
783 while [[ "${1}" == --* ]]; do
679 if [[ "${1}" = "--build-only" ]]; then 784 if [[ "${1}" = "--build-only" ]]; then
680 build_only="true" 785 build_only="true"
786 elif [[ "${1}" = "--with-dependencies" ]]; then
787 deep="--with-dependencies"
788 elif [[ "${1}" = "--into" ]]; then
789 destdir="${2}"
790 shift
791 else
792 die "java-pkg_jar-from called with unknown parameter: ${1}"
793 fi
681 shift 794 shift
682 fi 795 done
683 796
684 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 797 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
685 798
686 [[ -z ${target_pkg} ]] && die "Must specify a package" 799 [[ -z ${target_pkg} ]] && die "Must specify a package"
687 800
688 # default destjar to the target jar 801 # default destjar to the target jar
689 [[ -z "${destjar}" ]] && destjar="${target_jar}" 802 [[ -z "${destjar}" ]] && destjar="${target_jar}"
690 803
691 local error_msg="There was a problem getting the classpath for ${target_pkg}." 804 local error_msg="There was a problem getting the classpath for ${target_pkg}."
692 local classpath 805 local classpath
693 classpath="$(java-config --classpath=${target_pkg})" 806 classpath="$(java-config ${deep} --classpath=${target_pkg})"
694 [[ $? != 0 ]] && die ${error_msg} 807 [[ $? != 0 ]] && die ${error_msg}
695 808
809 pushd ${destdir} > /dev/null \
810 || die "failed to change directory to ${destdir}"
696 local jar 811 local jar
697 for jar in ${classpath//:/ }; do 812 for jar in ${classpath//:/ }; do
698 local jar_name=$(basename "${jar}") 813 local jar_name=$(basename "${jar}")
699 if [[ ! -f "${jar}" ]] ; then 814 if [[ ! -f "${jar}" ]] ; then
700 debug-print "${jar} from ${target_pkg} does not exist" 815 debug-print "${jar} from ${target_pkg} does not exist"
713 || die "Failed to make symlink from ${jar} to ${destjar}" 828 || die "Failed to make symlink from ${jar} to ${destjar}"
714 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 829 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
715 return 0 830 return 0
716 fi 831 fi
717 done 832 done
833 popd > /dev/null
718 # if no target was specified, we're ok 834 # if no target was specified, we're ok
719 if [[ -z "${target_jar}" ]] ; then 835 if [[ -z "${target_jar}" ]] ; then
720 return 0 836 return 0
721 # otherwise, die bitterly 837 # otherwise, die bitterly
722 else 838 else
741# The providing packages are recorded as dependencies into package.env DEPEND 857# The providing packages are recorded as dependencies into package.env DEPEND
742# line, unless "--build-only" is passed as the very first argument, for jars 858# line, unless "--build-only" is passed as the very first argument, for jars
743# that have to be present only at build time and are not needed on runtime 859# that have to be present only at build time and are not needed on runtime
744# (junit testing etc). 860# (junit testing etc).
745# 861#
746# Example: Get the classpath for xerces-2, 862# Example: Get the classpath for xerces-2 and xalan,
747# java-pkg_getjars xerces-2 xalan 863# java-pkg_getjars xerces-2,xalan
748# Example Return: 864# Example Return:
749# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 865# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
750# 866#
751# @param $1 - (optional) "--build-only" makes the jar(s) not added into 867# @param $opt
752# package.env DEPEND line. 868# --build-only - makes the jar(s) not added into package.env DEPEND line.
869# (assumed automatically when called inside src_test)
870# --with-dependencies - get jars also from requested package's dependencies
871# transitively.
753# @param $@ - list of packages to get jars from 872# @param $1 - list of packages to get jars from
873# (passed to java-config --classpath)
754# ------------------------------------------------------------------------------ 874# ------------------------------------------------------------------------------
755java-pkg_getjars() { 875java-pkg_getjars() {
756 debug-print-function ${FUNCNAME} $* 876 debug-print-function ${FUNCNAME} $*
757 877
758 local build_only="" 878 local build_only=""
879 local deep=""
880
881 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
759 882
883 while [[ "${1}" == --* ]]; do
760 if [[ "${1}" = "--build-only" ]]; then 884 if [[ "${1}" = "--build-only" ]]; then
761 build_only="true" 885 build_only="true"
886 elif [[ "${1}" = "--with-dependencies" ]]; then
887 deep="--with-dependencies"
888 else
889 die "java-pkg_jar-from called with unknown parameter: ${1}"
890 fi
762 shift 891 shift
763 fi
764
765 [[ ${#} -lt 1 ]] && die "At least one argument needed"
766
767 # NOTE could probably just pass $@ to java-config --classpath. and return it
768 local classpath pkg
769 for pkg in ${@//,/ }; do
770 #for pkg in $(echo "$@" | tr ',' ' '); do
771 jars="$(java-config --classpath=${pkg})"
772 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
773 debug-print "${pkg}:${jars}"
774
775 if [[ -z "${classpath}" ]]; then
776 classpath="${jars}"
777 else
778 classpath="${classpath}:${jars}"
779 fi
780 # Only record jars that aren't build-only
781 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
782 done 892 done
893
894 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
895
896 local classpath pkgs="${1}"
897 jars="$(java-config ${deep} --classpath=${pkgs})"
898 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
899 debug-print "${pkgs}:${jars}"
900
901 if [[ -z "${classpath}" ]]; then
902 classpath="${jars}"
903 else
904 classpath="${classpath}:${jars}"
905 fi
906
907 # Only record jars that aren't build-only
908 if [[ -z "${build_only}" ]]; then
909 oldifs="${IFS}"
910 IFS=","
911 for pkg in ${pkgs}; do
912 java-pkg_record-jar_ "${pkg}"
913 done
914 IFS="${oldifs}"
915 fi
916
783 echo "${classpath}" 917 echo "${classpath}"
784} 918}
785 919
786# ------------------------------------------------------------------------------ 920# ------------------------------------------------------------------------------
787# @ebuild-function java-pkg_getjar 921# @ebuild-function java-pkg_getjar
795# @example 929# @example
796# java-pkg_getjar xerces-2 xml-apis.jar 930# java-pkg_getjar xerces-2 xml-apis.jar
797# @example-return 931# @example-return
798# /usr/share/xerces-2/lib/xml-apis.jar 932# /usr/share/xerces-2/lib/xml-apis.jar
799# 933#
800# @param $1 - (optional) "--build-only" makes the jar not added into 934# @param $opt
801# package.env DEPEND line. 935# --build-only - makes the jar not added into package.env DEPEND line.
802# @param $1 - package to use 936# @param $1 - package to use
803# @param $2 - jar to get 937# @param $2 - jar to get
804# ------------------------------------------------------------------------------ 938# ------------------------------------------------------------------------------
805java-pkg_getjar() { 939java-pkg_getjar() {
806 debug-print-function ${FUNCNAME} $* 940 debug-print-function ${FUNCNAME} $*
807 941
808 local build_only="" 942 local build_only=""
943
944 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
809 945
946 while [[ "${1}" == --* ]]; do
810 if [[ "${1}" = "--build-only" ]]; then 947 if [[ "${1}" = "--build-only" ]]; then
811 build_only="true" 948 build_only="true"
949 else
950 die "java-pkg_jar-from called with unknown parameter: ${1}"
951 fi
812 shift 952 shift
813 fi 953 done
954
955 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
814 956
815 local pkg="${1}" target_jar="${2}" jar 957 local pkg="${1}" target_jar="${2}" jar
816 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 958 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
817 [[ -z ${target_jar} ]] && die "Must specify jar to get" 959 [[ -z ${target_jar} ]] && die "Must specify jar to get"
818 960
960# 1102#
961# export DEPEND="${DEPEND} ${depstr}" 1103# export DEPEND="${DEPEND} ${depstr}"
962# export RDEPEND="${RDEPEND} ${depstr}" 1104# export RDEPEND="${RDEPEND} ${depstr}"
963#} 1105#}
964 1106
1107# ------------------------------------------------------------------------------
1108# @ebuild-function java-pkg_find-normal-jars
1109#
1110# Find the files with suffix .jar file in the given directory or $WORKDIR
1111#
1112# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1113# ------------------------------------------------------------------------------
1114java-pkg_find-normal-jars() {
1115 local dir=$1
1116 [[ "${dir}" ]] || dir="${WORKDIR}"
1117 local found
1118 for jar in $(find "${dir}" -name "*.jar" -type f); do
1119 echo "${jar}"
1120 found="true"
1121 done
1122 [[ "${found}" ]]
1123 return $?
1124}
1125
1126# ------------------------------------------------------------------------------
1127# @ebuild-function java-pkg_ensure-no-bundled-jars
1128#
1129# Try to locate bundled jar files in ${WORKDIR} and die if found.
965# This should be used after S has been populated with symlinks to jars 1130# This function should be called after WORKDIR has been populated with symlink
966# TODO document 1131# to system jar files or bundled jars removed.
1132# ------------------------------------------------------------------------------
967java-pkg_ensure-no-bundled-jars() { 1133java-pkg_ensure-no-bundled-jars() {
968 debug-print-function ${FUNCNAME} $* 1134 debug-print-function ${FUNCNAME} $*
969 pushd ${WORKDIR} >/dev/null 2>/dev/null
970 1135
971 local bundled_jars=$(find . -name "*.jar" -type f) 1136 local bundled_jars=$(java-pkg_find-normal-jars)
972 if [[ -n ${bundled_jars} ]]; then 1137 if [[ -n ${bundled_jars} ]]; then
973 echo "Bundled jars found:" 1138 echo "Bundled jars found:"
974 local jar 1139 local jar
975 for jar in ${bundled_jars}; do 1140 for jar in ${bundled_jars}; do
976 echo $(pwd)${jar/./} 1141 echo $(pwd)${jar/./}
977 done 1142 done
978 die "Bundled jars found!" 1143 die "Bundled jars found!"
979
980 fi 1144 fi
981 popd >/dev/null 2>/dev/null
982} 1145}
983 1146
984# ------------------------------------------------------------------------------ 1147# ------------------------------------------------------------------------------
985# @internal-function java-pkg_ensure-vm-version-sufficient 1148# @internal-function java-pkg_ensure-vm-version-sufficient
986# 1149#
1135# @ebuild-function java-pkg_get-target 1298# @ebuild-function java-pkg_get-target
1136# 1299#
1137# Determines what target version should be used, for passing to -target. 1300# Determines what target version should be used, for passing to -target.
1138# If you don't care about lower versions, you can set _WANT_TARGET to the 1301# If you don't care about lower versions, you can set _WANT_TARGET to the
1139# version of your JDK. 1302# version of your JDK.
1140# Remember doing this will mostly like cause things to break.
1141# Doesn't allow it to be lower then the one in depend.
1142# Doesn't allow it to be higher then the active vm.
1143# 1303#
1144# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1304# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1145# ------------------------------------------------------------------------------ 1305# ------------------------------------------------------------------------------
1146java-pkg_get-target() { 1306java-pkg_get-target() {
1147 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1148 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1149 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1150 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1151 echo ${JAVA_PKG_WANT_TARGET}
1152 else
1153 echo ${min}
1154 fi
1155 else
1156 echo ${min}
1157 fi
1158
1159 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1307 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1160} 1308}
1161 1309
1162java-pkg_get-javac() { 1310java-pkg_get-javac() {
1163 debug-print-function ${FUNCNAME} $* 1311 debug-print-function ${FUNCNAME} $*
1164 1312
1165 java-pkg_init-compiler_ 1313
1166 local compiler="${GENTOO_COMPILER}" 1314 local compiler="${GENTOO_COMPILER}"
1167 1315
1168 local compiler_executable 1316 local compiler_executable
1169 if [[ "${compiler}" = "javac" ]]; then 1317 if [[ "${compiler}" = "javac" ]]; then
1170 # nothing fancy needs to be done for javac 1318 # nothing fancy needs to be done for javac
1178 unset JAVAC 1326 unset JAVAC
1179 # try to get value of JAVAC 1327 # try to get value of JAVAC
1180 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1328 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1181 export JAVAC=${old_javac} 1329 export JAVAC=${old_javac}
1182 1330
1183 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1331 if [[ -z ${compiler_executable} ]]; then
1332 echo "JAVAC is empty or undefined in ${compiler_env}"
1333 return 1
1334 fi
1184 1335
1185 # check that it's executable 1336 # check that it's executable
1186 if [[ ! -x ${compiler_executable} ]]; then 1337 if [[ ! -x ${compiler_executable} ]]; then
1187 eerror "Could not find ${compiler_executable}!"
1188 die "${compiler_executable} doesn't exist, or isn't executable" 1338 echo "${compiler_executable} doesn't exist, or isn't executable"
1339 return 1
1189 fi 1340 fi
1190 else 1341 else
1191 eerror "Could not find environment file for ${compiler}" 1342 echo "Could not find environment file for ${compiler}"
1192 die "Could not find ${compiler_env}" 1343 return 1
1193 fi 1344 fi
1194 fi 1345 fi
1195 echo ${compiler_executable} 1346 echo ${compiler_executable}
1196} 1347}
1197 1348
1214 1365
1215 debug-print "want source: ${want_source}" 1366 debug-print "want source: ${want_source}"
1216 debug-print "want target: ${want_target}" 1367 debug-print "want target: ${want_target}"
1217 1368
1218 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1369 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1219 debug-print "could not find valid -source/-target values" 1370 debug-print "could not find valid -source/-target values for javac"
1220 die "Could not find valid -source/-target values" 1371 echo "Could not find valid -source/-target values for javac"
1372 return 1
1221 else 1373 else
1222 if java-pkg_is-vm-version-ge "1.4"; then 1374 if java-pkg_is-vm-version-ge "1.4"; then
1223 echo "${source_str} ${target_str}" 1375 echo "${source_str} ${target_str}"
1224 else 1376 else
1225 echo "${target_str}" 1377 echo "${target_str}"
1229 1381
1230# TODO document 1382# TODO document
1231java-pkg_get-jni-cflags() { 1383java-pkg_get-jni-cflags() {
1232 local flags="-I${JAVA_HOME}/include" 1384 local flags="-I${JAVA_HOME}/include"
1233 1385
1386 local platform="linux"
1387 use elibc_FreeBSD && platform="freebsd"
1388
1234 # TODO do a check that the directories are valid 1389 # TODO do a check that the directories are valid
1235 # TODO figure out how to cope with other things than linux...
1236 flags="${flags} -I${JAVA_HOME}/include/linux" 1390 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1237 1391
1238 echo ${flags} 1392 echo ${flags}
1239} 1393}
1240 1394
1241java-pkg_ensure-gcj() { 1395java-pkg_ensure-gcj() {
1247 die "No GCJ support found!" 1401 die "No GCJ support found!"
1248 fi 1402 fi
1249} 1403}
1250 1404
1251java-pkg_ensure-test() { 1405java-pkg_ensure-test() {
1252 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1406 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1407 && hasq test ${IUSE} && ! use test;
1408 then
1253 eerror "You specified FEATURES=test, but USE=test is needed" 1409 eerror "You specified FEATURES=test, but USE=test is needed"
1254 eerror "to pull in the additional dependencies for testing" 1410 eerror "to pull in the additional dependencies for testing"
1255 die "Need USE=test enabled" 1411 die "Need USE=test enabled"
1256 fi 1412 fi
1257} 1413}
1258 1414
1259# ------------------------------------------------------------------------------ 1415# ------------------------------------------------------------------------------
1416# @ebuild-function java-pkg_register-ant-task
1417#
1418# Register this package as ant task, so that ant will load it when no specific
1419# ANT_TASKS are specified. Note that even without this registering, all packages
1420# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1421# packages, but can be also used by other ebuilds that used to symlink their
1422# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1423# compatibility.
1424#
1425# @param --version x.y Register only for ant version x.y (otherwise for any ant
1426# version). Used by the ant-* packages to prevent loading of mismatched
1427# ant-core ant tasks after core was updated, before the tasks are updated,
1428# without a need for blockers.
1429# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1430# ------------------------------------------------------------------------------
1431java-pkg_register-ant-task() {
1432 local TASKS_DIR="tasks"
1433
1434 # check for --version x.y parameters
1435 while [[ -n "${1}" && -n "${2}" ]]; do
1436 local var="${1#--}"
1437 local val="${2}"
1438 if [[ "${var}" == "version" ]]; then
1439 TASKS_DIR="tasks-${val}"
1440 else
1441 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1442 fi
1443 shift 2
1444 done
1445
1446 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1447
1448 dodir /usr/share/ant/${TASKS_DIR}
1449 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1450}
1451
1452# ------------------------------------------------------------------------------
1453# @internal-function java-pkg_ant-tasks-from-deps
1454#
1455# Function to determine ANT_TASKS from DEPEND variable for backwards
1456# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1457# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1458# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1459# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1460# be a problem, the worst it can do is activace all tasks when not needed.
1461# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1462# insufficient dependencies, otherwise all available tasks are used for
1463# backwards compatilbility.
1464#
1465# @return "all" or "none"
1466# ------------------------------------------------------------------------------
1467java-pkg_ant-tasks-from-deps() {
1468 local found_ant found_ant_tasks
1469
1470 for dep in ${DEPEND}
1471 do
1472 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1473 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1474 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1475 done
1476
1477 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1478 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1479 echo "all"
1480 else
1481 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1482 # so we deactivate all tasks that may be installed
1483 echo "none"
1484 fi
1485}
1486
1487# ------------------------------------------------------------------------------
1488# @internal-function java-pkg_ant-tasks-depend
1489#
1490# Translates the WANT_ANT_TASKS variable into valid dependencies.
1491# ------------------------------------------------------------------------------
1492java-pkg_ant-tasks-depend() {
1493 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1494
1495 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1496 local DEP=""
1497 for i in ${WANT_ANT_TASKS}
1498 do
1499 if [[ ${i} != ant-* ]]; then
1500 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1501 return 1
1502 fi
1503 DEP="${DEP}dev-java/${i} "
1504 done
1505 echo ${DEP}
1506 return 0
1507 else
1508 return 0
1509 fi
1510}
1511
1512# ------------------------------------------------------------------------------
1260# @section-end helper 1513# @section-end helper
1261# ------------------------------------------------------------------------------ 1514# ------------------------------------------------------------------------------
1262 1515
1263# ------------------------------------------------------------------------------ 1516# ------------------------------------------------------------------------------
1264# @section-begin build 1517# @section-begin build
1270 1523
1271# ------------------------------------------------------------------------------ 1524# ------------------------------------------------------------------------------
1272# @ebuild-function eant 1525# @ebuild-function eant
1273# 1526#
1274# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1527# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1275# compiler. 1528# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1276# 1529# variables:
1530# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1531# gentoo.classpath property. Be sure to call
1532# java-ant_rewrite-classpath in src_unpack.
1533# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1277# ------------------------------------------------------------------------------ 1534# ------------------------------------------------------------------------------
1278eant() { 1535eant() {
1279 debug-print-function ${FUNCNAME} $* 1536 debug-print-function ${FUNCNAME} $*
1280 1537
1281 # FIXME get this working 1538 # FIXME get this working
1282# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1539# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1283# java-pkg_announce-qa-violation \ 1540# java-pkg_announce-qa-violation \
1284# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1541# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1285# fi 1542# fi
1286 1543
1287 local antflags 1544 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1545 msg="You should inherit java-ant-2 when using eant"
1546 java-pkg_announce-qa-violation ${msg}
1547 die ${msg}
1548 fi
1549
1550 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1288 java-pkg_init-compiler_ 1551 java-pkg_init-compiler_
1289 local compiler="${GENTOO_COMPILER}" 1552 local compiler="${GENTOO_COMPILER}"
1290 1553
1291 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1554 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1292 1555
1294 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1557 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1295 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1558 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1296 fi 1559 fi
1297 1560
1298 if [[ ${compiler} != "javac" ]]; then 1561 if [[ ${compiler} != "javac" ]]; then
1299 antflags="-Dbuild.compiler=${build_compiler}" 1562 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1300 # Figure out any extra stuff to put on the classpath for compilers aside 1563 # Figure out any extra stuff to put on the classpath for compilers aside
1301 # from javac 1564 # from javac
1302 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1565 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1303 # java-config -p 1566 # java-config -p
1304 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1567 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1310 if is-java-strict; then 1573 if is-java-strict; then
1311 einfo "Disabling system classpath for ant" 1574 einfo "Disabling system classpath for ant"
1312 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1575 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1313 fi 1576 fi
1314 1577
1315 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1578 if has_version ">=dev-java/ant-core-1.7.0"; then
1316 antflags="${antflags} -debug" 1579 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1580 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1581
1582 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1583 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1584
1585 if is-java-strict; then
1586 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1587 if [[ -z "${ANT_TASKS}" ]]; then
1588 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1589 fi
1590 else
1591 # if ant-tasks is not set by ebuild or forced, activate all of them
1592 ANT_TASKS="${ANT_TASKS:-all}"
1593 fi
1594
1595 # at this point, ANT_TASKS should be "all", "none" or explicit list
1596 if [[ "${ANT_TASKS}" == "all" ]]; then
1597 einfo "Using all available ANT_TASKS"
1598 elif [[ "${ANT_TASKS}" == "none" ]]; then
1599 einfo "Disabling all optional ANT_TASKS"
1600 else
1601 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1602 fi
1603
1604 export ANT_TASKS
1605 fi
1606
1607 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1608 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1609
1610 local gcp="${EANT_GENTOO_CLASSPATH}"
1611
1612 if [[ "${gcp}" ]]; then
1613 local cp="$(java-pkg_getjars ${gcp})"
1614 # It seems ant does not like single quotes around ${cp}
1615 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1317 fi 1616 fi
1318 1617
1319 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1618 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1619 debug-print "Calling ant: ${antflags} ${@}"
1320 ant ${antflags} "${@}" || die "eant failed" 1620 ant ${antflags} "${@}" || die "eant failed"
1321 1621
1322} 1622}
1323 1623
1324# ------------------------------------------------------------------------------ 1624# ------------------------------------------------------------------------------
1330# @param $@ - Arguments to be passed to the compiler 1630# @param $@ - Arguments to be passed to the compiler
1331# ------------------------------------------------------------------------------ 1631# ------------------------------------------------------------------------------
1332ejavac() { 1632ejavac() {
1333 debug-print-function ${FUNCNAME} $* 1633 debug-print-function ${FUNCNAME} $*
1334 1634
1335 # FIXME using get-javac ends up printing stuff with einfo 1635 java-pkg_init-compiler_
1636
1637 local compiler_executable
1336# local compiler_executable=$(java-pkg_get-javac) 1638 compiler_executable=$(java-pkg_get-javac)
1337 local compiler_executable="javac" 1639 if [[ ${?} != 0 ]]; then
1640 eerror "There was a problem determining compiler: ${compiler_executable}"
1641 die "get-javac failed"
1642 fi
1338 1643
1644 local javac_args
1645 javac_args="$(java-pkg_javac-args)"
1646 if [[ ${?} != 0 ]]; then
1647 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1648 die "java-pkg_javac-args failed"
1649 fi
1650
1339 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1651 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1340 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1652 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1341} 1653}
1342 1654
1343# ------------------------------------------------------------------------------ 1655# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_filter-compiler 1656# @ebuild-function java-pkg_filter-compiler
1345# 1657#
1382# @return string - Name of the target to create javadocs 1694# @return string - Name of the target to create javadocs
1383# ------------------------------------------------------------------------------ 1695# ------------------------------------------------------------------------------
1384use_doc() { 1696use_doc() {
1385 use doc && echo ${@:-javadoc} 1697 use doc && echo ${@:-javadoc}
1386} 1698}
1699
1387 1700
1388# ------------------------------------------------------------------------------ 1701# ------------------------------------------------------------------------------
1389# @section-end build 1702# @section-end build
1390# ------------------------------------------------------------------------------ 1703# ------------------------------------------------------------------------------
1391 1704
1424 # When users have crazy classpaths some packages can fail to compile. 1737 # When users have crazy classpaths some packages can fail to compile.
1425 # and everything should work with empty CLASSPATH. 1738 # and everything should work with empty CLASSPATH.
1426 # This also helps prevent unexpected dependencies on random things 1739 # This also helps prevent unexpected dependencies on random things
1427 # from the CLASSPATH. 1740 # from the CLASSPATH.
1428 unset CLASSPATH 1741 unset CLASSPATH
1742
1743 # Unset external ANT_ stuff
1744 unset ANT_TASKS
1745 unset ANT_OPTS
1429} 1746}
1430 1747
1431# ------------------------------------------------------------------------------ 1748# ------------------------------------------------------------------------------
1432# @function-internal java-pkg-init-compiler_ 1749# @function-internal java-pkg-init-compiler_
1433# 1750#
1577# Writes the package.env out to disk. 1894# Writes the package.env out to disk.
1578# 1895#
1579# ------------------------------------------------------------------------------ 1896# ------------------------------------------------------------------------------
1580# TODO change to do-write, to match everything else 1897# TODO change to do-write, to match everything else
1581java-pkg_do_write_() { 1898java-pkg_do_write_() {
1899 java-pkg_init_paths_
1582 # Create directory for package.env 1900 # Create directory for package.env
1583 dodir "${JAVA_PKG_SHAREPATH}" 1901 dodir "${JAVA_PKG_SHAREPATH}"
1584 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1902 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1585 # Create package.env 1903 # Create package.env
1586 ( 1904 (
1614 # Strip unnecessary leading and trailing colons 1932 # Strip unnecessary leading and trailing colons
1615 # TODO try to cleanup if possible 1933 # TODO try to cleanup if possible
1616 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1934 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1617 fi 1935 fi
1618} 1936}
1619
1620 1937
1621# ------------------------------------------------------------------------------ 1938# ------------------------------------------------------------------------------
1622# @internal-function java-pkg_record-jar_ 1939# @internal-function java-pkg_record-jar_
1623# 1940#
1624# Record a dependency to the package.env 1941# Record a dependency to the package.env
1705# ------------------------------------------------------------------------------ 2022# ------------------------------------------------------------------------------
1706java-pkg_setup-vm() { 2023java-pkg_setup-vm() {
1707 debug-print-function ${FUNCNAME} $* 2024 debug-print-function ${FUNCNAME} $*
1708 2025
1709 local vendor="$(java-pkg_get-vm-vendor)" 2026 local vendor="$(java-pkg_get-vm-vendor)"
1710 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2027 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1711 addpredict "/dev/random" 2028 addpredict "/dev/random"
1712 elif [[ "${vendor}" == "ibm" ]]; then 2029 elif [[ "${vendor}" == "ibm" ]]; then
1713 addpredict "/proc/self/maps" 2030 addpredict "/proc/self/maps"
1714 addpredict "/proc/cpuinfo" 2031 addpredict "/proc/cpuinfo"
1715 export LANG="C" LC_ALL="C" 2032 export LANG="C" LC_ALL="C"
1775# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2092# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1776# verify that the current VM is sufficient. 2093# verify that the current VM is sufficient.
1777# Setup the environment for the VM being used. 2094# Setup the environment for the VM being used.
1778# ------------------------------------------------------------------------------ 2095# ------------------------------------------------------------------------------
1779java-pkg_switch-vm() { 2096java-pkg_switch-vm() {
2097 debug-print-function ${FUNCNAME} $*
2098
1780 if java-pkg_needs-vm; then 2099 if java-pkg_needs-vm; then
1781 # Use the VM specified by JAVA_PKG_FORCE_VM 2100 # Use the VM specified by JAVA_PKG_FORCE_VM
1782 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2101 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1783 # If you're forcing the VM, I hope you know what your doing... 2102 # If you're forcing the VM, I hope you know what your doing...
2103 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1784 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2104 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1785 # if we're allowed to switch the vm... 2105 # if we're allowed to switch the vm...
1786 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2106 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1787 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2107 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1788 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2108 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1789 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2109 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1790 else 2110 else
1791 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2111 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2112 fi
2113 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2114 eerror "Unable to determine VM for building from dependencies:"
2115 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2116 echo "VNEED: ${JAVA_PKG_VNEED}"
2117 die "Failed to determine VM for building."
2118 else
2119 export GENTOO_VM
1792 fi 2120 fi
1793 # otherwise just make sure the current VM is sufficient 2121 # otherwise just make sure the current VM is sufficient
1794 else 2122 else
1795 java-pkg_ensure-vm-version-sufficient 2123 java-pkg_ensure-vm-version-sufficient
1796 fi 2124 fi
1798 2126
1799 java-pkg_setup-vm 2127 java-pkg_setup-vm
1800 2128
1801 export JAVA=$(java-config --java) 2129 export JAVA=$(java-config --java)
1802 export JAVAC=$(java-config --javac) 2130 export JAVAC=$(java-config --javac)
1803 export JAVACFLAGS="$(java-pkg_javac-args)" 2131 JAVACFLAGS="$(java-pkg_javac-args)"
2132 if [[ ${?} != 0 ]]; then
2133 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2134 die "java-pkg_javac-args failed"
2135 fi
1804 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2136 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2137 export JAVACFLAGS
1805 2138
1806 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2139 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1807 export JDK_HOME=${JAVA_HOME} 2140 export JDK_HOME=${JAVA_HOME}
1808 2141
1809 #TODO If you know a better solution let us know. 2142 #TODO If you know a better solution let us know.
1871 ewarn "Possible problem" 2204 ewarn "Possible problem"
1872 die "Bad class files found" 2205 die "Bad class files found"
1873 fi 2206 fi
1874} 2207}
1875 2208
1876
1877# ------------------------------------------------------------------------------ 2209# ------------------------------------------------------------------------------
1878# @section-end internal 2210# @section-end internal
1879# ------------------------------------------------------------------------------ 2211# ------------------------------------------------------------------------------
1880 2212
1881java-pkg_check-phase() { 2213java-pkg_check-phase() {

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

  ViewVC Help
Powered by ViewVC 1.1.20