/[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.21 Revision 1.38
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.38 2006/12/31 19:30:54 betelgeuse Exp $
9 10
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
22# Java packages, or java-pkg-opt for packages that have optional Java support. 23# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
28
29IUSE="elibc_FreeBSD"
27 30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
200 203
201 java-pkg_do_write_ 204 java-pkg_do_write_
202} 205}
203 206
204 207
208# ------------------------------------------------------------------------------
209# @internal-function depend-java-query
210#
211# Wrapper for the depend-java-query binary to enable passing USE in env.
212# Using env variables keeps this eclass working with java-config versions that
213# do not handle use flags.
214# ------------------------------------------------------------------------------
215
216depend-java-query() {
217 USE="${USE}" $(which depend-java-query) "${@}"
218}
205 219
206# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 221# @ebuild-function java-pkg_regjar
208# 222#
209# Records an already installed jar in the package.env 223# Records an already installed jar in the package.env
242 java-pkg_init_paths_ 256 java-pkg_init_paths_
243 257
244 local jar jar_dir jar_file 258 local jar jar_dir jar_file
245 for jar in "$@"; do 259 for jar in "$@"; do
246 # TODO use java-pkg_check-versioned-jar 260 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 261 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
262 [[ -d "${jar}" || -d "${D}${jar}" ]] \
263 && die "Called ${FUNCNAME} on a directory $*"
248 # nelchael: we should strip ${D} in this case too, here's why: 264 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 265 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 266 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 267 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 268 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 269 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 270 else
257 die "${jar} does not exist" 271 die "${jar} does not exist"
258 fi 272 fi
259 done 273 done
260 274
261 java-pkg_do_write_ 275 java-pkg_do_write_
262} 276}
263
264 277
265# ------------------------------------------------------------------------------ 278# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 279# @ebuild-function java-pkg_newjar
267# 280#
268# Installs a jar with a new name 281# Installs a jar with a new name
287 cp "${original_jar}" "${new_jar_dest}" \ 300 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 301 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 302 java-pkg_dojar "${new_jar_dest}"
290} 303}
291 304
292
293# ------------------------------------------------------------------------------ 305# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 306# @ebuild-function java-pkg_addcp
295# 307#
296# Add something to the package's classpath. For jars, you should use dojar, 308# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 309# newjar, or regjar. This is typically used to add directories to the classpath.
301# ------------------------------------------------------------------------------ 313# ------------------------------------------------------------------------------
302java-pkg_addcp() { 314java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 315 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 316 java-pkg_do_write_
305} 317}
306
307 318
308# ------------------------------------------------------------------------------ 319# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 320# @ebuild-function java-pkg_doso
310# 321#
311# Installs any number of JNI libraries 322# Installs any number of JNI libraries
428# ------------------------------------------------------------------------------ 439# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 440java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 441 debug-print-function ${FUNCNAME} $*
431 442
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 443 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 444
445 # from /usr/lib/portage/bin/dohtml -h
446 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 447 dohtml -f package-list "$@"
448
435 # this probably shouldn't be here but it provides 449 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 450 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 451 # old ebuilds.
438 java-pkg_recordjavadoc 452 java-pkg_recordjavadoc
439} 453}
440 454
441# TODO document 455# ------------------------------------------------------------------------------
456# @ebuild-function java-pkg_dojavadoc
457#
458# Installs javadoc documentation. This should be controlled by the doc use flag.
459#
460# @param $1: - The javadoc root directory.
461#
462# @example:
463# java-pkg_dojavadoc docs/api
464#
465# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 466java-pkg_dojavadoc() {
443 local dir="$1" 467 local dir="$1"
444 468
445 java-pkg_check-phase install 469 java-pkg_check-phase install
446 470
518# @ebuild-function java-pkg_dolauncher 542# @ebuild-function java-pkg_dolauncher
519# 543#
520# Make a wrapper script to lauch/start this package 544# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 545# If necessary, the wrapper will switch to the appropriate VM.
522# 546#
547# Can be called without parameters if the package installs only one jar
548# that has the Main-class attribute set. The wrapper will be named ${PN}.
549#
523# @param $1 - filename of launcher to create 550# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 551# @param $2 - options, as follows:
525# --main the.main.class.too.start 552# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 553# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 554# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 555# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 556# --pwd
530# -into 557# -into
531# -pre 558# -pre
532# ------------------------------------------------------------------------------ 559# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 560java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 561 debug-print-function ${FUNCNAME} $*
535 562
536 java-pkg_check-phase install 563 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 564 java-pkg_init_paths_
541 565
566 if [[ ${#} = 0 ]]; then
567 local name="${PN}"
568 else
542 local name="${1}" 569 local name="${1}"
570 shift
571 fi
572
543 # TODO rename to launcher 573 # TODO rename to launcher
544 local target="${T}/${name}" 574 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 575 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 576 local target_dir pre
547 shift
548 577
549 # Process the other the rest of the arguments 578 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 580 local var="${1}" value="${2}"
552 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
582 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
584 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 586 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 587 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 588 pre="${value}"
558 fi 589 fi
559 shift 2 590 shift 2
560 done 591 done
592
593 # Test if no --jar and --main arguments were given and
594 # in that case check if the package only installs one jar
595 # and use that jar.
596 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
597 local cp="${JAVA_PKG_CLASSPATH}"
598 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
599 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
600 else
601 local msg="Not enough information to create a launcher given."
602 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
603 die "${msg}"
604 fi
605 fi
561 606
562 # Write the actual script 607 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 608 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 609 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 610 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
741# The providing packages are recorded as dependencies into package.env DEPEND 786# The providing packages are recorded as dependencies into package.env DEPEND
742# line, unless "--build-only" is passed as the very first argument, for jars 787# line, unless "--build-only" is passed as the very first argument, for jars
743# that have to be present only at build time and are not needed on runtime 788# that have to be present only at build time and are not needed on runtime
744# (junit testing etc). 789# (junit testing etc).
745# 790#
746# Example: Get the classpath for xerces-2, 791# Example: Get the classpath for xerces-2 and xalan,
747# java-pkg_getjars xerces-2 xalan 792# java-pkg_getjars xerces-2,xalan
748# Example Return: 793# Example Return:
749# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 794# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
750# 795#
751# @param $1 - (optional) "--build-only" makes the jar(s) not added into 796# @param $1 - (optional) "--build-only" makes the jar(s) not added into
752# package.env DEPEND line. 797# package.env DEPEND line.
753# @param $@ - list of packages to get jars from 798# @param $2 - list of packages to get jars from
799# (passed to java-config --classpath)
754# ------------------------------------------------------------------------------ 800# ------------------------------------------------------------------------------
755java-pkg_getjars() { 801java-pkg_getjars() {
756 debug-print-function ${FUNCNAME} $* 802 debug-print-function ${FUNCNAME} $*
757 803
758 local build_only=""
759
760 if [[ "${1}" = "--build-only" ]]; then 804 if [[ "${1}" = "--build-only" ]]; then
761 build_only="true" 805 local build_only="true"
762 shift 806 shift
763 fi 807 fi
764 808
765 [[ ${#} -lt 1 ]] && die "At least one argument needed" 809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
766 810
767 # NOTE could probably just pass $@ to java-config --classpath. and return it
768 local classpath pkg 811 local classpath pkgs="${1}"
769 for pkg in ${@//,/ }; do
770 #for pkg in $(echo "$@" | tr ',' ' '); do
771 jars="$(java-config --classpath=${pkg})" 812 jars="$(java-config --classpath=${pkgs})"
772 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed" 813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
773 debug-print "${pkg}:${jars}" 814 debug-print "${pkgs}:${jars}"
774 815
775 if [[ -z "${classpath}" ]]; then 816 if [[ -z "${classpath}" ]]; then
776 classpath="${jars}" 817 classpath="${jars}"
777 else 818 else
778 classpath="${classpath}:${jars}" 819 classpath="${classpath}:${jars}"
779 fi 820 fi
821
780 # Only record jars that aren't build-only 822 # Only record jars that aren't build-only
781 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 823 if [[ -z "${build_only}" ]]; then
824 oldifs="${IFS}"
825 IFS=","
826 for pkg in ${pkgs}; do
827 java-pkg_record-jar_ "${pkg}"
782 done 828 done
829 IFS="${oldifs}"
830 fi
831
783 echo "${classpath}" 832 echo "${classpath}"
784} 833}
785 834
786# ------------------------------------------------------------------------------ 835# ------------------------------------------------------------------------------
787# @ebuild-function java-pkg_getjar 836# @ebuild-function java-pkg_getjar
1135# @ebuild-function java-pkg_get-target 1184# @ebuild-function java-pkg_get-target
1136# 1185#
1137# Determines what target version should be used, for passing to -target. 1186# Determines what target version should be used, for passing to -target.
1138# If you don't care about lower versions, you can set _WANT_TARGET to the 1187# If you don't care about lower versions, you can set _WANT_TARGET to the
1139# version of your JDK. 1188# version of your JDK.
1140# Remember doing this will mostly like cause things to break.
1141# Doesn't allow it to be lower then the one in depend.
1142# Doesn't allow it to be higher then the active vm.
1143# 1189#
1144# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1190# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1145# ------------------------------------------------------------------------------ 1191# ------------------------------------------------------------------------------
1146java-pkg_get-target() { 1192java-pkg_get-target() {
1147 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1148 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1149 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1150 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1151 echo ${JAVA_PKG_WANT_TARGET}
1152 else
1153 echo ${min}
1154 fi
1155 else
1156 echo ${min}
1157 fi
1158
1159 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1193 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1160} 1194}
1161 1195
1162java-pkg_get-javac() { 1196java-pkg_get-javac() {
1163 debug-print-function ${FUNCNAME} $* 1197 debug-print-function ${FUNCNAME} $*
1164 1198
1165 java-pkg_init-compiler_ 1199
1166 local compiler="${GENTOO_COMPILER}" 1200 local compiler="${GENTOO_COMPILER}"
1167 1201
1168 local compiler_executable 1202 local compiler_executable
1169 if [[ "${compiler}" = "javac" ]]; then 1203 if [[ "${compiler}" = "javac" ]]; then
1170 # nothing fancy needs to be done for javac 1204 # nothing fancy needs to be done for javac
1178 unset JAVAC 1212 unset JAVAC
1179 # try to get value of JAVAC 1213 # try to get value of JAVAC
1180 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1214 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1181 export JAVAC=${old_javac} 1215 export JAVAC=${old_javac}
1182 1216
1183 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1217 if [[ -z ${compiler_executable} ]]; then
1218 echo "JAVAC is empty or undefined in ${compiler_env}"
1219 return 1
1220 fi
1184 1221
1185 # check that it's executable 1222 # check that it's executable
1186 if [[ ! -x ${compiler_executable} ]]; then 1223 if [[ ! -x ${compiler_executable} ]]; then
1187 eerror "Could not find ${compiler_executable}!"
1188 die "${compiler_executable} doesn't exist, or isn't executable" 1224 echo "${compiler_executable} doesn't exist, or isn't executable"
1225 return 1
1189 fi 1226 fi
1190 else 1227 else
1191 eerror "Could not find environment file for ${compiler}" 1228 echo "Could not find environment file for ${compiler}"
1192 die "Could not find ${compiler_env}" 1229 return 1
1193 fi 1230 fi
1194 fi 1231 fi
1195 echo ${compiler_executable} 1232 echo ${compiler_executable}
1196} 1233}
1197 1234
1214 1251
1215 debug-print "want source: ${want_source}" 1252 debug-print "want source: ${want_source}"
1216 debug-print "want target: ${want_target}" 1253 debug-print "want target: ${want_target}"
1217 1254
1218 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1255 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1219 debug-print "could not find valid -source/-target values" 1256 debug-print "could not find valid -source/-target values for javac"
1220 die "Could not find valid -source/-target values" 1257 echo "Could not find valid -source/-target values for javac"
1258 return 1
1221 else 1259 else
1222 if java-pkg_is-vm-version-ge "1.4"; then 1260 if java-pkg_is-vm-version-ge "1.4"; then
1223 echo "${source_str} ${target_str}" 1261 echo "${source_str} ${target_str}"
1224 else 1262 else
1225 echo "${target_str}" 1263 echo "${target_str}"
1229 1267
1230# TODO document 1268# TODO document
1231java-pkg_get-jni-cflags() { 1269java-pkg_get-jni-cflags() {
1232 local flags="-I${JAVA_HOME}/include" 1270 local flags="-I${JAVA_HOME}/include"
1233 1271
1272 local platform="linux"
1273 use elibc_FreeBSD && platform="freebsd"
1274
1234 # TODO do a check that the directories are valid 1275 # TODO do a check that the directories are valid
1235 # TODO figure out how to cope with other things than linux...
1236 flags="${flags} -I${JAVA_HOME}/include/linux" 1276 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1237 1277
1238 echo ${flags} 1278 echo ${flags}
1239} 1279}
1240 1280
1241java-pkg_ensure-gcj() { 1281java-pkg_ensure-gcj() {
1247 die "No GCJ support found!" 1287 die "No GCJ support found!"
1248 fi 1288 fi
1249} 1289}
1250 1290
1251java-pkg_ensure-test() { 1291java-pkg_ensure-test() {
1252 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1292 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1293 && hasq test ${IUSE} && ! use test;
1294 then
1253 eerror "You specified FEATURES=test, but USE=test is needed" 1295 eerror "You specified FEATURES=test, but USE=test is needed"
1254 eerror "to pull in the additional dependencies for testing" 1296 eerror "to pull in the additional dependencies for testing"
1255 die "Need USE=test enabled" 1297 die "Need USE=test enabled"
1256 fi 1298 fi
1257} 1299}
1282# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1324# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1283# java-pkg_announce-qa-violation \ 1325# java-pkg_announce-qa-violation \
1284# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1326# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1285# fi 1327# fi
1286 1328
1287 local antflags 1329 local antflags="-Dnoget=true"
1288 java-pkg_init-compiler_ 1330 java-pkg_init-compiler_
1289 local compiler="${GENTOO_COMPILER}" 1331 local compiler="${GENTOO_COMPILER}"
1290 1332
1291 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1333 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1292 1334
1294 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1336 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1295 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1337 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1296 fi 1338 fi
1297 1339
1298 if [[ ${compiler} != "javac" ]]; then 1340 if [[ ${compiler} != "javac" ]]; then
1299 antflags="-Dbuild.compiler=${build_compiler}" 1341 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1300 # Figure out any extra stuff to put on the classpath for compilers aside 1342 # Figure out any extra stuff to put on the classpath for compilers aside
1301 # from javac 1343 # from javac
1302 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1344 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1303 # java-config -p 1345 # java-config -p
1304 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1346 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1330# @param $@ - Arguments to be passed to the compiler 1372# @param $@ - Arguments to be passed to the compiler
1331# ------------------------------------------------------------------------------ 1373# ------------------------------------------------------------------------------
1332ejavac() { 1374ejavac() {
1333 debug-print-function ${FUNCNAME} $* 1375 debug-print-function ${FUNCNAME} $*
1334 1376
1335 # FIXME using get-javac ends up printing stuff with einfo 1377 java-pkg_init-compiler_
1378
1379 local compiler_executable
1336# local compiler_executable=$(java-pkg_get-javac) 1380 compiler_executable=$(java-pkg_get-javac)
1337 local compiler_executable="javac" 1381 if [[ ${?} != 0 ]]; then
1382 eerror "There was a problem determining compiler: ${compiler_executable}"
1383 die "get-javac failed"
1384 fi
1338 1385
1386 local javac_args
1387 javac_args="$(java-pkg_javac-args)"
1388 if [[ ${?} != 0 ]]; then
1389 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1390 die "java-pkg_javac-args failed"
1391 fi
1392
1339 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1393 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1340 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1394 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1341} 1395}
1342 1396
1343# ------------------------------------------------------------------------------ 1397# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_filter-compiler 1398# @ebuild-function java-pkg_filter-compiler
1345# 1399#
1382# @return string - Name of the target to create javadocs 1436# @return string - Name of the target to create javadocs
1383# ------------------------------------------------------------------------------ 1437# ------------------------------------------------------------------------------
1384use_doc() { 1438use_doc() {
1385 use doc && echo ${@:-javadoc} 1439 use doc && echo ${@:-javadoc}
1386} 1440}
1441
1387 1442
1388# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
1389# @section-end build 1444# @section-end build
1390# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1391 1446
1577# Writes the package.env out to disk. 1632# Writes the package.env out to disk.
1578# 1633#
1579# ------------------------------------------------------------------------------ 1634# ------------------------------------------------------------------------------
1580# TODO change to do-write, to match everything else 1635# TODO change to do-write, to match everything else
1581java-pkg_do_write_() { 1636java-pkg_do_write_() {
1637 java-pkg_init_paths_
1582 # Create directory for package.env 1638 # Create directory for package.env
1583 dodir "${JAVA_PKG_SHAREPATH}" 1639 dodir "${JAVA_PKG_SHAREPATH}"
1584 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1640 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1585 # Create package.env 1641 # Create package.env
1586 ( 1642 (
1614 # Strip unnecessary leading and trailing colons 1670 # Strip unnecessary leading and trailing colons
1615 # TODO try to cleanup if possible 1671 # TODO try to cleanup if possible
1616 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1672 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1617 fi 1673 fi
1618} 1674}
1619
1620 1675
1621# ------------------------------------------------------------------------------ 1676# ------------------------------------------------------------------------------
1622# @internal-function java-pkg_record-jar_ 1677# @internal-function java-pkg_record-jar_
1623# 1678#
1624# Record a dependency to the package.env 1679# Record a dependency to the package.env
1705# ------------------------------------------------------------------------------ 1760# ------------------------------------------------------------------------------
1706java-pkg_setup-vm() { 1761java-pkg_setup-vm() {
1707 debug-print-function ${FUNCNAME} $* 1762 debug-print-function ${FUNCNAME} $*
1708 1763
1709 local vendor="$(java-pkg_get-vm-vendor)" 1764 local vendor="$(java-pkg_get-vm-vendor)"
1710 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1765 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1711 addpredict "/dev/random" 1766 addpredict "/dev/random"
1712 elif [[ "${vendor}" == "ibm" ]]; then 1767 elif [[ "${vendor}" == "ibm" ]]; then
1713 addpredict "/proc/self/maps" 1768 addpredict "/proc/self/maps"
1714 addpredict "/proc/cpuinfo" 1769 addpredict "/proc/cpuinfo"
1715 export LANG="C" LC_ALL="C" 1770 export LANG="C" LC_ALL="C"
1764# @return - The version of the current VM 1819# @return - The version of the current VM
1765# ------------------------------------------------------------------------------ 1820# ------------------------------------------------------------------------------
1766java-pkg_get-vm-version() { 1821java-pkg_get-vm-version() {
1767 debug-print-function ${FUNCNAME} $* 1822 debug-print-function ${FUNCNAME} $*
1768 1823
1769 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1824 java-config -g PROVIDES_VERSION
1770} 1825}
1771 1826
1772# ------------------------------------------------------------------------------ 1827# ------------------------------------------------------------------------------
1773# @internal-function java-pkg_switch-vm 1828# @internal-function java-pkg_switch-vm
1774# 1829#
1775# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1830# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1776# verify that the current VM is sufficient. 1831# verify that the current VM is sufficient.
1777# Setup the environment for the VM being used. 1832# Setup the environment for the VM being used.
1778# ------------------------------------------------------------------------------ 1833# ------------------------------------------------------------------------------
1779java-pkg_switch-vm() { 1834java-pkg_switch-vm() {
1835 debug-print-function ${FUNCNAME} $*
1836
1780 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1781 # Use the VM specified by JAVA_PKG_FORCE_VM 1838 # Use the VM specified by JAVA_PKG_FORCE_VM
1782 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1839 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1783 # If you're forcing the VM, I hope you know what your doing... 1840 # If you're forcing the VM, I hope you know what your doing...
1841 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1784 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1842 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1785 # if we're allowed to switch the vm... 1843 # if we're allowed to switch the vm...
1786 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1844 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1787 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1845 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1788 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1846 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1789 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1847 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1790 else 1848 else
1791 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1849 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1850 fi
1851 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1852 eerror "Unable to determine VM for building from dependencies:"
1853 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1854 echo "VNEED: ${JAVA_PKG_VNEED}"
1855 die "Failed to determine VM for building."
1856 else
1857 export GENTOO_VM
1792 fi 1858 fi
1793 # otherwise just make sure the current VM is sufficient 1859 # otherwise just make sure the current VM is sufficient
1794 else 1860 else
1795 java-pkg_ensure-vm-version-sufficient 1861 java-pkg_ensure-vm-version-sufficient
1796 fi 1862 fi
1798 1864
1799 java-pkg_setup-vm 1865 java-pkg_setup-vm
1800 1866
1801 export JAVA=$(java-config --java) 1867 export JAVA=$(java-config --java)
1802 export JAVAC=$(java-config --javac) 1868 export JAVAC=$(java-config --javac)
1803 export JAVACFLAGS="$(java-pkg_javac-args)" 1869 JAVACFLAGS="$(java-pkg_javac-args)"
1870 if [[ ${?} != 0 ]]; then
1871 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1872 die "java-pkg_javac-args failed"
1873 fi
1804 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1874 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1875 export JAVACFLAGS
1805 1876
1806 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1877 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1807 export JDK_HOME=${JAVA_HOME} 1878 export JDK_HOME=${JAVA_HOME}
1808 1879
1809 #TODO If you know a better solution let us know. 1880 #TODO If you know a better solution let us know.
1871 ewarn "Possible problem" 1942 ewarn "Possible problem"
1872 die "Bad class files found" 1943 die "Bad class files found"
1873 fi 1944 fi
1874} 1945}
1875 1946
1876
1877# ------------------------------------------------------------------------------ 1947# ------------------------------------------------------------------------------
1878# @section-end internal 1948# @section-end internal
1879# ------------------------------------------------------------------------------ 1949# ------------------------------------------------------------------------------
1880 1950
1881java-pkg_check-phase() { 1951java-pkg_check-phase() {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20