/[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.33 Revision 1.63
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.33 2006/12/07 02:27:22 flameeyes Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.63 2007/03/03 20:37:35 betelgeuse Exp $
10 10
11 11
12# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
13# @eclass-begin 13# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
36# ----------------------------------------------------------------------------- 36# -----------------------------------------------------------------------------
37 37
38# Make sure we use java-config-2 38# Make sure we use java-config-2
39export WANT_JAVA_CONFIG="2" 39export WANT_JAVA_CONFIG="2"
40 40
41# 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# -----------------------------------------------------------------------------
42JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
43 66
44# ----------------------------------------------------------------------------- 67# -----------------------------------------------------------------------------
45# @variable-internal JAVA_PKG_E_DEPEND 68# @variable-internal JAVA_PKG_E_DEPEND
46# 69#
47# This is a convience variable to be used from the other java eclasses. This is 70# 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 71# the version of java-config we want to use. We also need a recent version
49# portage, that includes phase hooks. 72# portage, that includes phase hooks.
50# ----------------------------------------------------------------------------- 73# -----------------------------------------------------------------------------
51JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}"
52 75
53# ----------------------------------------------------------------------------- 76# -----------------------------------------------------------------------------
54# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
55# @variable-default yes 78# @variable-default yes
56# 79#
130# @note This should only be used internally or for testing. 153# @note This should only be used internally or for testing.
131# @example Use jikes and javac, in that order 154# @example Use jikes and javac, in that order
132# JAVA_PKG_FORCE_COMPILER="jikes javac" 155# JAVA_PKG_FORCE_COMPILER="jikes javac"
133# ----------------------------------------------------------------------------- 156# -----------------------------------------------------------------------------
134 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
170# -----------------------------------------------------------------------------
171
135# TODO document me 172# TODO document me
136JAVA_PKG_QA_VIOLATIONS=0 173JAVA_PKG_QA_VIOLATIONS=0
137 174
138# ----------------------------------------------------------------------------- 175# -----------------------------------------------------------------------------
139# @section-end variables 176# @section-end variables
146# 183#
147# These are used to install Java-related things, such as jars, Javadocs, JNI 184# These are used to install Java-related things, such as jars, Javadocs, JNI
148# libraries, etc. 185# libraries, etc.
149# ----------------------------------------------------------------------------- 186# -----------------------------------------------------------------------------
150 187
188# -----------------------------------------------------------------------------
189# @ebuild-function java-pkg_doexamples
190#
191# Installs given arguments to /usr/share/doc/${PF}/examples
192# If you give it only one parameter and it is a directory it will install
193# everything in that directory to the examples directory.
194#
195# @example
196# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/*
198#
199# @param $* - list of files to install
200# ------------------------------------------------------------------------------
201java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $*
203
204 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205
206 java-pkg_check-phase install
207
208 local dest=/usr/share/doc/${PF}/examples
209 if [[ ${#} = 1 && -d ${1} ]]; then
210 INSDESTTREE="${dest}" doins -r ${1}/* || die "Installing examples failed"
211 else
212 INSDESTTREE="${dest}" doins -r "${@}" || die "Installing examples failed"
213 fi
214}
151 215
152# ----------------------------------------------------------------------------- 216# -----------------------------------------------------------------------------
153# @ebuild-function java-pkg_dojar 217# @ebuild-function java-pkg_dojar
154# 218#
155# Installs any number of jars. 219# Installs any number of jars.
174 # Create JARDEST if it doesn't exist 238 # Create JARDEST if it doesn't exist
175 dodir ${JAVA_PKG_JARDEST} 239 dodir ${JAVA_PKG_JARDEST}
176 240
177 local jar 241 local jar
178 # for each jar 242 # for each jar
179 for jar in "$@"; do 243 for jar in "${@}"; do
180 local jar_basename=$(basename "${jar}") 244 local jar_basename=$(basename "${jar}")
181 245
182 java-pkg_check-versioned-jar ${jar_basename} 246 java-pkg_check-versioned-jar ${jar_basename}
183 247
184 # check if it exists 248 # check if it exists
185 if [[ -e "${jar}" ]] ; then 249 if [[ -e "${jar}" ]] ; then
250 # Don't overwrite if jar has already been installed with the same
251 # name
252 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
253 if [[ -e "${dest}" ]]; then
254 ewarn "Overwriting ${dest}"
255 fi
256
186 # install it into JARDEST if it's a non-symlink 257 # install it into JARDEST if it's a non-symlink
187 if [[ ! -L "${jar}" ]] ; then 258 if [[ ! -L "${jar}" ]] ; then
259 #but first check class version when in strict mode.
260 is-java-strict && java-pkg_verify-classes "${jar}"
261
188 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 262 INSDESTTREE="${JAVA_PKG_JARDEST}" \
189 doins "${jar}" || die "failed to install ${jar}" 263 doins "${jar}" || die "failed to install ${jar}"
190 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 264 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
191 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 265 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
192 # make a symlink to the original jar if it's symlink 266 # make a symlink to the original jar if it's symlink
203 277
204 java-pkg_do_write_ 278 java-pkg_do_write_
205} 279}
206 280
207 281
282# ------------------------------------------------------------------------------
283# @internal-function depend-java-query
284#
285# Wrapper for the depend-java-query binary to enable passing USE in env.
286# Using env variables keeps this eclass working with java-config versions that
287# do not handle use flags.
288# ------------------------------------------------------------------------------
289
290depend-java-query() {
291 # Used to have a which call here but it caused endless loops for some people
292 # that had some weird bashrc voodoo for which.
293 USE="${USE}" /usr/bin/depend-java-query "${@}"
294}
208 295
209# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
210# @ebuild-function java-pkg_regjar 297# @ebuild-function java-pkg_regjar
211# 298#
212# Records an already installed jar in the package.env 299# Records an already installed jar in the package.env
243 [[ ${#} -lt 1 ]] && die "at least one argument needed" 330 [[ ${#} -lt 1 ]] && die "at least one argument needed"
244 331
245 java-pkg_init_paths_ 332 java-pkg_init_paths_
246 333
247 local jar jar_dir jar_file 334 local jar jar_dir jar_file
248 for jar in "$@"; do 335 for jar in "${@}"; do
249 # TODO use java-pkg_check-versioned-jar 336 # TODO use java-pkg_check-versioned-jar
250 if [[ -e "${jar}" ]]; then 337 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
338 [[ -d "${jar}" || -d "${D}${jar}" ]] \
339 && die "Called ${FUNCNAME} on a directory $*"
340
341 #check that class version correct when in strict mode
342 is-java-strict && java-pkg_verify-classes "${jar}"
343
251 # nelchael: we should strip ${D} in this case too, here's why: 344 # nelchael: we should strip ${D} in this case too, here's why:
252 # imagine such call: 345 # imagine such call:
253 # java-pkg_regjar ${D}/opt/java/*.jar 346 # java-pkg_regjar ${D}/opt/java/*.jar
254 # such call will fall into this case (-e ${jar}) and will 347 # such call will fall into this case (-e ${jar}) and will
255 # record paths with ${D} in package.env 348 # record paths with ${D} in package.env
256 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 349 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
257 elif [[ -e "${D}${jar}" ]]; then
258 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
259 else 350 else
260 die "${jar} does not exist" 351 die "${jar} does not exist"
261 fi 352 fi
262 done 353 done
263 354
264 java-pkg_do_write_ 355 java-pkg_do_write_
265} 356}
266
267 357
268# ------------------------------------------------------------------------------ 358# ------------------------------------------------------------------------------
269# @ebuild-function java-pkg_newjar 359# @ebuild-function java-pkg_newjar
270# 360#
271# Installs a jar with a new name 361# Installs a jar with a new name
282 local original_jar="${1}" 372 local original_jar="${1}"
283 local new_jar="${2:-${PN}.jar}" 373 local new_jar="${2:-${PN}.jar}"
284 local new_jar_dest="${T}/${new_jar}" 374 local new_jar_dest="${T}/${new_jar}"
285 375
286 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 376 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
287 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 377 [[ ! -f ${original_jar} ]] \
378 && die "${original_jar} does not exist or is not a file!"
288 379
289 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 380 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
290 cp "${original_jar}" "${new_jar_dest}" \ 381 cp "${original_jar}" "${new_jar_dest}" \
291 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 382 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
292 java-pkg_dojar "${new_jar_dest}" 383 java-pkg_dojar "${new_jar_dest}"
341 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 432 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
342 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 433 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
343 # otherwise make a symlink to the symlink's origin 434 # otherwise make a symlink to the symlink's origin
344 else 435 else
345 # TODO use dosym 436 # TODO use dosym
437 ln -s "$(readlink "${lib}")" \
346 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 438 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
347 debug-print "${lib} is a symlink, linking accordanly" 439 debug-print "${lib} is a symlink, linking accordanly"
348 fi 440 fi
349 # otherwise die 441 # otherwise die
350 else 442 else
351 die "${lib} does not exist" 443 die "${lib} does not exist"
505 java-pkg_init_paths_ 597 java-pkg_init_paths_
506 598
507 local zip_name="${PN}-src.zip" 599 local zip_name="${PN}-src.zip"
508 local zip_path="${T}/${zip_name}" 600 local zip_path="${T}/${zip_name}"
509 local dir 601 local dir
510 for dir in ${@}; do 602 for dir in "${@}"; do
511 local dir_parent=$(dirname "${dir}") 603 local dir_parent=$(dirname "${dir}")
512 local dir_name=$(basename "${dir}") 604 local dir_name=$(basename "${dir}")
513 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 605 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
514 zip -q -r ${zip_path} ${dir_name} -i '*.java' 606 zip -q -r ${zip_path} ${dir_name} -i '*.java'
515 local result=$? 607 local result=$?
540# @param $1 - filename of launcher to create 632# @param $1 - filename of launcher to create
541# @param $2 - options, as follows: 633# @param $2 - options, as follows:
542# --main the.main.class.too.start 634# --main the.main.class.too.start
543# --jar /the/jar/too/launch.jar or just <name>.jar 635# --jar /the/jar/too/launch.jar or just <name>.jar
544# --java_args 'Extra arguments to pass to java' 636# --java_args 'Extra arguments to pass to java'
545# --pkg_args 'Extra arguments too pass to the package' 637# --pkg_args 'Extra arguments to pass to the package'
546# --pwd 638# --pwd Directory the launcher changes to before executing java
547# -into 639# -into Directory to install the launcher to, instead of /usr/bin
548# -pre 640# -pre Prepend contents of this file to the launcher
549# ------------------------------------------------------------------------------ 641# ------------------------------------------------------------------------------
550java-pkg_dolauncher() { 642java-pkg_dolauncher() {
551 debug-print-function ${FUNCNAME} $* 643 debug-print-function ${FUNCNAME} $*
552 644
553 java-pkg_check-phase install 645 java-pkg_check-phase install
565 local var_tmp="${T}/launcher_variables_tmp" 657 local var_tmp="${T}/launcher_variables_tmp"
566 local target_dir pre 658 local target_dir pre
567 659
568 # Process the other the rest of the arguments 660 # Process the other the rest of the arguments
569 while [[ -n "${1}" && -n "${2}" ]]; do 661 while [[ -n "${1}" && -n "${2}" ]]; do
570 local var=${1} value=${2} 662 local var="${1}" value="${2}"
571 if [[ "${var:0:2}" == "--" ]]; then 663 if [[ "${var:0:2}" == "--" ]]; then
572 local var=${var:2} 664 local var=${var:2}
573 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}" 665 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
574 local gjl_${var}="${value}" 666 local gjl_${var}="${value}"
575 elif [[ "${var}" == "-into" ]]; then 667 elif [[ "${var}" == "-into" ]]; then
594 fi 686 fi
595 fi 687 fi
596 688
597 # Write the actual script 689 # Write the actual script
598 echo "#!/bin/bash" > "${target}" 690 echo "#!/bin/bash" > "${target}"
599 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 691 if [[ -n "${pre}" ]]; then
692 if [[ -f "${pre}" ]]; then
693 cat "${pre}" >> "${target}"
694 else
695 die "-pre specified file '${pre}' does not exist"
696 fi
697 fi
600 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 698 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
601 cat "${var_tmp}" >> "${target}" 699 cat "${var_tmp}" >> "${target}"
602 rm -f "${var_tmp}" 700 rm -f "${var_tmp}"
603 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 701 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
604 702
696# Example: get a specific jar from xerces slot 2, and name it diffrently 794# Example: get a specific jar from xerces slot 2, and name it diffrently
697# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 795# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
698# Example: get junit.jar which is needed only for building 796# Example: get junit.jar which is needed only for building
699# java-pkg_jar-from --build-only junit junit.jar 797# java-pkg_jar-from --build-only junit junit.jar
700# 798#
701# @param $1 - (optional) "--build-only" makes the jar(s) not added into 799# @param $opt
702# package.env DEPEND line. 800# --build-only - makes the jar(s) not added into package.env DEPEND line.
801# (assumed automatically when called inside src_test)
802# --with-dependencies - get jars also from requested package's dependencies
803# transitively.
804# --into $dir - symlink jar(s) into $dir (must exist) instead of .
703# @param $1 - Package to get jars from. 805# @param $1 - Package to get jars from.
704# @param $2 - jar from package. If not specified, all jars will be used. 806# @param $2 - jar from package. If not specified, all jars will be used.
705# @param $3 - When a single jar is specified, destination filename of the 807# @param $3 - When a single jar is specified, destination filename of the
706# symlink. Defaults to the name of the jar. 808# symlink. Defaults to the name of the jar.
707# ------------------------------------------------------------------------------ 809# ------------------------------------------------------------------------------
708# TODO could probably be cleaned up a little 810# TODO could probably be cleaned up a little
709java-pkg_jar-from() { 811java-pkg_jar-from() {
710 debug-print-function ${FUNCNAME} $* 812 debug-print-function ${FUNCNAME} $*
711 813
712 local build_only="" 814 local build_only=""
815 local destdir="."
816 local deep=""
713 817
818 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
819
820 while [[ "${1}" == --* ]]; do
714 if [[ "${1}" = "--build-only" ]]; then 821 if [[ "${1}" = "--build-only" ]]; then
715 build_only="true" 822 build_only="true"
823 elif [[ "${1}" = "--with-dependencies" ]]; then
824 deep="--with-dependencies"
825 elif [[ "${1}" = "--into" ]]; then
826 destdir="${2}"
827 shift
828 else
829 die "java-pkg_jar-from called with unknown parameter: ${1}"
830 fi
716 shift 831 shift
717 fi 832 done
718 833
719 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 834 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
720 835
721 [[ -z ${target_pkg} ]] && die "Must specify a package" 836 [[ -z ${target_pkg} ]] && die "Must specify a package"
722 837
723 # default destjar to the target jar 838 # default destjar to the target jar
724 [[ -z "${destjar}" ]] && destjar="${target_jar}" 839 [[ -z "${destjar}" ]] && destjar="${target_jar}"
725 840
726 local error_msg="There was a problem getting the classpath for ${target_pkg}." 841 local error_msg="There was a problem getting the classpath for ${target_pkg}."
727 local classpath 842 local classpath
728 classpath="$(java-config --classpath=${target_pkg})" 843 classpath="$(java-config ${deep} --classpath=${target_pkg})"
729 [[ $? != 0 ]] && die ${error_msg} 844 [[ $? != 0 ]] && die ${error_msg}
845
846 pushd ${destdir} > /dev/null \
847 || die "failed to change directory to ${destdir}"
848
849 # When we have commas this functions is called to bring jars from multiple
850 # packages. This affects recording of dependencencies because that syntax uses :
851 # if we don't change them to : gjl and java-config -d -p break
852 if [[ ${target_pkg} = *,* ]]; then
853 build_only="true"
854 java-pkg_record-jar_ ${target_pkg//,/:}
855 fi
730 856
731 local jar 857 local jar
732 for jar in ${classpath//:/ }; do 858 for jar in ${classpath//:/ }; do
733 local jar_name=$(basename "${jar}") 859 local jar_name=$(basename "${jar}")
734 if [[ ! -f "${jar}" ]] ; then 860 if [[ ! -f "${jar}" ]] ; then
745 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 871 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
746 [[ -f "${destjar}" ]] && rm "${destjar}" 872 [[ -f "${destjar}" ]] && rm "${destjar}"
747 ln -snf "${jar}" "${destjar}" \ 873 ln -snf "${jar}" "${destjar}" \
748 || die "Failed to make symlink from ${jar} to ${destjar}" 874 || die "Failed to make symlink from ${jar} to ${destjar}"
749 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 875 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
876 popd > /dev/null
750 return 0 877 return 0
751 fi 878 fi
752 done 879 done
880 popd > /dev/null
753 # if no target was specified, we're ok 881 # if no target was specified, we're ok
754 if [[ -z "${target_jar}" ]] ; then 882 if [[ -z "${target_jar}" ]] ; then
755 return 0 883 return 0
756 # otherwise, die bitterly 884 # otherwise, die bitterly
757 else 885 else
781# Example: Get the classpath for xerces-2 and xalan, 909# Example: Get the classpath for xerces-2 and xalan,
782# java-pkg_getjars xerces-2,xalan 910# java-pkg_getjars xerces-2,xalan
783# Example Return: 911# Example Return:
784# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 912# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
785# 913#
786# @param $1 - (optional) "--build-only" makes the jar(s) not added into 914# @param $opt
787# package.env DEPEND line. 915# --build-only - makes the jar(s) not added into package.env DEPEND line.
916# (assumed automatically when called inside src_test)
917# --with-dependencies - get jars also from requested package's dependencies
918# transitively.
788# @param $2 - list of packages to get jars from 919# @param $1 - list of packages to get jars from
789# (passed to java-config --classpath) 920# (passed to java-config --classpath)
790# ------------------------------------------------------------------------------ 921# ------------------------------------------------------------------------------
791java-pkg_getjars() { 922java-pkg_getjars() {
792 debug-print-function ${FUNCNAME} $* 923 debug-print-function ${FUNCNAME} $*
793 924
794 [[ ${#} -lt 1 || ${#} -gt 2 ]] && die "${FUNCNAME} takes only one or two arguments" 925 local build_only=""
926 local deep=""
795 927
928 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
929
930 while [[ "${1}" == --* ]]; do
796 if [[ "${1}" = "--build-only" ]]; then 931 if [[ "${1}" = "--build-only" ]]; then
797 local build_only="true" 932 build_only="true"
933 elif [[ "${1}" = "--with-dependencies" ]]; then
934 deep="--with-dependencies"
935 else
936 die "java-pkg_jar-from called with unknown parameter: ${1}"
937 fi
798 shift 938 shift
799 fi 939 done
940
941 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
800 942
801 local classpath pkgs="${1}" 943 local classpath pkgs="${1}"
802 jars="$(java-config --classpath=${pkgs})" 944 jars="$(java-config ${deep} --classpath=${pkgs})"
803 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 945 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
804 debug-print "${pkgs}:${jars}" 946 debug-print "${pkgs}:${jars}"
805 947
806 if [[ -z "${classpath}" ]]; then 948 if [[ -z "${classpath}" ]]; then
807 classpath="${jars}" 949 classpath="${jars}"
834# @example 976# @example
835# java-pkg_getjar xerces-2 xml-apis.jar 977# java-pkg_getjar xerces-2 xml-apis.jar
836# @example-return 978# @example-return
837# /usr/share/xerces-2/lib/xml-apis.jar 979# /usr/share/xerces-2/lib/xml-apis.jar
838# 980#
839# @param $1 - (optional) "--build-only" makes the jar not added into 981# @param $opt
840# package.env DEPEND line. 982# --build-only - makes the jar not added into package.env DEPEND line.
841# @param $1 - package to use 983# @param $1 - package to use
842# @param $2 - jar to get 984# @param $2 - jar to get
843# ------------------------------------------------------------------------------ 985# ------------------------------------------------------------------------------
844java-pkg_getjar() { 986java-pkg_getjar() {
845 debug-print-function ${FUNCNAME} $* 987 debug-print-function ${FUNCNAME} $*
846 988
847 local build_only="" 989 local build_only=""
848 990
991 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
992
993 while [[ "${1}" == --* ]]; do
849 if [[ "${1}" = "--build-only" ]]; then 994 if [[ "${1}" = "--build-only" ]]; then
850 build_only="true" 995 build_only="true"
996 else
997 die "java-pkg_jar-from called with unknown parameter: ${1}"
998 fi
851 shift 999 shift
852 fi 1000 done
1001
1002 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
853 1003
854 local pkg="${1}" target_jar="${2}" jar 1004 local pkg="${1}" target_jar="${2}" jar
855 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1005 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
856 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1006 [[ -z ${target_jar} ]] && die "Must specify jar to get"
857 1007
999# 1149#
1000# export DEPEND="${DEPEND} ${depstr}" 1150# export DEPEND="${DEPEND} ${depstr}"
1001# export RDEPEND="${RDEPEND} ${depstr}" 1151# export RDEPEND="${RDEPEND} ${depstr}"
1002#} 1152#}
1003 1153
1154# ------------------------------------------------------------------------------
1155# @ebuild-function java-pkg_find-normal-jars
1156#
1157# Find the files with suffix .jar file in the given directory or $WORKDIR
1158#
1159# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1160# ------------------------------------------------------------------------------
1161java-pkg_find-normal-jars() {
1162 local dir=$1
1163 [[ "${dir}" ]] || dir="${WORKDIR}"
1164 local found
1165 for jar in $(find "${dir}" -name "*.jar" -type f); do
1166 echo "${jar}"
1167 found="true"
1168 done
1169 [[ "${found}" ]]
1170 return $?
1171}
1172
1173# ------------------------------------------------------------------------------
1174# @ebuild-function java-pkg_ensure-no-bundled-jars
1175#
1176# Try to locate bundled jar files in ${WORKDIR} and die if found.
1004# This should be used after S has been populated with symlinks to jars 1177# This function should be called after WORKDIR has been populated with symlink
1005# TODO document 1178# to system jar files or bundled jars removed.
1179# ------------------------------------------------------------------------------
1006java-pkg_ensure-no-bundled-jars() { 1180java-pkg_ensure-no-bundled-jars() {
1007 debug-print-function ${FUNCNAME} $* 1181 debug-print-function ${FUNCNAME} $*
1008 pushd ${WORKDIR} >/dev/null 2>/dev/null
1009 1182
1010 local bundled_jars=$(find . -name "*.jar" -type f) 1183 local bundled_jars=$(java-pkg_find-normal-jars)
1011 if [[ -n ${bundled_jars} ]]; then 1184 if [[ -n ${bundled_jars} ]]; then
1012 echo "Bundled jars found:" 1185 echo "Bundled jars found:"
1013 local jar 1186 local jar
1014 for jar in ${bundled_jars}; do 1187 for jar in ${bundled_jars}; do
1015 echo $(pwd)${jar/./} 1188 echo $(pwd)${jar/./}
1016 done 1189 done
1017 die "Bundled jars found!" 1190 die "Bundled jars found!"
1018
1019 fi 1191 fi
1020 popd >/dev/null 2>/dev/null
1021} 1192}
1022 1193
1023# ------------------------------------------------------------------------------ 1194# ------------------------------------------------------------------------------
1024# @internal-function java-pkg_ensure-vm-version-sufficient 1195# @internal-function java-pkg_ensure-vm-version-sufficient
1025# 1196#
1174# @ebuild-function java-pkg_get-target 1345# @ebuild-function java-pkg_get-target
1175# 1346#
1176# Determines what target version should be used, for passing to -target. 1347# Determines what target version should be used, for passing to -target.
1177# If you don't care about lower versions, you can set _WANT_TARGET to the 1348# If you don't care about lower versions, you can set _WANT_TARGET to the
1178# version of your JDK. 1349# version of your JDK.
1179# Remember doing this will mostly like cause things to break.
1180# Doesn't allow it to be lower then the one in depend.
1181# Doesn't allow it to be higher then the active vm.
1182# 1350#
1183# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1351# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1184# ------------------------------------------------------------------------------ 1352# ------------------------------------------------------------------------------
1185java-pkg_get-target() { 1353java-pkg_get-target() {
1186 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1187 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1188 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1189 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1190 echo ${JAVA_PKG_WANT_TARGET}
1191 else
1192 echo ${min}
1193 fi
1194 else
1195 echo ${min}
1196 fi
1197
1198 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1354 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1199} 1355}
1200 1356
1201java-pkg_get-javac() { 1357java-pkg_get-javac() {
1202 debug-print-function ${FUNCNAME} $* 1358 debug-print-function ${FUNCNAME} $*
1203 1359
1292 die "No GCJ support found!" 1448 die "No GCJ support found!"
1293 fi 1449 fi
1294} 1450}
1295 1451
1296java-pkg_ensure-test() { 1452java-pkg_ensure-test() {
1297 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1453 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1454 && hasq test ${IUSE} && ! use test;
1455 then
1298 eerror "You specified FEATURES=test, but USE=test is needed" 1456 eerror "You specified FEATURES=test, but USE=test is needed"
1299 eerror "to pull in the additional dependencies for testing" 1457 eerror "to pull in the additional dependencies for testing"
1300 die "Need USE=test enabled" 1458 die "Need USE=test enabled"
1301 fi 1459 fi
1302} 1460}
1303 1461
1304# ------------------------------------------------------------------------------ 1462# ------------------------------------------------------------------------------
1463# @ebuild-function java-pkg_register-ant-task
1464#
1465# Register this package as ant task, so that ant will load it when no specific
1466# ANT_TASKS are specified. Note that even without this registering, all packages
1467# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1468# packages, but can be also used by other ebuilds that used to symlink their
1469# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1470# compatibility.
1471#
1472# @param --version x.y Register only for ant version x.y (otherwise for any ant
1473# version). Used by the ant-* packages to prevent loading of mismatched
1474# ant-core ant tasks after core was updated, before the tasks are updated,
1475# without a need for blockers.
1476# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1477# ------------------------------------------------------------------------------
1478java-pkg_register-ant-task() {
1479 local TASKS_DIR="tasks"
1480
1481 # check for --version x.y parameters
1482 while [[ -n "${1}" && -n "${2}" ]]; do
1483 local var="${1#--}"
1484 local val="${2}"
1485 if [[ "${var}" == "version" ]]; then
1486 TASKS_DIR="tasks-${val}"
1487 else
1488 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1489 fi
1490 shift 2
1491 done
1492
1493 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1494
1495 dodir /usr/share/ant/${TASKS_DIR}
1496 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1497}
1498
1499# ------------------------------------------------------------------------------
1500# @internal-function java-pkg_ant-tasks-from-deps
1501#
1502# Function to determine ANT_TASKS from DEPEND variable for backwards
1503# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1504# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1505# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1506# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1507# be a problem, the worst it can do is activace all tasks when not needed.
1508# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1509# insufficient dependencies, otherwise all available tasks are used for
1510# backwards compatilbility.
1511#
1512# @return "all" or "none"
1513# ------------------------------------------------------------------------------
1514java-pkg_ant-tasks-from-deps() {
1515 local found_ant found_ant_tasks
1516
1517 for dep in ${DEPEND}
1518 do
1519 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1520 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1521 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1522 done
1523
1524 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1525 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1526 echo "all"
1527 else
1528 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1529 # so we deactivate all tasks that may be installed
1530 echo "none"
1531 fi
1532}
1533
1534# ------------------------------------------------------------------------------
1535# @internal-function java-pkg_ant-tasks-depend
1536#
1537# Translates the WANT_ANT_TASKS variable into valid dependencies.
1538# ------------------------------------------------------------------------------
1539java-pkg_ant-tasks-depend() {
1540 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1541
1542 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1543 local DEP=""
1544 for i in ${WANT_ANT_TASKS}
1545 do
1546 if [[ ${i} != ant-* ]]; then
1547 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1548 return 1
1549 fi
1550 DEP="${DEP}dev-java/${i} "
1551 done
1552 echo ${DEP}
1553 return 0
1554 else
1555 return 0
1556 fi
1557}
1558
1559# ------------------------------------------------------------------------------
1305# @section-end helper 1560# @section-end helper
1306# ------------------------------------------------------------------------------ 1561# ------------------------------------------------------------------------------
1307 1562
1308# ------------------------------------------------------------------------------ 1563# ------------------------------------------------------------------------------
1309# @section-begin build 1564# @section-begin build
1315 1570
1316# ------------------------------------------------------------------------------ 1571# ------------------------------------------------------------------------------
1317# @ebuild-function eant 1572# @ebuild-function eant
1318# 1573#
1319# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1574# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1320# compiler. 1575# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1321# 1576# variables:
1577# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1578# gentoo.classpath property. Be sure to call
1579# java-ant_rewrite-classpath in src_unpack.
1580# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1322# ------------------------------------------------------------------------------ 1581# ------------------------------------------------------------------------------
1323eant() { 1582eant() {
1324 debug-print-function ${FUNCNAME} $* 1583 debug-print-function ${FUNCNAME} $*
1325 1584
1326 # FIXME get this working 1585 # FIXME get this working
1327# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1586# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1328# java-pkg_announce-qa-violation \ 1587# java-pkg_announce-qa-violation \
1329# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1588# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1330# fi 1589# fi
1331 1590
1332 local antflags 1591 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1592 local msg="You should inherit java-ant-2 when using eant"
1593 java-pkg_announce-qa-violation ${msg}
1594 die ${msg}
1595 fi
1596
1597 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1598
1333 java-pkg_init-compiler_ 1599 java-pkg_init-compiler_
1334 local compiler="${GENTOO_COMPILER}" 1600 local compiler="${GENTOO_COMPILER}"
1335 1601
1336 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1602 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1337 1603
1339 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1605 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1340 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1606 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1341 fi 1607 fi
1342 1608
1343 if [[ ${compiler} != "javac" ]]; then 1609 if [[ ${compiler} != "javac" ]]; then
1344 antflags="-Dbuild.compiler=${build_compiler}" 1610 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1345 # Figure out any extra stuff to put on the classpath for compilers aside 1611 # Figure out any extra stuff to put on the classpath for compilers aside
1346 # from javac 1612 # from javac
1347 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1613 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1348 # java-config -p 1614 # java-config -p
1349 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1615 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1355 if is-java-strict; then 1621 if is-java-strict; then
1356 einfo "Disabling system classpath for ant" 1622 einfo "Disabling system classpath for ant"
1357 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1623 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1358 fi 1624 fi
1359 1625
1360 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1626 for arg in "${@}"; do
1361 antflags="${antflags} -debug" 1627 if [[ ${arg} = -lib ]]; then
1628 if is-java-strict; then
1629 eerror "You should not use the -lib argument to eant because it will fail"
1630 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1631 eerror "or ant properties to make dependencies available."
1632 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1633 eerror "split ant (>=dev-java/ant-core-1.7)."
1634 die "eant -lib is deprecated/forbidden"
1635 else
1636 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1637 echo "more info."
1638 fi
1639 fi
1640 done
1641
1642 if has_version ">=dev-java/ant-core-1.7.0"; then
1643 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1644 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1645
1646 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1647 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1648
1649 if is-java-strict; then
1650 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1651 if [[ -z "${ANT_TASKS}" ]]; then
1652 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1653 fi
1654 else
1655 # if ant-tasks is not set by ebuild or forced, activate all of them
1656 ANT_TASKS="${ANT_TASKS:-all}"
1657 fi
1658
1659 # at this point, ANT_TASKS should be "all", "none" or explicit list
1660 if [[ "${ANT_TASKS}" == "all" ]]; then
1661 einfo "Using all available ANT_TASKS"
1662 elif [[ "${ANT_TASKS}" == "none" ]]; then
1663 einfo "Disabling all optional ANT_TASKS"
1664 else
1665 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1666 fi
1667
1668 export ANT_TASKS
1669 fi
1670
1671 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1672 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1673
1674 local gcp="${EANT_GENTOO_CLASSPATH}"
1675
1676 if [[ ${EBUILD_PHASE} = "test" ]]; then
1677 antflags="${antflags} -DJunit.present=true"
1678 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1679 fi
1680
1681 local cp
1682
1683 for atom in ${gcp}; do
1684 cp="${cp}:$(java-pkg_getjars ${atom})"
1685 done
1686
1687 if [[ ${cp} ]]; then
1688 # It seems ant does not like single quotes around ${cp}
1689 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1362 fi 1690 fi
1363 1691
1364 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1692 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1693 debug-print "Calling ant: ${antflags} ${@}"
1365 ant ${antflags} "${@}" || die "eant failed" 1694 ant ${antflags} "${@}" || die "eant failed"
1366 1695
1367} 1696}
1368 1697
1369# ------------------------------------------------------------------------------ 1698# ------------------------------------------------------------------------------
1439# @return string - Name of the target to create javadocs 1768# @return string - Name of the target to create javadocs
1440# ------------------------------------------------------------------------------ 1769# ------------------------------------------------------------------------------
1441use_doc() { 1770use_doc() {
1442 use doc && echo ${@:-javadoc} 1771 use doc && echo ${@:-javadoc}
1443} 1772}
1773
1444 1774
1445# ------------------------------------------------------------------------------ 1775# ------------------------------------------------------------------------------
1446# @section-end build 1776# @section-end build
1447# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1448 1778
1481 # When users have crazy classpaths some packages can fail to compile. 1811 # When users have crazy classpaths some packages can fail to compile.
1482 # and everything should work with empty CLASSPATH. 1812 # and everything should work with empty CLASSPATH.
1483 # This also helps prevent unexpected dependencies on random things 1813 # This also helps prevent unexpected dependencies on random things
1484 # from the CLASSPATH. 1814 # from the CLASSPATH.
1485 unset CLASSPATH 1815 unset CLASSPATH
1816
1817 # Unset external ANT_ stuff
1818 unset ANT_TASKS
1819 unset ANT_OPTS
1486} 1820}
1487 1821
1488# ------------------------------------------------------------------------------ 1822# ------------------------------------------------------------------------------
1489# @function-internal java-pkg-init-compiler_ 1823# @function-internal java-pkg-init-compiler_
1490# 1824#
1832# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2166# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1833# verify that the current VM is sufficient. 2167# verify that the current VM is sufficient.
1834# Setup the environment for the VM being used. 2168# Setup the environment for the VM being used.
1835# ------------------------------------------------------------------------------ 2169# ------------------------------------------------------------------------------
1836java-pkg_switch-vm() { 2170java-pkg_switch-vm() {
2171 debug-print-function ${FUNCNAME} $*
2172
1837 if java-pkg_needs-vm; then 2173 if java-pkg_needs-vm; then
1838 # Use the VM specified by JAVA_PKG_FORCE_VM 2174 # Use the VM specified by JAVA_PKG_FORCE_VM
1839 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2175 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1840 # If you're forcing the VM, I hope you know what your doing... 2176 # If you're forcing the VM, I hope you know what your doing...
2177 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1841 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2178 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1842 # if we're allowed to switch the vm... 2179 # if we're allowed to switch the vm...
1843 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2180 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1844 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2181 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1845 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2182 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1925 einfo "Classes" 2262 einfo "Classes"
1926 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2263 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1927 fi 2264 fi
1928} 2265}
1929 2266
1930# TODO document 2267# ------------------------------------------------------------------------------
2268# @internal-function java-pkg_verify-classes
2269#
1931# Verify that the classes were compiled for the right source / target 2270# Verify that the classes were compiled for the right source / target. Dies if
2271# not.
2272# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2273# ------------------------------------------------------------------------------
1932java-pkg_verify-classes() { 2274java-pkg_verify-classes() {
1933 ebegin "Verifying java class versions"
1934 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2275 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1935 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2276 local target=$(java-pkg_get-target)
2277 local result
2278 local log="${T}/class-version-verify.log"
2279 if [[ -n "${1}" ]]; then
2280 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1936 result=$? 2281 result=$?
1937 eend ${result}
1938 if [[ ${result} == 0 ]]; then
1939 einfo "All good"
1940 else 2282 else
1941 ewarn "Possible problem" 2283 ebegin "Verifying java class versions (target: ${target})"
1942 die "Bad class files found" 2284 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2285 result=$?
2286 eend ${result}
2287 fi
2288 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2289 if [[ ${result} != 0 ]]; then
2290 eerror "Incorrect bytecode version found"
2291 [[ -n "${1}" ]] && eerror "in file: ${1}"
2292 eerror "See ${log} for more details."
2293 die "Incorrect bytecode found"
1943 fi 2294 fi
1944} 2295}
1945 2296
1946# ------------------------------------------------------------------------------ 2297# ------------------------------------------------------------------------------
1947# @section-end internal 2298# @section-end internal

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.63

  ViewVC Help
Powered by ViewVC 1.1.20