/[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.10 Revision 1.18
559 done 559 done
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 563
564 if [[ -n "${into}" ]]; then 564 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 565 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 566 local ret=$?
567 return ${ret} 567 return ${ret}
568 else 568 else
569 dobin "${target}" 569 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 597 echo "dowar: warning, skipping directory ${war}"
598 continue 598 continue
599 else 599 else
600 warpath="${war}" 600 warpath="${war}"
601 fi 601 fi
602 602
603 # Install those files like you mean it 603 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 604 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 605 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 606 doins ${warpath}
607 done 607 done
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} $*
663 670
671 local build_only=""
672
673 if [[ "${1}" = "--build-only" ]]; then
674 build_only="true"
675 shift
676 fi
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
668 # default destjar to the target jar 682 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 683 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 684
685 local error_msg="There was a problem getting the classpath for ${target_pkg}."
686 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 687 classpath="$(java-config --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 688 [[ $? != 0 ]] && die ${error_msg}
673 689
674 local jar 690 local jar
675 for jar in ${classpath//:/ }; do 691 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 692 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 693 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 697 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 698 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 699 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 700 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 701 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 702 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 703 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 704 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 705 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 706 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 707 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 708 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
693 return 0 709 return 0
694 fi 710 fi
695 done 711 done
696 # if no target was specified, we're ok 712 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 713 if [[ -z "${target_jar}" ]] ; then
714# ------------------------------------------------------------------------------ 730# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 731# @ebuild-function java-pkg_getjars
716# 732#
717# Get the classpath provided by any number of packages 733# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 734# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
719# 735# The providing packages are recorded as dependencies into package.env DEPEND
736# line, unless "--build-only" is passed as the very first argument, for jars
737# that have to be present only at build time and are not needed on runtime
738# (junit testing etc).
739#
720# Example: Get the classpath for xerces-2, 740# Example: Get the classpath for xerces-2,
721# java-pkg_getjars xerces-2 xalan 741# java-pkg_getjars xerces-2 xalan
722# Example Return: 742# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 743# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 744#
745# @param $1 - (optional) "--build-only" makes the jar(s) not added into
746# package.env DEPEND line.
725# @param $@ - list of packages to get jars from 747# @param $@ - list of packages to get jars from
726# ------------------------------------------------------------------------------ 748# ------------------------------------------------------------------------------
727java-pkg_getjars() { 749java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 750 debug-print-function ${FUNCNAME} $*
751
752 local build_only=""
753
754 if [[ "${1}" = "--build-only" ]]; then
755 build_only="true"
756 shift
757 fi
729 758
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 759 [[ ${#} -lt 1 ]] && die "At least one argument needed"
731 760
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 761 # NOTE could probably just pass $@ to java-config --classpath. and return it
733 local classpath pkg 762 local classpath pkg
734 for pkg in ${@//,/ }; do 763 for pkg in ${@//,/ }; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do 764 #for pkg in $(echo "$@" | tr ',' ' '); do
736 jars="$(java-config --classpath=${pkg})" 765 jars="$(java-config --classpath=${pkg})"
766 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
737 debug-print "${pkg}:${jars}" 767 debug-print "${pkg}:${jars}"
738 # TODO should we ensure jars exist? 768
739 if [[ -z "${classpath}" ]]; then 769 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}" 770 classpath="${jars}"
741 else 771 else
742 classpath="${classpath}:${jars}" 772 classpath="${classpath}:${jars}"
743 fi 773 fi
744 java-pkg_record-jar_ "${pkg}" 774 # Only record jars that aren't build-only
775 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
745 done 776 done
746 echo "${classpath}" 777 echo "${classpath}"
747} 778}
748 779
749# ------------------------------------------------------------------------------ 780# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 781# @ebuild-function java-pkg_getjar
751# 782#
752# Get the filename of a single jar from a package 783# Get the filename of a single jar from a package
784# The providing package is recorded as runtime dependency into package.env
785# DEPEND line, unless "--build-only" is passed as the very first argument, for
786# jars that have to be present only at build time and are not needed on runtime
787# (junit testing etc).
753# 788#
754# @example 789# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 790# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 791# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 792# /usr/share/xerces-2/lib/xml-apis.jar
758# 793#
794# @param $1 - (optional) "--build-only" makes the jar not added into
795# package.env DEPEND line.
759# @param $1 - package to use 796# @param $1 - package to use
760# @param $2 - jar to get 797# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 798# ------------------------------------------------------------------------------
762java-pkg_getjar() { 799java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 800 debug-print-function ${FUNCNAME} $*
801
802 local build_only=""
803
804 if [[ "${1}" = "--build-only" ]]; then
805 build_only="true"
806 shift
807 fi
764 808
765 local pkg="${1}" target_jar="${2}" jar 809 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 810 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 811 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 812
769 # TODO check that package is actually installed 813 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
814 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 815 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 816 [[ $? != 0 ]] && die ${error_msg}
817
772 for jar in ${classpath//:/ }; do 818 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 819 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 820 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 821 fi
776 822
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 823 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 824 # Only record jars that aren't build-only
825 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 826 echo "${jar}"
780 return 0 827 return 0
781 fi 828 fi
782 done 829 done
783 830
1051 return 1 1098 return 1
1052 fi 1099 fi
1053 fi 1100 fi
1054} 1101}
1055 1102
1103java-pkg_set-current-vm() {
1104 export GENTOO_VM=${1}
1105}
1106
1107java-pkg_get-current-vm() {
1108 echo ${GENTOO_VM}
1109}
1110
1111java-pkg_current-vm-matches() {
1112 hasq $(java-pkg_get-current-vm) ${@}
1113 return $?
1114}
1115
1056# ------------------------------------------------------------------------------ 1116# ------------------------------------------------------------------------------
1057# @ebuild-function java-pkg_get-source 1117# @ebuild-function java-pkg_get-source
1058# 1118#
1059# Determines what source version should be used, for passing to -source. 1119# Determines what source version should be used, for passing to -source.
1060# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1120# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1180 ebeep 5 1240 ebeep 5
1181 die "No GCJ support found!" 1241 die "No GCJ support found!"
1182 fi 1242 fi
1183} 1243}
1184 1244
1245java-pkg_ensure-test() {
1246 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then
1247 eerror "You specified FEATURES=test, but USE=test is needed"
1248 eerror "to pull in the additional dependencies for testing"
1249 die "Need USE=test enabled"
1250 fi
1251}
1252
1185# ------------------------------------------------------------------------------ 1253# ------------------------------------------------------------------------------
1186# @section-end helper 1254# @section-end helper
1187# ------------------------------------------------------------------------------ 1255# ------------------------------------------------------------------------------
1188 1256
1189# ------------------------------------------------------------------------------ 1257# ------------------------------------------------------------------------------
1201# compiler. 1269# compiler.
1202# 1270#
1203# ------------------------------------------------------------------------------ 1271# ------------------------------------------------------------------------------
1204eant() { 1272eant() {
1205 debug-print-function ${FUNCNAME} $* 1273 debug-print-function ${FUNCNAME} $*
1274
1275 # FIXME get this working
1276# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1277# java-pkg_announce-qa-violation \
1278# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1279# fi
1206 1280
1207 local antflags 1281 local antflags
1208 java-pkg_init-compiler_ 1282 java-pkg_init-compiler_
1209 local compiler="${GENTOO_COMPILER}" 1283 local compiler="${GENTOO_COMPILER}"
1210 1284
1832 let "JAVA_PKG_QA_VIOLATIONS+=1" 1906 let "JAVA_PKG_QA_VIOLATIONS+=1"
1833 export JAVA_PKG_QA_VIOLATIONS 1907 export JAVA_PKG_QA_VIOLATIONS
1834} 1908}
1835 1909
1836is-java-strict() { 1910is-java-strict() {
1837 hasq java-strict ${FEATURES}; 1911 [[ -n ${JAVA_PKG_STRICT} ]]
1838 return $? 1912 return $?
1839} 1913}
1840 1914
1841# ------------------------------------------------------------------------------ 1915# ------------------------------------------------------------------------------
1842# @eclass-end 1916# @eclass-end

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20