/[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.14 Revision 1.20
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
15# 15#
16# This eclass provides functionality which is used by 16# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 18#
19# @warning 19# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 20# You probably don't want to inherit this directly from an ebuild. Instead,
21# you should inherit java-ant for Ant-based Java packages, java-pkg for other 21# you should inherit java-ant for Ant-based Java packages, java-pkg for other
22# Java packages, or java-pkg-opt for packages that have optional Java support. 22# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 23#
24# ----------------------------------------------------------------------------- 24# -----------------------------------------------------------------------------
25 25
26inherit eutils versionator multilib 26inherit eutils versionator multilib
40 40
41# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 42# @variable-internal JAVA_PKG_E_DEPEND
43# 43#
44# This is a convience variable to be used from the other java eclasses. This is 44# This is a convience variable to be used from the other java eclasses. This is
45# the version of java-config we want to use. We also need a recent version 45# the version of java-config we want to use. We also need a recent version
46# portage, that includes phase hooks. 46# portage, that includes phase hooks.
47# ----------------------------------------------------------------------------- 47# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
49 49
50# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
100# ----------------------------------------------------------------------------- 100# -----------------------------------------------------------------------------
101 101
102# ----------------------------------------------------------------------------- 102# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 103# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 104# @default /usr/share/java-config-2/compiler
105# 105#
106# Directory where compiler settings are saved, without trailing slash. 106# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 107# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 108# -----------------------------------------------------------------------------
109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
110 110
120 120
121# ----------------------------------------------------------------------------- 121# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 122# @variable-external JAVA_PKG_FORCE_COMPILER
123# 123#
124# Explicitly set a list of compilers to use. This is normally read from 124# Explicitly set a list of compilers to use. This is normally read from
125# JAVA_PKG_COMPILERS_CONF. 125# JAVA_PKG_COMPILERS_CONF.
126# 126#
127# @note This should only be used internally or for testing. 127# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 128# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 129# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 130# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 150# @ebuild-function java-pkg_dojar
151# 151#
152# Installs any number of jars. 152# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 154# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 155# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 156# Instead, use java-pkg_newjar defined below.
157# 157#
158# @example 158# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 160#
222# will not work, because: 222# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 223# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 224# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 226# doesn't exist
227# 227#
228# you have to use it as: 228# you have to use it as:
229# 229#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 231#
232# @param $@ - jars to record 232# @param $@ - jars to record
305} 305}
306 306
307 307
308# ------------------------------------------------------------------------------ 308# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 309# @ebuild-function java-pkg_doso
310# 310#
311# Installs any number of JNI libraries 311# Installs any number of JNI libraries
312# They will be installed into /usr/lib by default, but java-pkg_sointo 312# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 313# can be used change this path
314# 314#
315# Example: 315# Example:
370 java-pkg_check-phase install 370 java-pkg_check-phase install
371 371
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 372 [[ ${#} -lt 1 ]] && "at least one argument needed"
373 373
374 java-pkg_init_paths_ 374 java-pkg_init_paths_
375 375
376 local lib target_dir 376 local lib target_dir
377 for lib in "$@" ; do 377 for lib in "$@" ; do
378 # Check the absolute path of the lib 378 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 379 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 380 target_dir="$(java-pkg_expand_dir_ ${lib})"
458} 458}
459 459
460# ------------------------------------------------------------------------------ 460# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 461# @ebuild-function java-pkg_dosrc
462# 462#
463# Installs a zip containing the source for a package, so it can used in 463# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 464# from IDEs like eclipse and netbeans.
465# 465#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 466# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 467#
468# It also should be controlled by USE=source. 468# It also should be controlled by USE=source.
469# 469#
470# @example: 470# @example:
471# java-pkg_dosrc src/* 471# java-pkg_dosrc src/*
472# 472#
473# ------------------------------------------------------------------------------ 473# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 474# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 475# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 476# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 477# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 478# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 479java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 480 debug-print-function ${FUNCNAME} $*
481 481
482 [ ${#} -lt 1 ] && die "At least one argument needed" 482 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then 483 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi 485 fi
486 486
487 java-pkg_check-phase install 487 java-pkg_check-phase install
488 488
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 489 [[ ${#} -lt 1 ]] && die "At least one argument needed"
490 490
491 java-pkg_init_paths_ 491 java-pkg_init_paths_
492 492
493 local zip_name="${PN}-src.zip" 493 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 494 local zip_path="${T}/${zip_name}"
522# 522#
523# @param $1 - filename of launcher to create 523# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 524# @param $2 - options, as follows:
525# --main the.main.class.too.start 525# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 526# --jar /the/jar/too/launch.jar
527# --java_args 'Extra arguments to pass too jave' 527# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 528# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 529# --pwd
530# -into 530# -into
531# -pre 531# -pre
532# ------------------------------------------------------------------------------ 532# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 533java-pkg_dolauncher() {
540 java-pkg_init_paths_ 540 java-pkg_init_paths_
541 541
542 local name="${1}" 542 local name="${1}"
543 # TODO rename to launcher 543 # TODO rename to launcher
544 local target="${T}/${name}" 544 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 546 local target_dir pre
546 shift 547 shift
547 548
548 echo "#!/bin/bash" > "${target}" 549 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 550 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 551 local var=${1} value=${2}
551 if [[ "${var:0:2}" == "--" ]]; then 552 if [[ "${var:0:2}" == "--" ]]; then
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}"
553 elif [[ "${var}" == "-into" ]]; then 554 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 555 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 556 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 557 pre="${value}"
557 fi 558 fi
558 shift 2 559 shift 2
559 done 560 done
561
562 # Write the actual script
563 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 566 cat "${var_tmp}" >> "${target}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 567 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 568
564 if [[ -n "${into}" ]]; then 569 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 570 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 571 local ret=$?
567 return ${ret} 572 return ${ret}
568 else 573 else
569 dobin "${target}" 574 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 602 echo "dowar: warning, skipping directory ${war}"
598 continue 603 continue
599 else 604 else
600 warpath="${war}" 605 warpath="${war}"
601 fi 606 fi
602 607
603 # Install those files like you mean it 608 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 609 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 610 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 611 doins ${warpath}
607 done 612 done
642# @ebuild-function java-pkg_jar-from 647# @ebuild-function java-pkg_jar-from
643# 648#
644# Makes a symlink to a jar from a certain package 649# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 650# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 651# You can use this function to replace these bundled dependencies.
652# The dependency is recorded into package.env DEPEND line, unless "--build-only"
653# is passed as the very first argument, for jars that have to be present only
654# at build time and are not needed on runtime (junit testing etc).
647# 655#
648# Example: get all jars from xerces slot 2 656# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 657# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 658# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 659# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 660# Example: get a specific jar from xerces slot 2, and name it diffrently
653# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 661# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
662# Example: get junit.jar which is needed only for building
663# java-pkg_jar-from --build-only junit junit.jar
654# 664#
665# @param $1 - (optional) "--build-only" makes the jar(s) not added into
666# package.env DEPEND line.
655# @param $1 - Package to get jars from. 667# @param $1 - Package to get jars from.
656# @param $2 - jar from package. If not specified, all jars will be used. 668# @param $2 - jar from package. If not specified, all jars will be used.
657# @param $3 - When a single jar is specified, destination filename of the 669# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 670# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 671# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 672# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 673java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 674 debug-print-function ${FUNCNAME} $*
663 675
676 local build_only=""
677
678 if [[ "${1}" = "--build-only" ]]; then
679 build_only="true"
680 shift
681 fi
682
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 683 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 684
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 685 [[ -z ${target_pkg} ]] && die "Must specify a package"
667 686
668 # default destjar to the target jar 687 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 688 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 689
690 local error_msg="There was a problem getting the classpath for ${target_pkg}."
691 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 692 classpath="$(java-config --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 693 [[ $? != 0 ]] && die ${error_msg}
673 694
674 local jar 695 local jar
675 for jar in ${classpath//:/ }; do 696 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 697 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 698 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 702 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 703 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 704 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 705 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 706 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 707 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 708 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 709 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 710 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 711 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 712 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 713 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
693 return 0 714 return 0
694 fi 715 fi
695 done 716 done
696 # if no target was specified, we're ok 717 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 718 if [[ -z "${target_jar}" ]] ; then
714# ------------------------------------------------------------------------------ 735# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 736# @ebuild-function java-pkg_getjars
716# 737#
717# Get the classpath provided by any number of packages 738# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 739# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
740# The providing packages are recorded as dependencies into package.env DEPEND
741# line, unless "--build-only" is passed as the very first argument, for jars
742# that have to be present only at build time and are not needed on runtime
743# (junit testing etc).
719# 744#
720# Example: Get the classpath for xerces-2, 745# Example: Get the classpath for xerces-2,
721# java-pkg_getjars xerces-2 xalan 746# java-pkg_getjars xerces-2 xalan
722# Example Return: 747# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 748# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 749#
750# @param $1 - (optional) "--build-only" makes the jar(s) not added into
751# package.env DEPEND line.
725# @param $@ - list of packages to get jars from 752# @param $@ - list of packages to get jars from
726# ------------------------------------------------------------------------------ 753# ------------------------------------------------------------------------------
727java-pkg_getjars() { 754java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 755 debug-print-function ${FUNCNAME} $*
756
757 local build_only=""
758
759 if [[ "${1}" = "--build-only" ]]; then
760 build_only="true"
761 shift
762 fi
729 763
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 764 [[ ${#} -lt 1 ]] && die "At least one argument needed"
731 765
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 766 # NOTE could probably just pass $@ to java-config --classpath. and return it
733 local classpath pkg 767 local classpath pkg
734 for pkg in ${@//,/ }; do 768 for pkg in ${@//,/ }; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do 769 #for pkg in $(echo "$@" | tr ',' ' '); do
736 jars="$(java-config --classpath=${pkg})" 770 jars="$(java-config --classpath=${pkg})"
771 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
737 debug-print "${pkg}:${jars}" 772 debug-print "${pkg}:${jars}"
738 # TODO should we ensure jars exist? 773
739 if [[ -z "${classpath}" ]]; then 774 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}" 775 classpath="${jars}"
741 else 776 else
742 classpath="${classpath}:${jars}" 777 classpath="${classpath}:${jars}"
743 fi 778 fi
744 java-pkg_record-jar_ "${pkg}" 779 # Only record jars that aren't build-only
780 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
745 done 781 done
746 echo "${classpath}" 782 echo "${classpath}"
747} 783}
748 784
749# ------------------------------------------------------------------------------ 785# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 786# @ebuild-function java-pkg_getjar
751# 787#
752# Get the filename of a single jar from a package 788# Get the filename of a single jar from a package
789# The providing package is recorded as runtime dependency into package.env
790# DEPEND line, unless "--build-only" is passed as the very first argument, for
791# jars that have to be present only at build time and are not needed on runtime
792# (junit testing etc).
753# 793#
754# @example 794# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 795# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 796# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 797# /usr/share/xerces-2/lib/xml-apis.jar
758# 798#
799# @param $1 - (optional) "--build-only" makes the jar not added into
800# package.env DEPEND line.
759# @param $1 - package to use 801# @param $1 - package to use
760# @param $2 - jar to get 802# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 803# ------------------------------------------------------------------------------
762java-pkg_getjar() { 804java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 805 debug-print-function ${FUNCNAME} $*
806
807 local build_only=""
808
809 if [[ "${1}" = "--build-only" ]]; then
810 build_only="true"
811 shift
812 fi
764 813
765 local pkg="${1}" target_jar="${2}" jar 814 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 815 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 816 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 817
769 # TODO check that package is actually installed 818 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
819 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 820 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 821 [[ $? != 0 ]] && die ${error_msg}
822
772 for jar in ${classpath//:/ }; do 823 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 824 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 825 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 826 fi
776 827
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 828 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 829 # Only record jars that aren't build-only
830 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 831 echo "${jar}"
780 return 0 832 return 0
781 fi 833 fi
782 done 834 done
783 835
784 die "Could not find ${target_jar} in ${pkg}" 836 die "Could not find ${target_jar} in ${pkg}"
785 return 1 837 return 1
786} 838}
787 839
788# This function reads stdin, and based on that input, figures out how to 840# This function reads stdin, and based on that input, figures out how to
802# line="${line// /}" 854# line="${line// /}"
803# 855#
804# # format: path=jarinfo 856# # format: path=jarinfo
805# local path=${line%%=*} 857# local path=${line%%=*}
806# local jarinfo=${line##*=} 858# local jarinfo=${line##*=}
807# 859#
808# # format: jar@package 860# # format: jar@package
809# local jar=${jarinfo%%@*}.jar 861# local jar=${jarinfo%%@*}.jar
810# local package=${jarinfo##*@} 862# local package=${jarinfo##*@}
811# if [[ -n ${replace_only} ]]; then 863# if [[ -n ${replace_only} ]]; then
812# [[ ! -f $path ]] && die "No jar exists at ${path}" 864# [[ ! -f $path ]] && die "No jar exists at ${path}"
825# @section-end query 877# @section-end query
826# ------------------------------------------------------------------------------ 878# ------------------------------------------------------------------------------
827 879
828# ------------------------------------------------------------------------------ 880# ------------------------------------------------------------------------------
829# @section-begin helper 881# @section-begin helper
830# @section-summary Helper functions 882# @section-summary Helper functions
831# 883#
832# Various other functions to use from an ebuild 884# Various other functions to use from an ebuild
833# ------------------------------------------------------------------------------ 885# ------------------------------------------------------------------------------
834 886
835# ------------------------------------------------------------------------------ 887# ------------------------------------------------------------------------------
841# jdbc-stdext 893# jdbc-stdext
842# jaf 894# jaf
843# jdbc-rowset 895# jdbc-rowset
844# jms 896# jms
845# 897#
846# @param $1 - Optionally indicate that the dependencies are controlled by 898# @param $1 - Optionally indicate that the dependencies are controlled by
847# a use flag by specifying '--use' Requires $2. 899# a use flag by specifying '--use' Requires $2.
848# @param $2 - USE flag which will enable the dependencies. 900# @param $2 - USE flag which will enable the dependencies.
849# @param $@ - virtual packages to add depenedencies for 901# @param $@ - virtual packages to add depenedencies for
850# ------------------------------------------------------------------------------ 902# ------------------------------------------------------------------------------
851# TODO rewrite to parse a line based declaration file instead -- karltk 903# TODO rewrite to parse a line based declaration file instead -- karltk
945 fi 997 fi
946} 998}
947 999
948# ------------------------------------------------------------------------------ 1000# ------------------------------------------------------------------------------
949# @internal-function java-pkg_is-vm-version-sufficient 1001# @internal-function java-pkg_is-vm-version-sufficient
950# 1002#
951# @return zero - VM is sufficient 1003# @return zero - VM is sufficient
952# @return non-zero - VM is not sufficient 1004# @return non-zero - VM is not sufficient
953# ------------------------------------------------------------------------------ 1005# ------------------------------------------------------------------------------
954java-pkg_is-vm-version-sufficient() { 1006java-pkg_is-vm-version-sufficient() {
955 debug-print-function ${FUNCNAME} $* 1007 debug-print-function ${FUNCNAME} $*
975 die "Active Java VM too old" 1027 die "Active Java VM too old"
976 fi 1028 fi
977} 1029}
978 1030
979# ------------------------------------------------------------------------------ 1031# ------------------------------------------------------------------------------
980# @internal-function java-pkg_is-vm-version-eq 1032# @internal-function java-pkg_is-vm-version-eq
981# 1033#
982# @param $@ - VM version to compare current VM to 1034# @param $@ - VM version to compare current VM to
983# @return zero - VM versions are equal 1035# @return zero - VM versions are equal
984# @return non-zero - VM version are not equal 1036# @return non-zero - VM version are not equal
985# ------------------------------------------------------------------------------ 1037# ------------------------------------------------------------------------------
986java-pkg_is-vm-version-eq() { 1038java-pkg_is-vm-version-eq() {
1016# 1068#
1017# @param $@ - VM version to compare current to 1069# @param $@ - VM version to compare current to
1018# ------------------------------------------------------------------------------ 1070# ------------------------------------------------------------------------------
1019java-pkg_ensure-vm-version-ge() { 1071java-pkg_ensure-vm-version-ge() {
1020 debug-print-function ${FUNCNAME} $* 1072 debug-print-function ${FUNCNAME} $*
1021 1073
1022 if ! java-pkg_is-vm-version-ge "$@" ; then 1074 if ! java-pkg_is-vm-version-ge "$@" ; then
1023 debug-print "vm is not suffient" 1075 debug-print "vm is not suffient"
1024 eerror "This package requires a Java VM version >= $@" 1076 eerror "This package requires a Java VM version >= $@"
1025 einfo "Please use java-config -S to set the correct one" 1077 einfo "Please use java-config -S to set the correct one"
1026 die "Active Java VM too old" 1078 die "Active Java VM too old"
1027 fi 1079 fi
1028} 1080}
1029 1081
1030# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1031# @internal-function java-pkg_is-vm-version-ge 1083# @internal-function java-pkg_is-vm-version-ge
1032# 1084#
1033# @param $@ - VM version to compare current VM to 1085# @param $@ - VM version to compare current VM to
1034# @return zero - current VM version is greater than checked version 1086# @return zero - current VM version is greater than checked version
1035# @return non-zero - current VM version is not greater than checked version 1087# @return non-zero - current VM version is not greater than checked version
1036# ------------------------------------------------------------------------------ 1088# ------------------------------------------------------------------------------
1037java-pkg_is-vm-version-ge() { 1089java-pkg_is-vm-version-ge() {
1060java-pkg_get-current-vm() { 1112java-pkg_get-current-vm() {
1061 echo ${GENTOO_VM} 1113 echo ${GENTOO_VM}
1062} 1114}
1063 1115
1064java-pkg_current-vm-matches() { 1116java-pkg_current-vm-matches() {
1065 hasq java-pkg_get-currenv-vm ${@} 1117 hasq $(java-pkg_get-current-vm) ${@}
1066 return $? 1118 return $?
1067} 1119}
1068 1120
1069# ------------------------------------------------------------------------------ 1121# ------------------------------------------------------------------------------
1070# @ebuild-function java-pkg_get-source 1122# @ebuild-function java-pkg_get-source
1071# 1123#
1072# Determines what source version should be used, for passing to -source. 1124# Determines what source version should be used, for passing to -source.
1073# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1125# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1074# 1126#
1075# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1127# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1076# ------------------------------------------------------------------------------ 1128# ------------------------------------------------------------------------------
1081# ------------------------------------------------------------------------------ 1133# ------------------------------------------------------------------------------
1082# @ebuild-function java-pkg_get-target 1134# @ebuild-function java-pkg_get-target
1083# 1135#
1084# Determines what target version should be used, for passing to -target. 1136# Determines what target version should be used, for passing to -target.
1085# If you don't care about lower versions, you can set _WANT_TARGET to the 1137# If you don't care about lower versions, you can set _WANT_TARGET to the
1086# version of your JDK. 1138# version of your JDK.
1087# Remember doing this will mostly like cause things to break. 1139# Remember doing this will mostly like cause things to break.
1088# Doesn't allow it to be lower then the one in depend. 1140# Doesn't allow it to be lower then the one in depend.
1089# Doesn't allow it to be higher then the active vm. 1141# Doesn't allow it to be higher then the active vm.
1090# 1142#
1091# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1143# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1092# ------------------------------------------------------------------------------ 1144# ------------------------------------------------------------------------------
1093java-pkg_get-target() { 1145java-pkg_get-target() {
1094 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") 1146 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1095 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then 1147 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1096 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" 1148 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1097 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then 1149 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1098 echo ${JAVA_PKG_WANT_TARGET} 1150 echo ${JAVA_PKG_WANT_TARGET}
1099 else 1151 else
1126 # try to get value of JAVAC 1178 # try to get value of JAVAC
1127 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1179 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1128 export JAVAC=${old_javac} 1180 export JAVAC=${old_javac}
1129 1181
1130 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1182 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}"
1131 1183
1132 # check that it's executable 1184 # check that it's executable
1133 if [[ ! -x ${compiler_executable} ]]; then 1185 if [[ ! -x ${compiler_executable} ]]; then
1134 eerror "Could not find ${compiler_executable}!" 1186 eerror "Could not find ${compiler_executable}!"
1135 die "${compiler_executable} doesn't exist, or isn't executable" 1187 die "${compiler_executable} doesn't exist, or isn't executable"
1136 fi 1188 fi
1141 fi 1193 fi
1142 echo ${compiler_executable} 1194 echo ${compiler_executable}
1143} 1195}
1144 1196
1145# ------------------------------------------------------------------------------ 1197# ------------------------------------------------------------------------------
1146# @ebuild-function java-pkg_javac-args 1198# @ebuild-function java-pkg_javac-args
1147# 1199#
1148# If an ebuild uses javac directly, instead of using ejavac, it should call this 1200# If an ebuild uses javac directly, instead of using ejavac, it should call this
1149# to know what -source/-target to use. 1201# to know what -source/-target to use.
1150# 1202#
1151# @return string - arguments to pass to javac, complete with -target and -source 1203# @return string - arguments to pass to javac, complete with -target and -source
1154 debug-print-function ${FUNCNAME} $* 1206 debug-print-function ${FUNCNAME} $*
1155 1207
1156 local want_source="$(java-pkg_get-source)" 1208 local want_source="$(java-pkg_get-source)"
1157 local want_target="$(java-pkg_get-target)" 1209 local want_target="$(java-pkg_get-target)"
1158 1210
1159 local source_str="-source ${want_source}" 1211 local source_str="-source ${want_source}"
1160 local target_str="-target ${want_target}" 1212 local target_str="-target ${want_target}"
1161 1213
1162 debug-print "want source: ${want_source}" 1214 debug-print "want source: ${want_source}"
1163 debug-print "want target: ${want_target}" 1215 debug-print "want target: ${want_target}"
1164 1216
1256 1308
1257 if is-java-strict; then 1309 if is-java-strict; then
1258 einfo "Disabling system classpath for ant" 1310 einfo "Disabling system classpath for ant"
1259 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1311 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1260 fi 1312 fi
1261 1313
1262 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1314 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1263 antflags="${antflags} -debug" 1315 antflags="${antflags} -debug"
1264 fi 1316 fi
1265 1317
1266 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1318 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1267 ant ${antflags} "${@}" || die "eant failed" 1319 ant ${antflags} "${@}" || die "eant failed"
1268 1320
1269} 1321}
1270 1322
1271# ------------------------------------------------------------------------------ 1323# ------------------------------------------------------------------------------
1272# @ebuild-function ejavac 1324# @ebuild-function ejavac
1273# 1325#
1274# Javac wrapper function. Will use the appropriate compiler, based on 1326# Javac wrapper function. Will use the appropriate compiler, based on
1275# /etc/java-config/compilers.conf 1327# /etc/java-config/compilers.conf
1276# 1328#
1277# @param $@ - Arguments to be passed to the compiler 1329# @param $@ - Arguments to be passed to the compiler
1278# ------------------------------------------------------------------------------ 1330# ------------------------------------------------------------------------------
1279ejavac() { 1331ejavac() {
1287 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1339 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1288} 1340}
1289 1341
1290# ------------------------------------------------------------------------------ 1342# ------------------------------------------------------------------------------
1291# @ebuild-function java-pkg_filter-compiler 1343# @ebuild-function java-pkg_filter-compiler
1292# 1344#
1293# Used to prevent the use of some compilers. Should be used in src_compile. 1345# Used to prevent the use of some compilers. Should be used in src_compile.
1294# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1346# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1295# 1347#
1296# @param $@ - compilers to filter 1348# @param $@ - compilers to filter
1297# ------------------------------------------------------------------------------ 1349# ------------------------------------------------------------------------------
1315# ------------------------------------------------------------------------------ 1367# ------------------------------------------------------------------------------
1316# @ebuild-function use_doc 1368# @ebuild-function use_doc
1317# 1369#
1318# Helper function for getting ant to build javadocs. If the user has USE=doc, 1370# Helper function for getting ant to build javadocs. If the user has USE=doc,
1319# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1371# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1320# 1372#
1321# The output of this should be passed to ant. 1373# The output of this should be passed to ant.
1322# 1374#
1323# Example: build javadocs by calling 'javadoc' target 1375# Example: build javadocs by calling 'javadoc' target
1324# eant $(use_doc) 1376# eant $(use_doc)
1325# Example: build javadocs by calling 'apidoc' target 1377# Example: build javadocs by calling 'apidoc' target
1333} 1385}
1334 1386
1335# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1336# @section-end build 1388# @section-end build
1337# ------------------------------------------------------------------------------ 1389# ------------------------------------------------------------------------------
1338 1390
1339# ------------------------------------------------------------------------------ 1391# ------------------------------------------------------------------------------
1340# @section-begin internal 1392# @section-begin internal
1341# @section-summary Internal functions 1393# @section-summary Internal functions
1342# 1394#
1343# Do __NOT__ use any of these from an ebuild! These are only to be used from 1395# Do __NOT__ use any of these from an ebuild! These are only to be used from
1344# within the java eclasses. 1396# within the java eclasses.
1345# ------------------------------------------------------------------------------ 1397# ------------------------------------------------------------------------------
1346 1398
1347# ----------------------------------------------------------------------------- 1399# -----------------------------------------------------------------------------
1348# @function-internal java-pkg_init 1400# @function-internal java-pkg_init
1349# 1401#
1350# The purpose of this function, as the name might imply, is to initialize the 1402# The purpose of this function, as the name might imply, is to initialize the
1351# Java environment. It ensures that that there aren't any environment variables 1403# Java environment. It ensures that that there aren't any environment variables
1352# that'll muss things up. It initializes some variables, which are used 1404# that'll muss things up. It initializes some variables, which are used
1353# internally. And most importantly, it'll switch the VM if necessary. 1405# internally. And most importantly, it'll switch the VM if necessary.
1354# 1406#
1366 # TODO we will probably want to set JAVAC and JAVACFLAGS 1418 # TODO we will probably want to set JAVAC and JAVACFLAGS
1367 1419
1368 # Do some QA checks 1420 # Do some QA checks
1369 java-pkg_check-jikes 1421 java-pkg_check-jikes
1370 1422
1371 # When users have crazy classpaths some packages can fail to compile. 1423 # When users have crazy classpaths some packages can fail to compile.
1372 # and everything should work with empty CLASSPATH. 1424 # and everything should work with empty CLASSPATH.
1373 # This also helps prevent unexpected dependencies on random things 1425 # This also helps prevent unexpected dependencies on random things
1374 # from the CLASSPATH. 1426 # from the CLASSPATH.
1375 unset CLASSPATH 1427 unset CLASSPATH
1376} 1428}
1377 1429
1378# ------------------------------------------------------------------------------ 1430# ------------------------------------------------------------------------------
1379# @function-internal java-pkg-init-compiler_ 1431# @function-internal java-pkg-init-compiler_
1380# 1432#
1381# This function attempts to figure out what compiler should be used. It does 1433# This function attempts to figure out what compiler should be used. It does
1382# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1434# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1383# COMPILERS variable defined there. 1435# COMPILERS variable defined there.
1384# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1436# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1385# 1437#
1386# It will go through the list of compilers, and verify that it supports the 1438# It will go through the list of compilers, and verify that it supports the
1387# target and source that are needed. If it is not suitable, then the next 1439# target and source that are needed. If it is not suitable, then the next
1388# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1440# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1389# isn't done. 1441# isn't done.
1390# 1442#
1412 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1464 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1413 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1465 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1414 else 1466 else
1415 compilers=${JAVA_PKG_FORCE_COMPILER} 1467 compilers=${JAVA_PKG_FORCE_COMPILER}
1416 fi 1468 fi
1417 1469
1418 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1470 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1419 1471
1420 # Figure out if we should announce what compiler we're using 1472 # Figure out if we should announce what compiler we're using
1421 local compiler 1473 local compiler
1422 for compiler in ${compilers}; do 1474 for compiler in ${compilers}; do
1425 if [[ ${compiler} = "javac" ]]; then 1477 if [[ ${compiler} = "javac" ]]; then
1426 debug-print "Found javac... breaking" 1478 debug-print "Found javac... breaking"
1427 export GENTOO_COMPILER="javac" 1479 export GENTOO_COMPILER="javac"
1428 break 1480 break
1429 fi 1481 fi
1430 1482
1431 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1483 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1432 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1484 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1433 einfo "Filtering ${compiler}" 1485 einfo "Filtering ${compiler}"
1434 continue 1486 continue
1435 fi 1487 fi
1436 fi 1488 fi
1437 1489
1438 # for non-javac, we need to make sure it supports the right target and 1490 # for non-javac, we need to make sure it supports the right target and
1439 # source 1491 # source
1440 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1492 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1441 if [[ -f ${compiler_env} ]]; then 1493 if [[ -f ${compiler_env} ]]; then
1442 local desired_target="$(java-pkg_get-target)" 1494 local desired_target="$(java-pkg_get-target)"
1538 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1590 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1539 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1591 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1540 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1592 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1541 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1593 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1542 ) > "${JAVA_PKG_ENV}" 1594 ) > "${JAVA_PKG_ENV}"
1543 1595
1544 # register target/source 1596 # register target/source
1545 local target="$(java-pkg_get-target)" 1597 local target="$(java-pkg_get-target)"
1546 local source="$(java-pkg_get-source)" 1598 local source="$(java-pkg_get-source)"
1547 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1599 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1548 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1600 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1615 fi 1667 fi
1616} 1668}
1617 1669
1618# ------------------------------------------------------------------------------ 1670# ------------------------------------------------------------------------------
1619# @internal-function java-pkg_expand_dir_ 1671# @internal-function java-pkg_expand_dir_
1620# 1672#
1621# Gets the full path of the file/directory's parent. 1673# Gets the full path of the file/directory's parent.
1622# @param $1 - file/directory to find parent directory for 1674# @param $1 - file/directory to find parent directory for
1623# @return - path to $1's parent directory 1675# @return - path to $1's parent directory
1624# ------------------------------------------------------------------------------ 1676# ------------------------------------------------------------------------------
1625java-pkg_expand_dir_() { 1677java-pkg_expand_dir_() {
1717} 1769}
1718 1770
1719# ------------------------------------------------------------------------------ 1771# ------------------------------------------------------------------------------
1720# @internal-function java-pkg_switch-vm 1772# @internal-function java-pkg_switch-vm
1721# 1773#
1722# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1774# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1723# verify that the current VM is sufficient. 1775# verify that the current VM is sufficient.
1724# Setup the environment for the VM being used. 1776# Setup the environment for the VM being used.
1725# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1726java-pkg_switch-vm() { 1778java-pkg_switch-vm() {
1727 if java-pkg_needs-vm; then 1779 if java-pkg_needs-vm; then
1740 # otherwise just make sure the current VM is sufficient 1792 # otherwise just make sure the current VM is sufficient
1741 else 1793 else
1742 java-pkg_ensure-vm-version-sufficient 1794 java-pkg_ensure-vm-version-sufficient
1743 fi 1795 fi
1744 debug-print "Using: $(java-config -f)" 1796 debug-print "Using: $(java-config -f)"
1745 1797
1746 java-pkg_setup-vm 1798 java-pkg_setup-vm
1747 1799
1748 export JAVA=$(java-config --java) 1800 export JAVA=$(java-config --java)
1749 export JAVAC=$(java-config --javac) 1801 export JAVAC=$(java-config --javac)
1750 export JAVACFLAGS="$(java-pkg_javac-args)" 1802 export JAVACFLAGS="$(java-pkg_javac-args)"
1751 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1803 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1752 1804
1753 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1805 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1754 export JDK_HOME=${JAVA_HOME} 1806 export JDK_HOME=${JAVA_HOME}
1755 1807
1756 #TODO If you know a better solution let us know. 1808 #TODO If you know a better solution let us know.
1757 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1809 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1758 1810
1759 local tann="${T}/announced-vm" 1811 local tann="${T}/announced-vm"
1760 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1812 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1761 # Add a check for setup/preinst phase... to avoid duplicate outputs 1813 # Add a check for setup/preinst phase... to avoid duplicate outputs
1762 # for when FEATURES=buildpkg 1814 # for when FEATURES=buildpkg
1763 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1815 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1807# TODO document 1859# TODO document
1808# Verify that the classes were compiled for the right source / target 1860# Verify that the classes were compiled for the right source / target
1809java-pkg_verify-classes() { 1861java-pkg_verify-classes() {
1810 ebegin "Verifying java class versions" 1862 ebegin "Verifying java class versions"
1811 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 1863 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1812 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 1864 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1813 result=$? 1865 result=$?
1814 eend ${result} 1866 eend ${result}
1815 if [[ ${result} == 0 ]]; then 1867 if [[ ${result} == 0 ]]; then
1816 einfo "All good" 1868 einfo "All good"
1817 else 1869 else

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20