/[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.18 Revision 1.19
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}"
546 shift 546 shift
547 547
548 echo "#!/bin/bash" > "${target}" 548 echo "#!/bin/bash" > "${target}"
549 while [[ -n "${1}" && -n "${2}" ]]; do 549 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 550 local var=${1} value=${2}
551 if [[ "${var:0:2}" == "--" ]]; then 551 if [[ "${var:0:2}" == "--" ]]; then
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 552 echo "gjl_${var:2}=\"${value}\"" >> "${target}"
553 elif [[ "${var}" == "-into" ]]; then 553 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 554 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 555 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 556 pre="${value}"
558 shift 2 558 shift 2
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 "${target_dir}" ]]; 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
734# 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'.
735# The providing packages are recorded as dependencies into package.env DEPEND 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 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 737# that have to be present only at build time and are not needed on runtime
738# (junit testing etc). 738# (junit testing etc).
739# 739#
740# Example: Get the classpath for xerces-2, 740# Example: Get the classpath for xerces-2,
741# java-pkg_getjars xerces-2 xalan 741# java-pkg_getjars xerces-2 xalan
742# Example Return: 742# Example Return:
743# /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
744# 744#
745# @param $1 - (optional) "--build-only" makes the jar(s) not added into 745# @param $1 - (optional) "--build-only" makes the jar(s) not added into
746# package.env DEPEND line. 746# package.env DEPEND line.
747# @param $@ - list of packages to get jars from 747# @param $@ - list of packages to get jars from
748# ------------------------------------------------------------------------------ 748# ------------------------------------------------------------------------------
749java-pkg_getjars() { 749java-pkg_getjars() {
788# 788#
789# @example 789# @example
790# java-pkg_getjar xerces-2 xml-apis.jar 790# java-pkg_getjar xerces-2 xml-apis.jar
791# @example-return 791# @example-return
792# /usr/share/xerces-2/lib/xml-apis.jar 792# /usr/share/xerces-2/lib/xml-apis.jar
793# 793#
794# @param $1 - (optional) "--build-only" makes the jar not added into 794# @param $1 - (optional) "--build-only" makes the jar not added into
795# package.env DEPEND line. 795# package.env DEPEND line.
796# @param $1 - package to use 796# @param $1 - package to use
797# @param $2 - jar to get 797# @param $2 - jar to get
798# ------------------------------------------------------------------------------ 798# ------------------------------------------------------------------------------
825 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 825 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
826 echo "${jar}" 826 echo "${jar}"
827 return 0 827 return 0
828 fi 828 fi
829 done 829 done
830 830
831 die "Could not find ${target_jar} in ${pkg}" 831 die "Could not find ${target_jar} in ${pkg}"
832 return 1 832 return 1
833} 833}
834 834
835# This function reads stdin, and based on that input, figures out how to 835# This function reads stdin, and based on that input, figures out how to
849# line="${line// /}" 849# line="${line// /}"
850# 850#
851# # format: path=jarinfo 851# # format: path=jarinfo
852# local path=${line%%=*} 852# local path=${line%%=*}
853# local jarinfo=${line##*=} 853# local jarinfo=${line##*=}
854# 854#
855# # format: jar@package 855# # format: jar@package
856# local jar=${jarinfo%%@*}.jar 856# local jar=${jarinfo%%@*}.jar
857# local package=${jarinfo##*@} 857# local package=${jarinfo##*@}
858# if [[ -n ${replace_only} ]]; then 858# if [[ -n ${replace_only} ]]; then
859# [[ ! -f $path ]] && die "No jar exists at ${path}" 859# [[ ! -f $path ]] && die "No jar exists at ${path}"
872# @section-end query 872# @section-end query
873# ------------------------------------------------------------------------------ 873# ------------------------------------------------------------------------------
874 874
875# ------------------------------------------------------------------------------ 875# ------------------------------------------------------------------------------
876# @section-begin helper 876# @section-begin helper
877# @section-summary Helper functions 877# @section-summary Helper functions
878# 878#
879# Various other functions to use from an ebuild 879# Various other functions to use from an ebuild
880# ------------------------------------------------------------------------------ 880# ------------------------------------------------------------------------------
881 881
882# ------------------------------------------------------------------------------ 882# ------------------------------------------------------------------------------
888# jdbc-stdext 888# jdbc-stdext
889# jaf 889# jaf
890# jdbc-rowset 890# jdbc-rowset
891# jms 891# jms
892# 892#
893# @param $1 - Optionally indicate that the dependencies are controlled by 893# @param $1 - Optionally indicate that the dependencies are controlled by
894# a use flag by specifying '--use' Requires $2. 894# a use flag by specifying '--use' Requires $2.
895# @param $2 - USE flag which will enable the dependencies. 895# @param $2 - USE flag which will enable the dependencies.
896# @param $@ - virtual packages to add depenedencies for 896# @param $@ - virtual packages to add depenedencies for
897# ------------------------------------------------------------------------------ 897# ------------------------------------------------------------------------------
898# TODO rewrite to parse a line based declaration file instead -- karltk 898# TODO rewrite to parse a line based declaration file instead -- karltk
992 fi 992 fi
993} 993}
994 994
995# ------------------------------------------------------------------------------ 995# ------------------------------------------------------------------------------
996# @internal-function java-pkg_is-vm-version-sufficient 996# @internal-function java-pkg_is-vm-version-sufficient
997# 997#
998# @return zero - VM is sufficient 998# @return zero - VM is sufficient
999# @return non-zero - VM is not sufficient 999# @return non-zero - VM is not sufficient
1000# ------------------------------------------------------------------------------ 1000# ------------------------------------------------------------------------------
1001java-pkg_is-vm-version-sufficient() { 1001java-pkg_is-vm-version-sufficient() {
1002 debug-print-function ${FUNCNAME} $* 1002 debug-print-function ${FUNCNAME} $*
1022 die "Active Java VM too old" 1022 die "Active Java VM too old"
1023 fi 1023 fi
1024} 1024}
1025 1025
1026# ------------------------------------------------------------------------------ 1026# ------------------------------------------------------------------------------
1027# @internal-function java-pkg_is-vm-version-eq 1027# @internal-function java-pkg_is-vm-version-eq
1028# 1028#
1029# @param $@ - VM version to compare current VM to 1029# @param $@ - VM version to compare current VM to
1030# @return zero - VM versions are equal 1030# @return zero - VM versions are equal
1031# @return non-zero - VM version are not equal 1031# @return non-zero - VM version are not equal
1032# ------------------------------------------------------------------------------ 1032# ------------------------------------------------------------------------------
1033java-pkg_is-vm-version-eq() { 1033java-pkg_is-vm-version-eq() {
1063# 1063#
1064# @param $@ - VM version to compare current to 1064# @param $@ - VM version to compare current to
1065# ------------------------------------------------------------------------------ 1065# ------------------------------------------------------------------------------
1066java-pkg_ensure-vm-version-ge() { 1066java-pkg_ensure-vm-version-ge() {
1067 debug-print-function ${FUNCNAME} $* 1067 debug-print-function ${FUNCNAME} $*
1068 1068
1069 if ! java-pkg_is-vm-version-ge "$@" ; then 1069 if ! java-pkg_is-vm-version-ge "$@" ; then
1070 debug-print "vm is not suffient" 1070 debug-print "vm is not suffient"
1071 eerror "This package requires a Java VM version >= $@" 1071 eerror "This package requires a Java VM version >= $@"
1072 einfo "Please use java-config -S to set the correct one" 1072 einfo "Please use java-config -S to set the correct one"
1073 die "Active Java VM too old" 1073 die "Active Java VM too old"
1074 fi 1074 fi
1075} 1075}
1076 1076
1077# ------------------------------------------------------------------------------ 1077# ------------------------------------------------------------------------------
1078# @internal-function java-pkg_is-vm-version-ge 1078# @internal-function java-pkg_is-vm-version-ge
1079# 1079#
1080# @param $@ - VM version to compare current VM to 1080# @param $@ - VM version to compare current VM to
1081# @return zero - current VM version is greater than checked version 1081# @return zero - current VM version is greater than checked version
1082# @return non-zero - current VM version is not greater than checked version 1082# @return non-zero - current VM version is not greater than checked version
1083# ------------------------------------------------------------------------------ 1083# ------------------------------------------------------------------------------
1084java-pkg_is-vm-version-ge() { 1084java-pkg_is-vm-version-ge() {
1113 return $? 1113 return $?
1114} 1114}
1115 1115
1116# ------------------------------------------------------------------------------ 1116# ------------------------------------------------------------------------------
1117# @ebuild-function java-pkg_get-source 1117# @ebuild-function java-pkg_get-source
1118# 1118#
1119# Determines what source version should be used, for passing to -source. 1119# Determines what source version should be used, for passing to -source.
1120# 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
1121# 1121#
1122# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1122# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1123# ------------------------------------------------------------------------------ 1123# ------------------------------------------------------------------------------
1128# ------------------------------------------------------------------------------ 1128# ------------------------------------------------------------------------------
1129# @ebuild-function java-pkg_get-target 1129# @ebuild-function java-pkg_get-target
1130# 1130#
1131# Determines what target version should be used, for passing to -target. 1131# Determines what target version should be used, for passing to -target.
1132# If you don't care about lower versions, you can set _WANT_TARGET to the 1132# If you don't care about lower versions, you can set _WANT_TARGET to the
1133# version of your JDK. 1133# version of your JDK.
1134# Remember doing this will mostly like cause things to break. 1134# Remember doing this will mostly like cause things to break.
1135# Doesn't allow it to be lower then the one in depend. 1135# Doesn't allow it to be lower then the one in depend.
1136# Doesn't allow it to be higher then the active vm. 1136# Doesn't allow it to be higher then the active vm.
1137# 1137#
1138# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1138# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1139# ------------------------------------------------------------------------------ 1139# ------------------------------------------------------------------------------
1140java-pkg_get-target() { 1140java-pkg_get-target() {
1141 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") 1141 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1142 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then 1142 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1143 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" 1143 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1144 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then 1144 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1145 echo ${JAVA_PKG_WANT_TARGET} 1145 echo ${JAVA_PKG_WANT_TARGET}
1146 else 1146 else
1173 # try to get value of JAVAC 1173 # try to get value of JAVAC
1174 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1174 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1175 export JAVAC=${old_javac} 1175 export JAVAC=${old_javac}
1176 1176
1177 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1177 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}"
1178 1178
1179 # check that it's executable 1179 # check that it's executable
1180 if [[ ! -x ${compiler_executable} ]]; then 1180 if [[ ! -x ${compiler_executable} ]]; then
1181 eerror "Could not find ${compiler_executable}!" 1181 eerror "Could not find ${compiler_executable}!"
1182 die "${compiler_executable} doesn't exist, or isn't executable" 1182 die "${compiler_executable} doesn't exist, or isn't executable"
1183 fi 1183 fi
1188 fi 1188 fi
1189 echo ${compiler_executable} 1189 echo ${compiler_executable}
1190} 1190}
1191 1191
1192# ------------------------------------------------------------------------------ 1192# ------------------------------------------------------------------------------
1193# @ebuild-function java-pkg_javac-args 1193# @ebuild-function java-pkg_javac-args
1194# 1194#
1195# If an ebuild uses javac directly, instead of using ejavac, it should call this 1195# If an ebuild uses javac directly, instead of using ejavac, it should call this
1196# to know what -source/-target to use. 1196# to know what -source/-target to use.
1197# 1197#
1198# @return string - arguments to pass to javac, complete with -target and -source 1198# @return string - arguments to pass to javac, complete with -target and -source
1201 debug-print-function ${FUNCNAME} $* 1201 debug-print-function ${FUNCNAME} $*
1202 1202
1203 local want_source="$(java-pkg_get-source)" 1203 local want_source="$(java-pkg_get-source)"
1204 local want_target="$(java-pkg_get-target)" 1204 local want_target="$(java-pkg_get-target)"
1205 1205
1206 local source_str="-source ${want_source}" 1206 local source_str="-source ${want_source}"
1207 local target_str="-target ${want_target}" 1207 local target_str="-target ${want_target}"
1208 1208
1209 debug-print "want source: ${want_source}" 1209 debug-print "want source: ${want_source}"
1210 debug-print "want target: ${want_target}" 1210 debug-print "want target: ${want_target}"
1211 1211
1303 1303
1304 if is-java-strict; then 1304 if is-java-strict; then
1305 einfo "Disabling system classpath for ant" 1305 einfo "Disabling system classpath for ant"
1306 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1306 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1307 fi 1307 fi
1308 1308
1309 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1309 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1310 antflags="${antflags} -debug" 1310 antflags="${antflags} -debug"
1311 fi 1311 fi
1312 1312
1313 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1313 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1314 ant ${antflags} "${@}" || die "eant failed" 1314 ant ${antflags} "${@}" || die "eant failed"
1315 1315
1316} 1316}
1317 1317
1318# ------------------------------------------------------------------------------ 1318# ------------------------------------------------------------------------------
1319# @ebuild-function ejavac 1319# @ebuild-function ejavac
1320# 1320#
1321# Javac wrapper function. Will use the appropriate compiler, based on 1321# Javac wrapper function. Will use the appropriate compiler, based on
1322# /etc/java-config/compilers.conf 1322# /etc/java-config/compilers.conf
1323# 1323#
1324# @param $@ - Arguments to be passed to the compiler 1324# @param $@ - Arguments to be passed to the compiler
1325# ------------------------------------------------------------------------------ 1325# ------------------------------------------------------------------------------
1326ejavac() { 1326ejavac() {
1334 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1334 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1335} 1335}
1336 1336
1337# ------------------------------------------------------------------------------ 1337# ------------------------------------------------------------------------------
1338# @ebuild-function java-pkg_filter-compiler 1338# @ebuild-function java-pkg_filter-compiler
1339# 1339#
1340# Used to prevent the use of some compilers. Should be used in src_compile. 1340# Used to prevent the use of some compilers. Should be used in src_compile.
1341# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1341# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1342# 1342#
1343# @param $@ - compilers to filter 1343# @param $@ - compilers to filter
1344# ------------------------------------------------------------------------------ 1344# ------------------------------------------------------------------------------
1362# ------------------------------------------------------------------------------ 1362# ------------------------------------------------------------------------------
1363# @ebuild-function use_doc 1363# @ebuild-function use_doc
1364# 1364#
1365# Helper function for getting ant to build javadocs. If the user has USE=doc, 1365# Helper function for getting ant to build javadocs. If the user has USE=doc,
1366# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1366# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1367# 1367#
1368# The output of this should be passed to ant. 1368# The output of this should be passed to ant.
1369# 1369#
1370# Example: build javadocs by calling 'javadoc' target 1370# Example: build javadocs by calling 'javadoc' target
1371# eant $(use_doc) 1371# eant $(use_doc)
1372# Example: build javadocs by calling 'apidoc' target 1372# Example: build javadocs by calling 'apidoc' target
1380} 1380}
1381 1381
1382# ------------------------------------------------------------------------------ 1382# ------------------------------------------------------------------------------
1383# @section-end build 1383# @section-end build
1384# ------------------------------------------------------------------------------ 1384# ------------------------------------------------------------------------------
1385 1385
1386# ------------------------------------------------------------------------------ 1386# ------------------------------------------------------------------------------
1387# @section-begin internal 1387# @section-begin internal
1388# @section-summary Internal functions 1388# @section-summary Internal functions
1389# 1389#
1390# Do __NOT__ use any of these from an ebuild! These are only to be used from 1390# Do __NOT__ use any of these from an ebuild! These are only to be used from
1391# within the java eclasses. 1391# within the java eclasses.
1392# ------------------------------------------------------------------------------ 1392# ------------------------------------------------------------------------------
1393 1393
1394# ----------------------------------------------------------------------------- 1394# -----------------------------------------------------------------------------
1395# @function-internal java-pkg_init 1395# @function-internal java-pkg_init
1396# 1396#
1397# The purpose of this function, as the name might imply, is to initialize the 1397# The purpose of this function, as the name might imply, is to initialize the
1398# Java environment. It ensures that that there aren't any environment variables 1398# Java environment. It ensures that that there aren't any environment variables
1399# that'll muss things up. It initializes some variables, which are used 1399# that'll muss things up. It initializes some variables, which are used
1400# internally. And most importantly, it'll switch the VM if necessary. 1400# internally. And most importantly, it'll switch the VM if necessary.
1401# 1401#
1413 # TODO we will probably want to set JAVAC and JAVACFLAGS 1413 # TODO we will probably want to set JAVAC and JAVACFLAGS
1414 1414
1415 # Do some QA checks 1415 # Do some QA checks
1416 java-pkg_check-jikes 1416 java-pkg_check-jikes
1417 1417
1418 # When users have crazy classpaths some packages can fail to compile. 1418 # When users have crazy classpaths some packages can fail to compile.
1419 # and everything should work with empty CLASSPATH. 1419 # and everything should work with empty CLASSPATH.
1420 # This also helps prevent unexpected dependencies on random things 1420 # This also helps prevent unexpected dependencies on random things
1421 # from the CLASSPATH. 1421 # from the CLASSPATH.
1422 unset CLASSPATH 1422 unset CLASSPATH
1423} 1423}
1424 1424
1425# ------------------------------------------------------------------------------ 1425# ------------------------------------------------------------------------------
1426# @function-internal java-pkg-init-compiler_ 1426# @function-internal java-pkg-init-compiler_
1427# 1427#
1428# This function attempts to figure out what compiler should be used. It does 1428# This function attempts to figure out what compiler should be used. It does
1429# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1429# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1430# COMPILERS variable defined there. 1430# COMPILERS variable defined there.
1431# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1431# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1432# 1432#
1433# It will go through the list of compilers, and verify that it supports the 1433# It will go through the list of compilers, and verify that it supports the
1434# target and source that are needed. If it is not suitable, then the next 1434# target and source that are needed. If it is not suitable, then the next
1435# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1435# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1436# isn't done. 1436# isn't done.
1437# 1437#
1459 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1459 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1460 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 1461 else
1462 compilers=${JAVA_PKG_FORCE_COMPILER} 1462 compilers=${JAVA_PKG_FORCE_COMPILER}
1463 fi 1463 fi
1464 1464
1465 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1465 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1466 1466
1467 # Figure out if we should announce what compiler we're using 1467 # Figure out if we should announce what compiler we're using
1468 local compiler 1468 local compiler
1469 for compiler in ${compilers}; do 1469 for compiler in ${compilers}; do
1472 if [[ ${compiler} = "javac" ]]; then 1472 if [[ ${compiler} = "javac" ]]; then
1473 debug-print "Found javac... breaking" 1473 debug-print "Found javac... breaking"
1474 export GENTOO_COMPILER="javac" 1474 export GENTOO_COMPILER="javac"
1475 break 1475 break
1476 fi 1476 fi
1477 1477
1478 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1478 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1479 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1479 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1480 einfo "Filtering ${compiler}" 1480 einfo "Filtering ${compiler}"
1481 continue 1481 continue
1482 fi 1482 fi
1483 fi 1483 fi
1484 1484
1485 # for non-javac, we need to make sure it supports the right target and 1485 # for non-javac, we need to make sure it supports the right target and
1486 # source 1486 # source
1487 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1487 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1488 if [[ -f ${compiler_env} ]]; then 1488 if [[ -f ${compiler_env} ]]; then
1489 local desired_target="$(java-pkg_get-target)" 1489 local desired_target="$(java-pkg_get-target)"
1585 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1585 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1586 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1586 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1587 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1587 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1588 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1588 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1589 ) > "${JAVA_PKG_ENV}" 1589 ) > "${JAVA_PKG_ENV}"
1590 1590
1591 # register target/source 1591 # register target/source
1592 local target="$(java-pkg_get-target)" 1592 local target="$(java-pkg_get-target)"
1593 local source="$(java-pkg_get-source)" 1593 local source="$(java-pkg_get-source)"
1594 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1594 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1595 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1595 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1662 fi 1662 fi
1663} 1663}
1664 1664
1665# ------------------------------------------------------------------------------ 1665# ------------------------------------------------------------------------------
1666# @internal-function java-pkg_expand_dir_ 1666# @internal-function java-pkg_expand_dir_
1667# 1667#
1668# Gets the full path of the file/directory's parent. 1668# Gets the full path of the file/directory's parent.
1669# @param $1 - file/directory to find parent directory for 1669# @param $1 - file/directory to find parent directory for
1670# @return - path to $1's parent directory 1670# @return - path to $1's parent directory
1671# ------------------------------------------------------------------------------ 1671# ------------------------------------------------------------------------------
1672java-pkg_expand_dir_() { 1672java-pkg_expand_dir_() {
1764} 1764}
1765 1765
1766# ------------------------------------------------------------------------------ 1766# ------------------------------------------------------------------------------
1767# @internal-function java-pkg_switch-vm 1767# @internal-function java-pkg_switch-vm
1768# 1768#
1769# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1769# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1770# verify that the current VM is sufficient. 1770# verify that the current VM is sufficient.
1771# Setup the environment for the VM being used. 1771# Setup the environment for the VM being used.
1772# ------------------------------------------------------------------------------ 1772# ------------------------------------------------------------------------------
1773java-pkg_switch-vm() { 1773java-pkg_switch-vm() {
1774 if java-pkg_needs-vm; then 1774 if java-pkg_needs-vm; then
1787 # otherwise just make sure the current VM is sufficient 1787 # otherwise just make sure the current VM is sufficient
1788 else 1788 else
1789 java-pkg_ensure-vm-version-sufficient 1789 java-pkg_ensure-vm-version-sufficient
1790 fi 1790 fi
1791 debug-print "Using: $(java-config -f)" 1791 debug-print "Using: $(java-config -f)"
1792 1792
1793 java-pkg_setup-vm 1793 java-pkg_setup-vm
1794 1794
1795 export JAVA=$(java-config --java) 1795 export JAVA=$(java-config --java)
1796 export JAVAC=$(java-config --javac) 1796 export JAVAC=$(java-config --javac)
1797 export JAVACFLAGS="$(java-pkg_javac-args)" 1797 export JAVACFLAGS="$(java-pkg_javac-args)"
1798 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1798 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1799 1799
1800 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1800 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1801 export JDK_HOME=${JAVA_HOME} 1801 export JDK_HOME=${JAVA_HOME}
1802 1802
1803 #TODO If you know a better solution let us know. 1803 #TODO If you know a better solution let us know.
1804 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1804 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1805 1805
1806 local tann="${T}/announced-vm" 1806 local tann="${T}/announced-vm"
1807 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1807 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1808 # Add a check for setup/preinst phase... to avoid duplicate outputs 1808 # Add a check for setup/preinst phase... to avoid duplicate outputs
1809 # for when FEATURES=buildpkg 1809 # for when FEATURES=buildpkg
1810 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1810 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1854# TODO document 1854# TODO document
1855# Verify that the classes were compiled for the right source / target 1855# Verify that the classes were compiled for the right source / target
1856java-pkg_verify-classes() { 1856java-pkg_verify-classes() {
1857 ebegin "Verifying java class versions" 1857 ebegin "Verifying java class versions"
1858 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 1858 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1859 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 1859 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1860 result=$? 1860 result=$?
1861 eend ${result} 1861 eend ${result}
1862 if [[ ${result} == 0 ]]; then 1862 if [[ ${result} == 0 ]]; then
1863 einfo "All good" 1863 einfo "All good"
1864 else 1864 else

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

  ViewVC Help
Powered by ViewVC 1.1.20