/[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.15 Revision 1.16
642# @ebuild-function java-pkg_jar-from 642# @ebuild-function java-pkg_jar-from
643# 643#
644# Makes a symlink to a jar from a certain package 644# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 645# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 646# You can use this function to replace these bundled dependencies.
647# The dependency is recorded into package.env DEPEND line, unless "--build-only"
648# is passed as the very first argument, for jars that have to be present only
649# at build time and are not needed on runtime (junit testing etc).
647# 650#
648# Example: get all jars from xerces slot 2 651# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 652# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 653# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 654# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 655# 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 656# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
657# Example: get junit.jar which is needed only for building
658# java-pkg_jar-from --build-only junit junit.jar
654# 659#
660# @param $1 - (optional) "--build-only" makes the jar(s) not added into
661# package.env DEPEND line.
655# @param $1 - Package to get jars from. 662# @param $1 - Package to get jars from.
656# @param $2 - jar from package. If not specified, all jars will be used. 663# @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 664# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 665# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 666# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 667# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 668java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 669 debug-print-function ${FUNCNAME} $*
670
671 local build_only=""
672
673 if [[ "${1}" = "--build-only" ]]; then
674 build_only="true"
675 shift
676 fi
663 677
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 678 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 679
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 680 [[ -z ${target_pkg} ]] && die "Must specify a package"
667 681
681 # If no specific target jar was indicated, link it 695 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 696 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 697 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 698 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 699 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 700 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 701 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 702 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 703 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 704 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 705 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 706 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
693 return 0 707 return 0
694 fi 708 fi
695 done 709 done
696 # if no target was specified, we're ok 710 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 711 if [[ -z "${target_jar}" ]] ; then
714# ------------------------------------------------------------------------------ 728# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 729# @ebuild-function java-pkg_getjars
716# 730#
717# Get the classpath provided by any number of packages 731# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 732# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
719# 733# The providing packages are recorded as dependencies into package.env DEPEND
734# line, unless "--build-only" is passed as the very first argument, for jars
735# that have to be present only at build time and are not needed on runtime
736# (junit testing etc).
737#
720# Example: Get the classpath for xerces-2, 738# Example: Get the classpath for xerces-2,
721# java-pkg_getjars xerces-2 xalan 739# java-pkg_getjars xerces-2 xalan
722# Example Return: 740# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 741# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 742#
743# @param $1 - (optional) "--build-only" makes the jar(s) not added into
744# package.env DEPEND line.
725# @param $@ - list of packages to get jars from 745# @param $@ - list of packages to get jars from
726# ------------------------------------------------------------------------------ 746# ------------------------------------------------------------------------------
727java-pkg_getjars() { 747java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 748 debug-print-function ${FUNCNAME} $*
749
750 local build_only=""
751
752 if [[ "${1}" = "--build-only" ]]; then
753 build_only="true"
754 shift
755 fi
729 756
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 757 [[ ${#} -lt 1 ]] && die "At least one argument needed"
731 758
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 759 # NOTE could probably just pass $@ to java-config --classpath. and return it
733 local classpath pkg 760 local classpath pkg
739 if [[ -z "${classpath}" ]]; then 766 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}" 767 classpath="${jars}"
741 else 768 else
742 classpath="${classpath}:${jars}" 769 classpath="${classpath}:${jars}"
743 fi 770 fi
744 java-pkg_record-jar_ "${pkg}" 771 # Only record jars that aren't build-only
772 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
745 done 773 done
746 echo "${classpath}" 774 echo "${classpath}"
747} 775}
748 776
749# ------------------------------------------------------------------------------ 777# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 778# @ebuild-function java-pkg_getjar
751# 779#
752# Get the filename of a single jar from a package 780# Get the filename of a single jar from a package
781# The providing package is recorded as runtime dependency into package.env
782# DEPEND line, unless "--build-only" is passed as the very first argument, for
783# jars that have to be present only at build time and are not needed on runtime
784# (junit testing etc).
753# 785#
754# @example 786# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 787# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 788# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 789# /usr/share/xerces-2/lib/xml-apis.jar
758# 790#
791# @param $1 - (optional) "--build-only" makes the jar not added into
792# package.env DEPEND line.
759# @param $1 - package to use 793# @param $1 - package to use
760# @param $2 - jar to get 794# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 795# ------------------------------------------------------------------------------
762java-pkg_getjar() { 796java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 797 debug-print-function ${FUNCNAME} $*
798
799 local build_only=""
800
801 if [[ "${1}" = "--build-only" ]]; then
802 build_only="true"
803 shift
804 fi
764 805
765 local pkg="${1}" target_jar="${2}" jar 806 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 807 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 808 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 809
769 # TODO check that package is actually installed 810 # TODO check that package is actually installed
770 local classpath=$(java-config --classpath=${pkg}) 811 local classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 812 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?"
772 for jar in ${classpath//:/ }; do 813 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 814 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 815 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 816 fi
776 817
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 818 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 819 # Only record jars that aren't build-only
820 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 821 echo "${jar}"
780 return 0 822 return 0
781 fi 823 fi
782 done 824 done
783 825

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20