/[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.48 Revision 1.49
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.48 2007/01/21 21:12:52 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.49 2007/01/25 11:46:22 caster 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
757# Example: get a specific jar from xerces slot 2, and name it diffrently 757# Example: get a specific jar from xerces slot 2, and name it diffrently
758# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 758# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
759# Example: get junit.jar which is needed only for building 759# Example: get junit.jar which is needed only for building
760# java-pkg_jar-from --build-only junit junit.jar 760# java-pkg_jar-from --build-only junit junit.jar
761# 761#
762# @param $1 - (optional) "--build-only" makes the jar(s) not added into 762# @param $opt
763# package.env DEPEND line. 763# --build-only - makes the jar(s) not added into package.env DEPEND line.
764# (assumed automatically when called inside src_test)
765# --with-dependencies - get jars also from requested package's dependencies
766# transitively.
767# --into $dir - symlink jar(s) into $dir (must exist) instead of .
764# @param $1 - Package to get jars from. 768# @param $1 - Package to get jars from.
765# @param $2 - jar from package. If not specified, all jars will be used. 769# @param $2 - jar from package. If not specified, all jars will be used.
766# @param $3 - When a single jar is specified, destination filename of the 770# @param $3 - When a single jar is specified, destination filename of the
767# symlink. Defaults to the name of the jar. 771# symlink. Defaults to the name of the jar.
768# ------------------------------------------------------------------------------ 772# ------------------------------------------------------------------------------
769# TODO could probably be cleaned up a little 773# TODO could probably be cleaned up a little
770java-pkg_jar-from() { 774java-pkg_jar-from() {
771 debug-print-function ${FUNCNAME} $* 775 debug-print-function ${FUNCNAME} $*
772 776
773 local build_only="" 777 local build_only=""
778 local destdir="."
779 local deep=""
780
781 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
774 782
775 if [[ "${1}" = "--build-only" || "${EBUILD_PHASE}" == "test" ]]; then 783 while [[ "${1}" == --* ]]; do
784 if [[ "${1}" = "--build-only" ]]; then
776 build_only="true" 785 build_only="true"
786 elif [[ "${1}" = "--with-dependencies" ]]; then
787 deep="--with-dependencies"
788 elif [[ "${1}" = "--into" ]]; then
789 destdir="${2}"
790 shift
791 else
792 die "java-pkg_jar-from called with unknown parameter: ${1}"
793 fi
777 shift 794 shift
778 fi 795 done
779
780 if [[ "${1}" = "--with-dependencies" ]]; then
781 local deep="--with-dependencies"
782 shift
783 fi
784 796
785 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 797 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
786 798
787 [[ -z ${target_pkg} ]] && die "Must specify a package" 799 [[ -z ${target_pkg} ]] && die "Must specify a package"
788 800
792 local error_msg="There was a problem getting the classpath for ${target_pkg}." 804 local error_msg="There was a problem getting the classpath for ${target_pkg}."
793 local classpath 805 local classpath
794 classpath="$(java-config ${deep} --classpath=${target_pkg})" 806 classpath="$(java-config ${deep} --classpath=${target_pkg})"
795 [[ $? != 0 ]] && die ${error_msg} 807 [[ $? != 0 ]] && die ${error_msg}
796 808
809 pushd ${destdir} > /dev/null \
810 || die "failed to change directory to ${destdir}"
797 local jar 811 local jar
798 for jar in ${classpath//:/ }; do 812 for jar in ${classpath//:/ }; do
799 local jar_name=$(basename "${jar}") 813 local jar_name=$(basename "${jar}")
800 if [[ ! -f "${jar}" ]] ; then 814 if [[ ! -f "${jar}" ]] ; then
801 debug-print "${jar} from ${target_pkg} does not exist" 815 debug-print "${jar} from ${target_pkg} does not exist"
814 || die "Failed to make symlink from ${jar} to ${destjar}" 828 || die "Failed to make symlink from ${jar} to ${destjar}"
815 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 829 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
816 return 0 830 return 0
817 fi 831 fi
818 done 832 done
833 popd > /dev/null
819 # if no target was specified, we're ok 834 # if no target was specified, we're ok
820 if [[ -z "${target_jar}" ]] ; then 835 if [[ -z "${target_jar}" ]] ; then
821 return 0 836 return 0
822 # otherwise, die bitterly 837 # otherwise, die bitterly
823 else 838 else
847# Example: Get the classpath for xerces-2 and xalan, 862# Example: Get the classpath for xerces-2 and xalan,
848# java-pkg_getjars xerces-2,xalan 863# java-pkg_getjars xerces-2,xalan
849# Example Return: 864# Example Return:
850# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 865# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
851# 866#
852# @param $1 - (optional) "--build-only" makes the jar(s) not added into 867# @param $opt
853# package.env DEPEND line. 868# --build-only - makes the jar(s) not added into package.env DEPEND line.
869# (assumed automatically when called inside src_test)
870# --with-dependencies - get jars also from requested package's dependencies
871# transitively.
854# @param $2 - list of packages to get jars from 872# @param $1 - list of packages to get jars from
855# (passed to java-config --classpath) 873# (passed to java-config --classpath)
856# ------------------------------------------------------------------------------ 874# ------------------------------------------------------------------------------
857java-pkg_getjars() { 875java-pkg_getjars() {
858 debug-print-function ${FUNCNAME} $* 876 debug-print-function ${FUNCNAME} $*
859 877
860 if [[ "${1}" = "--build-only" || "${EBUILD_PHASE}" == "test" ]]; then
861 local build_only="true" 878 local build_only=""
879 local deep=""
880
881 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
882
883 while [[ "${1}" == --* ]]; do
884 if [[ "${1}" = "--build-only" ]]; then
885 build_only="true"
886 elif [[ "${1}" = "--with-dependencies" ]]; then
887 deep="--with-dependencies"
888 else
889 die "java-pkg_jar-from called with unknown parameter: ${1}"
890 fi
862 shift 891 shift
863 fi 892 done
864 893
865 if [[ "${1}" = "--with-dependencies" ]]; then
866 local deep="--with-dependencies"
867 shift
868 fi
869
870 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only" 894 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
871 895
872 local classpath pkgs="${1}" 896 local classpath pkgs="${1}"
873 jars="$(java-config ${deep} --classpath=${pkgs})" 897 jars="$(java-config ${deep} --classpath=${pkgs})"
874 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 898 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
875 debug-print "${pkgs}:${jars}" 899 debug-print "${pkgs}:${jars}"
905# @example 929# @example
906# java-pkg_getjar xerces-2 xml-apis.jar 930# java-pkg_getjar xerces-2 xml-apis.jar
907# @example-return 931# @example-return
908# /usr/share/xerces-2/lib/xml-apis.jar 932# /usr/share/xerces-2/lib/xml-apis.jar
909# 933#
910# @param $1 - (optional) "--build-only" makes the jar not added into 934# @param $opt
911# package.env DEPEND line. 935# --build-only - makes the jar not added into package.env DEPEND line.
912# @param $1 - package to use 936# @param $1 - package to use
913# @param $2 - jar to get 937# @param $2 - jar to get
914# ------------------------------------------------------------------------------ 938# ------------------------------------------------------------------------------
915java-pkg_getjar() { 939java-pkg_getjar() {
916 debug-print-function ${FUNCNAME} $* 940 debug-print-function ${FUNCNAME} $*
917 941
918 local build_only="" 942 local build_only=""
943
944 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
919 945
920 if [[ "${1}" = "--build-only" || "${EBUILD_PHASE}" == "test" ]]; then 946 while [[ "${1}" == --* ]]; do
947 if [[ "${1}" = "--build-only" ]]; then
921 build_only="true" 948 build_only="true"
949 else
950 die "java-pkg_jar-from called with unknown parameter: ${1}"
951 fi
922 shift 952 shift
923 fi 953 done
954
955 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
924 956
925 local pkg="${1}" target_jar="${2}" jar 957 local pkg="${1}" target_jar="${2}" jar
926 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 958 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
927 [[ -z ${target_jar} ]] && die "Must specify jar to get" 959 [[ -z ${target_jar} ]] && die "Must specify jar to get"
928 960

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

  ViewVC Help
Powered by ViewVC 1.1.20