/[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.12 Revision 1.42
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.42 2007/01/15 00:01:21 caster 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
14# @eclass-maintainer java@gentoo.org 15# @eclass-maintainer java@gentoo.org
15# 16#
16# This eclass provides functionality which is used by 17# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 18# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 19#
19# @warning 20# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 21# 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 22# 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. 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#
40 43
41# ----------------------------------------------------------------------------- 44# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 45# @variable-internal JAVA_PKG_E_DEPEND
43# 46#
44# This is a convience variable to be used from the other java eclasses. This is 47# 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 48# the version of java-config we want to use. We also need a recent version
46# portage, that includes phase hooks. 49# portage, that includes phase hooks.
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 51JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
49 52
50# ----------------------------------------------------------------------------- 53# -----------------------------------------------------------------------------
100# ----------------------------------------------------------------------------- 103# -----------------------------------------------------------------------------
101 104
102# ----------------------------------------------------------------------------- 105# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 106# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 107# @default /usr/share/java-config-2/compiler
105# 108#
106# Directory where compiler settings are saved, without trailing slash. 109# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 110# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 111# -----------------------------------------------------------------------------
109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 112JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
110 113
120 123
121# ----------------------------------------------------------------------------- 124# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 125# @variable-external JAVA_PKG_FORCE_COMPILER
123# 126#
124# Explicitly set a list of compilers to use. This is normally read from 127# Explicitly set a list of compilers to use. This is normally read from
125# JAVA_PKG_COMPILERS_CONF. 128# JAVA_PKG_COMPILERS_CONF.
126# 129#
127# @note This should only be used internally or for testing. 130# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 131# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 132# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 133# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 153# @ebuild-function java-pkg_dojar
151# 154#
152# Installs any number of jars. 155# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 156# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 157# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 158# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 159# Instead, use java-pkg_newjar defined below.
157# 160#
158# @example 161# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 162# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 163#
171 # Create JARDEST if it doesn't exist 174 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 175 dodir ${JAVA_PKG_JARDEST}
173 176
174 local jar 177 local jar
175 # for each jar 178 # for each jar
176 for jar in "$@"; do 179 for jar in ${@}; do
177 local jar_basename=$(basename "${jar}") 180 local jar_basename=$(basename "${jar}")
178 181
179 java-pkg_check-versioned-jar ${jar_basename} 182 java-pkg_check-versioned-jar ${jar_basename}
180 183
181 # check if it exists 184 # check if it exists
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
222# will not work, because: 236# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 237# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 238# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 239# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 240# doesn't exist
227# 241#
228# you have to use it as: 242# you have to use it as:
229# 243#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 244# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 245#
232# @param $@ - jars to record 246# @param $@ - jars to record
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 254 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 255
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.
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 318
307
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
312# They will be installed into /usr/lib by default, but java-pkg_sointo 323# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 324# can be used change this path
314# 325#
315# Example: 326# Example:
370 java-pkg_check-phase install 381 java-pkg_check-phase install
371 382
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 383 [[ ${#} -lt 1 ]] && "at least one argument needed"
373 384
374 java-pkg_init_paths_ 385 java-pkg_init_paths_
375 386
376 local lib target_dir 387 local lib target_dir
377 for lib in "$@" ; do 388 for lib in "$@" ; do
378 # Check the absolute path of the lib 389 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 390 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 391 target_dir="$(java-pkg_expand_dir_ ${lib})"
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
458} 482}
459 483
460# ------------------------------------------------------------------------------ 484# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 485# @ebuild-function java-pkg_dosrc
462# 486#
463# Installs a zip containing the source for a package, so it can used in 487# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 488# from IDEs like eclipse and netbeans.
465# 489#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 490# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 491#
468# It also should be controlled by USE=source. 492# It also should be controlled by USE=source.
469# 493#
470# @example: 494# @example:
471# java-pkg_dosrc src/* 495# java-pkg_dosrc src/*
472# 496#
473# ------------------------------------------------------------------------------ 497# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 498# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 499# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 500# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 501# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 502# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 503java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 504 debug-print-function ${FUNCNAME} $*
481 505
482 [ ${#} -lt 1 ] && die "At least one argument needed" 506 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then 507 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 508 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi 509 fi
486 510
487 java-pkg_check-phase install 511 java-pkg_check-phase install
488 512
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 513 [[ ${#} -lt 1 ]] && die "At least one argument needed"
490 514
491 java-pkg_init_paths_ 515 java-pkg_init_paths_
492 516
493 local zip_name="${PN}-src.zip" 517 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 518 local zip_path="${T}/${zip_name}"
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 too jave' 554# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 555# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 556# --pwd Directory the launcher changes to before executing java
530# -into 557# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 558# -pre Prepend contents of this file to the launcher
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}"
575 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 576 local target_dir pre
546 shift
547 577
548 echo "#!/bin/bash" > "${target}" 578 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 580 local var="${1}" value="${2}"
551 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
582 local var=${var:2}
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
584 local gjl_${var}="${value}"
553 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 586 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 587 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 588 pre="${value}"
557 fi 589 fi
558 shift 2 590 shift 2
559 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
606
607 # Write the actual script
608 echo "#!/bin/bash" > "${target}"
609 if [[ -n "${pre}" ]]; then
610 if [[ -f "${pre}" ]]; then
611 cat "${pre}" >> "${target}"
612 else
613 die "-pre specified file '${pre}' does not exist"
614 fi
615 fi
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 616 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 617 cat "${var_tmp}" >> "${target}"
618 rm -f "${var_tmp}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 619 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 620
564 if [[ -n "${into}" ]]; then 621 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 622 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 623 local ret=$?
567 return ${ret} 624 return ${ret}
568 else 625 else
569 dobin "${target}" 626 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 654 echo "dowar: warning, skipping directory ${war}"
598 continue 655 continue
599 else 656 else
600 warpath="${war}" 657 warpath="${war}"
601 fi 658 fi
602 659
603 # Install those files like you mean it 660 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 661 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 662 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 663 doins ${warpath}
607 done 664 done
642# @ebuild-function java-pkg_jar-from 699# @ebuild-function java-pkg_jar-from
643# 700#
644# Makes a symlink to a jar from a certain package 701# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 702# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 703# You can use this function to replace these bundled dependencies.
704# The dependency is recorded into package.env DEPEND line, unless "--build-only"
705# is passed as the very first argument, for jars that have to be present only
706# at build time and are not needed on runtime (junit testing etc).
647# 707#
648# Example: get all jars from xerces slot 2 708# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 709# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 710# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 711# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 712# Example: get a specific jar from xerces slot 2, and name it diffrently
653# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 713# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
714# Example: get junit.jar which is needed only for building
715# java-pkg_jar-from --build-only junit junit.jar
654# 716#
717# @param $1 - (optional) "--build-only" makes the jar(s) not added into
718# package.env DEPEND line.
655# @param $1 - Package to get jars from. 719# @param $1 - Package to get jars from.
656# @param $2 - jar from package. If not specified, all jars will be used. 720# @param $2 - jar from package. If not specified, all jars will be used.
657# @param $3 - When a single jar is specified, destination filename of the 721# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 722# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 723# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 724# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 725java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 726 debug-print-function ${FUNCNAME} $*
663 727
728 local build_only=""
729
730 if [[ "${1}" = "--build-only" ]]; then
731 build_only="true"
732 shift
733 fi
734
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 735 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 736
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 737 [[ -z ${target_pkg} ]] && die "Must specify a package"
667 738
668 # default destjar to the target jar 739 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 740 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 741
742 local error_msg="There was a problem getting the classpath for ${target_pkg}."
743 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 744 classpath="$(java-config --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 745 [[ $? != 0 ]] && die ${error_msg}
673 746
674 local jar 747 local jar
675 for jar in ${classpath//:/ }; do 748 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 749 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 750 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 754 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 755 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 756 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 757 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 758 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 759 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 760 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 761 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 762 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 763 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 764 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 765 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
693 return 0 766 return 0
694 fi 767 fi
695 done 768 done
696 # if no target was specified, we're ok 769 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 770 if [[ -z "${target_jar}" ]] ; then
714# ------------------------------------------------------------------------------ 787# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 788# @ebuild-function java-pkg_getjars
716# 789#
717# Get the classpath provided by any number of packages 790# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 791# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
792# The providing packages are recorded as dependencies into package.env DEPEND
793# line, unless "--build-only" is passed as the very first argument, for jars
794# that have to be present only at build time and are not needed on runtime
795# (junit testing etc).
719# 796#
720# Example: Get the classpath for xerces-2, 797# Example: Get the classpath for xerces-2 and xalan,
721# java-pkg_getjars xerces-2 xalan 798# java-pkg_getjars xerces-2,xalan
722# Example Return: 799# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 800# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 801#
802# @param $1 - (optional) "--build-only" makes the jar(s) not added into
803# package.env DEPEND line.
725# @param $@ - list of packages to get jars from 804# @param $2 - list of packages to get jars from
805# (passed to java-config --classpath)
726# ------------------------------------------------------------------------------ 806# ------------------------------------------------------------------------------
727java-pkg_getjars() { 807java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 808 debug-print-function ${FUNCNAME} $*
729 809
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 810 if [[ "${1}" = "--build-only" ]]; then
811 local build_only="true"
812 shift
813 fi
731 814
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 815 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
816
733 local classpath pkg 817 local classpath pkgs="${1}"
734 for pkg in ${@//,/ }; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do
736 jars="$(java-config --classpath=${pkg})" 818 jars="$(java-config --classpath=${pkgs})"
819 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
737 debug-print "${pkg}:${jars}" 820 debug-print "${pkgs}:${jars}"
738 # TODO should we ensure jars exist? 821
739 if [[ -z "${classpath}" ]]; then 822 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}" 823 classpath="${jars}"
741 else 824 else
742 classpath="${classpath}:${jars}" 825 classpath="${classpath}:${jars}"
743 fi 826 fi
827
828 # Only record jars that aren't build-only
829 if [[ -z "${build_only}" ]]; then
830 oldifs="${IFS}"
831 IFS=","
832 for pkg in ${pkgs}; do
744 java-pkg_record-jar_ "${pkg}" 833 java-pkg_record-jar_ "${pkg}"
745 done 834 done
835 IFS="${oldifs}"
836 fi
837
746 echo "${classpath}" 838 echo "${classpath}"
747} 839}
748 840
749# ------------------------------------------------------------------------------ 841# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 842# @ebuild-function java-pkg_getjar
751# 843#
752# Get the filename of a single jar from a package 844# Get the filename of a single jar from a package
845# The providing package is recorded as runtime dependency into package.env
846# DEPEND line, unless "--build-only" is passed as the very first argument, for
847# jars that have to be present only at build time and are not needed on runtime
848# (junit testing etc).
753# 849#
754# @example 850# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 851# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 852# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 853# /usr/share/xerces-2/lib/xml-apis.jar
758# 854#
855# @param $1 - (optional) "--build-only" makes the jar not added into
856# package.env DEPEND line.
759# @param $1 - package to use 857# @param $1 - package to use
760# @param $2 - jar to get 858# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 859# ------------------------------------------------------------------------------
762java-pkg_getjar() { 860java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 861 debug-print-function ${FUNCNAME} $*
862
863 local build_only=""
864
865 if [[ "${1}" = "--build-only" ]]; then
866 build_only="true"
867 shift
868 fi
764 869
765 local pkg="${1}" target_jar="${2}" jar 870 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 871 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 872 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 873
769 # TODO check that package is actually installed 874 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
875 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 876 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 877 [[ $? != 0 ]] && die ${error_msg}
878
772 for jar in ${classpath//:/ }; do 879 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 880 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 881 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 882 fi
776 883
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 884 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 885 # Only record jars that aren't build-only
886 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 887 echo "${jar}"
780 return 0 888 return 0
781 fi 889 fi
782 done 890 done
783 891
784 die "Could not find ${target_jar} in ${pkg}" 892 die "Could not find ${target_jar} in ${pkg}"
785 return 1 893 return 1
786} 894}
787 895
788# This function reads stdin, and based on that input, figures out how to 896# This function reads stdin, and based on that input, figures out how to
802# line="${line// /}" 910# line="${line// /}"
803# 911#
804# # format: path=jarinfo 912# # format: path=jarinfo
805# local path=${line%%=*} 913# local path=${line%%=*}
806# local jarinfo=${line##*=} 914# local jarinfo=${line##*=}
807# 915#
808# # format: jar@package 916# # format: jar@package
809# local jar=${jarinfo%%@*}.jar 917# local jar=${jarinfo%%@*}.jar
810# local package=${jarinfo##*@} 918# local package=${jarinfo##*@}
811# if [[ -n ${replace_only} ]]; then 919# if [[ -n ${replace_only} ]]; then
812# [[ ! -f $path ]] && die "No jar exists at ${path}" 920# [[ ! -f $path ]] && die "No jar exists at ${path}"
825# @section-end query 933# @section-end query
826# ------------------------------------------------------------------------------ 934# ------------------------------------------------------------------------------
827 935
828# ------------------------------------------------------------------------------ 936# ------------------------------------------------------------------------------
829# @section-begin helper 937# @section-begin helper
830# @section-summary Helper functions 938# @section-summary Helper functions
831# 939#
832# Various other functions to use from an ebuild 940# Various other functions to use from an ebuild
833# ------------------------------------------------------------------------------ 941# ------------------------------------------------------------------------------
834 942
835# ------------------------------------------------------------------------------ 943# ------------------------------------------------------------------------------
841# jdbc-stdext 949# jdbc-stdext
842# jaf 950# jaf
843# jdbc-rowset 951# jdbc-rowset
844# jms 952# jms
845# 953#
846# @param $1 - Optionally indicate that the dependencies are controlled by 954# @param $1 - Optionally indicate that the dependencies are controlled by
847# a use flag by specifying '--use' Requires $2. 955# a use flag by specifying '--use' Requires $2.
848# @param $2 - USE flag which will enable the dependencies. 956# @param $2 - USE flag which will enable the dependencies.
849# @param $@ - virtual packages to add depenedencies for 957# @param $@ - virtual packages to add depenedencies for
850# ------------------------------------------------------------------------------ 958# ------------------------------------------------------------------------------
851# TODO rewrite to parse a line based declaration file instead -- karltk 959# TODO rewrite to parse a line based declaration file instead -- karltk
907# 1015#
908# export DEPEND="${DEPEND} ${depstr}" 1016# export DEPEND="${DEPEND} ${depstr}"
909# export RDEPEND="${RDEPEND} ${depstr}" 1017# export RDEPEND="${RDEPEND} ${depstr}"
910#} 1018#}
911 1019
1020# ------------------------------------------------------------------------------
1021# @ebuild-function java-pkg_find-normal-jars
1022#
1023# Find the files with suffix .jar file in the given directory or $WORKDIR
1024#
1025# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1026# ------------------------------------------------------------------------------
1027java-pkg_find-normal-jars() {
1028 local dir=$1
1029 [[ "${dir}" ]] || dir="${WORKDIR}"
1030 local found
1031 for jar in $(find "${dir}" -name "*.jar" -type f); do
1032 echo "${jar}"
1033 found="true"
1034 done
1035 [[ "${found}" ]]
1036 return $?
1037}
1038
1039# ------------------------------------------------------------------------------
1040# @ebuild-function java-pkg_ensure-no-bundled-jars
1041#
1042# Try to locate bundled jar files in ${WORKDIR} and die if found.
912# This should be used after S has been populated with symlinks to jars 1043# This function should be called after WORKDIR has been populated with symlink
913# TODO document 1044# to system jar files or bundled jars removed.
1045# ------------------------------------------------------------------------------
914java-pkg_ensure-no-bundled-jars() { 1046java-pkg_ensure-no-bundled-jars() {
915 debug-print-function ${FUNCNAME} $* 1047 debug-print-function ${FUNCNAME} $*
916 pushd ${WORKDIR} >/dev/null 2>/dev/null
917 1048
918 local bundled_jars=$(find . -name "*.jar" -type f) 1049 local bundled_jars=$(java-pkg_find-normal-jars)
919 if [[ -n ${bundled_jars} ]]; then 1050 if [[ -n ${bundled_jars} ]]; then
920 echo "Bundled jars found:" 1051 echo "Bundled jars found:"
921 local jar 1052 local jar
922 for jar in ${bundled_jars}; do 1053 for jar in ${bundled_jars}; do
923 echo $(pwd)${jar/./} 1054 echo $(pwd)${jar/./}
924 done 1055 done
925 die "Bundled jars found!" 1056 die "Bundled jars found!"
926
927 fi 1057 fi
928 popd >/dev/null 2>/dev/null
929} 1058}
930 1059
931# ------------------------------------------------------------------------------ 1060# ------------------------------------------------------------------------------
932# @internal-function java-pkg_ensure-vm-version-sufficient 1061# @internal-function java-pkg_ensure-vm-version-sufficient
933# 1062#
945 fi 1074 fi
946} 1075}
947 1076
948# ------------------------------------------------------------------------------ 1077# ------------------------------------------------------------------------------
949# @internal-function java-pkg_is-vm-version-sufficient 1078# @internal-function java-pkg_is-vm-version-sufficient
950# 1079#
951# @return zero - VM is sufficient 1080# @return zero - VM is sufficient
952# @return non-zero - VM is not sufficient 1081# @return non-zero - VM is not sufficient
953# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
954java-pkg_is-vm-version-sufficient() { 1083java-pkg_is-vm-version-sufficient() {
955 debug-print-function ${FUNCNAME} $* 1084 debug-print-function ${FUNCNAME} $*
975 die "Active Java VM too old" 1104 die "Active Java VM too old"
976 fi 1105 fi
977} 1106}
978 1107
979# ------------------------------------------------------------------------------ 1108# ------------------------------------------------------------------------------
980# @internal-function java-pkg_is-vm-version-eq 1109# @internal-function java-pkg_is-vm-version-eq
981# 1110#
982# @param $@ - VM version to compare current VM to 1111# @param $@ - VM version to compare current VM to
983# @return zero - VM versions are equal 1112# @return zero - VM versions are equal
984# @return non-zero - VM version are not equal 1113# @return non-zero - VM version are not equal
985# ------------------------------------------------------------------------------ 1114# ------------------------------------------------------------------------------
986java-pkg_is-vm-version-eq() { 1115java-pkg_is-vm-version-eq() {
1016# 1145#
1017# @param $@ - VM version to compare current to 1146# @param $@ - VM version to compare current to
1018# ------------------------------------------------------------------------------ 1147# ------------------------------------------------------------------------------
1019java-pkg_ensure-vm-version-ge() { 1148java-pkg_ensure-vm-version-ge() {
1020 debug-print-function ${FUNCNAME} $* 1149 debug-print-function ${FUNCNAME} $*
1021 1150
1022 if ! java-pkg_is-vm-version-ge "$@" ; then 1151 if ! java-pkg_is-vm-version-ge "$@" ; then
1023 debug-print "vm is not suffient" 1152 debug-print "vm is not suffient"
1024 eerror "This package requires a Java VM version >= $@" 1153 eerror "This package requires a Java VM version >= $@"
1025 einfo "Please use java-config -S to set the correct one" 1154 einfo "Please use java-config -S to set the correct one"
1026 die "Active Java VM too old" 1155 die "Active Java VM too old"
1027 fi 1156 fi
1028} 1157}
1029 1158
1030# ------------------------------------------------------------------------------ 1159# ------------------------------------------------------------------------------
1031# @internal-function java-pkg_is-vm-version-ge 1160# @internal-function java-pkg_is-vm-version-ge
1032# 1161#
1033# @param $@ - VM version to compare current VM to 1162# @param $@ - VM version to compare current VM to
1034# @return zero - current VM version is greater than checked version 1163# @return zero - current VM version is greater than checked version
1035# @return non-zero - current VM version is not greater than checked version 1164# @return non-zero - current VM version is not greater than checked version
1036# ------------------------------------------------------------------------------ 1165# ------------------------------------------------------------------------------
1037java-pkg_is-vm-version-ge() { 1166java-pkg_is-vm-version-ge() {
1060java-pkg_get-current-vm() { 1189java-pkg_get-current-vm() {
1061 echo ${GENTOO_VM} 1190 echo ${GENTOO_VM}
1062} 1191}
1063 1192
1064java-pkg_current-vm-matches() { 1193java-pkg_current-vm-matches() {
1065 hasq java-pkg_get-currenv-vm ${@} 1194 hasq $(java-pkg_get-current-vm) ${@}
1066 return $? 1195 return $?
1067} 1196}
1068 1197
1069# ------------------------------------------------------------------------------ 1198# ------------------------------------------------------------------------------
1070# @ebuild-function java-pkg_get-source 1199# @ebuild-function java-pkg_get-source
1071# 1200#
1072# Determines what source version should be used, for passing to -source. 1201# Determines what source version should be used, for passing to -source.
1073# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1202# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1074# 1203#
1075# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1204# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1076# ------------------------------------------------------------------------------ 1205# ------------------------------------------------------------------------------
1081# ------------------------------------------------------------------------------ 1210# ------------------------------------------------------------------------------
1082# @ebuild-function java-pkg_get-target 1211# @ebuild-function java-pkg_get-target
1083# 1212#
1084# Determines what target version should be used, for passing to -target. 1213# Determines what target version should be used, for passing to -target.
1085# If you don't care about lower versions, you can set _WANT_TARGET to the 1214# If you don't care about lower versions, you can set _WANT_TARGET to the
1086# version of your JDK. 1215# version of your JDK.
1087# Remember doing this will mostly like cause things to break.
1088# Doesn't allow it to be lower then the one in depend.
1089# Doesn't allow it to be higher then the active vm.
1090# 1216#
1091# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1217# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1092# ------------------------------------------------------------------------------ 1218# ------------------------------------------------------------------------------
1093java-pkg_get-target() { 1219java-pkg_get-target() {
1094 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1095 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1096 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1097 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1098 echo ${JAVA_PKG_WANT_TARGET}
1099 else
1100 echo ${min}
1101 fi
1102 else
1103 echo ${min}
1104 fi
1105
1106 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1220 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1107} 1221}
1108 1222
1109java-pkg_get-javac() { 1223java-pkg_get-javac() {
1110 debug-print-function ${FUNCNAME} $* 1224 debug-print-function ${FUNCNAME} $*
1111 1225
1112 java-pkg_init-compiler_ 1226
1113 local compiler="${GENTOO_COMPILER}" 1227 local compiler="${GENTOO_COMPILER}"
1114 1228
1115 local compiler_executable 1229 local compiler_executable
1116 if [[ "${compiler}" = "javac" ]]; then 1230 if [[ "${compiler}" = "javac" ]]; then
1117 # nothing fancy needs to be done for javac 1231 # nothing fancy needs to be done for javac
1125 unset JAVAC 1239 unset JAVAC
1126 # try to get value of JAVAC 1240 # try to get value of JAVAC
1127 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1241 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1128 export JAVAC=${old_javac} 1242 export JAVAC=${old_javac}
1129 1243
1130 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1244 if [[ -z ${compiler_executable} ]]; then
1131 1245 echo "JAVAC is empty or undefined in ${compiler_env}"
1246 return 1
1247 fi
1248
1132 # check that it's executable 1249 # check that it's executable
1133 if [[ ! -x ${compiler_executable} ]]; then 1250 if [[ ! -x ${compiler_executable} ]]; then
1134 eerror "Could not find ${compiler_executable}!"
1135 die "${compiler_executable} doesn't exist, or isn't executable" 1251 echo "${compiler_executable} doesn't exist, or isn't executable"
1252 return 1
1136 fi 1253 fi
1137 else 1254 else
1138 eerror "Could not find environment file for ${compiler}" 1255 echo "Could not find environment file for ${compiler}"
1139 die "Could not find ${compiler_env}" 1256 return 1
1140 fi 1257 fi
1141 fi 1258 fi
1142 echo ${compiler_executable} 1259 echo ${compiler_executable}
1143} 1260}
1144 1261
1145# ------------------------------------------------------------------------------ 1262# ------------------------------------------------------------------------------
1146# @ebuild-function java-pkg_javac-args 1263# @ebuild-function java-pkg_javac-args
1147# 1264#
1148# If an ebuild uses javac directly, instead of using ejavac, it should call this 1265# If an ebuild uses javac directly, instead of using ejavac, it should call this
1149# to know what -source/-target to use. 1266# to know what -source/-target to use.
1150# 1267#
1151# @return string - arguments to pass to javac, complete with -target and -source 1268# @return string - arguments to pass to javac, complete with -target and -source
1154 debug-print-function ${FUNCNAME} $* 1271 debug-print-function ${FUNCNAME} $*
1155 1272
1156 local want_source="$(java-pkg_get-source)" 1273 local want_source="$(java-pkg_get-source)"
1157 local want_target="$(java-pkg_get-target)" 1274 local want_target="$(java-pkg_get-target)"
1158 1275
1159 local source_str="-source ${want_source}" 1276 local source_str="-source ${want_source}"
1160 local target_str="-target ${want_target}" 1277 local target_str="-target ${want_target}"
1161 1278
1162 debug-print "want source: ${want_source}" 1279 debug-print "want source: ${want_source}"
1163 debug-print "want target: ${want_target}" 1280 debug-print "want target: ${want_target}"
1164 1281
1165 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1282 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1166 debug-print "could not find valid -source/-target values" 1283 debug-print "could not find valid -source/-target values for javac"
1167 die "Could not find valid -source/-target values" 1284 echo "Could not find valid -source/-target values for javac"
1285 return 1
1168 else 1286 else
1169 if java-pkg_is-vm-version-ge "1.4"; then 1287 if java-pkg_is-vm-version-ge "1.4"; then
1170 echo "${source_str} ${target_str}" 1288 echo "${source_str} ${target_str}"
1171 else 1289 else
1172 echo "${target_str}" 1290 echo "${target_str}"
1176 1294
1177# TODO document 1295# TODO document
1178java-pkg_get-jni-cflags() { 1296java-pkg_get-jni-cflags() {
1179 local flags="-I${JAVA_HOME}/include" 1297 local flags="-I${JAVA_HOME}/include"
1180 1298
1299 local platform="linux"
1300 use elibc_FreeBSD && platform="freebsd"
1301
1181 # TODO do a check that the directories are valid 1302 # TODO do a check that the directories are valid
1182 # TODO figure out how to cope with other things than linux...
1183 flags="${flags} -I${JAVA_HOME}/include/linux" 1303 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1184 1304
1185 echo ${flags} 1305 echo ${flags}
1186} 1306}
1187 1307
1188java-pkg_ensure-gcj() { 1308java-pkg_ensure-gcj() {
1193 ebeep 5 1313 ebeep 5
1194 die "No GCJ support found!" 1314 die "No GCJ support found!"
1195 fi 1315 fi
1196} 1316}
1197 1317
1318java-pkg_ensure-test() {
1319 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1320 && hasq test ${IUSE} && ! use test;
1321 then
1322 eerror "You specified FEATURES=test, but USE=test is needed"
1323 eerror "to pull in the additional dependencies for testing"
1324 die "Need USE=test enabled"
1325 fi
1326}
1327
1198# ------------------------------------------------------------------------------ 1328# ------------------------------------------------------------------------------
1199# @section-end helper 1329# @section-end helper
1200# ------------------------------------------------------------------------------ 1330# ------------------------------------------------------------------------------
1201 1331
1202# ------------------------------------------------------------------------------ 1332# ------------------------------------------------------------------------------
1210# ------------------------------------------------------------------------------ 1340# ------------------------------------------------------------------------------
1211# @ebuild-function eant 1341# @ebuild-function eant
1212# 1342#
1213# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1343# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1214# compiler. 1344# compiler.
1345# variables:
1346# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1347# gentoo.classpath property. Be sure to call
1348# java-ant_rewrite-classpath in src_unpack.
1215# 1349#
1216# ------------------------------------------------------------------------------ 1350# ------------------------------------------------------------------------------
1217eant() { 1351eant() {
1218 debug-print-function ${FUNCNAME} $* 1352 debug-print-function ${FUNCNAME} $*
1219 1353
1221# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1355# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1222# java-pkg_announce-qa-violation \ 1356# java-pkg_announce-qa-violation \
1223# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1357# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1224# fi 1358# fi
1225 1359
1226 local antflags 1360 local antflags="-Dnoget=true"
1227 java-pkg_init-compiler_ 1361 java-pkg_init-compiler_
1228 local compiler="${GENTOO_COMPILER}" 1362 local compiler="${GENTOO_COMPILER}"
1229 1363
1230 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1364 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1231 1365
1233 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1367 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1234 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1368 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1235 fi 1369 fi
1236 1370
1237 if [[ ${compiler} != "javac" ]]; then 1371 if [[ ${compiler} != "javac" ]]; then
1238 antflags="-Dbuild.compiler=${build_compiler}" 1372 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1239 # Figure out any extra stuff to put on the classpath for compilers aside 1373 # Figure out any extra stuff to put on the classpath for compilers aside
1240 # from javac 1374 # from javac
1241 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1375 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1242 # java-config -p 1376 # java-config -p
1243 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1377 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1248 1382
1249 if is-java-strict; then 1383 if is-java-strict; then
1250 einfo "Disabling system classpath for ant" 1384 einfo "Disabling system classpath for ant"
1251 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1385 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1252 fi 1386 fi
1253 1387
1254 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1388 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1255 antflags="${antflags} -debug" 1389 antflags="${antflags} -debug"
1256 fi 1390 fi
1257 1391
1392 local gcp="${EANT_GENTOO_CLASSPATH}"
1393
1394 if [[ "${gcp}" ]]; then
1395 local cp="$(java-pkg_getjars ${gcp})"
1396 # It seems ant does not like single quotes around ${cp}
1397 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1398 fi
1399
1258 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1400 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1259 ant ${antflags} "${@}" || die "eant failed" 1401 ant ${antflags} "${@}" || die "eant failed"
1260 1402
1261} 1403}
1262 1404
1263# ------------------------------------------------------------------------------ 1405# ------------------------------------------------------------------------------
1264# @ebuild-function ejavac 1406# @ebuild-function ejavac
1265# 1407#
1266# Javac wrapper function. Will use the appropriate compiler, based on 1408# Javac wrapper function. Will use the appropriate compiler, based on
1267# /etc/java-config/compilers.conf 1409# /etc/java-config/compilers.conf
1268# 1410#
1269# @param $@ - Arguments to be passed to the compiler 1411# @param $@ - Arguments to be passed to the compiler
1270# ------------------------------------------------------------------------------ 1412# ------------------------------------------------------------------------------
1271ejavac() { 1413ejavac() {
1272 debug-print-function ${FUNCNAME} $* 1414 debug-print-function ${FUNCNAME} $*
1273 1415
1274 # FIXME using get-javac ends up printing stuff with einfo 1416 java-pkg_init-compiler_
1417
1418 local compiler_executable
1275# local compiler_executable=$(java-pkg_get-javac) 1419 compiler_executable=$(java-pkg_get-javac)
1276 local compiler_executable="javac" 1420 if [[ ${?} != 0 ]]; then
1421 eerror "There was a problem determining compiler: ${compiler_executable}"
1422 die "get-javac failed"
1423 fi
1277 1424
1425 local javac_args
1426 javac_args="$(java-pkg_javac-args)"
1427 if [[ ${?} != 0 ]]; then
1428 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1429 die "java-pkg_javac-args failed"
1430 fi
1431
1278 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1432 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1279 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1433 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1280} 1434}
1281 1435
1282# ------------------------------------------------------------------------------ 1436# ------------------------------------------------------------------------------
1283# @ebuild-function java-pkg_filter-compiler 1437# @ebuild-function java-pkg_filter-compiler
1284# 1438#
1285# Used to prevent the use of some compilers. Should be used in src_compile. 1439# Used to prevent the use of some compilers. Should be used in src_compile.
1286# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1440# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1287# 1441#
1288# @param $@ - compilers to filter 1442# @param $@ - compilers to filter
1289# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
1307# ------------------------------------------------------------------------------ 1461# ------------------------------------------------------------------------------
1308# @ebuild-function use_doc 1462# @ebuild-function use_doc
1309# 1463#
1310# Helper function for getting ant to build javadocs. If the user has USE=doc, 1464# Helper function for getting ant to build javadocs. If the user has USE=doc,
1311# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1465# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1312# 1466#
1313# The output of this should be passed to ant. 1467# The output of this should be passed to ant.
1314# 1468#
1315# Example: build javadocs by calling 'javadoc' target 1469# Example: build javadocs by calling 'javadoc' target
1316# eant $(use_doc) 1470# eant $(use_doc)
1317# Example: build javadocs by calling 'apidoc' target 1471# Example: build javadocs by calling 'apidoc' target
1322# ------------------------------------------------------------------------------ 1476# ------------------------------------------------------------------------------
1323use_doc() { 1477use_doc() {
1324 use doc && echo ${@:-javadoc} 1478 use doc && echo ${@:-javadoc}
1325} 1479}
1326 1480
1481
1327# ------------------------------------------------------------------------------ 1482# ------------------------------------------------------------------------------
1328# @section-end build 1483# @section-end build
1329# ------------------------------------------------------------------------------ 1484# ------------------------------------------------------------------------------
1330 1485
1331# ------------------------------------------------------------------------------ 1486# ------------------------------------------------------------------------------
1332# @section-begin internal 1487# @section-begin internal
1333# @section-summary Internal functions 1488# @section-summary Internal functions
1334# 1489#
1335# Do __NOT__ use any of these from an ebuild! These are only to be used from 1490# Do __NOT__ use any of these from an ebuild! These are only to be used from
1336# within the java eclasses. 1491# within the java eclasses.
1337# ------------------------------------------------------------------------------ 1492# ------------------------------------------------------------------------------
1338 1493
1339# ----------------------------------------------------------------------------- 1494# -----------------------------------------------------------------------------
1340# @function-internal java-pkg_init 1495# @function-internal java-pkg_init
1341# 1496#
1342# The purpose of this function, as the name might imply, is to initialize the 1497# The purpose of this function, as the name might imply, is to initialize the
1343# Java environment. It ensures that that there aren't any environment variables 1498# Java environment. It ensures that that there aren't any environment variables
1344# that'll muss things up. It initializes some variables, which are used 1499# that'll muss things up. It initializes some variables, which are used
1345# internally. And most importantly, it'll switch the VM if necessary. 1500# internally. And most importantly, it'll switch the VM if necessary.
1346# 1501#
1358 # TODO we will probably want to set JAVAC and JAVACFLAGS 1513 # TODO we will probably want to set JAVAC and JAVACFLAGS
1359 1514
1360 # Do some QA checks 1515 # Do some QA checks
1361 java-pkg_check-jikes 1516 java-pkg_check-jikes
1362 1517
1363 # When users have crazy classpaths some packages can fail to compile. 1518 # When users have crazy classpaths some packages can fail to compile.
1364 # and everything should work with empty CLASSPATH. 1519 # and everything should work with empty CLASSPATH.
1365 # This also helps prevent unexpected dependencies on random things 1520 # This also helps prevent unexpected dependencies on random things
1366 # from the CLASSPATH. 1521 # from the CLASSPATH.
1367 unset CLASSPATH 1522 unset CLASSPATH
1368} 1523}
1369 1524
1370# ------------------------------------------------------------------------------ 1525# ------------------------------------------------------------------------------
1371# @function-internal java-pkg-init-compiler_ 1526# @function-internal java-pkg-init-compiler_
1372# 1527#
1373# This function attempts to figure out what compiler should be used. It does 1528# This function attempts to figure out what compiler should be used. It does
1374# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1529# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1375# COMPILERS variable defined there. 1530# COMPILERS variable defined there.
1376# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1531# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1377# 1532#
1378# It will go through the list of compilers, and verify that it supports the 1533# It will go through the list of compilers, and verify that it supports the
1379# target and source that are needed. If it is not suitable, then the next 1534# target and source that are needed. If it is not suitable, then the next
1380# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1535# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1381# isn't done. 1536# isn't done.
1382# 1537#
1404 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1559 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1405 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1560 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1406 else 1561 else
1407 compilers=${JAVA_PKG_FORCE_COMPILER} 1562 compilers=${JAVA_PKG_FORCE_COMPILER}
1408 fi 1563 fi
1409 1564
1410 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1565 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1411 1566
1412 # Figure out if we should announce what compiler we're using 1567 # Figure out if we should announce what compiler we're using
1413 local compiler 1568 local compiler
1414 for compiler in ${compilers}; do 1569 for compiler in ${compilers}; do
1417 if [[ ${compiler} = "javac" ]]; then 1572 if [[ ${compiler} = "javac" ]]; then
1418 debug-print "Found javac... breaking" 1573 debug-print "Found javac... breaking"
1419 export GENTOO_COMPILER="javac" 1574 export GENTOO_COMPILER="javac"
1420 break 1575 break
1421 fi 1576 fi
1422 1577
1423 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1578 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1424 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1579 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1425 einfo "Filtering ${compiler}" 1580 einfo "Filtering ${compiler}"
1426 continue 1581 continue
1427 fi 1582 fi
1428 fi 1583 fi
1429 1584
1430 # for non-javac, we need to make sure it supports the right target and 1585 # for non-javac, we need to make sure it supports the right target and
1431 # source 1586 # source
1432 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1587 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1433 if [[ -f ${compiler_env} ]]; then 1588 if [[ -f ${compiler_env} ]]; then
1434 local desired_target="$(java-pkg_get-target)" 1589 local desired_target="$(java-pkg_get-target)"
1516# Writes the package.env out to disk. 1671# Writes the package.env out to disk.
1517# 1672#
1518# ------------------------------------------------------------------------------ 1673# ------------------------------------------------------------------------------
1519# TODO change to do-write, to match everything else 1674# TODO change to do-write, to match everything else
1520java-pkg_do_write_() { 1675java-pkg_do_write_() {
1676 java-pkg_init_paths_
1521 # Create directory for package.env 1677 # Create directory for package.env
1522 dodir "${JAVA_PKG_SHAREPATH}" 1678 dodir "${JAVA_PKG_SHAREPATH}"
1523 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1679 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1524 # Create package.env 1680 # Create package.env
1525 ( 1681 (
1530 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1686 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1531 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1687 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1532 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1688 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1533 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1689 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1534 ) > "${JAVA_PKG_ENV}" 1690 ) > "${JAVA_PKG_ENV}"
1535 1691
1536 # register target/source 1692 # register target/source
1537 local target="$(java-pkg_get-target)" 1693 local target="$(java-pkg_get-target)"
1538 local source="$(java-pkg_get-source)" 1694 local source="$(java-pkg_get-source)"
1539 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1695 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1540 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1696 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1553 # Strip unnecessary leading and trailing colons 1709 # Strip unnecessary leading and trailing colons
1554 # TODO try to cleanup if possible 1710 # TODO try to cleanup if possible
1555 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1711 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1556 fi 1712 fi
1557} 1713}
1558
1559 1714
1560# ------------------------------------------------------------------------------ 1715# ------------------------------------------------------------------------------
1561# @internal-function java-pkg_record-jar_ 1716# @internal-function java-pkg_record-jar_
1562# 1717#
1563# Record a dependency to the package.env 1718# Record a dependency to the package.env
1607 fi 1762 fi
1608} 1763}
1609 1764
1610# ------------------------------------------------------------------------------ 1765# ------------------------------------------------------------------------------
1611# @internal-function java-pkg_expand_dir_ 1766# @internal-function java-pkg_expand_dir_
1612# 1767#
1613# Gets the full path of the file/directory's parent. 1768# Gets the full path of the file/directory's parent.
1614# @param $1 - file/directory to find parent directory for 1769# @param $1 - file/directory to find parent directory for
1615# @return - path to $1's parent directory 1770# @return - path to $1's parent directory
1616# ------------------------------------------------------------------------------ 1771# ------------------------------------------------------------------------------
1617java-pkg_expand_dir_() { 1772java-pkg_expand_dir_() {
1644# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1645java-pkg_setup-vm() { 1800java-pkg_setup-vm() {
1646 debug-print-function ${FUNCNAME} $* 1801 debug-print-function ${FUNCNAME} $*
1647 1802
1648 local vendor="$(java-pkg_get-vm-vendor)" 1803 local vendor="$(java-pkg_get-vm-vendor)"
1649 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1804 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1650 addpredict "/dev/random" 1805 addpredict "/dev/random"
1651 elif [[ "${vendor}" == "ibm" ]]; then 1806 elif [[ "${vendor}" == "ibm" ]]; then
1652 addpredict "/proc/self/maps" 1807 addpredict "/proc/self/maps"
1653 addpredict "/proc/cpuinfo" 1808 addpredict "/proc/cpuinfo"
1654 export LANG="C" LC_ALL="C" 1809 export LANG="C" LC_ALL="C"
1703# @return - The version of the current VM 1858# @return - The version of the current VM
1704# ------------------------------------------------------------------------------ 1859# ------------------------------------------------------------------------------
1705java-pkg_get-vm-version() { 1860java-pkg_get-vm-version() {
1706 debug-print-function ${FUNCNAME} $* 1861 debug-print-function ${FUNCNAME} $*
1707 1862
1708 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1863 java-config -g PROVIDES_VERSION
1709} 1864}
1710 1865
1711# ------------------------------------------------------------------------------ 1866# ------------------------------------------------------------------------------
1712# @internal-function java-pkg_switch-vm 1867# @internal-function java-pkg_switch-vm
1713# 1868#
1714# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1869# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1715# verify that the current VM is sufficient. 1870# verify that the current VM is sufficient.
1716# Setup the environment for the VM being used. 1871# Setup the environment for the VM being used.
1717# ------------------------------------------------------------------------------ 1872# ------------------------------------------------------------------------------
1718java-pkg_switch-vm() { 1873java-pkg_switch-vm() {
1874 debug-print-function ${FUNCNAME} $*
1875
1719 if java-pkg_needs-vm; then 1876 if java-pkg_needs-vm; then
1720 # Use the VM specified by JAVA_PKG_FORCE_VM 1877 # Use the VM specified by JAVA_PKG_FORCE_VM
1721 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1878 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1722 # If you're forcing the VM, I hope you know what your doing... 1879 # If you're forcing the VM, I hope you know what your doing...
1880 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1723 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1881 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1724 # if we're allowed to switch the vm... 1882 # if we're allowed to switch the vm...
1725 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1883 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1726 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1884 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1727 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1885 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1728 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1886 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1729 else 1887 else
1730 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1888 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1889 fi
1890 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1891 eerror "Unable to determine VM for building from dependencies:"
1892 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1893 echo "VNEED: ${JAVA_PKG_VNEED}"
1894 die "Failed to determine VM for building."
1895 else
1896 export GENTOO_VM
1731 fi 1897 fi
1732 # otherwise just make sure the current VM is sufficient 1898 # otherwise just make sure the current VM is sufficient
1733 else 1899 else
1734 java-pkg_ensure-vm-version-sufficient 1900 java-pkg_ensure-vm-version-sufficient
1735 fi 1901 fi
1736 debug-print "Using: $(java-config -f)" 1902 debug-print "Using: $(java-config -f)"
1737 1903
1738 java-pkg_setup-vm 1904 java-pkg_setup-vm
1739 1905
1740 export JAVA=$(java-config --java) 1906 export JAVA=$(java-config --java)
1741 export JAVAC=$(java-config --javac) 1907 export JAVAC=$(java-config --javac)
1742 export JAVACFLAGS="$(java-pkg_javac-args)" 1908 JAVACFLAGS="$(java-pkg_javac-args)"
1909 if [[ ${?} != 0 ]]; then
1910 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1911 die "java-pkg_javac-args failed"
1912 fi
1743 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1913 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1914 export JAVACFLAGS
1744 1915
1745 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1916 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1746 export JDK_HOME=${JAVA_HOME} 1917 export JDK_HOME=${JAVA_HOME}
1747 1918
1748 #TODO If you know a better solution let us know. 1919 #TODO If you know a better solution let us know.
1749 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1920 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1750 1921
1751 local tann="${T}/announced-vm" 1922 local tann="${T}/announced-vm"
1752 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1923 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1753 # Add a check for setup/preinst phase... to avoid duplicate outputs 1924 # Add a check for setup/preinst phase... to avoid duplicate outputs
1754 # for when FEATURES=buildpkg 1925 # for when FEATURES=buildpkg
1755 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1926 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1799# TODO document 1970# TODO document
1800# Verify that the classes were compiled for the right source / target 1971# Verify that the classes were compiled for the right source / target
1801java-pkg_verify-classes() { 1972java-pkg_verify-classes() {
1802 ebegin "Verifying java class versions" 1973 ebegin "Verifying java class versions"
1803 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 1974 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1804 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 1975 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1805 result=$? 1976 result=$?
1806 eend ${result} 1977 eend ${result}
1807 if [[ ${result} == 0 ]]; then 1978 if [[ ${result} == 0 ]]; then
1808 einfo "All good" 1979 einfo "All good"
1809 else 1980 else
1810 ewarn "Possible problem" 1981 ewarn "Possible problem"
1811 die "Bad class files found" 1982 die "Bad class files found"
1812 fi 1983 fi
1813} 1984}
1814 1985
1815
1816# ------------------------------------------------------------------------------ 1986# ------------------------------------------------------------------------------
1817# @section-end internal 1987# @section-end internal
1818# ------------------------------------------------------------------------------ 1988# ------------------------------------------------------------------------------
1819 1989
1820java-pkg_check-phase() { 1990java-pkg_check-phase() {
1851 let "JAVA_PKG_QA_VIOLATIONS+=1" 2021 let "JAVA_PKG_QA_VIOLATIONS+=1"
1852 export JAVA_PKG_QA_VIOLATIONS 2022 export JAVA_PKG_QA_VIOLATIONS
1853} 2023}
1854 2024
1855is-java-strict() { 2025is-java-strict() {
1856 hasq java-strict ${FEATURES} && ! hasq -java-strict ${FEATURES} 2026 [[ -n ${JAVA_PKG_STRICT} ]]
1857 return $? 2027 return $?
1858} 2028}
1859 2029
1860# ------------------------------------------------------------------------------ 2030# ------------------------------------------------------------------------------
1861# @eclass-end 2031# @eclass-end

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.42

  ViewVC Help
Powered by ViewVC 1.1.20