/[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.5 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
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#
33# ----------------------------------------------------------------------------- 36# -----------------------------------------------------------------------------
34 37
35# Make sure we use java-config-2 38# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 39export WANT_JAVA_CONFIG="2"
37 40
41# TODO document
42JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
43
38# ----------------------------------------------------------------------------- 44# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 45# @variable-internal JAVA_PKG_E_DEPEND
40# 46#
41# 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
42# 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
43# portage, that includes phase hooks. 49# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 51JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 52
47# ----------------------------------------------------------------------------- 53# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 54# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 55# @variable-default yes
50# 56#
97# ----------------------------------------------------------------------------- 103# -----------------------------------------------------------------------------
98 104
99# ----------------------------------------------------------------------------- 105# -----------------------------------------------------------------------------
100# @variable-internal JAVA_PKG_COMPILER_DIR 106# @variable-internal JAVA_PKG_COMPILER_DIR
101# @default /usr/share/java-config-2/compiler 107# @default /usr/share/java-config-2/compiler
102# 108#
103# Directory where compiler settings are saved, without trailing slash. 109# Directory where compiler settings are saved, without trailing slash.
104# Probably shouldn't touch this variable. 110# Probably shouldn't touch this variable.
105# ----------------------------------------------------------------------------- 111# -----------------------------------------------------------------------------
106JAVA_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"}
107 113
117 123
118# ----------------------------------------------------------------------------- 124# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_FORCE_COMPILER 125# @variable-external JAVA_PKG_FORCE_COMPILER
120# 126#
121# 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
122# JAVA_PKG_COMPILERS_CONF. 128# JAVA_PKG_COMPILERS_CONF.
123# 129#
124# @note This should only be used internally or for testing. 130# @note This should only be used internally or for testing.
125# @example Use jikes and javac, in that order 131# @example Use jikes and javac, in that order
126# JAVA_PKG_FORCE_COMPILER="jikes javac" 132# JAVA_PKG_FORCE_COMPILER="jikes javac"
127# ----------------------------------------------------------------------------- 133# -----------------------------------------------------------------------------
147# @ebuild-function java-pkg_dojar 153# @ebuild-function java-pkg_dojar
148# 154#
149# Installs any number of jars. 155# Installs any number of jars.
150# 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.
151# You can use java-pkg_jarinto to change this path. 157# You can use java-pkg_jarinto to change this path.
152# 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.
153# Instead, use java-pkg_newjar defined below. 159# Instead, use java-pkg_newjar defined below.
154# 160#
155# @example 161# @example
156# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 162# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
157# 163#
197 203
198 java-pkg_do_write_ 204 java-pkg_do_write_
199} 205}
200 206
201 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}
202 219
203# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
204# @ebuild-function java-pkg_regjar 221# @ebuild-function java-pkg_regjar
205# 222#
206# Records an already installed jar in the package.env 223# Records an already installed jar in the package.env
219# will not work, because: 236# will not work, because:
220# * 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
221# don't exist yet 238# don't exist yet
222# * 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'
223# doesn't exist 240# doesn't exist
224# 241#
225# you have to use it as: 242# you have to use it as:
226# 243#
227# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 244# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
228# 245#
229# @param $@ - jars to record 246# @param $@ - jars to record
230# ------------------------------------------------------------------------------ 247# ------------------------------------------------------------------------------
231# TODO fix me! 248# TODO should we be making sure the jar is present on ${D} or wherever?
232java-pkg_regjar() { 249java-pkg_regjar() {
233 debug-print-function ${FUNCNAME} $* 250 debug-print-function ${FUNCNAME} $*
234 251
235 java-pkg_check-phase install 252 java-pkg_check-phase install
236 253
239 java-pkg_init_paths_ 256 java-pkg_init_paths_
240 257
241 local jar jar_dir jar_file 258 local jar jar_dir jar_file
242 for jar in "$@"; do 259 for jar in "$@"; do
243 # TODO use java-pkg_check-versioned-jar 260 # TODO use java-pkg_check-versioned-jar
244 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 $*"
245 # 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:
246 # imagine such call: 265 # imagine such call:
247 # java-pkg_regjar ${D}/opt/java/*.jar 266 # java-pkg_regjar ${D}/opt/java/*.jar
248 # such call will fall into this case (-e ${jar}) and will 267 # such call will fall into this case (-e ${jar}) and will
249 # record paths with ${D} in package.env 268 # record paths with ${D} in package.env
250 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 269 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
251 elif [[ -e "${D}${jar}" ]]; then
252 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
253 else 270 else
254 die "${jar} does not exist" 271 die "${jar} does not exist"
255 fi 272 fi
256 done 273 done
257 274
258 java-pkg_do_write_ 275 java-pkg_do_write_
259} 276}
260
261 277
262# ------------------------------------------------------------------------------ 278# ------------------------------------------------------------------------------
263# @ebuild-function java-pkg_newjar 279# @ebuild-function java-pkg_newjar
264# 280#
265# Installs a jar with a new name 281# Installs a jar with a new name
276 local original_jar="${1}" 292 local original_jar="${1}"
277 local new_jar="${2:-${PN}.jar}" 293 local new_jar="${2:-${PN}.jar}"
278 local new_jar_dest="${T}/${new_jar}" 294 local new_jar_dest="${T}/${new_jar}"
279 295
280 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 296 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
281 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 297 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
282 298
283 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 299 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
284 cp "${original_jar}" "${new_jar_dest}" \ 300 cp "${original_jar}" "${new_jar_dest}" \
285 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 301 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
286 java-pkg_dojar "${new_jar_dest}" 302 java-pkg_dojar "${new_jar_dest}"
287} 303}
288 304
289
290# ------------------------------------------------------------------------------ 305# ------------------------------------------------------------------------------
291# @ebuild-function java-pkg_addcp 306# @ebuild-function java-pkg_addcp
292# 307#
293# 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,
294# 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.
299java-pkg_addcp() { 314java-pkg_addcp() {
300 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 315 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
301 java-pkg_do_write_ 316 java-pkg_do_write_
302} 317}
303 318
304
305# ------------------------------------------------------------------------------ 319# ------------------------------------------------------------------------------
306# @ebuild-function java-pkg_doso 320# @ebuild-function java-pkg_doso
307# 321#
308# Installs any number of JNI libraries 322# Installs any number of JNI libraries
309# 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
310# can be used change this path 324# can be used change this path
311# 325#
312# Example: 326# Example:
367 java-pkg_check-phase install 381 java-pkg_check-phase install
368 382
369 [[ ${#} -lt 1 ]] && "at least one argument needed" 383 [[ ${#} -lt 1 ]] && "at least one argument needed"
370 384
371 java-pkg_init_paths_ 385 java-pkg_init_paths_
372 386
373 local lib target_dir 387 local lib target_dir
374 for lib in "$@" ; do 388 for lib in "$@" ; do
375 # Check the absolute path of the lib 389 # Check the absolute path of the lib
376 if [[ -e "${lib}" ]] ; then 390 if [[ -e "${lib}" ]] ; then
377 target_dir="$(java-pkg_expand_dir_ ${lib})" 391 target_dir="$(java-pkg_expand_dir_ ${lib})"
425# ------------------------------------------------------------------------------ 439# ------------------------------------------------------------------------------
426java-pkg_dohtml() { 440java-pkg_dohtml() {
427 debug-print-function ${FUNCNAME} $* 441 debug-print-function ${FUNCNAME} $*
428 442
429 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 443 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
430 # 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.
431 dohtml -f package-list "$@" 447 dohtml -f package-list "$@"
448
432 # this probably shouldn't be here but it provides 449 # this probably shouldn't be here but it provides
433 # a reasonable way to catch # docs for all of the 450 # a reasonable way to catch # docs for all of the
434 # old ebuilds. 451 # old ebuilds.
435 java-pkg_recordjavadoc 452 java-pkg_recordjavadoc
436} 453}
437 454
438# 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# ------------------------------------------------------------------------------
439java-pkg_dojavadoc() { 466java-pkg_dojavadoc() {
440 local dir="$1" 467 local dir="$1"
441 468
442 java-pkg_check-phase install 469 java-pkg_check-phase install
443 470
455} 482}
456 483
457# ------------------------------------------------------------------------------ 484# ------------------------------------------------------------------------------
458# @ebuild-function java-pkg_dosrc 485# @ebuild-function java-pkg_dosrc
459# 486#
460# 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
461# from IDEs like eclipse and netbeans. 488# from IDEs like eclipse and netbeans.
462# 489#
463# Ebuild needs to DEPEND on app-arch/zip to use this. 490# Ebuild needs to DEPEND on app-arch/zip to use this.
464# 491#
465# It also should be controlled by USE=source. 492# It also should be controlled by USE=source.
466# 493#
467# @example: 494# @example:
468# java-pkg_dosrc src/* 495# java-pkg_dosrc src/*
469# 496#
470# ------------------------------------------------------------------------------ 497# ------------------------------------------------------------------------------
471# 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
472# source -nichoj 499# source -nichoj
473# 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
474# TODO maybe we can take an existing zip/jar? -nichoj 501# TODO maybe we can take an existing zip/jar? -nichoj
475# FIXME apparently this fails if you give it an empty directories 502# FIXME apparently this fails if you give it an empty directories
476java-pkg_dosrc() { 503java-pkg_dosrc() {
477 debug-print-function ${FUNCNAME} $* 504 debug-print-function ${FUNCNAME} $*
478 505
479 [ ${#} -lt 1 ] && die "At least one argument needed" 506 [ ${#} -lt 1 ] && die "At least one argument needed"
480 if ! hasq source ${IUSE}; then 507 if ! hasq source ${IUSE}; then
481 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 508 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
482 fi 509 fi
483 510
484 java-pkg_check-phase install 511 java-pkg_check-phase install
485 512
486 [[ ${#} -lt 1 ]] && die "At least one argument needed" 513 [[ ${#} -lt 1 ]] && die "At least one argument needed"
487 514
488 java-pkg_init_paths_ 515 java-pkg_init_paths_
489 516
490 local zip_name="${PN}-src.zip" 517 local zip_name="${PN}-src.zip"
491 local zip_path="${T}/${zip_name}" 518 local zip_path="${T}/${zip_name}"
515# @ebuild-function java-pkg_dolauncher 542# @ebuild-function java-pkg_dolauncher
516# 543#
517# Make a wrapper script to lauch/start this package 544# Make a wrapper script to lauch/start this package
518# If necessary, the wrapper will switch to the appropriate VM. 545# If necessary, the wrapper will switch to the appropriate VM.
519# 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#
520# @param $1 - filename of launcher to create 550# @param $1 - filename of launcher to create
521# @param $2 - options, as follows: 551# @param $2 - options, as follows:
522# --main the.main.class.too.start 552# --main the.main.class.too.start
523# --jar /the/jar/too/launch.jar 553# --jar /the/jar/too/launch.jar or just <name>.jar
524# --java_args 'Extra arguments to pass too jave' 554# --java_args 'Extra arguments to pass to java'
525# --pkg_args 'extra arguments too pass too the package' 555# --pkg_args 'Extra arguments too pass to the package'
526# --pwd 556# --pwd
527# -into 557# -into
528# -pre 558# -pre
529# ------------------------------------------------------------------------------ 559# ------------------------------------------------------------------------------
530java-pkg_dolauncher() { 560java-pkg_dolauncher() {
531 debug-print-function ${FUNCNAME} $* 561 debug-print-function ${FUNCNAME} $*
532 562
533 java-pkg_check-phase install 563 java-pkg_check-phase install
534
535 [[ ${#} -lt 1 ]] && die "Need at least one argument"
536
537 java-pkg_init_paths_ 564 java-pkg_init_paths_
538 565
566 if [[ ${#} = 0 ]]; then
567 local name="${PN}"
568 else
539 local name="${1}" 569 local name="${1}"
570 shift
571 fi
572
540 # TODO rename to launcher 573 # TODO rename to launcher
541 local target="${T}/${name}" 574 local target="${T}/${name}"
575 local var_tmp="${T}/launcher_variables_tmp"
542 local target_dir pre 576 local target_dir pre
543 shift
544 577
545 echo "#!/bin/bash" > "${target}" 578 # Process the other the rest of the arguments
546 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
547 local var=${1} value=${2} 580 local var="${1}" value="${2}"
548 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
582 local var=${var:2}
549 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
584 local gjl_${var}="${value}"
550 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
551 target_dir="${value}" 586 target_dir="${value}"
552 elif [[ "${var}" == "-pre" ]]; then 587 elif [[ "${var}" == "-pre" ]]; then
553 pre="${value}" 588 pre="${value}"
554 fi 589 fi
555 shift 2 590 shift 2
556 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 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
557 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 610 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
558 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 611 cat "${var_tmp}" >> "${target}"
612 rm -f "${var_tmp}"
559 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 613 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
560 614
561 if [[ -n "${into}" ]]; then 615 if [[ -n "${target_dir}" ]]; then
562 DESTTREE="${target_dir}" dobin "${target}" 616 DESTTREE="${target_dir}" dobin "${target}"
563 local ret=$? 617 local ret=$?
564 return ${ret} 618 return ${ret}
565 else 619 else
566 dobin "${target}" 620 dobin "${target}"
594 echo "dowar: warning, skipping directory ${war}" 648 echo "dowar: warning, skipping directory ${war}"
595 continue 649 continue
596 else 650 else
597 warpath="${war}" 651 warpath="${war}"
598 fi 652 fi
599 653
600 # Install those files like you mean it 654 # Install those files like you mean it
601 INSOPTIONS="-m 0644" \ 655 INSOPTIONS="-m 0644" \
602 INSDESTTREE=${JAVA_PKG_WARDEST} \ 656 INSDESTTREE=${JAVA_PKG_WARDEST} \
603 doins ${warpath} 657 doins ${warpath}
604 done 658 done
639# @ebuild-function java-pkg_jar-from 693# @ebuild-function java-pkg_jar-from
640# 694#
641# Makes a symlink to a jar from a certain package 695# Makes a symlink to a jar from a certain package
642# A lot of java packages include dependencies in a lib/ directory 696# A lot of java packages include dependencies in a lib/ directory
643# You can use this function to replace these bundled dependencies. 697# You can use this function to replace these bundled dependencies.
698# The dependency is recorded into package.env DEPEND line, unless "--build-only"
699# is passed as the very first argument, for jars that have to be present only
700# at build time and are not needed on runtime (junit testing etc).
644# 701#
645# Example: get all jars from xerces slot 2 702# Example: get all jars from xerces slot 2
646# java-pkg_jar-from xerces-2 703# java-pkg_jar-from xerces-2
647# Example: get a specific jar from xerces slot 2 704# Example: get a specific jar from xerces slot 2
648# java-pkg_jar-from xerces-2 xml-apis.jar 705# java-pkg_jar-from xerces-2 xml-apis.jar
649# Example get a specific jar from xerces slot 2, and name it diffrently 706# Example: get a specific jar from xerces slot 2, and name it diffrently
650# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 707# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
708# Example: get junit.jar which is needed only for building
709# java-pkg_jar-from --build-only junit junit.jar
651# 710#
711# @param $1 - (optional) "--build-only" makes the jar(s) not added into
712# package.env DEPEND line.
652# @param $1 - Package to get jars from. 713# @param $1 - Package to get jars from.
653# @param $2 - jar from package. If not specified, all jars will be used. 714# @param $2 - jar from package. If not specified, all jars will be used.
654# @param $3 - When a single jar is specified, destination filename of the 715# @param $3 - When a single jar is specified, destination filename of the
655# symlink. Defaults to the name of the jar. 716# symlink. Defaults to the name of the jar.
656# ------------------------------------------------------------------------------ 717# ------------------------------------------------------------------------------
657# TODO could probably be cleaned up a little 718# TODO could probably be cleaned up a little
658java-pkg_jar-from() { 719java-pkg_jar-from() {
659 debug-print-function ${FUNCNAME} $* 720 debug-print-function ${FUNCNAME} $*
660 721
722 local build_only=""
723
724 if [[ "${1}" = "--build-only" ]]; then
725 build_only="true"
726 shift
727 fi
728
661 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 729 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
662 730
663 [[ -z ${target_pkg} ]] && die "Must specify a package" 731 [[ -z ${target_pkg} ]] && die "Must specify a package"
664 732
665 # default destjar to the target jar 733 # default destjar to the target jar
666 [[ -z "${destjar}" ]] && destjar="${target_jar}" 734 [[ -z "${destjar}" ]] && destjar="${target_jar}"
667 735
736 local error_msg="There was a problem getting the classpath for ${target_pkg}."
737 local classpath
668 local classpath="$(java-config --classpath=${target_pkg})" 738 classpath="$(java-config --classpath=${target_pkg})"
669 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 739 [[ $? != 0 ]] && die ${error_msg}
670 740
671 local jar 741 local jar
672 for jar in ${classpath//:/ }; do 742 for jar in ${classpath//:/ }; do
673 local jar_name=$(basename "${jar}") 743 local jar_name=$(basename "${jar}")
674 if [[ ! -f "${jar}" ]] ; then 744 if [[ ! -f "${jar}" ]] ; then
678 # If no specific target jar was indicated, link it 748 # If no specific target jar was indicated, link it
679 if [[ -z "${target_jar}" ]] ; then 749 if [[ -z "${target_jar}" ]] ; then
680 [[ -f "${target_jar}" ]] && rm "${target_jar}" 750 [[ -f "${target_jar}" ]] && rm "${target_jar}"
681 ln -snf "${jar}" \ 751 ln -snf "${jar}" \
682 || die "Failed to make symlink from ${jar} to ${jar_name}" 752 || die "Failed to make symlink from ${jar} to ${jar_name}"
683 java-pkg_record-jar_ "${target_pkg}" "${jar}" 753 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
684 # otherwise, if the current jar is the target jar, link it 754 # otherwise, if the current jar is the target jar, link it
685 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 755 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
686 [[ -f "${destjar}" ]] && rm "${destjar}" 756 [[ -f "${destjar}" ]] && rm "${destjar}"
687 ln -snf "${jar}" "${destjar}" \ 757 ln -snf "${jar}" "${destjar}" \
688 || die "Failed to make symlink from ${jar} to ${destjar}" 758 || die "Failed to make symlink from ${jar} to ${destjar}"
689 java-pkg_record-jar_ "${target_pkg}" "${jar}" 759 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
690 return 0 760 return 0
691 fi 761 fi
692 done 762 done
693 # if no target was specified, we're ok 763 # if no target was specified, we're ok
694 if [[ -z "${target_jar}" ]] ; then 764 if [[ -z "${target_jar}" ]] ; then
711# ------------------------------------------------------------------------------ 781# ------------------------------------------------------------------------------
712# @ebuild-function java-pkg_getjars 782# @ebuild-function java-pkg_getjars
713# 783#
714# Get the classpath provided by any number of packages 784# Get the classpath provided by any number of packages
715# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 785# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
786# The providing packages are recorded as dependencies into package.env DEPEND
787# line, unless "--build-only" is passed as the very first argument, for jars
788# that have to be present only at build time and are not needed on runtime
789# (junit testing etc).
716# 790#
717# Example: Get the classpath for xerces-2, 791# Example: Get the classpath for xerces-2 and xalan,
718# java-pkg_getjars xerces-2 xalan 792# java-pkg_getjars xerces-2,xalan
719# Example Return: 793# Example Return:
720# /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
721# 795#
796# @param $1 - (optional) "--build-only" makes the jar(s) not added into
797# package.env DEPEND line.
722# @param $@ - list of packages to get jars from 798# @param $2 - list of packages to get jars from
799# (passed to java-config --classpath)
723# ------------------------------------------------------------------------------ 800# ------------------------------------------------------------------------------
724java-pkg_getjars() { 801java-pkg_getjars() {
725 debug-print-function ${FUNCNAME} $* 802 debug-print-function ${FUNCNAME} $*
726 803
727 [[ ${#} -lt 1 ]] && die "At least one argument needed" 804 if [[ "${1}" = "--build-only" ]]; then
805 local build_only="true"
806 shift
807 fi
728 808
729 # NOTE could probably just pass $@ to java-config --classpath. and return it 809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
810
730 local classpath pkg 811 local classpath pkgs="${1}"
731 for pkg in ${@//,/ }; do
732 #for pkg in $(echo "$@" | tr ',' ' '); do
733 jars="$(java-config --classpath=${pkg})" 812 jars="$(java-config --classpath=${pkgs})"
813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
734 debug-print "${pkg}:${jars}" 814 debug-print "${pkgs}:${jars}"
735 # TODO should we ensure jars exist? 815
736 if [[ -z "${classpath}" ]]; then 816 if [[ -z "${classpath}" ]]; then
737 classpath="${jars}" 817 classpath="${jars}"
738 else 818 else
739 classpath="${classpath}:${jars}" 819 classpath="${classpath}:${jars}"
740 fi 820 fi
821
822 # Only record jars that aren't build-only
823 if [[ -z "${build_only}" ]]; then
824 oldifs="${IFS}"
825 IFS=","
826 for pkg in ${pkgs}; do
741 java-pkg_record-jar_ "${pkg}" 827 java-pkg_record-jar_ "${pkg}"
742 done 828 done
829 IFS="${oldifs}"
830 fi
831
743 echo "${classpath}" 832 echo "${classpath}"
744} 833}
745 834
746# ------------------------------------------------------------------------------ 835# ------------------------------------------------------------------------------
747# @ebuild-function java-pkg_getjar 836# @ebuild-function java-pkg_getjar
748# 837#
749# Get the filename of a single jar from a package 838# Get the filename of a single jar from a package
839# The providing package is recorded as runtime dependency into package.env
840# DEPEND line, unless "--build-only" is passed as the very first argument, for
841# jars that have to be present only at build time and are not needed on runtime
842# (junit testing etc).
750# 843#
751# @example 844# @example
752# java-pkg_getjar xerces-2 xml-apis.jar 845# java-pkg_getjar xerces-2 xml-apis.jar
753# @example-return 846# @example-return
754# /usr/share/xerces-2/lib/xml-apis.jar 847# /usr/share/xerces-2/lib/xml-apis.jar
755# 848#
849# @param $1 - (optional) "--build-only" makes the jar not added into
850# package.env DEPEND line.
756# @param $1 - package to use 851# @param $1 - package to use
757# @param $2 - jar to get 852# @param $2 - jar to get
758# ------------------------------------------------------------------------------ 853# ------------------------------------------------------------------------------
759java-pkg_getjar() { 854java-pkg_getjar() {
760 debug-print-function ${FUNCNAME} $* 855 debug-print-function ${FUNCNAME} $*
856
857 local build_only=""
858
859 if [[ "${1}" = "--build-only" ]]; then
860 build_only="true"
861 shift
862 fi
761 863
762 local pkg="${1}" target_jar="${2}" jar 864 local pkg="${1}" target_jar="${2}" jar
763 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 865 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
764 [[ -z ${target_jar} ]] && die "Must specify jar to get" 866 [[ -z ${target_jar} ]] && die "Must specify jar to get"
765 867
766 # TODO check that package is actually installed 868 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
869 local classpath
767 local classpath=$(java-config --classpath=${pkg}) 870 classpath=$(java-config --classpath=${pkg})
768 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 871 [[ $? != 0 ]] && die ${error_msg}
872
769 for jar in ${classpath//:/ }; do 873 for jar in ${classpath//:/ }; do
770 if [[ ! -f "${jar}" ]] ; then 874 if [[ ! -f "${jar}" ]] ; then
771 die "Installation problems with jars in ${pkg} - is it installed?" 875 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
772 fi 876 fi
773 877
774 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 878 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
775 java-pkg_record-jar_ "${pkg}" "${jar}" 879 # Only record jars that aren't build-only
880 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
776 echo "${jar}" 881 echo "${jar}"
777 return 0 882 return 0
778 fi 883 fi
779 done 884 done
780 885
781 die "Could not find ${target_jar} in ${pkg}" 886 die "Could not find ${target_jar} in ${pkg}"
782 return 1 887 return 1
783} 888}
784 889
785# This function reads stdin, and based on that input, figures out how to 890# This function reads stdin, and based on that input, figures out how to
799# line="${line// /}" 904# line="${line// /}"
800# 905#
801# # format: path=jarinfo 906# # format: path=jarinfo
802# local path=${line%%=*} 907# local path=${line%%=*}
803# local jarinfo=${line##*=} 908# local jarinfo=${line##*=}
804# 909#
805# # format: jar@package 910# # format: jar@package
806# local jar=${jarinfo%%@*}.jar 911# local jar=${jarinfo%%@*}.jar
807# local package=${jarinfo##*@} 912# local package=${jarinfo##*@}
808# if [[ -n ${replace_only} ]]; then 913# if [[ -n ${replace_only} ]]; then
809# [[ ! -f $path ]] && die "No jar exists at ${path}" 914# [[ ! -f $path ]] && die "No jar exists at ${path}"
822# @section-end query 927# @section-end query
823# ------------------------------------------------------------------------------ 928# ------------------------------------------------------------------------------
824 929
825# ------------------------------------------------------------------------------ 930# ------------------------------------------------------------------------------
826# @section-begin helper 931# @section-begin helper
827# @section-summary Helper functions 932# @section-summary Helper functions
828# 933#
829# Various other functions to use from an ebuild 934# Various other functions to use from an ebuild
830# ------------------------------------------------------------------------------ 935# ------------------------------------------------------------------------------
831 936
832# ------------------------------------------------------------------------------ 937# ------------------------------------------------------------------------------
838# jdbc-stdext 943# jdbc-stdext
839# jaf 944# jaf
840# jdbc-rowset 945# jdbc-rowset
841# jms 946# jms
842# 947#
843# @param $1 - Optionally indicate that the dependencies are controlled by 948# @param $1 - Optionally indicate that the dependencies are controlled by
844# a use flag by specifying '--use' Requires $2. 949# a use flag by specifying '--use' Requires $2.
845# @param $2 - USE flag which will enable the dependencies. 950# @param $2 - USE flag which will enable the dependencies.
846# @param $@ - virtual packages to add depenedencies for 951# @param $@ - virtual packages to add depenedencies for
847# ------------------------------------------------------------------------------ 952# ------------------------------------------------------------------------------
848# TODO rewrite to parse a line based declaration file instead -- karltk 953# TODO rewrite to parse a line based declaration file instead -- karltk
942 fi 1047 fi
943} 1048}
944 1049
945# ------------------------------------------------------------------------------ 1050# ------------------------------------------------------------------------------
946# @internal-function java-pkg_is-vm-version-sufficient 1051# @internal-function java-pkg_is-vm-version-sufficient
947# 1052#
948# @return zero - VM is sufficient 1053# @return zero - VM is sufficient
949# @return non-zero - VM is not sufficient 1054# @return non-zero - VM is not sufficient
950# ------------------------------------------------------------------------------ 1055# ------------------------------------------------------------------------------
951java-pkg_is-vm-version-sufficient() { 1056java-pkg_is-vm-version-sufficient() {
952 debug-print-function ${FUNCNAME} $* 1057 debug-print-function ${FUNCNAME} $*
972 die "Active Java VM too old" 1077 die "Active Java VM too old"
973 fi 1078 fi
974} 1079}
975 1080
976# ------------------------------------------------------------------------------ 1081# ------------------------------------------------------------------------------
977# @internal-function java-pkg_is-vm-version-eq 1082# @internal-function java-pkg_is-vm-version-eq
978# 1083#
979# @param $@ - VM version to compare current VM to 1084# @param $@ - VM version to compare current VM to
980# @return zero - VM versions are equal 1085# @return zero - VM versions are equal
981# @return non-zero - VM version are not equal 1086# @return non-zero - VM version are not equal
982# ------------------------------------------------------------------------------ 1087# ------------------------------------------------------------------------------
983java-pkg_is-vm-version-eq() { 1088java-pkg_is-vm-version-eq() {
1013# 1118#
1014# @param $@ - VM version to compare current to 1119# @param $@ - VM version to compare current to
1015# ------------------------------------------------------------------------------ 1120# ------------------------------------------------------------------------------
1016java-pkg_ensure-vm-version-ge() { 1121java-pkg_ensure-vm-version-ge() {
1017 debug-print-function ${FUNCNAME} $* 1122 debug-print-function ${FUNCNAME} $*
1018 1123
1019 if ! java-pkg_is-vm-version-ge "$@" ; then 1124 if ! java-pkg_is-vm-version-ge "$@" ; then
1020 debug-print "vm is not suffient" 1125 debug-print "vm is not suffient"
1021 eerror "This package requires a Java VM version >= $@" 1126 eerror "This package requires a Java VM version >= $@"
1022 einfo "Please use java-config -S to set the correct one" 1127 einfo "Please use java-config -S to set the correct one"
1023 die "Active Java VM too old" 1128 die "Active Java VM too old"
1024 fi 1129 fi
1025} 1130}
1026 1131
1027# ------------------------------------------------------------------------------ 1132# ------------------------------------------------------------------------------
1028# @internal-function java-pkg_is-vm-version-ge 1133# @internal-function java-pkg_is-vm-version-ge
1029# 1134#
1030# @param $@ - VM version to compare current VM to 1135# @param $@ - VM version to compare current VM to
1031# @return zero - current VM version is greater than checked version 1136# @return zero - current VM version is greater than checked version
1032# @return non-zero - current VM version is not greater than checked version 1137# @return non-zero - current VM version is not greater than checked version
1033# ------------------------------------------------------------------------------ 1138# ------------------------------------------------------------------------------
1034java-pkg_is-vm-version-ge() { 1139java-pkg_is-vm-version-ge() {
1048 return 1 1153 return 1
1049 fi 1154 fi
1050 fi 1155 fi
1051} 1156}
1052 1157
1158java-pkg_set-current-vm() {
1159 export GENTOO_VM=${1}
1160}
1161
1162java-pkg_get-current-vm() {
1163 echo ${GENTOO_VM}
1164}
1165
1166java-pkg_current-vm-matches() {
1167 hasq $(java-pkg_get-current-vm) ${@}
1168 return $?
1169}
1170
1053# ------------------------------------------------------------------------------ 1171# ------------------------------------------------------------------------------
1054# @ebuild-function java-pkg_get-source 1172# @ebuild-function java-pkg_get-source
1055# 1173#
1056# Determines what source version should be used, for passing to -source. 1174# Determines what source version should be used, for passing to -source.
1057# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1175# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1058# 1176#
1059# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1177# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1060# ------------------------------------------------------------------------------ 1178# ------------------------------------------------------------------------------
1065# ------------------------------------------------------------------------------ 1183# ------------------------------------------------------------------------------
1066# @ebuild-function java-pkg_get-target 1184# @ebuild-function java-pkg_get-target
1067# 1185#
1068# Determines what target version should be used, for passing to -target. 1186# Determines what target version should be used, for passing to -target.
1069# 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
1070# version of your JDK. 1188# version of your JDK.
1071# Remember doing this will mostly like cause things to break.
1072# Doesn't allow it to be lower then the one in depend.
1073# Doesn't allow it to be higher then the active vm.
1074# 1189#
1075# @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
1076# ------------------------------------------------------------------------------ 1191# ------------------------------------------------------------------------------
1077java-pkg_get-target() { 1192java-pkg_get-target() {
1078 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1079 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1080 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1081 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1082 echo ${JAVA_PKG_WANT_TARGET}
1083 else
1084 echo ${min}
1085 fi
1086 else
1087 echo ${min}
1088 fi
1089
1090 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1193 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1091} 1194}
1092 1195
1093java-pkg_get-javac() { 1196java-pkg_get-javac() {
1094 debug-print-function ${FUNCNAME} $* 1197 debug-print-function ${FUNCNAME} $*
1095 1198
1096 java-pkg_init-compiler_ 1199
1097 local compiler="${GENTOO_COMPILER}" 1200 local compiler="${GENTOO_COMPILER}"
1098 1201
1099 local compiler_executable 1202 local compiler_executable
1100 if [[ "${compiler}" = "javac" ]]; then 1203 if [[ "${compiler}" = "javac" ]]; then
1101 # nothing fancy needs to be done for javac 1204 # nothing fancy needs to be done for javac
1109 unset JAVAC 1212 unset JAVAC
1110 # try to get value of JAVAC 1213 # try to get value of JAVAC
1111 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})"
1112 export JAVAC=${old_javac} 1215 export JAVAC=${old_javac}
1113 1216
1114 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1217 if [[ -z ${compiler_executable} ]]; then
1115 1218 echo "JAVAC is empty or undefined in ${compiler_env}"
1219 return 1
1220 fi
1221
1116 # check that it's executable 1222 # check that it's executable
1117 if [[ ! -x ${compiler_executable} ]]; then 1223 if [[ ! -x ${compiler_executable} ]]; then
1118 eerror "Could not find ${compiler_executable}!"
1119 die "${compiler_executable} doesn't exist, or isn't executable" 1224 echo "${compiler_executable} doesn't exist, or isn't executable"
1225 return 1
1120 fi 1226 fi
1121 else 1227 else
1122 eerror "Could not find environment file for ${compiler}" 1228 echo "Could not find environment file for ${compiler}"
1123 die "Could not find ${compiler_env}" 1229 return 1
1124 fi 1230 fi
1125 fi 1231 fi
1126 echo ${compiler_executable} 1232 echo ${compiler_executable}
1127} 1233}
1128 1234
1129# ------------------------------------------------------------------------------ 1235# ------------------------------------------------------------------------------
1130# @ebuild-function java-pkg_javac-args 1236# @ebuild-function java-pkg_javac-args
1131# 1237#
1132# If an ebuild uses javac directly, instead of using ejavac, it should call this 1238# If an ebuild uses javac directly, instead of using ejavac, it should call this
1133# to know what -source/-target to use. 1239# to know what -source/-target to use.
1134# 1240#
1135# @return string - arguments to pass to javac, complete with -target and -source 1241# @return string - arguments to pass to javac, complete with -target and -source
1138 debug-print-function ${FUNCNAME} $* 1244 debug-print-function ${FUNCNAME} $*
1139 1245
1140 local want_source="$(java-pkg_get-source)" 1246 local want_source="$(java-pkg_get-source)"
1141 local want_target="$(java-pkg_get-target)" 1247 local want_target="$(java-pkg_get-target)"
1142 1248
1143 local source_str="-source ${want_source}" 1249 local source_str="-source ${want_source}"
1144 local target_str="-target ${want_target}" 1250 local target_str="-target ${want_target}"
1145 1251
1146 debug-print "want source: ${want_source}" 1252 debug-print "want source: ${want_source}"
1147 debug-print "want target: ${want_target}" 1253 debug-print "want target: ${want_target}"
1148 1254
1149 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1255 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1150 debug-print "could not find valid -source/-target values" 1256 debug-print "could not find valid -source/-target values for javac"
1151 die "Could not find valid -source/-target values" 1257 echo "Could not find valid -source/-target values for javac"
1258 return 1
1152 else 1259 else
1153 if java-pkg_is-vm-version-ge "1.4"; then 1260 if java-pkg_is-vm-version-ge "1.4"; then
1154 echo "${source_str} ${target_str}" 1261 echo "${source_str} ${target_str}"
1155 else 1262 else
1156 echo "${target_str}" 1263 echo "${target_str}"
1160 1267
1161# TODO document 1268# TODO document
1162java-pkg_get-jni-cflags() { 1269java-pkg_get-jni-cflags() {
1163 local flags="-I${JAVA_HOME}/include" 1270 local flags="-I${JAVA_HOME}/include"
1164 1271
1165 # TODO figure out how to cope with other things than linux... 1272 local platform="linux"
1273 use elibc_FreeBSD && platform="freebsd"
1274
1275 # TODO do a check that the directories are valid
1166 flags="${flags} -I${JAVA_HOME}/include/linux" 1276 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1167 1277
1168 echo ${flags} 1278 echo ${flags}
1279}
1280
1281java-pkg_ensure-gcj() {
1282 if ! built_with_use sys-devel/gcc gcj ; then
1283 ewarn
1284 ewarn "You must build gcc with the gcj support to build with gcj"
1285 ewarn
1286 ebeep 5
1287 die "No GCJ support found!"
1288 fi
1289}
1290
1291java-pkg_ensure-test() {
1292 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1293 && hasq test ${IUSE} && ! use test;
1294 then
1295 eerror "You specified FEATURES=test, but USE=test is needed"
1296 eerror "to pull in the additional dependencies for testing"
1297 die "Need USE=test enabled"
1298 fi
1169} 1299}
1170 1300
1171# ------------------------------------------------------------------------------ 1301# ------------------------------------------------------------------------------
1172# @section-end helper 1302# @section-end helper
1173# ------------------------------------------------------------------------------ 1303# ------------------------------------------------------------------------------
1188# 1318#
1189# ------------------------------------------------------------------------------ 1319# ------------------------------------------------------------------------------
1190eant() { 1320eant() {
1191 debug-print-function ${FUNCNAME} $* 1321 debug-print-function ${FUNCNAME} $*
1192 1322
1193 local antflags 1323 # FIXME get this working
1324# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1325# java-pkg_announce-qa-violation \
1326# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1327# fi
1328
1329 local antflags="-Dnoget=true"
1194 java-pkg_init-compiler_ 1330 java-pkg_init-compiler_
1195 local compiler="${GENTOO_COMPILER}" 1331 local compiler="${GENTOO_COMPILER}"
1196 1332
1197 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1333 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1198 1334
1200 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1336 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1201 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1337 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1202 fi 1338 fi
1203 1339
1204 if [[ ${compiler} != "javac" ]]; then 1340 if [[ ${compiler} != "javac" ]]; then
1205 antflags="-Dbuild.compiler=${build_compiler}" 1341 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1206 # 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
1207 # from javac 1343 # from javac
1208 # 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
1209 # java-config -p 1345 # java-config -p
1210 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})"
1211 if [[ -n ${build_compiler_deps} ]]; then 1347 if [[ -n ${build_compiler_deps} ]]; then
1212 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1348 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1213 fi 1349 fi
1214 fi 1350 fi
1215 1351
1352 if is-java-strict; then
1353 einfo "Disabling system classpath for ant"
1354 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1355 fi
1356
1216 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1357 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1217 antflags="${antflags} -debug" 1358 antflags="${antflags} -debug"
1218 fi 1359 fi
1219 1360
1220 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1361 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1221 ant ${antflags} "${@}" || die "eant failed" 1362 ant ${antflags} "${@}" || die "eant failed"
1222 1363
1223} 1364}
1224 1365
1225# ------------------------------------------------------------------------------ 1366# ------------------------------------------------------------------------------
1226# @ebuild-function ejavac 1367# @ebuild-function ejavac
1227# 1368#
1228# Javac wrapper function. Will use the appropriate compiler, based on 1369# Javac wrapper function. Will use the appropriate compiler, based on
1229# /etc/java-config/compilers.conf 1370# /etc/java-config/compilers.conf
1230# 1371#
1231# @param $@ - Arguments to be passed to the compiler 1372# @param $@ - Arguments to be passed to the compiler
1232# ------------------------------------------------------------------------------ 1373# ------------------------------------------------------------------------------
1233ejavac() { 1374ejavac() {
1234 debug-print-function ${FUNCNAME} $* 1375 debug-print-function ${FUNCNAME} $*
1235 1376
1377 java-pkg_init-compiler_
1378
1379 local compiler_executable
1236 local compiler_executable=$(java-pkg_get-javac) 1380 compiler_executable=$(java-pkg_get-javac)
1381 if [[ ${?} != 0 ]]; then
1382 eerror "There was a problem determining compiler: ${compiler_executable}"
1383 die "get-javac failed"
1384 fi
1237 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
1238 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1393 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1239 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1394 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1240} 1395}
1241 1396
1242# ------------------------------------------------------------------------------ 1397# ------------------------------------------------------------------------------
1243# @ebuild-function java-pkg_filter-compiler 1398# @ebuild-function java-pkg_filter-compiler
1244# 1399#
1245# Used to prevent the use of some compilers. Should be used in src_compile. 1400# Used to prevent the use of some compilers. Should be used in src_compile.
1246# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1401# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1247# 1402#
1248# @param $@ - compilers to filter 1403# @param $@ - compilers to filter
1249# ------------------------------------------------------------------------------ 1404# ------------------------------------------------------------------------------
1250java-pkg_filter-compiler() { 1405java-pkg_filter-compiler() {
1251 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1406 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1252} 1407}
1253 1408
1254# ------------------------------------------------------------------------------ 1409# ------------------------------------------------------------------------------
1410# @ebuild-function java-pkg_force-compiler
1411#
1412# Used to force the use of particular compilers. Should be used in src_compile.
1413# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1414# OutOfMemoryErrors that may come up.
1415#
1416# @param $@ - compilers to force
1417# ------------------------------------------------------------------------------
1418java-pkg_force-compiler() {
1419 JAVA_PKG_FORCE_COMPILER="$@"
1420}
1421
1422# ------------------------------------------------------------------------------
1255# @ebuild-function use_doc 1423# @ebuild-function use_doc
1256# 1424#
1257# Helper function for getting ant to build javadocs. If the user has USE=doc, 1425# Helper function for getting ant to build javadocs. If the user has USE=doc,
1258# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1426# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1259# 1427#
1260# The output of this should be passed to ant. 1428# The output of this should be passed to ant.
1261# 1429#
1262# Example: build javadocs by calling 'javadoc' target 1430# Example: build javadocs by calling 'javadoc' target
1263# eant $(use_doc) 1431# eant $(use_doc)
1264# Example: build javadocs by calling 'apidoc' target 1432# Example: build javadocs by calling 'apidoc' target
1269# ------------------------------------------------------------------------------ 1437# ------------------------------------------------------------------------------
1270use_doc() { 1438use_doc() {
1271 use doc && echo ${@:-javadoc} 1439 use doc && echo ${@:-javadoc}
1272} 1440}
1273 1441
1442
1274# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
1275# @section-end build 1444# @section-end build
1276# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1277 1446
1278# ------------------------------------------------------------------------------ 1447# ------------------------------------------------------------------------------
1279# @section-begin internal 1448# @section-begin internal
1280# @section-summary Internal functions 1449# @section-summary Internal functions
1281# 1450#
1282# Do __NOT__ use any of these from an ebuild! These are only to be used from 1451# Do __NOT__ use any of these from an ebuild! These are only to be used from
1283# within the java eclasses. 1452# within the java eclasses.
1284# ------------------------------------------------------------------------------ 1453# ------------------------------------------------------------------------------
1285 1454
1286# ----------------------------------------------------------------------------- 1455# -----------------------------------------------------------------------------
1287# @function-internal java-pkg_init 1456# @function-internal java-pkg_init
1288# 1457#
1289# The purpose of this function, as the name might imply, is to initialize the 1458# The purpose of this function, as the name might imply, is to initialize the
1290# Java environment. It ensures that that there aren't any environment variables 1459# Java environment. It ensures that that there aren't any environment variables
1291# that'll muss things up. It initializes some variables, which are used 1460# that'll muss things up. It initializes some variables, which are used
1292# internally. And most importantly, it'll switch the VM if necessary. 1461# internally. And most importantly, it'll switch the VM if necessary.
1293# 1462#
1305 # TODO we will probably want to set JAVAC and JAVACFLAGS 1474 # TODO we will probably want to set JAVAC and JAVACFLAGS
1306 1475
1307 # Do some QA checks 1476 # Do some QA checks
1308 java-pkg_check-jikes 1477 java-pkg_check-jikes
1309 1478
1310 # When users have crazy classpaths some packages can fail to compile. 1479 # When users have crazy classpaths some packages can fail to compile.
1311 # and everything should work with empty CLASSPATH. 1480 # and everything should work with empty CLASSPATH.
1312 # This also helps prevent unexpected dependencies on random things 1481 # This also helps prevent unexpected dependencies on random things
1313 # from the CLASSPATH. 1482 # from the CLASSPATH.
1314 unset CLASSPATH 1483 unset CLASSPATH
1315} 1484}
1316 1485
1317# ------------------------------------------------------------------------------ 1486# ------------------------------------------------------------------------------
1318# @function-internal java-pkg-init-compiler_ 1487# @function-internal java-pkg-init-compiler_
1319# 1488#
1320# This function attempts to figure out what compiler should be used. It does 1489# This function attempts to figure out what compiler should be used. It does
1321# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1490# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1322# COMPILERS variable defined there. 1491# COMPILERS variable defined there.
1323# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1492# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1324# 1493#
1325# It will go through the list of compilers, and verify that it supports the 1494# It will go through the list of compilers, and verify that it supports the
1326# target and source that are needed. If it is not suitable, then the next 1495# target and source that are needed. If it is not suitable, then the next
1327# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1496# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1328# isn't done. 1497# isn't done.
1329# 1498#
1351 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1520 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1352 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1521 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1353 else 1522 else
1354 compilers=${JAVA_PKG_FORCE_COMPILER} 1523 compilers=${JAVA_PKG_FORCE_COMPILER}
1355 fi 1524 fi
1356 1525
1357 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1526 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1358 1527
1359 # Figure out if we should announce what compiler we're using 1528 # Figure out if we should announce what compiler we're using
1360 local compiler 1529 local compiler
1361 for compiler in ${compilers}; do 1530 for compiler in ${compilers}; do
1364 if [[ ${compiler} = "javac" ]]; then 1533 if [[ ${compiler} = "javac" ]]; then
1365 debug-print "Found javac... breaking" 1534 debug-print "Found javac... breaking"
1366 export GENTOO_COMPILER="javac" 1535 export GENTOO_COMPILER="javac"
1367 break 1536 break
1368 fi 1537 fi
1369 1538
1370 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1539 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1371 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1540 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1372 einfo "Filtering ${compiler}" 1541 einfo "Filtering ${compiler}"
1373 continue 1542 continue
1374 fi 1543 fi
1375 fi 1544 fi
1376 1545
1377 # for non-javac, we need to make sure it supports the right target and 1546 # for non-javac, we need to make sure it supports the right target and
1378 # source 1547 # source
1379 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1548 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1380 if [[ -f ${compiler_env} ]]; then 1549 if [[ -f ${compiler_env} ]]; then
1381 local desired_target="$(java-pkg_get-target)" 1550 local desired_target="$(java-pkg_get-target)"
1463# Writes the package.env out to disk. 1632# Writes the package.env out to disk.
1464# 1633#
1465# ------------------------------------------------------------------------------ 1634# ------------------------------------------------------------------------------
1466# TODO change to do-write, to match everything else 1635# TODO change to do-write, to match everything else
1467java-pkg_do_write_() { 1636java-pkg_do_write_() {
1637 java-pkg_init_paths_
1468 # Create directory for package.env 1638 # Create directory for package.env
1469 dodir "${JAVA_PKG_SHAREPATH}" 1639 dodir "${JAVA_PKG_SHAREPATH}"
1470 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
1471 # Create package.env 1641 # Create package.env
1472 ( 1642 (
1477 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1647 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1478 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1648 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1479 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1649 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1480 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1650 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1481 ) > "${JAVA_PKG_ENV}" 1651 ) > "${JAVA_PKG_ENV}"
1482 1652
1483 # register target/source 1653 # register target/source
1484 local target="$(java-pkg_get-target)" 1654 local target="$(java-pkg_get-target)"
1485 local source="$(java-pkg_get-source)" 1655 local source="$(java-pkg_get-source)"
1486 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1656 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1487 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1657 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1500 # Strip unnecessary leading and trailing colons 1670 # Strip unnecessary leading and trailing colons
1501 # TODO try to cleanup if possible 1671 # TODO try to cleanup if possible
1502 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 ?"
1503 fi 1673 fi
1504} 1674}
1505
1506 1675
1507# ------------------------------------------------------------------------------ 1676# ------------------------------------------------------------------------------
1508# @internal-function java-pkg_record-jar_ 1677# @internal-function java-pkg_record-jar_
1509# 1678#
1510# Record a dependency to the package.env 1679# Record a dependency to the package.env
1554 fi 1723 fi
1555} 1724}
1556 1725
1557# ------------------------------------------------------------------------------ 1726# ------------------------------------------------------------------------------
1558# @internal-function java-pkg_expand_dir_ 1727# @internal-function java-pkg_expand_dir_
1559# 1728#
1560# Gets the full path of the file/directory's parent. 1729# Gets the full path of the file/directory's parent.
1561# @param $1 - file/directory to find parent directory for 1730# @param $1 - file/directory to find parent directory for
1562# @return - path to $1's parent directory 1731# @return - path to $1's parent directory
1563# ------------------------------------------------------------------------------ 1732# ------------------------------------------------------------------------------
1564java-pkg_expand_dir_() { 1733java-pkg_expand_dir_() {
1591# ------------------------------------------------------------------------------ 1760# ------------------------------------------------------------------------------
1592java-pkg_setup-vm() { 1761java-pkg_setup-vm() {
1593 debug-print-function ${FUNCNAME} $* 1762 debug-print-function ${FUNCNAME} $*
1594 1763
1595 local vendor="$(java-pkg_get-vm-vendor)" 1764 local vendor="$(java-pkg_get-vm-vendor)"
1596 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
1597 addpredict "/dev/random" 1766 addpredict "/dev/random"
1598 elif [[ "${vendor}" == "ibm" ]]; then 1767 elif [[ "${vendor}" == "ibm" ]]; then
1599 addpredict "/proc/self/maps" 1768 addpredict "/proc/self/maps"
1600 addpredict "/proc/cpuinfo" 1769 addpredict "/proc/cpuinfo"
1601 export LANG="C" LC_ALL="C" 1770 export LANG="C" LC_ALL="C"
1650# @return - The version of the current VM 1819# @return - The version of the current VM
1651# ------------------------------------------------------------------------------ 1820# ------------------------------------------------------------------------------
1652java-pkg_get-vm-version() { 1821java-pkg_get-vm-version() {
1653 debug-print-function ${FUNCNAME} $* 1822 debug-print-function ${FUNCNAME} $*
1654 1823
1655 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1824 java-config -g PROVIDES_VERSION
1656} 1825}
1657 1826
1658# ------------------------------------------------------------------------------ 1827# ------------------------------------------------------------------------------
1659# @internal-function java-pkg_switch-vm 1828# @internal-function java-pkg_switch-vm
1660# 1829#
1661# 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
1662# verify that the current VM is sufficient. 1831# verify that the current VM is sufficient.
1663# Setup the environment for the VM being used. 1832# Setup the environment for the VM being used.
1664# ------------------------------------------------------------------------------ 1833# ------------------------------------------------------------------------------
1665java-pkg_switch-vm() { 1834java-pkg_switch-vm() {
1835 debug-print-function ${FUNCNAME} $*
1836
1666 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1667 # Use the VM specified by JAVA_PKG_FORCE_VM 1838 # Use the VM specified by JAVA_PKG_FORCE_VM
1668 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1839 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1669 # 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}"
1670 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1842 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1671 # if we're allowed to switch the vm... 1843 # if we're allowed to switch the vm...
1672 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1844 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1673 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}"
1674 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1846 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1675 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}}")"
1676 else 1848 else
1677 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
1678 fi 1858 fi
1679 # otherwise just make sure the current VM is sufficient 1859 # otherwise just make sure the current VM is sufficient
1680 else 1860 else
1681 java-pkg_ensure-vm-version-sufficient 1861 java-pkg_ensure-vm-version-sufficient
1682 fi 1862 fi
1683 debug-print "Using: $(java-config -f)" 1863 debug-print "Using: $(java-config -f)"
1684 1864
1685 java-pkg_setup-vm 1865 java-pkg_setup-vm
1686 1866
1687 export JAVA=$(java-config --java) 1867 export JAVA=$(java-config --java)
1688 export JAVAC=$(java-config --javac) 1868 export JAVAC=$(java-config --javac)
1689 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
1690 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1874 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1875 export JAVACFLAGS
1691 1876
1692 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1877 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1693 export JDK_HOME=${JAVA_HOME} 1878 export JDK_HOME=${JAVA_HOME}
1694 1879
1695 #TODO If you know a better solution let us know. 1880 #TODO If you know a better solution let us know.
1696 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1881 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1697 1882
1698 local tann="${T}/announced-vm" 1883 local tann="${T}/announced-vm"
1699 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1884 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1700 # Add a check for setup/preinst phase... to avoid duplicate outputs 1885 # Add a check for setup/preinst phase... to avoid duplicate outputs
1701 # for when FEATURES=buildpkg 1886 # for when FEATURES=buildpkg
1702 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1887 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1727 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1912 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1728 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1913 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1729 echo "and of course, the output of emerge --info" >&2 1914 echo "and of course, the output of emerge --info" >&2
1730} 1915}
1731 1916
1917
1918# TODO document
1919# List jars in the source directory, ${S}
1920java-pkg_jar-list() {
1921 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1922 einfo "Linked Jars"
1923 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1924 einfo "Jars"
1925 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1926 einfo "Classes"
1927 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1928 fi
1929}
1930
1931# TODO document
1932# Verify that the classes were compiled for the right source / target
1933java-pkg_verify-classes() {
1934 ebegin "Verifying java class versions"
1935 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1936 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1937 result=$?
1938 eend ${result}
1939 if [[ ${result} == 0 ]]; then
1940 einfo "All good"
1941 else
1942 ewarn "Possible problem"
1943 die "Bad class files found"
1944 fi
1945}
1946
1732# ------------------------------------------------------------------------------ 1947# ------------------------------------------------------------------------------
1733# @section-end internal 1948# @section-end internal
1734# ------------------------------------------------------------------------------ 1949# ------------------------------------------------------------------------------
1735 1950
1736java-pkg_check-phase() { 1951java-pkg_check-phase() {
1737 local phase=${1} 1952 local phase=${1}
1738 local funcname=${2} 1953 local funcname=${2}
1739 # TODO add check for java-stricter
1740 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1954 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1741 java-pkg_announce-qa-violation \ 1955 java-pkg_announce-qa-violation \
1742 "${funcname} used outside of src_${phase}" 1956 "${funcname} used outside of src_${phase}"
1743 fi 1957 fi
1744} 1958}
1745 1959
1756 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1970 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1757 fi 1971 fi
1758} 1972}
1759 1973
1760java-pkg_announce-qa-violation() { 1974java-pkg_announce-qa-violation() {
1761 if hasq java-strict ${FEATURES}; then 1975 if is-java-strict; then
1762 echo "Java QA Notice: $@" >&2 1976 echo "Java QA Notice: $@" >&2
1763 increment-qa-violations 1977 increment-qa-violations
1764 fi 1978 fi
1765} 1979}
1766 1980
1767increment-qa-violations() { 1981increment-qa-violations() {
1768 let "JAVA_PKG_QA_VIOLATIONS+=1" 1982 let "JAVA_PKG_QA_VIOLATIONS+=1"
1769 export JAVA_PKG_QA_VIOLATIONS 1983 export JAVA_PKG_QA_VIOLATIONS
1770} 1984}
1771 1985
1986is-java-strict() {
1987 [[ -n ${JAVA_PKG_STRICT} ]]
1988 return $?
1989}
1990
1772# ------------------------------------------------------------------------------ 1991# ------------------------------------------------------------------------------
1773# @eclass-end 1992# @eclass-end
1774# ------------------------------------------------------------------------------ 1993# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20