/[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.2 Revision 1.18
33# ----------------------------------------------------------------------------- 33# -----------------------------------------------------------------------------
34 34
35# Make sure we use java-config-2 35# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 36export WANT_JAVA_CONFIG="2"
37 37
38# TODO document
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40
38# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 42# @variable-internal JAVA_PKG_E_DEPEND
40# 43#
41# 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
42# 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
43# portage, that includes phase hooks. 46# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 47# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 49
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 52# @variable-default yes
50# 53#
206# Records an already installed jar in the package.env 209# Records an already installed jar in the package.env
207# This would mostly be used if the package has make or a custom script to 210# This would mostly be used if the package has make or a custom script to
208# install things. 211# install things.
209# 212#
210# Example: 213# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 214# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
215#
216# WARNING:
217# if you want to use shell expansion, you have to use ${D}/... as the for in
218# this function will not be able to expand the path, here's an example:
219#
220# java-pkg_regjar /opt/my-java/lib/*.jar
221#
222# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist
227#
228# you have to use it as:
229#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 231#
213# @param $@ - jars to record 232# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 233# ------------------------------------------------------------------------------
215# TODO fix me! 234# TODO should we be making sure the jar is present on ${D} or wherever?
216java-pkg_regjar() { 235java-pkg_regjar() {
217 debug-print-function ${FUNCNAME} $* 236 debug-print-function ${FUNCNAME} $*
218 237
219 java-pkg_check-phase install 238 java-pkg_check-phase install
220 239
224 243
225 local jar jar_dir jar_file 244 local jar jar_dir jar_file
226 for jar in "$@"; do 245 for jar in "$@"; do
227 # TODO use java-pkg_check-versioned-jar 246 # TODO use java-pkg_check-versioned-jar
228 if [[ -e "${jar}" ]]; then 247 if [[ -e "${jar}" ]]; then
248 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env
229 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}" 253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
230 elif [[ -e "${D}${jar}" ]]; then 254 elif [[ -e "${D}${jar}" ]]; then
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 256 else
233 die "${jar} does not exist" 257 die "${jar} does not exist"
234 fi 258 fi
255 local original_jar="${1}" 279 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 280 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 281 local new_jar_dest="${T}/${new_jar}"
258 282
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 283 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
261 285
262 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
263 cp "${original_jar}" "${new_jar_dest}" \ 287 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 288 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 289 java-pkg_dojar "${new_jar_dest}"
535 done 559 done
536 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
537 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
538 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
539 563
540 if [[ -n "${into}" ]]; then 564 if [[ -n "${target_dir}" ]]; then
541 DESTTREE="${target_dir}" dobin "${target}" 565 DESTTREE="${target_dir}" dobin "${target}"
542 local ret=$? 566 local ret=$?
543 return ${ret} 567 return ${ret}
544 else 568 else
545 dobin "${target}" 569 dobin "${target}"
573 echo "dowar: warning, skipping directory ${war}" 597 echo "dowar: warning, skipping directory ${war}"
574 continue 598 continue
575 else 599 else
576 warpath="${war}" 600 warpath="${war}"
577 fi 601 fi
578 602
579 # Install those files like you mean it 603 # Install those files like you mean it
580 INSOPTIONS="-m 0644" \ 604 INSOPTIONS="-m 0644" \
581 INSDESTTREE=${JAVA_PKG_WARDEST} \ 605 INSDESTTREE=${JAVA_PKG_WARDEST} \
582 doins ${warpath} 606 doins ${warpath}
583 done 607 done
618# @ebuild-function java-pkg_jar-from 642# @ebuild-function java-pkg_jar-from
619# 643#
620# Makes a symlink to a jar from a certain package 644# Makes a symlink to a jar from a certain package
621# A lot of java packages include dependencies in a lib/ directory 645# A lot of java packages include dependencies in a lib/ directory
622# 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).
623# 650#
624# Example: get all jars from xerces slot 2 651# Example: get all jars from xerces slot 2
625# java-pkg_jar-from xerces-2 652# java-pkg_jar-from xerces-2
626# Example: get a specific jar from xerces slot 2 653# Example: get a specific jar from xerces slot 2
627# java-pkg_jar-from xerces-2 xml-apis.jar 654# java-pkg_jar-from xerces-2 xml-apis.jar
628# 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
629# 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
630# 659#
660# @param $1 - (optional) "--build-only" makes the jar(s) not added into
661# package.env DEPEND line.
631# @param $1 - Package to get jars from. 662# @param $1 - Package to get jars from.
632# @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.
633# @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
634# symlink. Defaults to the name of the jar. 665# symlink. Defaults to the name of the jar.
635# ------------------------------------------------------------------------------ 666# ------------------------------------------------------------------------------
636# TODO could probably be cleaned up a little 667# TODO could probably be cleaned up a little
637java-pkg_jar-from() { 668java-pkg_jar-from() {
638 debug-print-function ${FUNCNAME} $* 669 debug-print-function ${FUNCNAME} $*
639 670
671 local build_only=""
672
673 if [[ "${1}" = "--build-only" ]]; then
674 build_only="true"
675 shift
676 fi
677
640 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 678 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
641 679
642 [[ -z ${target_pkg} ]] && die "Must specify a package" 680 [[ -z ${target_pkg} ]] && die "Must specify a package"
643 681
644 # default destjar to the target jar 682 # default destjar to the target jar
645 [[ -z "${destjar}" ]] && destjar="${target_jar}" 683 [[ -z "${destjar}" ]] && destjar="${target_jar}"
646 684
685 local error_msg="There was a problem getting the classpath for ${target_pkg}."
686 local classpath
647 local classpath="$(java-config --classpath=${target_pkg})" 687 classpath="$(java-config --classpath=${target_pkg})"
648 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 688 [[ $? != 0 ]] && die ${error_msg}
649 689
650 local jar 690 local jar
651 for jar in ${classpath//:/ }; do 691 for jar in ${classpath//:/ }; do
652 local jar_name=$(basename "${jar}") 692 local jar_name=$(basename "${jar}")
653 if [[ ! -f "${jar}" ]] ; then 693 if [[ ! -f "${jar}" ]] ; then
657 # If no specific target jar was indicated, link it 697 # If no specific target jar was indicated, link it
658 if [[ -z "${target_jar}" ]] ; then 698 if [[ -z "${target_jar}" ]] ; then
659 [[ -f "${target_jar}" ]] && rm "${target_jar}" 699 [[ -f "${target_jar}" ]] && rm "${target_jar}"
660 ln -snf "${jar}" \ 700 ln -snf "${jar}" \
661 || die "Failed to make symlink from ${jar} to ${jar_name}" 701 || die "Failed to make symlink from ${jar} to ${jar_name}"
662 java-pkg_record-jar_ "${target_pkg}" "${jar}" 702 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
663 # otherwise, if the current jar is the target jar, link it 703 # otherwise, if the current jar is the target jar, link it
664 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 704 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
665 [[ -f "${destjar}" ]] && rm "${destjar}" 705 [[ -f "${destjar}" ]] && rm "${destjar}"
666 ln -snf "${jar}" "${destjar}" \ 706 ln -snf "${jar}" "${destjar}" \
667 || die "Failed to make symlink from ${jar} to ${destjar}" 707 || die "Failed to make symlink from ${jar} to ${destjar}"
668 java-pkg_record-jar_ "${target_pkg}" "${jar}" 708 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
669 return 0 709 return 0
670 fi 710 fi
671 done 711 done
672 # if no target was specified, we're ok 712 # if no target was specified, we're ok
673 if [[ -z "${target_jar}" ]] ; then 713 if [[ -z "${target_jar}" ]] ; then
690# ------------------------------------------------------------------------------ 730# ------------------------------------------------------------------------------
691# @ebuild-function java-pkg_getjars 731# @ebuild-function java-pkg_getjars
692# 732#
693# Get the classpath provided by any number of packages 733# Get the classpath provided by any number of packages
694# 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'.
695# 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#
696# Example: Get the classpath for xerces-2, 740# Example: Get the classpath for xerces-2,
697# java-pkg_getjars xerces-2 xalan 741# java-pkg_getjars xerces-2 xalan
698# Example Return: 742# Example Return:
699# /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
700# 744#
745# @param $1 - (optional) "--build-only" makes the jar(s) not added into
746# package.env DEPEND line.
701# @param $@ - list of packages to get jars from 747# @param $@ - list of packages to get jars from
702# ------------------------------------------------------------------------------ 748# ------------------------------------------------------------------------------
703java-pkg_getjars() { 749java-pkg_getjars() {
704 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
705 758
706 [[ ${#} -lt 1 ]] && die "At least one argument needed" 759 [[ ${#} -lt 1 ]] && die "At least one argument needed"
707 760
708 # 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
709 local classpath pkg 762 local classpath pkg
710 for pkg in ${@//,/ }; do 763 for pkg in ${@//,/ }; do
711 #for pkg in $(echo "$@" | tr ',' ' '); do 764 #for pkg in $(echo "$@" | tr ',' ' '); do
712 jars="$(java-config --classpath=${pkg})" 765 jars="$(java-config --classpath=${pkg})"
766 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
713 debug-print "${pkg}:${jars}" 767 debug-print "${pkg}:${jars}"
714 # TODO should we ensure jars exist? 768
715 if [[ -z "${classpath}" ]]; then 769 if [[ -z "${classpath}" ]]; then
716 classpath="${jars}" 770 classpath="${jars}"
717 else 771 else
718 classpath="${classpath}:${jars}" 772 classpath="${classpath}:${jars}"
719 fi 773 fi
720 java-pkg_record-jar_ "${pkg}" 774 # Only record jars that aren't build-only
775 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
721 done 776 done
722 echo "${classpath}" 777 echo "${classpath}"
723} 778}
724 779
725# ------------------------------------------------------------------------------ 780# ------------------------------------------------------------------------------
726# @ebuild-function java-pkg_getjar 781# @ebuild-function java-pkg_getjar
727# 782#
728# 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).
729# 788#
730# @example 789# @example
731# java-pkg_getjar xerces-2 xml-apis.jar 790# java-pkg_getjar xerces-2 xml-apis.jar
732# @example-return 791# @example-return
733# /usr/share/xerces-2/lib/xml-apis.jar 792# /usr/share/xerces-2/lib/xml-apis.jar
734# 793#
794# @param $1 - (optional) "--build-only" makes the jar not added into
795# package.env DEPEND line.
735# @param $1 - package to use 796# @param $1 - package to use
736# @param $2 - jar to get 797# @param $2 - jar to get
737# ------------------------------------------------------------------------------ 798# ------------------------------------------------------------------------------
738java-pkg_getjar() { 799java-pkg_getjar() {
739 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
740 808
741 local pkg="${1}" target_jar="${2}" jar 809 local pkg="${1}" target_jar="${2}" jar
742 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 810 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
743 [[ -z ${target_jar} ]] && die "Must specify jar to get" 811 [[ -z ${target_jar} ]] && die "Must specify jar to get"
744 812
745 # 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
746 local classpath=$(java-config --classpath=${pkg}) 815 classpath=$(java-config --classpath=${pkg})
747 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 816 [[ $? != 0 ]] && die ${error_msg}
817
748 for jar in ${classpath//:/ }; do 818 for jar in ${classpath//:/ }; do
749 if [[ ! -f "${jar}" ]] ; then 819 if [[ ! -f "${jar}" ]] ; then
750 die "Installation problems with jars in ${pkg} - is it installed?" 820 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
751 fi 821 fi
752 822
753 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 823 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
754 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}"
755 echo "${jar}" 826 echo "${jar}"
756 return 0 827 return 0
757 fi 828 fi
758 done 829 done
759 830
1027 return 1 1098 return 1
1028 fi 1099 fi
1029 fi 1100 fi
1030} 1101}
1031 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
1032# ------------------------------------------------------------------------------ 1116# ------------------------------------------------------------------------------
1033# @ebuild-function java-pkg_get-source 1117# @ebuild-function java-pkg_get-source
1034# 1118#
1035# Determines what source version should be used, for passing to -source. 1119# Determines what source version should be used, for passing to -source.
1036# 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
1139 1223
1140# TODO document 1224# TODO document
1141java-pkg_get-jni-cflags() { 1225java-pkg_get-jni-cflags() {
1142 local flags="-I${JAVA_HOME}/include" 1226 local flags="-I${JAVA_HOME}/include"
1143 1227
1228 # TODO do a check that the directories are valid
1144 # TODO figure out how to cope with other things than linux... 1229 # TODO figure out how to cope with other things than linux...
1145 flags="${flags} -I${JAVA_HOME}/include/linux" 1230 flags="${flags} -I${JAVA_HOME}/include/linux"
1146 1231
1147 echo ${flags} 1232 echo ${flags}
1148} 1233}
1149 1234
1235java-pkg_ensure-gcj() {
1236 if ! built_with_use sys-devel/gcc gcj ; then
1237 ewarn
1238 ewarn "You must build gcc with the gcj support to build with gcj"
1239 ewarn
1240 ebeep 5
1241 die "No GCJ support found!"
1242 fi
1243}
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
1150# ------------------------------------------------------------------------------ 1253# ------------------------------------------------------------------------------
1151# @section-end helper 1254# @section-end helper
1152# ------------------------------------------------------------------------------ 1255# ------------------------------------------------------------------------------
1153 1256
1154# ------------------------------------------------------------------------------ 1257# ------------------------------------------------------------------------------
1166# compiler. 1269# compiler.
1167# 1270#
1168# ------------------------------------------------------------------------------ 1271# ------------------------------------------------------------------------------
1169eant() { 1272eant() {
1170 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
1171 1280
1172 local antflags 1281 local antflags
1173 java-pkg_init-compiler_ 1282 java-pkg_init-compiler_
1174 local compiler="${GENTOO_COMPILER}" 1283 local compiler="${GENTOO_COMPILER}"
1175 1284
1189 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1298 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1190 if [[ -n ${build_compiler_deps} ]]; then 1299 if [[ -n ${build_compiler_deps} ]]; then
1191 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1300 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1192 fi 1301 fi
1193 fi 1302 fi
1303
1304 if is-java-strict; then
1305 einfo "Disabling system classpath for ant"
1306 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1307 fi
1194 1308
1195 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1309 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1196 antflags="${antflags} -debug" 1310 antflags="${antflags} -debug"
1197 fi 1311 fi
1198 1312
1210# @param $@ - Arguments to be passed to the compiler 1324# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 1325# ------------------------------------------------------------------------------
1212ejavac() { 1326ejavac() {
1213 debug-print-function ${FUNCNAME} $* 1327 debug-print-function ${FUNCNAME} $*
1214 1328
1329 # FIXME using get-javac ends up printing stuff with einfo
1215 local compiler_executable=$(java-pkg_get-javac) 1330# local compiler_executable=$(java-pkg_get-javac)
1331 local compiler_executable="javac"
1216 1332
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1333 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1334 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1219} 1335}
1220 1336
1226# 1342#
1227# @param $@ - compilers to filter 1343# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 1344# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 1345java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1346 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1347}
1348
1349# ------------------------------------------------------------------------------
1350# @ebuild-function java-pkg_force-compiler
1351#
1352# Used to force the use of particular compilers. Should be used in src_compile.
1353# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1354# OutOfMemoryErrors that may come up.
1355#
1356# @param $@ - compilers to force
1357# ------------------------------------------------------------------------------
1358java-pkg_force-compiler() {
1359 JAVA_PKG_FORCE_COMPILER="$@"
1231} 1360}
1232 1361
1233# ------------------------------------------------------------------------------ 1362# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 1363# @ebuild-function use_doc
1235# 1364#
1324 if [[ -n ${GENTOO_COMPILER} ]]; then 1453 if [[ -n ${GENTOO_COMPILER} ]]; then
1325 debug-print "GENTOO_COMPILER already set" 1454 debug-print "GENTOO_COMPILER already set"
1326 return 1455 return
1327 fi 1456 fi
1328 1457
1458 local compilers;
1459 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1329 local compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1460 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1461 else
1462 compilers=${JAVA_PKG_FORCE_COMPILER}
1463 fi
1464
1330 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1465 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1331 1466
1332 # Figure out if we should announce what compiler we're using 1467 # Figure out if we should announce what compiler we're using
1333 local compiler 1468 local compiler
1334 for compiler in ${compilers}; do 1469 for compiler in ${compilers}; do
1655 fi 1790 fi
1656 debug-print "Using: $(java-config -f)" 1791 debug-print "Using: $(java-config -f)"
1657 1792
1658 java-pkg_setup-vm 1793 java-pkg_setup-vm
1659 1794
1795 export JAVA=$(java-config --java)
1796 export JAVAC=$(java-config --javac)
1660 export JAVACFLAGS="$(java-pkg_javac-args)" 1797 export JAVACFLAGS="$(java-pkg_javac-args)"
1661 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1798 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1662 1799
1663 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1800 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1664 export JDK_HOME=${JAVA_HOME} 1801 export JDK_HOME=${JAVA_HOME}
1698 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1835 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1699 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1836 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1700 echo "and of course, the output of emerge --info" >&2 1837 echo "and of course, the output of emerge --info" >&2
1701} 1838}
1702 1839
1840
1841# TODO document
1842# List jars in the source directory, ${S}
1843java-pkg_jar-list() {
1844 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1845 einfo "Linked Jars"
1846 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1847 einfo "Jars"
1848 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1849 einfo "Classes"
1850 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1851 fi
1852}
1853
1854# TODO document
1855# Verify that the classes were compiled for the right source / target
1856java-pkg_verify-classes() {
1857 ebegin "Verifying java class versions"
1858 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1859 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1860 result=$?
1861 eend ${result}
1862 if [[ ${result} == 0 ]]; then
1863 einfo "All good"
1864 else
1865 ewarn "Possible problem"
1866 die "Bad class files found"
1867 fi
1868}
1869
1870
1703# ------------------------------------------------------------------------------ 1871# ------------------------------------------------------------------------------
1704# @section-end internal 1872# @section-end internal
1705# ------------------------------------------------------------------------------ 1873# ------------------------------------------------------------------------------
1706 1874
1707java-pkg_check-phase() { 1875java-pkg_check-phase() {
1708 local phase=${1} 1876 local phase=${1}
1709 local funcname=${2} 1877 local funcname=${2}
1710 # TODO add check for java-stricter
1711 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1878 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1712 java-pkg_announce-qa-violation \ 1879 java-pkg_announce-qa-violation \
1713 "${funcname} used outside of src_${phase}" 1880 "${funcname} used outside of src_${phase}"
1714 fi 1881 fi
1715} 1882}
1716 1883
1727 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1894 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1728 fi 1895 fi
1729} 1896}
1730 1897
1731java-pkg_announce-qa-violation() { 1898java-pkg_announce-qa-violation() {
1732 if hasq java-strict ${FEATURES}; then 1899 if is-java-strict; then
1733 echo "Java QA Notice: $@" >&2 1900 echo "Java QA Notice: $@" >&2
1734 increment-qa-violations 1901 increment-qa-violations
1735 fi 1902 fi
1736} 1903}
1737 1904
1738increment-qa-violations() { 1905increment-qa-violations() {
1739 let "JAVA_PKG_QA_VIOLATIONS+=1" 1906 let "JAVA_PKG_QA_VIOLATIONS+=1"
1740 export JAVA_PKG_QA_VIOLATIONS 1907 export JAVA_PKG_QA_VIOLATIONS
1741} 1908}
1742 1909
1910is-java-strict() {
1911 [[ -n ${JAVA_PKG_STRICT} ]]
1912 return $?
1913}
1914
1743# ------------------------------------------------------------------------------ 1915# ------------------------------------------------------------------------------
1744# @eclass-end 1916# @eclass-end
1745# ------------------------------------------------------------------------------ 1917# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20