/[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.38 Revision 1.92
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.38 2006/12/31 19:30:54 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.92 2007/08/05 08:17:05 betelgeuse Exp $
10
11 10
12# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
13# @eclass-begin 12# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
15# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
36# ----------------------------------------------------------------------------- 35# -----------------------------------------------------------------------------
37 36
38# Make sure we use java-config-2 37# Make sure we use java-config-2
39export WANT_JAVA_CONFIG="2" 38export WANT_JAVA_CONFIG="2"
40 39
41# TODO document 40# -----------------------------------------------------------------------------
41# @variable-external WANT_ANT_TASKS
42# @variable-default ""
43#
44# An $IFS separated list of ant tasks.
45# Ebuild can specify this variable before inheriting java-ant-2 eclass to
46# determine ANT_TASKS it needs. They will be automatically translated to
47# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
48# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
49# Ebuilds that need to depend conditionally on certain tasks and specify them
50# differently for different eant calls can't use this simplified approach.
51# You also cannot specify version or anything else than ant-*.
52#
53# @example WANT_ANT_TASKS="ant-junit ant-trax"
54#
55# @seealso JAVA_PKG_FORCE_ANT_TASKS
56# -----------------------------------------------------------------------------
57#WANT_ANT_TASKS
58
59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env
64# saving.
65# -----------------------------------------------------------------------------
42JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
43 67
44# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
45# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
46# 70#
47# 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
48# 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
49# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
50# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
51JAVA_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.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
52 76
53# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
54# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
55# @variable-default yes 79# @variable-default yes
56# 80#
130# @note This should only be used internally or for testing. 154# @note This should only be used internally or for testing.
131# @example Use jikes and javac, in that order 155# @example Use jikes and javac, in that order
132# JAVA_PKG_FORCE_COMPILER="jikes javac" 156# JAVA_PKG_FORCE_COMPILER="jikes javac"
133# ----------------------------------------------------------------------------- 157# -----------------------------------------------------------------------------
134 158
159# -----------------------------------------------------------------------------
160# @variable-external JAVA_PKG_FORCE_ANT_TASKS
161#
162# An $IFS separated list of ant tasks. Can be set in environment before calling
163# emerge/ebuild to override variables set in ebuild, mainly for testing before
164# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
165# eant() call, not the dependencies specified in WANT_ANT_TASKS.
166#
167# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
168# ebuild foo.ebuild compile
169#
170# @seealso WANT_ANT_TASKS
171# -----------------------------------------------------------------------------
172
135# TODO document me 173# TODO document me
136JAVA_PKG_QA_VIOLATIONS=0 174JAVA_PKG_QA_VIOLATIONS=0
137 175
138# ----------------------------------------------------------------------------- 176# -----------------------------------------------------------------------------
139# @section-end variables 177# @section-end variables
146# 184#
147# 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
148# libraries, etc. 186# libraries, etc.
149# ----------------------------------------------------------------------------- 187# -----------------------------------------------------------------------------
150 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}
151 222
152# ----------------------------------------------------------------------------- 223# -----------------------------------------------------------------------------
153# @ebuild-function java-pkg_dojar 224# @ebuild-function java-pkg_dojar
154# 225#
155# Installs any number of jars. 226# Installs any number of jars.
174 # Create JARDEST if it doesn't exist 245 # Create JARDEST if it doesn't exist
175 dodir ${JAVA_PKG_JARDEST} 246 dodir ${JAVA_PKG_JARDEST}
176 247
177 local jar 248 local jar
178 # for each jar 249 # for each jar
179 for jar in "$@"; do 250 for jar in "${@}"; do
180 local jar_basename=$(basename "${jar}") 251 local jar_basename=$(basename "${jar}")
181 252
182 java-pkg_check-versioned-jar ${jar_basename} 253 java-pkg_check-versioned-jar ${jar_basename}
183 254
184 # check if it exists 255 # check if it exists
185 if [[ -e "${jar}" ]] ; then 256 if [[ -e "${jar}" ]] ; then
257 # Don't overwrite if jar has already been installed with the same
258 # name
259 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
260 if [[ -e "${dest}" ]]; then
261 ewarn "Overwriting ${dest}"
262 fi
263
186 # install it into JARDEST if it's a non-symlink 264 # install it into JARDEST if it's a non-symlink
187 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
188 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 269 INSDESTTREE="${JAVA_PKG_JARDEST}" \
189 doins "${jar}" || die "failed to install ${jar}" 270 doins "${jar}" || die "failed to install ${jar}"
190 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 271 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
191 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 272 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
192 # make a symlink to the original jar if it's symlink 273 # make a symlink to the original jar if it's symlink
212# 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
213# do not handle use flags. 294# do not handle use flags.
214# ------------------------------------------------------------------------------ 295# ------------------------------------------------------------------------------
215 296
216depend-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.
217 USE="${USE}" $(which depend-java-query) "${@}" 300 USE="${USE}" /usr/bin/depend-java-query "${@}"
218} 301}
219 302
220# ------------------------------------------------------------------------------ 303# ------------------------------------------------------------------------------
221# @ebuild-function java-pkg_regjar 304# @ebuild-function java-pkg_regjar
222# 305#
254 [[ ${#} -lt 1 ]] && die "at least one argument needed" 337 [[ ${#} -lt 1 ]] && die "at least one argument needed"
255 338
256 java-pkg_init_paths_ 339 java-pkg_init_paths_
257 340
258 local jar jar_dir jar_file 341 local jar jar_dir jar_file
259 for jar in "$@"; do 342 for jar in "${@}"; do
260 # TODO use java-pkg_check-versioned-jar 343 # TODO use java-pkg_check-versioned-jar
261 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then 344 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
262 [[ -d "${jar}" || -d "${D}${jar}" ]] \ 345 [[ -d "${jar}" || -d "${D}${jar}" ]] \
263 && 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
264 # 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:
265 # imagine such call: 352 # imagine such call:
266 # java-pkg_regjar ${D}/opt/java/*.jar 353 # java-pkg_regjar ${D}/opt/java/*.jar
267 # such call will fall into this case (-e ${jar}) and will 354 # such call will fall into this case (-e ${jar}) and will
268 # record paths with ${D} in package.env 355 # record paths with ${D} in package.env
269 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 356 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
270 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
271 die "${jar} does not exist" 363 die "${jar} does not exist"
272 fi 364 fi
273 done 365 done
274 366
275 java-pkg_do_write_ 367 java-pkg_do_write_
292 local original_jar="${1}" 384 local original_jar="${1}"
293 local new_jar="${2:-${PN}.jar}" 385 local new_jar="${2:-${PN}.jar}"
294 local new_jar_dest="${T}/${new_jar}" 386 local new_jar_dest="${T}/${new_jar}"
295 387
296 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 388 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
297 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 389 [[ ! -f ${original_jar} ]] \
390 && die "${original_jar} does not exist or is not a file!"
298 391
299 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 392 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
300 cp "${original_jar}" "${new_jar_dest}" \ 393 cp "${original_jar}" "${new_jar_dest}" \
301 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 394 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
302 java-pkg_dojar "${new_jar_dest}" 395 java-pkg_dojar "${new_jar_dest}"
351 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
352 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
353 # otherwise make a symlink to the symlink's origin 446 # otherwise make a symlink to the symlink's origin
354 else 447 else
355 # TODO use dosym 448 # TODO use dosym
449 ln -s "$(readlink "${lib}")" \
356 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 450 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
357 debug-print "${lib} is a symlink, linking accordanly" 451 debug-print "${lib} is a symlink, linking accordanly"
358 fi 452 fi
359 # otherwise die 453 # otherwise die
360 else 454 else
361 die "${lib} does not exist" 455 die "${lib} does not exist"
462# @example: 556# @example:
463# java-pkg_dojavadoc docs/api 557# java-pkg_dojavadoc docs/api
464# 558#
465# ------------------------------------------------------------------------------ 559# ------------------------------------------------------------------------------
466java-pkg_dojavadoc() { 560java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $*
467 local dir="$1" 562 local dir="$1"
563
564 # QA checks
468 565
469 java-pkg_check-phase install 566 java-pkg_check-phase install
470 567
471 [[ -z "${dir}" ]] && die "Must specify a directory!" 568 [[ -z "${dir}" ]] && die "Must specify a directory!"
472 [[ ! -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
473 577
474 local dir_to_install="${dir}" 578 local dir_to_install="${dir}"
475 if [[ "$(basename "${dir}")" != "api" ]]; then 579 if [[ "$(basename "${dir}")" != "api" ]]; then
476 dir_to_install="${T}/api" 580 dir_to_install="${T}/api"
477 # TODO use doins 581 # TODO use doins
478 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 582 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
479 fi 583 fi
584
585 # Actual installation
480 586
481 java-pkg_dohtml -r ${dir_to_install} 587 java-pkg_dohtml -r ${dir_to_install}
482} 588}
483 589
484# ------------------------------------------------------------------------------ 590# ------------------------------------------------------------------------------
502# FIXME apparently this fails if you give it an empty directories 608# FIXME apparently this fails if you give it an empty directories
503java-pkg_dosrc() { 609java-pkg_dosrc() {
504 debug-print-function ${FUNCNAME} $* 610 debug-print-function ${FUNCNAME} $*
505 611
506 [ ${#} -lt 1 ] && die "At least one argument needed" 612 [ ${#} -lt 1 ] && die "At least one argument needed"
507 if ! hasq source ${IUSE}; then
508 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
509 fi
510 613
511 java-pkg_check-phase install 614 java-pkg_check-phase install
512 615
513 [[ ${#} -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
514 628
515 java-pkg_init_paths_ 629 java-pkg_init_paths_
516 630
517 local zip_name="${PN}-src.zip" 631 local zip_name="${PN}-src.zip"
518 local zip_path="${T}/${zip_name}" 632 local zip_path="${T}/${zip_name}"
519 local dir 633 local dir
520 for dir in ${@}; do 634 for dir in "${@}"; do
521 local dir_parent=$(dirname "${dir}") 635 local dir_parent=$(dirname "${dir}")
522 local dir_name=$(basename "${dir}") 636 local dir_name=$(basename "${dir}")
523 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 637 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
524 zip -q -r ${zip_path} ${dir_name} -i '*.java' 638 zip -q -r ${zip_path} ${dir_name} -i '*.java'
525 local result=$? 639 local result=$?
550# @param $1 - filename of launcher to create 664# @param $1 - filename of launcher to create
551# @param $2 - options, as follows: 665# @param $2 - options, as follows:
552# --main the.main.class.too.start 666# --main the.main.class.too.start
553# --jar /the/jar/too/launch.jar or just <name>.jar 667# --jar /the/jar/too/launch.jar or just <name>.jar
554# --java_args 'Extra arguments to pass to java' 668# --java_args 'Extra arguments to pass to java'
555# --pkg_args 'Extra arguments too pass to the package' 669# --pkg_args 'Extra arguments to pass to the package'
556# --pwd 670# --pwd Directory the launcher changes to before executing java
557# -into 671# -into Directory to install the launcher to, instead of /usr/bin
558# -pre 672# -pre Prepend contents of this file to the launcher
559# ------------------------------------------------------------------------------ 673# ------------------------------------------------------------------------------
560java-pkg_dolauncher() { 674java-pkg_dolauncher() {
561 debug-print-function ${FUNCNAME} $* 675 debug-print-function ${FUNCNAME} $*
562 676
563 java-pkg_check-phase install 677 java-pkg_check-phase install
604 fi 718 fi
605 fi 719 fi
606 720
607 # Write the actual script 721 # Write the actual script
608 echo "#!/bin/bash" > "${target}" 722 echo "#!/bin/bash" > "${target}"
609 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 723 if [[ -n "${pre}" ]]; then
724 if [[ -f "${pre}" ]]; then
725 cat "${pre}" >> "${target}"
726 else
727 die "-pre specified file '${pre}' does not exist"
728 fi
729 fi
610 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 730 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
611 cat "${var_tmp}" >> "${target}" 731 cat "${var_tmp}" >> "${target}"
612 rm -f "${var_tmp}" 732 rm -f "${var_tmp}"
613 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 733 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
614 734
706# 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
707# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 827# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
708# Example: get junit.jar which is needed only for building 828# Example: get junit.jar which is needed only for building
709# java-pkg_jar-from --build-only junit junit.jar 829# java-pkg_jar-from --build-only junit junit.jar
710# 830#
711# @param $1 - (optional) "--build-only" makes the jar(s) not added into 831# @param $opt
712# package.env DEPEND line. 832# --build-only - makes the jar(s) not added into package.env DEPEND line.
713# @param $1 - Package to get jars from. 833# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies
835# transitively.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of .
837# @param $1 - Package to get jars from, or comma-separated list of packages in
838# case other parameters are not used.
714# @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.
715# @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
716# symlink. Defaults to the name of the jar. 841# symlink. Defaults to the name of the jar.
717# ------------------------------------------------------------------------------ 842# ------------------------------------------------------------------------------
718# TODO could probably be cleaned up a little 843# TODO could probably be cleaned up a little
719java-pkg_jar-from() { 844java-pkg_jar-from() {
720 debug-print-function ${FUNCNAME} $* 845 debug-print-function ${FUNCNAME} $*
721 846
722 local build_only="" 847 local build_only=""
848 local destdir="."
849 local deep=""
723 850
851 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
852
853 while [[ "${1}" == --* ]]; do
724 if [[ "${1}" = "--build-only" ]]; then 854 if [[ "${1}" = "--build-only" ]]; then
725 build_only="true" 855 build_only="build"
856 elif [[ "${1}" = "--with-dependencies" ]]; then
857 deep="--with-dependencies"
858 elif [[ "${1}" = "--into" ]]; then
859 destdir="${2}"
860 shift
861 else
862 die "java-pkg_jar-from called with unknown parameter: ${1}"
863 fi
726 shift 864 shift
727 fi 865 done
728 866
729 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 867 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
730 868
731 [[ -z ${target_pkg} ]] && die "Must specify a package" 869 [[ -z ${target_pkg} ]] && die "Must specify a package"
732 870
733 # default destjar to the target jar 871 # default destjar to the target jar
734 [[ -z "${destjar}" ]] && destjar="${target_jar}" 872 [[ -z "${destjar}" ]] && destjar="${target_jar}"
735 873
736 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}."
737 local classpath 875 local classpath
738 classpath="$(java-config --classpath=${target_pkg})" 876 classpath="$(java-config ${deep} --classpath=${target_pkg})"
739 [[ $? != 0 ]] && die ${error_msg} 877 [[ $? != 0 ]] && die ${error_msg}
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
893 pushd ${destdir} > /dev/null \
894 || die "failed to change directory to ${destdir}"
740 895
741 local jar 896 local jar
742 for jar in ${classpath//:/ }; do 897 for jar in ${classpath//:/ }; do
743 local jar_name=$(basename "${jar}") 898 local jar_name=$(basename "${jar}")
744 if [[ ! -f "${jar}" ]] ; then 899 if [[ ! -f "${jar}" ]] ; then
755 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 910 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
756 [[ -f "${destjar}" ]] && rm "${destjar}" 911 [[ -f "${destjar}" ]] && rm "${destjar}"
757 ln -snf "${jar}" "${destjar}" \ 912 ln -snf "${jar}" "${destjar}" \
758 || die "Failed to make symlink from ${jar} to ${destjar}" 913 || die "Failed to make symlink from ${jar} to ${destjar}"
759 [[ -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
760 return 0 916 return 0
761 fi 917 fi
762 done 918 done
919 popd > /dev/null
763 # if no target was specified, we're ok 920 # if no target was specified, we're ok
764 if [[ -z "${target_jar}" ]] ; then 921 if [[ -z "${target_jar}" ]] ; then
765 return 0 922 return 0
766 # otherwise, die bitterly 923 # otherwise, die bitterly
767 else 924 else
791# Example: Get the classpath for xerces-2 and xalan, 948# Example: Get the classpath for xerces-2 and xalan,
792# java-pkg_getjars xerces-2,xalan 949# java-pkg_getjars xerces-2,xalan
793# Example Return: 950# Example Return:
794# /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
795# 952#
796# @param $1 - (optional) "--build-only" makes the jar(s) not added into 953# @param $opt
797# package.env DEPEND line. 954# --build-only - makes the jar(s) not added into package.env DEPEND line.
955# (assumed automatically when called inside src_test)
956# --with-dependencies - get jars also from requested package's dependencies
957# transitively.
798# @param $2 - list of packages to get jars from 958# @param $1 - list of packages to get jars from
799# (passed to java-config --classpath) 959# (passed to java-config --classpath)
800# ------------------------------------------------------------------------------ 960# ------------------------------------------------------------------------------
801java-pkg_getjars() { 961java-pkg_getjars() {
802 debug-print-function ${FUNCNAME} $* 962 debug-print-function ${FUNCNAME} $*
803 963
964 local build_only=""
965 local deep=""
966
967 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
968
969 while [[ "${1}" == --* ]]; do
804 if [[ "${1}" = "--build-only" ]]; then 970 if [[ "${1}" = "--build-only" ]]; then
805 local build_only="true" 971 build_only="build"
972 elif [[ "${1}" = "--with-dependencies" ]]; then
973 deep="--with-dependencies"
974 else
975 die "java-pkg_jar-from called with unknown parameter: ${1}"
976 fi
806 shift 977 shift
807 fi 978 done
808 979
809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only" 980 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
981
810 982
811 local classpath pkgs="${1}" 983 local classpath pkgs="${1}"
812 jars="$(java-config --classpath=${pkgs})" 984 jars="$(java-config ${deep} --classpath=${pkgs})"
813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 985 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
814 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
815 991
816 if [[ -z "${classpath}" ]]; then 992 if [[ -z "${classpath}" ]]; then
817 classpath="${jars}" 993 classpath="${jars}"
818 else 994 else
819 classpath="${classpath}:${jars}" 995 classpath="${classpath}:${jars}"
820 fi 996 fi
821 997
822 # Only record jars that aren't build-only 998 # Only record jars that aren't build-only
823 if [[ -z "${build_only}" ]]; then 999 if [[ -z "${build_only}" ]]; then
824 oldifs="${IFS}"
825 IFS=","
826 for pkg in ${pkgs}; do 1000 for pkg in ${pkgs//,/ }; do
827 java-pkg_record-jar_ "${pkg}" 1001 java-pkg_record-jar_ "${pkg}"
828 done 1002 done
829 IFS="${oldifs}"
830 fi 1003 fi
831 1004
832 echo "${classpath}" 1005 echo "${classpath}"
833} 1006}
834 1007
844# @example 1017# @example
845# java-pkg_getjar xerces-2 xml-apis.jar 1018# java-pkg_getjar xerces-2 xml-apis.jar
846# @example-return 1019# @example-return
847# /usr/share/xerces-2/lib/xml-apis.jar 1020# /usr/share/xerces-2/lib/xml-apis.jar
848# 1021#
849# @param $1 - (optional) "--build-only" makes the jar not added into 1022# @param $opt
850# package.env DEPEND line. 1023# --build-only - makes the jar not added into package.env DEPEND line.
851# @param $1 - package to use 1024# @param $1 - package to use
852# @param $2 - jar to get 1025# @param $2 - jar to get
853# ------------------------------------------------------------------------------ 1026# ------------------------------------------------------------------------------
854java-pkg_getjar() { 1027java-pkg_getjar() {
855 debug-print-function ${FUNCNAME} $* 1028 debug-print-function ${FUNCNAME} $*
856 1029
857 local build_only="" 1030 local build_only=""
858 1031
1032 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1033
1034 while [[ "${1}" == --* ]]; do
859 if [[ "${1}" = "--build-only" ]]; then 1035 if [[ "${1}" = "--build-only" ]]; then
860 build_only="true" 1036 build_only="build"
1037 else
1038 die "java-pkg_jar-from called with unknown parameter: ${1}"
1039 fi
861 shift 1040 shift
862 fi 1041 done
1042
1043 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
863 1044
864 local pkg="${1}" target_jar="${2}" jar 1045 local pkg="${1}" target_jar="${2}" jar
865 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1046 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
866 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1047 [[ -z ${target_jar} ]] && die "Must specify jar to get"
867 1048
868 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?"
869 local classpath 1050 local classpath
870 classpath=$(java-config --classpath=${pkg}) 1051 classpath=$(java-config --classpath=${pkg})
871 [[ $? != 0 ]] && die ${error_msg} 1052 [[ $? != 0 ]] && die ${error_msg}
1053
1054 java-pkg_ensure-dep "${build_only}" "${pkg}"
872 1055
873 for jar in ${classpath//:/ }; do 1056 for jar in ${classpath//:/ }; do
874 if [[ ! -f "${jar}" ]] ; then 1057 if [[ ! -f "${jar}" ]] ; then
875 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1058 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
876 fi 1059 fi
883 fi 1066 fi
884 done 1067 done
885 1068
886 die "Could not find ${target_jar} in ${pkg}" 1069 die "Could not find ${target_jar} in ${pkg}"
887 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#
1083# @param $1 - comma-separated list of packages, or a single package
1084# @param $2 - if param $1 is a single package, optionally specify the jar
1085# to depend on
1086#
1087# Example: Record the dependency on whole xerces-2 and xalan,
1088# java-pkg_register-dependency xerces-2,xalan
1089# Example: Record the dependency on ant.jar from ant-core
1090# java-pkg_register-dependency ant-core ant.jar
1091#
1092# Note: Passing both list of packages as the first parameter AND specifying the
1093# jar as the second is not allowed and will cause the function to die. We assume
1094# that there's more chance one passes such combination as a mistake, than that
1095# there are more packages providing identically named jar without class
1096# collisions.
1097# ------------------------------------------------------------------------------
1098java-pkg_register-dependency() {
1099 debug-print-function ${FUNCNAME} $*
1100
1101 java-pkg_check-phase install
1102
1103 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1104
1105 local pkgs="${1}"
1106 local jar="${2}"
1107
1108 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1109
1110 if [[ -z "${jar}" ]]; then
1111 for pkg in ${pkgs//,/ }; do
1112 java-pkg_ensure-dep runtime "${pkg}"
1113 java-pkg_record-jar_ "${pkg}"
1114 done
1115 else
1116 [[ ${pkgs} == *,* ]] && \
1117 die "${FUNCNAME} called with both package list and jar name"
1118 java-pkg_ensure-dep runtime "${pkgs}"
1119 java-pkg_record-jar_ "${pkgs}" "${jar}"
1120 fi
1121
1122 java-pkg_do_write_
1123}
1124
1125# ------------------------------------------------------------------------------
1126# @ebuild-function java-pkg_register-optional-dependency
1127#
1128# Registers optional runtime dependency on a package, list of packages, or a
1129# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1130# called in src_install phase.
1131# Intended for packages that can use other packages when those are in classpath.
1132# Will be put on classpath by launcher if they are installed. Typical case is
1133# JDBC implementations for various databases. It's better than having USE flag
1134# for each implementation triggering hard dependency.
1135#
1136# @param $1 - comma-separated list of packages, or a single package
1137# @param $2 - if param $1 is a single package, optionally specify the jar
1138# to depend on
1139#
1140# Example: Record the optional dependency on some jdbc providers
1141# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1142#
1143# Note: Passing both list of packages as the first parameter AND specifying the
1144# jar as the second is not allowed and will cause the function to die. We assume
1145# that there's more chance one passes such combination as a mistake, than that
1146# there are more packages providing identically named jar without class
1147# collisions.
1148# ------------------------------------------------------------------------------
1149java-pkg_register-optional-dependency() {
1150 debug-print-function ${FUNCNAME} $*
1151
1152 java-pkg_check-phase install
1153
1154 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1155
1156 local pkgs="${1}"
1157 local jar="${2}"
1158
1159 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1160
1161 if [[ -z "${jar}" ]]; then
1162 for pkg in ${pkgs//,/ }; do
1163 java-pkg_record-jar_ --optional "${pkg}"
1164 done
1165 else
1166 [[ ${pkgs} == *,* ]] && \
1167 die "${FUNCNAME} called with both package list and jar name"
1168 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1169 fi
1170
1171 java-pkg_do_write_
1172}
1173
1174# ------------------------------------------------------------------------------
1175# @ebuild-function java-pkg_register-environment-variable
1176#
1177# Register an arbitrary environment variable into package.env. The gjl launcher
1178# for this package or any package depending on this will export it into
1179# environement before executing java command.
1180# Must only be called in src_install phase.
1181#
1182# @param $1 - variable name
1183# @param $2 - variable value
1184# ------------------------------------------------------------------------------
1185JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1186JAVA_PKG_EXTRA_ENV_VARS=""
1187java-pkg_register-environment-variable() {
1188 debug-print-function ${FUNCNAME} $*
1189
1190 java-pkg_check-phase install
1191
1192 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1193
1194 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1195 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1196
1197 java-pkg_do_write_
888} 1198}
889 1199
890# This function reads stdin, and based on that input, figures out how to 1200# This function reads stdin, and based on that input, figures out how to
891# populate jars from the filesystem. 1201# populate jars from the filesystem.
892# Need to figure out a good way of making use of this, ie be able to use a 1202# Need to figure out a good way of making use of this, ie be able to use a
1009# 1319#
1010# export DEPEND="${DEPEND} ${depstr}" 1320# export DEPEND="${DEPEND} ${depstr}"
1011# export RDEPEND="${RDEPEND} ${depstr}" 1321# export RDEPEND="${RDEPEND} ${depstr}"
1012#} 1322#}
1013 1323
1324# ------------------------------------------------------------------------------
1325# @ebuild-function java-pkg_find-normal-jars
1326#
1327# Find the files with suffix .jar file in the given directory or $WORKDIR
1328#
1329# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1330# ------------------------------------------------------------------------------
1331java-pkg_find-normal-jars() {
1332 local dir=$1
1333 [[ "${dir}" ]] || dir="${WORKDIR}"
1334 local found
1335 for jar in $(find "${dir}" -name "*.jar" -type f); do
1336 echo "${jar}"
1337 found="true"
1338 done
1339 [[ "${found}" ]]
1340 return $?
1341}
1342
1343# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_ensure-no-bundled-jars
1345#
1346# Try to locate bundled jar files in ${WORKDIR} and die if found.
1014# This should be used after S has been populated with symlinks to jars 1347# This function should be called after WORKDIR has been populated with symlink
1015# TODO document 1348# to system jar files or bundled jars removed.
1349# ------------------------------------------------------------------------------
1016java-pkg_ensure-no-bundled-jars() { 1350java-pkg_ensure-no-bundled-jars() {
1017 debug-print-function ${FUNCNAME} $* 1351 debug-print-function ${FUNCNAME} $*
1018 pushd ${WORKDIR} >/dev/null 2>/dev/null
1019 1352
1020 local bundled_jars=$(find . -name "*.jar" -type f) 1353 local bundled_jars=$(java-pkg_find-normal-jars)
1021 if [[ -n ${bundled_jars} ]]; then 1354 if [[ -n ${bundled_jars} ]]; then
1022 echo "Bundled jars found:" 1355 echo "Bundled jars found:"
1023 local jar 1356 local jar
1024 for jar in ${bundled_jars}; do 1357 for jar in ${bundled_jars}; do
1025 echo $(pwd)${jar/./} 1358 echo $(pwd)${jar/./}
1026 done 1359 done
1027 die "Bundled jars found!" 1360 die "Bundled jars found!"
1028
1029 fi 1361 fi
1030 popd >/dev/null 2>/dev/null
1031} 1362}
1032 1363
1033# ------------------------------------------------------------------------------ 1364# ------------------------------------------------------------------------------
1034# @internal-function java-pkg_ensure-vm-version-sufficient 1365# @internal-function java-pkg_ensure-vm-version-sufficient
1035# 1366#
1297 die "Need USE=test enabled" 1628 die "Need USE=test enabled"
1298 fi 1629 fi
1299} 1630}
1300 1631
1301# ------------------------------------------------------------------------------ 1632# ------------------------------------------------------------------------------
1633# @ebuild-function java-pkg_register-ant-task
1634#
1635# Register this package as ant task, so that ant will load it when no specific
1636# ANT_TASKS are specified. Note that even without this registering, all packages
1637# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1638# packages, but can be also used by other ebuilds that used to symlink their
1639# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1640# compatibility.
1641#
1642# @param --version x.y Register only for ant version x.y (otherwise for any ant
1643# version). Used by the ant-* packages to prevent loading of mismatched
1644# ant-core ant tasks after core was updated, before the tasks are updated,
1645# without a need for blockers.
1646# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1647# ------------------------------------------------------------------------------
1648java-pkg_register-ant-task() {
1649 local TASKS_DIR="tasks"
1650
1651 # check for --version x.y parameters
1652 while [[ -n "${1}" && -n "${2}" ]]; do
1653 local var="${1#--}"
1654 local val="${2}"
1655 if [[ "${var}" == "version" ]]; then
1656 TASKS_DIR="tasks-${val}"
1657 else
1658 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1659 fi
1660 shift 2
1661 done
1662
1663 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1664
1665 dodir /usr/share/ant/${TASKS_DIR}
1666 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1667}
1668
1669# ------------------------------------------------------------------------------
1670# @internal-function java-pkg_ant-tasks-from-deps
1671#
1672# Function to determine ANT_TASKS from DEPEND variable for backwards
1673# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1674# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1675# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1676# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1677# be a problem, the worst it can do is activace all tasks when not needed.
1678# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1679# insufficient dependencies, otherwise all available tasks are used for
1680# backwards compatilbility.
1681#
1682# @return "all" or "none"
1683# ------------------------------------------------------------------------------
1684java-pkg_ant-tasks-from-deps() {
1685 local found_ant found_ant_tasks
1686
1687 for dep in ${DEPEND}
1688 do
1689 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1690 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1691 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1692 done
1693
1694 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1695 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1696 echo "all"
1697 else
1698 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1699 # so we deactivate all tasks that may be installed
1700 echo "none"
1701 fi
1702}
1703
1704# ------------------------------------------------------------------------------
1705# @internal-function java-pkg_ant-tasks-depend
1706#
1707# Translates the WANT_ANT_TASKS variable into valid dependencies.
1708# ------------------------------------------------------------------------------
1709java-pkg_ant-tasks-depend() {
1710 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1711
1712 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1713 local DEP=""
1714 for i in ${WANT_ANT_TASKS}
1715 do
1716 if [[ ${i} != ant-* ]]; then
1717 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1718 return 1
1719 fi
1720 DEP="${DEP}dev-java/${i} "
1721 done
1722 echo ${DEP}
1723 return 0
1724 else
1725 return 0
1726 fi
1727}
1728
1729# ------------------------------------------------------------------------------
1730# @ebuild-function ejunit
1731#
1732# Junit wrapper function. Makes it easier to run the tests and checks for
1733# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1734#
1735# Examples:
1736# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1737# ejunit org.blinkenlights.jid3.test.AllTests
1738#
1739# @param $1 - -cp or -classpath
1740# @param $2 - classpath; junit and recorded dependencies get appended
1741# @param $@ - the rest of the parameters are passed to java
1742# ------------------------------------------------------------------------------
1743ejunit() {
1744 debug-print-function ${FUNCNAME} $*
1745
1746 local pkgs
1747 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1748 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1749 done
1750
1751 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1752 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1753 cp="${2}:${cp}"
1754 shift 2
1755 else
1756 cp=".:${cp}"
1757 fi
1758
1759 local runner=junit.textui.TestRunner
1760 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1761 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1762}
1763
1764# ------------------------------------------------------------------------------
1302# @section-end helper 1765# @section-end helper
1303# ------------------------------------------------------------------------------ 1766# ------------------------------------------------------------------------------
1304 1767
1305# ------------------------------------------------------------------------------ 1768# ------------------------------------------------------------------------------
1306# @section-begin build 1769# @section-begin build
1312 1775
1313# ------------------------------------------------------------------------------ 1776# ------------------------------------------------------------------------------
1314# @ebuild-function eant 1777# @ebuild-function eant
1315# 1778#
1316# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1779# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1317# compiler. 1780# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1318# 1781# variables:
1782# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1783# gentoo.classpath property. Be sure to call
1784# java-ant_rewrite-classpath in src_unpack.
1785# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1786# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1319# ------------------------------------------------------------------------------ 1787# ------------------------------------------------------------------------------
1320eant() { 1788eant() {
1321 debug-print-function ${FUNCNAME} $* 1789 debug-print-function ${FUNCNAME} $*
1322 1790
1323 # FIXME get this working 1791 if [[ ${EBUILD_PHASE} = compile ]]; then
1324# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1792 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1793 # finally get rid of the hooks without breaking stuff
1794
1795 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1796 && java-ant_ignore-system-classes "${S}/build.xml"
1797
1798 if hasq java-ant-2 ${INHERITED}; then
1799 java-ant_bsfix
1800 fi
1801
1802 # eant can be called multiple times
1803 JAVA_PKG_BSFIX="off"
1804
1805 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1806 echo "Searching for bundled jars:"
1807 java-pkg_find-normal-jars || echo "None found."
1808 echo "Searching for bundled classes (no output if none found):"
1809 find "${WORKDIR}" -name "*.class"
1810 echo "Search done."
1811 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1812 fi
1813 fi
1814
1815 if ! hasq java-ant-2 ${INHERITED}; then
1816 local msg="You should inherit java-ant-2 when using eant"
1325# java-pkg_announce-qa-violation \ 1817 java-pkg_announce-qa-violation "${msg}"
1326# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1327# fi 1818 fi
1328 1819
1329 local antflags="-Dnoget=true" 1820 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1821
1330 java-pkg_init-compiler_ 1822 java-pkg_init-compiler_
1331 local compiler="${GENTOO_COMPILER}" 1823 local compiler="${GENTOO_COMPILER}"
1332 1824
1333 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1825 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1334
1335 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1826 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1336 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1827 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1337 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1828 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1338 fi 1829 fi
1339 1830
1352 if is-java-strict; then 1843 if is-java-strict; then
1353 einfo "Disabling system classpath for ant" 1844 einfo "Disabling system classpath for ant"
1354 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1845 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1355 fi 1846 fi
1356 1847
1357 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1848 for arg in "${@}"; do
1358 antflags="${antflags} -debug" 1849 if [[ ${arg} = -lib ]]; then
1850 if is-java-strict; then
1851 eerror "You should not use the -lib argument to eant because it will fail"
1852 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1853 eerror "or ant properties to make dependencies available."
1854 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1855 eerror "split ant (>=dev-java/ant-core-1.7)."
1856 die "eant -lib is deprecated/forbidden"
1857 else
1858 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1859 echo "more info."
1860 fi
1861 fi
1862 done
1863
1864 # we use this in src_* so we run ant from /
1865 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1866 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1867 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1868
1869 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1870 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1871
1872 if is-java-strict; then
1873 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1874 if [[ -z "${ANT_TASKS}" ]]; then
1875 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1876 fi
1877 else
1878 # if ant-tasks is not set by ebuild or forced, activate all of them
1879 ANT_TASKS="${ANT_TASKS:-all}"
1880 fi
1881
1882 # at this point, ANT_TASKS should be "all", "none" or explicit list
1883 if [[ "${ANT_TASKS}" == "all" ]]; then
1884 einfo "Using all available ANT_TASKS"
1885 elif [[ "${ANT_TASKS}" == "none" ]]; then
1886 einfo "Disabling all optional ANT_TASKS"
1887 else
1888 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1889 fi
1890
1891 export ANT_TASKS
1892 fi
1893
1894 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1895 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1896
1897 local gcp="${EANT_GENTOO_CLASSPATH}"
1898 local getjarsarg=""
1899
1900 if [[ ${EBUILD_PHASE} = "test" ]]; then
1901 antflags="${antflags} -DJunit.present=true"
1902 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1903 getjarsarg="--with-dependencies"
1904 fi
1905
1906 local cp
1907
1908 for atom in ${gcp}; do
1909 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1910 done
1911
1912 if [[ ${cp} ]]; then
1913 # It seems ant does not like single quotes around ${cp}
1914 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1359 fi 1915 fi
1360 1916
1361 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1917 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1918 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1362 ant ${antflags} "${@}" || die "eant failed" 1919 ant ${antflags} "${@}" || die "eant failed"
1363
1364} 1920}
1365 1921
1366# ------------------------------------------------------------------------------ 1922# ------------------------------------------------------------------------------
1367# @ebuild-function ejavac 1923# @ebuild-function ejavac
1368# 1924#
1465# 2021#
1466# ----------------------------------------------------------------------------- 2022# -----------------------------------------------------------------------------
1467java-pkg_init() { 2023java-pkg_init() {
1468 unset JAVAC 2024 unset JAVAC
1469 unset JAVA_HOME 2025 unset JAVA_HOME
2026
2027 # People do all kinds of weird things.
2028 # http://forums.gentoo.org/viewtopic-p-3943166.html
2029 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2030 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2031 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2032 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2033 ewarn "sun-jdk vms and and as such break configure scripts that"
2034 ewarn "use it (for example app-office/openoffice) so we filter it out."
2035 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2036 ewarn "make.conf for example) to silence this warning or"
2037 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2038 fi
2039
2040 if [[ -z ${accept} ]]; then
2041 unset _JAVA_OPTIONS
2042 # phase hooks make this run many times without this
2043 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2044 fi
2045
2046 if java-pkg_func-exists ant_src_unpack; then
2047 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2048 fi
2049
1470 java-pkg_init_paths_ 2050 java-pkg_init_paths_
1471 java-pkg_switch-vm 2051 java-pkg_switch-vm
1472 PATH=${JAVA_HOME}/bin:${PATH} 2052 PATH=${JAVA_HOME}/bin:${PATH}
1473 2053
1474 # TODO we will probably want to set JAVAC and JAVACFLAGS 2054 # TODO we will probably want to set JAVAC and JAVACFLAGS
1479 # When users have crazy classpaths some packages can fail to compile. 2059 # When users have crazy classpaths some packages can fail to compile.
1480 # and everything should work with empty CLASSPATH. 2060 # and everything should work with empty CLASSPATH.
1481 # This also helps prevent unexpected dependencies on random things 2061 # This also helps prevent unexpected dependencies on random things
1482 # from the CLASSPATH. 2062 # from the CLASSPATH.
1483 unset CLASSPATH 2063 unset CLASSPATH
2064
2065 # Unset external ANT_ stuff
2066 unset ANT_TASKS
2067 unset ANT_OPTS
1484} 2068}
1485 2069
1486# ------------------------------------------------------------------------------ 2070# ------------------------------------------------------------------------------
1487# @function-internal java-pkg-init-compiler_ 2071# @function-internal java-pkg-init-compiler_
1488# 2072#
1632# Writes the package.env out to disk. 2216# Writes the package.env out to disk.
1633# 2217#
1634# ------------------------------------------------------------------------------ 2218# ------------------------------------------------------------------------------
1635# TODO change to do-write, to match everything else 2219# TODO change to do-write, to match everything else
1636java-pkg_do_write_() { 2220java-pkg_do_write_() {
2221 debug-print-function ${FUNCNAME} $*
1637 java-pkg_init_paths_ 2222 java-pkg_init_paths_
1638 # Create directory for package.env 2223 # Create directory for package.env
1639 dodir "${JAVA_PKG_SHAREPATH}" 2224 dodir "${JAVA_PKG_SHAREPATH}"
1640 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2225 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2226 "${JAVA_PKG_DEPEND_FILE}" || -f \
2227 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1641 # Create package.env 2228 # Create package.env
1642 ( 2229 (
1643 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2230 echo "DESCRIPTION=\"${DESCRIPTION}\""
1644 echo "GENERATION=\"2\"" 2231 echo "GENERATION=\"2\""
1645 2232
1646 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2233 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1647 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2234 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1648 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2235 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1649 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2236 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2237 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2238 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2239 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
1650 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2240 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1651 ) > "${JAVA_PKG_ENV}" 2241 ) > "${JAVA_PKG_ENV}"
1652 2242
1653 # register target/source 2243 # register target/source
1654 local target="$(java-pkg_get-target)" 2244 local target="$(java-pkg_get-target)"
1665 2255
1666 2256
1667 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2257 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1668 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2258 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1669 2259
2260 # extra env variables
2261 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2262 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2263 # nested echo to remove leading/trailing spaces
2264 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2265 >> "${JAVA_PKG_ENV}" || die
2266 fi
2267
1670 # Strip unnecessary leading and trailing colons 2268 # Strip unnecessary leading and trailing colons
1671 # TODO try to cleanup if possible 2269 # TODO try to cleanup if possible
1672 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2270 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2271 else
2272 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2273 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2274 debug-print "write package.env."
1673 fi 2275 fi
1674} 2276}
1675 2277
1676# ------------------------------------------------------------------------------ 2278# ------------------------------------------------------------------------------
1677# @internal-function java-pkg_record-jar_ 2279# @internal-function java-pkg_record-jar_
1678# 2280#
1679# Record a dependency to the package.env 2281# Record an (optional) dependency to the package.env
1680# 2282# @param --optional - record dependency as optional
2283# @param $1 - package to record
2284# @param $2 - (optional) jar of package to record
1681# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
1682JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2286JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2287JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
1683 2288
1684java-pkg_record-jar_() { 2289java-pkg_record-jar_() {
1685 debug-print-function ${FUNCNAME} $* 2290 debug-print-function ${FUNCNAME} $*
2291
2292 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2293 if [[ "${1}" == "--optional" ]]; then
2294 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2295 shift
2296 fi
1686 2297
1687 local pkg=${1} jar=${2} append 2298 local pkg=${1} jar=${2} append
1688 if [[ -z "${jar}" ]]; then 2299 if [[ -z "${jar}" ]]; then
1689 append="${pkg}" 2300 append="${pkg}"
1690 else 2301 else
1691 append="$(basename ${jar})@${pkg}" 2302 append="$(basename ${jar})@${pkg}"
1692 fi 2303 fi
1693 2304
1694 echo ${append} >> ${JAVA_PKG_DEPEND} 2305 echo "${append}" >> "${depend_file}"
1695} 2306}
1696 2307
1697# ------------------------------------------------------------------------------ 2308# ------------------------------------------------------------------------------
1698# @internal-function java-pkg_append_ 2309# @internal-function java-pkg_append_
1699# 2310#
1759# 2370#
1760# ------------------------------------------------------------------------------ 2371# ------------------------------------------------------------------------------
1761java-pkg_setup-vm() { 2372java-pkg_setup-vm() {
1762 debug-print-function ${FUNCNAME} $* 2373 debug-print-function ${FUNCNAME} $*
1763 2374
2375 export LANG="C" LC_ALL="C"
2376
1764 local vendor="$(java-pkg_get-vm-vendor)" 2377 local vendor="$(java-pkg_get-vm-vendor)"
1765 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2378 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1766 addpredict "/dev/random" 2379 addpredict "/dev/random"
1767 elif [[ "${vendor}" == "ibm" ]]; then 2380 elif [[ "${vendor}" == "ibm" ]]; then
1768 addpredict "/proc/self/maps" 2381 addpredict "/proc/self/maps"
1769 addpredict "/proc/cpuinfo" 2382 addpredict "/proc/cpuinfo"
1770 export LANG="C" LC_ALL="C"
1771 elif [[ "${vendor}" == "jrockit" ]]; then 2383 elif [[ "${vendor}" == "jrockit" ]]; then
1772 addpredict "/proc/cpuinfo" 2384 addpredict "/proc/cpuinfo"
1773 fi 2385 fi
1774} 2386}
1775 2387
1879 2491
1880 #TODO If you know a better solution let us know. 2492 #TODO If you know a better solution let us know.
1881 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2493 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1882 2494
1883 local tann="${T}/announced-vm" 2495 local tann="${T}/announced-vm"
2496 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2497 # if people have for example modified eclasses some where
1884 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2498 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1885 # Add a check for setup/preinst phase... to avoid duplicate outputs
1886 # for when FEATURES=buildpkg
1887 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1888 then
1889 einfo "Using: $(java-config -f)" 2499 einfo "Using: $(java-config -f)"
1890 [[ ! -f "${tann}" ]] && touch "${tann}" 2500 [[ ! -f "${tann}" ]] && touch "${tann}"
1891 fi
1892 fi 2501 fi
1893 2502
1894 else 2503 else
1895 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2504 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
1896 fi 2505 fi
1926 einfo "Classes" 2535 einfo "Classes"
1927 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2536 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1928 fi 2537 fi
1929} 2538}
1930 2539
1931# TODO document 2540# ------------------------------------------------------------------------------
2541# @internal-function java-pkg_verify-classes
2542#
1932# Verify that the classes were compiled for the right source / target 2543# Verify that the classes were compiled for the right source / target. Dies if
2544# not.
2545# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2546# ------------------------------------------------------------------------------
1933java-pkg_verify-classes() { 2547java-pkg_verify-classes() {
1934 ebegin "Verifying java class versions"
1935 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2548 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1936 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2549 local target=$(java-pkg_get-target)
2550 local result
2551 local log="${T}/class-version-verify.log"
2552 if [[ -n "${1}" ]]; then
2553 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1937 result=$? 2554 result=$?
1938 eend ${result}
1939 if [[ ${result} == 0 ]]; then
1940 einfo "All good"
1941 else 2555 else
1942 ewarn "Possible problem" 2556 ebegin "Verifying java class versions (target: ${target})"
1943 die "Bad class files found" 2557 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2558 result=$?
2559 eend ${result}
2560 fi
2561 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2562 if [[ ${result} != 0 ]]; then
2563 eerror "Incorrect bytecode version found"
2564 [[ -n "${1}" ]] && eerror "in file: ${1}"
2565 eerror "See ${log} for more details."
2566 die "Incorrect bytecode found"
2567 fi
2568}
2569
2570# ----------------------------------------------------------------------------
2571# @internal-function java-pkg_ensure-dep
2572# Check that a package being used in jarfrom, getjars and getjar is contained
2573# within DEPEND or RDEPEND.
2574# @param $1 - empty - check both vars; "runtime" or "build" - check only
2575# RDEPEND, resp. DEPEND
2576# @param $2 - Package name and slot.
2577
2578java-pkg_ensure-dep() {
2579 debug-print-function ${FUNCNAME} $*
2580
2581 local limit_to="${1}"
2582 local target_pkg="${2}"
2583 local dev_error=""
2584
2585 local stripped_pkg=$(echo "${target_pkg}" | sed \
2586 's/-[0-9]*\(\.[0-9]\)*$//')
2587
2588 debug-print "Matching against: ${stripped_pkg}"
2589
2590 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2591 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2592 dev_error="${dev_error} declared in DEPEND."
2593 if is-java-strict; then
2594 eerror "${dev_error}"
2595 die "${dev_error}"
2596 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2597 eerror "${dev_error}"
2598 elog "Because you have this package installed the package will"
2599 elog "build without problems, but please report this to"
2600 elog "http://bugs.gentoo.org"
2601 fi
2602 fi
2603
2604 if [[ ${limit_to} != build ]]; then
2605 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2606 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2607 dev_error="The ebuild is attempting to use ${target_pkg},"
2608 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2609 dev_error="${dev_error} or PDEPEND."
2610 if is-java-strict; then
2611 eerror "${dev_error}"
2612 die "${dev_error}"
2613 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2614 eerror "${dev_error}"
2615 elog "The package will build without problems, but may fail to run"
2616 elog "if you don't have ${target_pkg} installed, so please report"
2617 elog "this to http://bugs.gentoo.org"
2618 fi
2619 fi
2620 fi
1944 fi 2621 fi
1945} 2622}
1946 2623
1947# ------------------------------------------------------------------------------ 2624# ------------------------------------------------------------------------------
1948# @section-end internal 2625# @section-end internal
1949# ------------------------------------------------------------------------------ 2626# ------------------------------------------------------------------------------
1950 2627
1951java-pkg_check-phase() { 2628java-pkg_check-phase() {
1952 local phase=${1} 2629 local phase=${1}
1953 local funcname=${2} 2630 local funcname=${FUNCNAME[1]}
1954 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2631 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
1955 java-pkg_announce-qa-violation \
1956 "${funcname} used outside of src_${phase}" 2632 local msg="${funcname} used outside of src_${phase}"
2633 java-pkg_announce-qa-violation "${msg}"
1957 fi 2634 fi
1958} 2635}
1959 2636
1960java-pkg_check-versioned-jar() { 2637java-pkg_check-versioned-jar() {
1961 local jar=${1} 2638 local jar=${1}
1970 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2647 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1971 fi 2648 fi
1972} 2649}
1973 2650
1974java-pkg_announce-qa-violation() { 2651java-pkg_announce-qa-violation() {
1975 if is-java-strict; then 2652 local nodie
2653 if [[ ${1} == "--nodie" ]]; then
2654 nodie="true"
2655 shift
2656 fi
1976 echo "Java QA Notice: $@" >&2 2657 echo "Java QA Notice: $@" >&2
1977 increment-qa-violations 2658 increment-qa-violations
1978 fi 2659 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
1979} 2660}
1980 2661
1981increment-qa-violations() { 2662increment-qa-violations() {
1982 let "JAVA_PKG_QA_VIOLATIONS+=1" 2663 let "JAVA_PKG_QA_VIOLATIONS+=1"
1983 export JAVA_PKG_QA_VIOLATIONS 2664 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.92

  ViewVC Help
Powered by ViewVC 1.1.20