/[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.4 Revision 1.33
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.33 2006/12/07 02:27:22 flameeyes 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#
206# Records an already installed jar in the package.env 212# Records an already installed jar in the package.env
207# This would mostly be used if the package has make or a custom script to 213# This would mostly be used if the package has make or a custom script to
208# install things. 214# install things.
209# 215#
210# Example: 216# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 217# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
218#
219# WARNING:
220# if you want to use shell expansion, you have to use ${D}/... as the for in
221# this function will not be able to expand the path, here's an example:
222#
223# java-pkg_regjar /opt/my-java/lib/*.jar
224#
225# will not work, because:
226# * the `for jar in "$@"` can't expand the path to jar file names, as they
227# don't exist yet
228# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
229# doesn't exist
230#
231# you have to use it as:
232#
233# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 234#
213# @param $@ - jars to record 235# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 236# ------------------------------------------------------------------------------
215# TODO fix me! 237# TODO should we be making sure the jar is present on ${D} or wherever?
216java-pkg_regjar() { 238java-pkg_regjar() {
217 debug-print-function ${FUNCNAME} $* 239 debug-print-function ${FUNCNAME} $*
218 240
219 java-pkg_check-phase install 241 java-pkg_check-phase install
220 242
224 246
225 local jar jar_dir jar_file 247 local jar jar_dir jar_file
226 for jar in "$@"; do 248 for jar in "$@"; do
227 # TODO use java-pkg_check-versioned-jar 249 # TODO use java-pkg_check-versioned-jar
228 if [[ -e "${jar}" ]]; then 250 if [[ -e "${jar}" ]]; then
251 # nelchael: we should strip ${D} in this case too, here's why:
252 # imagine such call:
253 # java-pkg_regjar ${D}/opt/java/*.jar
254 # such call will fall into this case (-e ${jar}) and will
255 # record paths with ${D} in package.env
229 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}" 256 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
230 elif [[ -e "${D}${jar}" ]]; then 257 elif [[ -e "${D}${jar}" ]]; then
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 258 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 259 else
233 die "${jar} does not exist" 260 die "${jar} does not exist"
234 fi 261 fi
255 local original_jar="${1}" 282 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 283 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 284 local new_jar_dest="${T}/${new_jar}"
258 285
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 286 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 287 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
261 288
262 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 289 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
263 cp "${original_jar}" "${new_jar_dest}" \ 290 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 291 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 292 java-pkg_dojar "${new_jar_dest}"
266} 293}
267 294
268
269# ------------------------------------------------------------------------------ 295# ------------------------------------------------------------------------------
270# @ebuild-function java-pkg_addcp 296# @ebuild-function java-pkg_addcp
271# 297#
272# Add something to the package's classpath. For jars, you should use dojar, 298# Add something to the package's classpath. For jars, you should use dojar,
273# newjar, or regjar. This is typically used to add directories to the classpath. 299# newjar, or regjar. This is typically used to add directories to the classpath.
278java-pkg_addcp() { 304java-pkg_addcp() {
279 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 305 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
280 java-pkg_do_write_ 306 java-pkg_do_write_
281} 307}
282 308
283
284# ------------------------------------------------------------------------------ 309# ------------------------------------------------------------------------------
285# @ebuild-function java-pkg_doso 310# @ebuild-function java-pkg_doso
286# 311#
287# Installs any number of JNI libraries 312# Installs any number of JNI libraries
288# They will be installed into /usr/lib by default, but java-pkg_sointo 313# They will be installed into /usr/lib by default, but java-pkg_sointo
289# can be used change this path 314# can be used change this path
290# 315#
291# Example: 316# Example:
346 java-pkg_check-phase install 371 java-pkg_check-phase install
347 372
348 [[ ${#} -lt 1 ]] && "at least one argument needed" 373 [[ ${#} -lt 1 ]] && "at least one argument needed"
349 374
350 java-pkg_init_paths_ 375 java-pkg_init_paths_
351 376
352 local lib target_dir 377 local lib target_dir
353 for lib in "$@" ; do 378 for lib in "$@" ; do
354 # Check the absolute path of the lib 379 # Check the absolute path of the lib
355 if [[ -e "${lib}" ]] ; then 380 if [[ -e "${lib}" ]] ; then
356 target_dir="$(java-pkg_expand_dir_ ${lib})" 381 target_dir="$(java-pkg_expand_dir_ ${lib})"
404# ------------------------------------------------------------------------------ 429# ------------------------------------------------------------------------------
405java-pkg_dohtml() { 430java-pkg_dohtml() {
406 debug-print-function ${FUNCNAME} $* 431 debug-print-function ${FUNCNAME} $*
407 432
408 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 433 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
409 # TODO-nichoj find out what exactly -f package-list does 434
435 # from /usr/lib/portage/bin/dohtml -h
436 # -f Set list of allowed extensionless file names.
410 dohtml -f package-list "$@" 437 dohtml -f package-list "$@"
438
411 # this probably shouldn't be here but it provides 439 # this probably shouldn't be here but it provides
412 # a reasonable way to catch # docs for all of the 440 # a reasonable way to catch # docs for all of the
413 # old ebuilds. 441 # old ebuilds.
414 java-pkg_recordjavadoc 442 java-pkg_recordjavadoc
415} 443}
416 444
417# TODO document 445# ------------------------------------------------------------------------------
446# @ebuild-function java-pkg_dojavadoc
447#
448# Installs javadoc documentation. This should be controlled by the doc use flag.
449#
450# @param $1: - The javadoc root directory.
451#
452# @example:
453# java-pkg_dojavadoc docs/api
454#
455# ------------------------------------------------------------------------------
418java-pkg_dojavadoc() { 456java-pkg_dojavadoc() {
419 local dir="$1" 457 local dir="$1"
420 458
421 java-pkg_check-phase install 459 java-pkg_check-phase install
422 460
434} 472}
435 473
436# ------------------------------------------------------------------------------ 474# ------------------------------------------------------------------------------
437# @ebuild-function java-pkg_dosrc 475# @ebuild-function java-pkg_dosrc
438# 476#
439# Installs a zip containing the source for a package, so it can used in 477# Installs a zip containing the source for a package, so it can used in
440# from IDEs like eclipse and netbeans. 478# from IDEs like eclipse and netbeans.
441# 479#
442# Ebuild needs to DEPEND on app-arch/zip to use this. 480# Ebuild needs to DEPEND on app-arch/zip to use this.
443# 481#
444# It also should be controlled by USE=source. 482# It also should be controlled by USE=source.
445# 483#
446# @example: 484# @example:
447# java-pkg_dosrc src/* 485# java-pkg_dosrc src/*
448# 486#
449# ------------------------------------------------------------------------------ 487# ------------------------------------------------------------------------------
450# TODO change so it the arguments it takes are the base directories containing 488# TODO change so it the arguments it takes are the base directories containing
451# source -nichoj 489# source -nichoj
452# TODO should we be able to handle multiple calls to dosrc? -nichoj 490# TODO should we be able to handle multiple calls to dosrc? -nichoj
453# TODO maybe we can take an existing zip/jar? -nichoj 491# TODO maybe we can take an existing zip/jar? -nichoj
454# FIXME apparently this fails if you give it an empty directories 492# FIXME apparently this fails if you give it an empty directories
455java-pkg_dosrc() { 493java-pkg_dosrc() {
456 debug-print-function ${FUNCNAME} $* 494 debug-print-function ${FUNCNAME} $*
457 495
458 [ ${#} -lt 1 ] && die "At least one argument needed" 496 [ ${#} -lt 1 ] && die "At least one argument needed"
459 if ! hasq source ${IUSE}; then 497 if ! hasq source ${IUSE}; then
460 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 498 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
461 fi 499 fi
462 500
463 java-pkg_check-phase install 501 java-pkg_check-phase install
464 502
465 [[ ${#} -lt 1 ]] && die "At least one argument needed" 503 [[ ${#} -lt 1 ]] && die "At least one argument needed"
466 504
467 java-pkg_init_paths_ 505 java-pkg_init_paths_
468 506
469 local zip_name="${PN}-src.zip" 507 local zip_name="${PN}-src.zip"
470 local zip_path="${T}/${zip_name}" 508 local zip_path="${T}/${zip_name}"
494# @ebuild-function java-pkg_dolauncher 532# @ebuild-function java-pkg_dolauncher
495# 533#
496# Make a wrapper script to lauch/start this package 534# Make a wrapper script to lauch/start this package
497# If necessary, the wrapper will switch to the appropriate VM. 535# If necessary, the wrapper will switch to the appropriate VM.
498# 536#
537# Can be called without parameters if the package installs only one jar
538# that has the Main-class attribute set. The wrapper will be named ${PN}.
539#
499# @param $1 - filename of launcher to create 540# @param $1 - filename of launcher to create
500# @param $2 - options, as follows: 541# @param $2 - options, as follows:
501# --main the.main.class.too.start 542# --main the.main.class.too.start
502# --jar /the/jar/too/launch.jar 543# --jar /the/jar/too/launch.jar or just <name>.jar
503# --java_args 'Extra arguments to pass too jave' 544# --java_args 'Extra arguments to pass to java'
504# --pkg_args 'extra arguments too pass too the package' 545# --pkg_args 'Extra arguments too pass to the package'
505# --pwd 546# --pwd
506# -into 547# -into
507# -pre 548# -pre
508# ------------------------------------------------------------------------------ 549# ------------------------------------------------------------------------------
509java-pkg_dolauncher() { 550java-pkg_dolauncher() {
510 debug-print-function ${FUNCNAME} $* 551 debug-print-function ${FUNCNAME} $*
511 552
512 java-pkg_check-phase install 553 java-pkg_check-phase install
513
514 [[ ${#} -lt 1 ]] && die "Need at least one argument"
515
516 java-pkg_init_paths_ 554 java-pkg_init_paths_
517 555
556 if [[ ${#} = 0 ]]; then
557 local name="${PN}"
558 else
518 local name="${1}" 559 local name="${1}"
560 shift
561 fi
562
519 # TODO rename to launcher 563 # TODO rename to launcher
520 local target="${T}/${name}" 564 local target="${T}/${name}"
565 local var_tmp="${T}/launcher_variables_tmp"
521 local target_dir pre 566 local target_dir pre
522 shift
523 567
524 echo "#!/bin/bash" > "${target}" 568 # Process the other the rest of the arguments
525 while [[ -n "${1}" && -n "${2}" ]]; do 569 while [[ -n "${1}" && -n "${2}" ]]; do
526 local var=${1} value=${2} 570 local var=${1} value=${2}
527 if [[ "${var:0:2}" == "--" ]]; then 571 if [[ "${var:0:2}" == "--" ]]; then
572 local var=${var:2}
528 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 573 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
574 local gjl_${var}="${value}"
529 elif [[ "${var}" == "-into" ]]; then 575 elif [[ "${var}" == "-into" ]]; then
530 target_dir="${value}" 576 target_dir="${value}"
531 elif [[ "${var}" == "-pre" ]]; then 577 elif [[ "${var}" == "-pre" ]]; then
532 pre="${value}" 578 pre="${value}"
533 fi 579 fi
534 shift 2 580 shift 2
535 done 581 done
582
583 # Test if no --jar and --main arguments were given and
584 # in that case check if the package only installs one jar
585 # and use that jar.
586 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
587 local cp="${JAVA_PKG_CLASSPATH}"
588 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
589 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
590 else
591 local msg="Not enough information to create a launcher given."
592 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
593 die "${msg}"
594 fi
595 fi
596
597 # Write the actual script
598 echo "#!/bin/bash" > "${target}"
599 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
536 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 600 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
537 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 601 cat "${var_tmp}" >> "${target}"
602 rm -f "${var_tmp}"
538 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 603 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
539 604
540 if [[ -n "${into}" ]]; then 605 if [[ -n "${target_dir}" ]]; then
541 DESTTREE="${target_dir}" dobin "${target}" 606 DESTTREE="${target_dir}" dobin "${target}"
542 local ret=$? 607 local ret=$?
543 return ${ret} 608 return ${ret}
544 else 609 else
545 dobin "${target}" 610 dobin "${target}"
573 echo "dowar: warning, skipping directory ${war}" 638 echo "dowar: warning, skipping directory ${war}"
574 continue 639 continue
575 else 640 else
576 warpath="${war}" 641 warpath="${war}"
577 fi 642 fi
578 643
579 # Install those files like you mean it 644 # Install those files like you mean it
580 INSOPTIONS="-m 0644" \ 645 INSOPTIONS="-m 0644" \
581 INSDESTTREE=${JAVA_PKG_WARDEST} \ 646 INSDESTTREE=${JAVA_PKG_WARDEST} \
582 doins ${warpath} 647 doins ${warpath}
583 done 648 done
618# @ebuild-function java-pkg_jar-from 683# @ebuild-function java-pkg_jar-from
619# 684#
620# Makes a symlink to a jar from a certain package 685# Makes a symlink to a jar from a certain package
621# A lot of java packages include dependencies in a lib/ directory 686# A lot of java packages include dependencies in a lib/ directory
622# You can use this function to replace these bundled dependencies. 687# You can use this function to replace these bundled dependencies.
688# The dependency is recorded into package.env DEPEND line, unless "--build-only"
689# is passed as the very first argument, for jars that have to be present only
690# at build time and are not needed on runtime (junit testing etc).
623# 691#
624# Example: get all jars from xerces slot 2 692# Example: get all jars from xerces slot 2
625# java-pkg_jar-from xerces-2 693# java-pkg_jar-from xerces-2
626# Example: get a specific jar from xerces slot 2 694# Example: get a specific jar from xerces slot 2
627# java-pkg_jar-from xerces-2 xml-apis.jar 695# java-pkg_jar-from xerces-2 xml-apis.jar
628# Example get a specific jar from xerces slot 2, and name it diffrently 696# Example: get a specific jar from xerces slot 2, and name it diffrently
629# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 697# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
698# Example: get junit.jar which is needed only for building
699# java-pkg_jar-from --build-only junit junit.jar
630# 700#
701# @param $1 - (optional) "--build-only" makes the jar(s) not added into
702# package.env DEPEND line.
631# @param $1 - Package to get jars from. 703# @param $1 - Package to get jars from.
632# @param $2 - jar from package. If not specified, all jars will be used. 704# @param $2 - jar from package. If not specified, all jars will be used.
633# @param $3 - When a single jar is specified, destination filename of the 705# @param $3 - When a single jar is specified, destination filename of the
634# symlink. Defaults to the name of the jar. 706# symlink. Defaults to the name of the jar.
635# ------------------------------------------------------------------------------ 707# ------------------------------------------------------------------------------
636# TODO could probably be cleaned up a little 708# TODO could probably be cleaned up a little
637java-pkg_jar-from() { 709java-pkg_jar-from() {
638 debug-print-function ${FUNCNAME} $* 710 debug-print-function ${FUNCNAME} $*
639 711
712 local build_only=""
713
714 if [[ "${1}" = "--build-only" ]]; then
715 build_only="true"
716 shift
717 fi
718
640 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 719 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
641 720
642 [[ -z ${target_pkg} ]] && die "Must specify a package" 721 [[ -z ${target_pkg} ]] && die "Must specify a package"
643 722
644 # default destjar to the target jar 723 # default destjar to the target jar
645 [[ -z "${destjar}" ]] && destjar="${target_jar}" 724 [[ -z "${destjar}" ]] && destjar="${target_jar}"
646 725
726 local error_msg="There was a problem getting the classpath for ${target_pkg}."
727 local classpath
647 local classpath="$(java-config --classpath=${target_pkg})" 728 classpath="$(java-config --classpath=${target_pkg})"
648 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 729 [[ $? != 0 ]] && die ${error_msg}
649 730
650 local jar 731 local jar
651 for jar in ${classpath//:/ }; do 732 for jar in ${classpath//:/ }; do
652 local jar_name=$(basename "${jar}") 733 local jar_name=$(basename "${jar}")
653 if [[ ! -f "${jar}" ]] ; then 734 if [[ ! -f "${jar}" ]] ; then
657 # If no specific target jar was indicated, link it 738 # If no specific target jar was indicated, link it
658 if [[ -z "${target_jar}" ]] ; then 739 if [[ -z "${target_jar}" ]] ; then
659 [[ -f "${target_jar}" ]] && rm "${target_jar}" 740 [[ -f "${target_jar}" ]] && rm "${target_jar}"
660 ln -snf "${jar}" \ 741 ln -snf "${jar}" \
661 || die "Failed to make symlink from ${jar} to ${jar_name}" 742 || die "Failed to make symlink from ${jar} to ${jar_name}"
662 java-pkg_record-jar_ "${target_pkg}" "${jar}" 743 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
663 # otherwise, if the current jar is the target jar, link it 744 # otherwise, if the current jar is the target jar, link it
664 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 745 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
665 [[ -f "${destjar}" ]] && rm "${destjar}" 746 [[ -f "${destjar}" ]] && rm "${destjar}"
666 ln -snf "${jar}" "${destjar}" \ 747 ln -snf "${jar}" "${destjar}" \
667 || die "Failed to make symlink from ${jar} to ${destjar}" 748 || die "Failed to make symlink from ${jar} to ${destjar}"
668 java-pkg_record-jar_ "${target_pkg}" "${jar}" 749 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
669 return 0 750 return 0
670 fi 751 fi
671 done 752 done
672 # if no target was specified, we're ok 753 # if no target was specified, we're ok
673 if [[ -z "${target_jar}" ]] ; then 754 if [[ -z "${target_jar}" ]] ; then
690# ------------------------------------------------------------------------------ 771# ------------------------------------------------------------------------------
691# @ebuild-function java-pkg_getjars 772# @ebuild-function java-pkg_getjars
692# 773#
693# Get the classpath provided by any number of packages 774# Get the classpath provided by any number of packages
694# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 775# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
776# The providing packages are recorded as dependencies into package.env DEPEND
777# line, unless "--build-only" is passed as the very first argument, for jars
778# that have to be present only at build time and are not needed on runtime
779# (junit testing etc).
695# 780#
696# Example: Get the classpath for xerces-2, 781# Example: Get the classpath for xerces-2 and xalan,
697# java-pkg_getjars xerces-2 xalan 782# java-pkg_getjars xerces-2,xalan
698# Example Return: 783# Example Return:
699# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 784# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
700# 785#
786# @param $1 - (optional) "--build-only" makes the jar(s) not added into
787# package.env DEPEND line.
701# @param $@ - list of packages to get jars from 788# @param $2 - list of packages to get jars from
789# (passed to java-config --classpath)
702# ------------------------------------------------------------------------------ 790# ------------------------------------------------------------------------------
703java-pkg_getjars() { 791java-pkg_getjars() {
704 debug-print-function ${FUNCNAME} $* 792 debug-print-function ${FUNCNAME} $*
705 793
706 [[ ${#} -lt 1 ]] && die "At least one argument needed" 794 [[ ${#} -lt 1 || ${#} -gt 2 ]] && die "${FUNCNAME} takes only one or two arguments"
707 795
708 # NOTE could probably just pass $@ to java-config --classpath. and return it 796 if [[ "${1}" = "--build-only" ]]; then
797 local build_only="true"
798 shift
799 fi
800
709 local classpath pkg 801 local classpath pkgs="${1}"
710 for pkg in ${@//,/ }; do
711 #for pkg in $(echo "$@" | tr ',' ' '); do
712 jars="$(java-config --classpath=${pkg})" 802 jars="$(java-config --classpath=${pkgs})"
803 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
713 debug-print "${pkg}:${jars}" 804 debug-print "${pkgs}:${jars}"
714 # TODO should we ensure jars exist? 805
715 if [[ -z "${classpath}" ]]; then 806 if [[ -z "${classpath}" ]]; then
716 classpath="${jars}" 807 classpath="${jars}"
717 else 808 else
718 classpath="${classpath}:${jars}" 809 classpath="${classpath}:${jars}"
719 fi 810 fi
811
812 # Only record jars that aren't build-only
813 if [[ -z "${build_only}" ]]; then
814 oldifs="${IFS}"
815 IFS=","
816 for pkg in ${pkgs}; do
720 java-pkg_record-jar_ "${pkg}" 817 java-pkg_record-jar_ "${pkg}"
721 done 818 done
819 IFS="${oldifs}"
820 fi
821
722 echo "${classpath}" 822 echo "${classpath}"
723} 823}
724 824
725# ------------------------------------------------------------------------------ 825# ------------------------------------------------------------------------------
726# @ebuild-function java-pkg_getjar 826# @ebuild-function java-pkg_getjar
727# 827#
728# Get the filename of a single jar from a package 828# Get the filename of a single jar from a package
829# The providing package is recorded as runtime dependency into package.env
830# DEPEND line, unless "--build-only" is passed as the very first argument, for
831# jars that have to be present only at build time and are not needed on runtime
832# (junit testing etc).
729# 833#
730# @example 834# @example
731# java-pkg_getjar xerces-2 xml-apis.jar 835# java-pkg_getjar xerces-2 xml-apis.jar
732# @example-return 836# @example-return
733# /usr/share/xerces-2/lib/xml-apis.jar 837# /usr/share/xerces-2/lib/xml-apis.jar
734# 838#
839# @param $1 - (optional) "--build-only" makes the jar not added into
840# package.env DEPEND line.
735# @param $1 - package to use 841# @param $1 - package to use
736# @param $2 - jar to get 842# @param $2 - jar to get
737# ------------------------------------------------------------------------------ 843# ------------------------------------------------------------------------------
738java-pkg_getjar() { 844java-pkg_getjar() {
739 debug-print-function ${FUNCNAME} $* 845 debug-print-function ${FUNCNAME} $*
846
847 local build_only=""
848
849 if [[ "${1}" = "--build-only" ]]; then
850 build_only="true"
851 shift
852 fi
740 853
741 local pkg="${1}" target_jar="${2}" jar 854 local pkg="${1}" target_jar="${2}" jar
742 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 855 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
743 [[ -z ${target_jar} ]] && die "Must specify jar to get" 856 [[ -z ${target_jar} ]] && die "Must specify jar to get"
744 857
745 # TODO check that package is actually installed 858 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
859 local classpath
746 local classpath=$(java-config --classpath=${pkg}) 860 classpath=$(java-config --classpath=${pkg})
747 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 861 [[ $? != 0 ]] && die ${error_msg}
862
748 for jar in ${classpath//:/ }; do 863 for jar in ${classpath//:/ }; do
749 if [[ ! -f "${jar}" ]] ; then 864 if [[ ! -f "${jar}" ]] ; then
750 die "Installation problems with jars in ${pkg} - is it installed?" 865 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
751 fi 866 fi
752 867
753 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 868 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
754 java-pkg_record-jar_ "${pkg}" "${jar}" 869 # Only record jars that aren't build-only
870 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
755 echo "${jar}" 871 echo "${jar}"
756 return 0 872 return 0
757 fi 873 fi
758 done 874 done
759 875
760 die "Could not find ${target_jar} in ${pkg}" 876 die "Could not find ${target_jar} in ${pkg}"
761 return 1 877 return 1
762} 878}
763 879
764# This function reads stdin, and based on that input, figures out how to 880# This function reads stdin, and based on that input, figures out how to
778# line="${line// /}" 894# line="${line// /}"
779# 895#
780# # format: path=jarinfo 896# # format: path=jarinfo
781# local path=${line%%=*} 897# local path=${line%%=*}
782# local jarinfo=${line##*=} 898# local jarinfo=${line##*=}
783# 899#
784# # format: jar@package 900# # format: jar@package
785# local jar=${jarinfo%%@*}.jar 901# local jar=${jarinfo%%@*}.jar
786# local package=${jarinfo##*@} 902# local package=${jarinfo##*@}
787# if [[ -n ${replace_only} ]]; then 903# if [[ -n ${replace_only} ]]; then
788# [[ ! -f $path ]] && die "No jar exists at ${path}" 904# [[ ! -f $path ]] && die "No jar exists at ${path}"
801# @section-end query 917# @section-end query
802# ------------------------------------------------------------------------------ 918# ------------------------------------------------------------------------------
803 919
804# ------------------------------------------------------------------------------ 920# ------------------------------------------------------------------------------
805# @section-begin helper 921# @section-begin helper
806# @section-summary Helper functions 922# @section-summary Helper functions
807# 923#
808# Various other functions to use from an ebuild 924# Various other functions to use from an ebuild
809# ------------------------------------------------------------------------------ 925# ------------------------------------------------------------------------------
810 926
811# ------------------------------------------------------------------------------ 927# ------------------------------------------------------------------------------
817# jdbc-stdext 933# jdbc-stdext
818# jaf 934# jaf
819# jdbc-rowset 935# jdbc-rowset
820# jms 936# jms
821# 937#
822# @param $1 - Optionally indicate that the dependencies are controlled by 938# @param $1 - Optionally indicate that the dependencies are controlled by
823# a use flag by specifying '--use' Requires $2. 939# a use flag by specifying '--use' Requires $2.
824# @param $2 - USE flag which will enable the dependencies. 940# @param $2 - USE flag which will enable the dependencies.
825# @param $@ - virtual packages to add depenedencies for 941# @param $@ - virtual packages to add depenedencies for
826# ------------------------------------------------------------------------------ 942# ------------------------------------------------------------------------------
827# TODO rewrite to parse a line based declaration file instead -- karltk 943# TODO rewrite to parse a line based declaration file instead -- karltk
921 fi 1037 fi
922} 1038}
923 1039
924# ------------------------------------------------------------------------------ 1040# ------------------------------------------------------------------------------
925# @internal-function java-pkg_is-vm-version-sufficient 1041# @internal-function java-pkg_is-vm-version-sufficient
926# 1042#
927# @return zero - VM is sufficient 1043# @return zero - VM is sufficient
928# @return non-zero - VM is not sufficient 1044# @return non-zero - VM is not sufficient
929# ------------------------------------------------------------------------------ 1045# ------------------------------------------------------------------------------
930java-pkg_is-vm-version-sufficient() { 1046java-pkg_is-vm-version-sufficient() {
931 debug-print-function ${FUNCNAME} $* 1047 debug-print-function ${FUNCNAME} $*
951 die "Active Java VM too old" 1067 die "Active Java VM too old"
952 fi 1068 fi
953} 1069}
954 1070
955# ------------------------------------------------------------------------------ 1071# ------------------------------------------------------------------------------
956# @internal-function java-pkg_is-vm-version-eq 1072# @internal-function java-pkg_is-vm-version-eq
957# 1073#
958# @param $@ - VM version to compare current VM to 1074# @param $@ - VM version to compare current VM to
959# @return zero - VM versions are equal 1075# @return zero - VM versions are equal
960# @return non-zero - VM version are not equal 1076# @return non-zero - VM version are not equal
961# ------------------------------------------------------------------------------ 1077# ------------------------------------------------------------------------------
962java-pkg_is-vm-version-eq() { 1078java-pkg_is-vm-version-eq() {
992# 1108#
993# @param $@ - VM version to compare current to 1109# @param $@ - VM version to compare current to
994# ------------------------------------------------------------------------------ 1110# ------------------------------------------------------------------------------
995java-pkg_ensure-vm-version-ge() { 1111java-pkg_ensure-vm-version-ge() {
996 debug-print-function ${FUNCNAME} $* 1112 debug-print-function ${FUNCNAME} $*
997 1113
998 if ! java-pkg_is-vm-version-ge "$@" ; then 1114 if ! java-pkg_is-vm-version-ge "$@" ; then
999 debug-print "vm is not suffient" 1115 debug-print "vm is not suffient"
1000 eerror "This package requires a Java VM version >= $@" 1116 eerror "This package requires a Java VM version >= $@"
1001 einfo "Please use java-config -S to set the correct one" 1117 einfo "Please use java-config -S to set the correct one"
1002 die "Active Java VM too old" 1118 die "Active Java VM too old"
1003 fi 1119 fi
1004} 1120}
1005 1121
1006# ------------------------------------------------------------------------------ 1122# ------------------------------------------------------------------------------
1007# @internal-function java-pkg_is-vm-version-ge 1123# @internal-function java-pkg_is-vm-version-ge
1008# 1124#
1009# @param $@ - VM version to compare current VM to 1125# @param $@ - VM version to compare current VM to
1010# @return zero - current VM version is greater than checked version 1126# @return zero - current VM version is greater than checked version
1011# @return non-zero - current VM version is not greater than checked version 1127# @return non-zero - current VM version is not greater than checked version
1012# ------------------------------------------------------------------------------ 1128# ------------------------------------------------------------------------------
1013java-pkg_is-vm-version-ge() { 1129java-pkg_is-vm-version-ge() {
1027 return 1 1143 return 1
1028 fi 1144 fi
1029 fi 1145 fi
1030} 1146}
1031 1147
1148java-pkg_set-current-vm() {
1149 export GENTOO_VM=${1}
1150}
1151
1152java-pkg_get-current-vm() {
1153 echo ${GENTOO_VM}
1154}
1155
1156java-pkg_current-vm-matches() {
1157 hasq $(java-pkg_get-current-vm) ${@}
1158 return $?
1159}
1160
1032# ------------------------------------------------------------------------------ 1161# ------------------------------------------------------------------------------
1033# @ebuild-function java-pkg_get-source 1162# @ebuild-function java-pkg_get-source
1034# 1163#
1035# Determines what source version should be used, for passing to -source. 1164# Determines what source version should be used, for passing to -source.
1036# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1165# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1037# 1166#
1038# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1167# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1039# ------------------------------------------------------------------------------ 1168# ------------------------------------------------------------------------------
1044# ------------------------------------------------------------------------------ 1173# ------------------------------------------------------------------------------
1045# @ebuild-function java-pkg_get-target 1174# @ebuild-function java-pkg_get-target
1046# 1175#
1047# Determines what target version should be used, for passing to -target. 1176# Determines what target version should be used, for passing to -target.
1048# If you don't care about lower versions, you can set _WANT_TARGET to the 1177# If you don't care about lower versions, you can set _WANT_TARGET to the
1049# version of your JDK. 1178# version of your JDK.
1050# Remember doing this will mostly like cause things to break. 1179# Remember doing this will mostly like cause things to break.
1051# Doesn't allow it to be lower then the one in depend. 1180# Doesn't allow it to be lower then the one in depend.
1052# Doesn't allow it to be higher then the active vm. 1181# Doesn't allow it to be higher then the active vm.
1053# 1182#
1054# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1183# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1055# ------------------------------------------------------------------------------ 1184# ------------------------------------------------------------------------------
1056java-pkg_get-target() { 1185java-pkg_get-target() {
1057 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") 1186 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1058 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then 1187 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1059 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" 1188 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1060 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then 1189 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1061 echo ${JAVA_PKG_WANT_TARGET} 1190 echo ${JAVA_PKG_WANT_TARGET}
1062 else 1191 else
1070} 1199}
1071 1200
1072java-pkg_get-javac() { 1201java-pkg_get-javac() {
1073 debug-print-function ${FUNCNAME} $* 1202 debug-print-function ${FUNCNAME} $*
1074 1203
1075 java-pkg_init-compiler_ 1204
1076 local compiler="${GENTOO_COMPILER}" 1205 local compiler="${GENTOO_COMPILER}"
1077 1206
1078 local compiler_executable 1207 local compiler_executable
1079 if [[ "${compiler}" = "javac" ]]; then 1208 if [[ "${compiler}" = "javac" ]]; then
1080 # nothing fancy needs to be done for javac 1209 # nothing fancy needs to be done for javac
1088 unset JAVAC 1217 unset JAVAC
1089 # try to get value of JAVAC 1218 # try to get value of JAVAC
1090 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1219 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1091 export JAVAC=${old_javac} 1220 export JAVAC=${old_javac}
1092 1221
1093 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1222 if [[ -z ${compiler_executable} ]]; then
1094 1223 echo "JAVAC is empty or undefined in ${compiler_env}"
1224 return 1
1225 fi
1226
1095 # check that it's executable 1227 # check that it's executable
1096 if [[ ! -x ${compiler_executable} ]]; then 1228 if [[ ! -x ${compiler_executable} ]]; then
1097 eerror "Could not find ${compiler_executable}!"
1098 die "${compiler_executable} doesn't exist, or isn't executable" 1229 echo "${compiler_executable} doesn't exist, or isn't executable"
1230 return 1
1099 fi 1231 fi
1100 else 1232 else
1101 eerror "Could not find environment file for ${compiler}" 1233 echo "Could not find environment file for ${compiler}"
1102 die "Could not find ${compiler_env}" 1234 return 1
1103 fi 1235 fi
1104 fi 1236 fi
1105 echo ${compiler_executable} 1237 echo ${compiler_executable}
1106} 1238}
1107 1239
1108# ------------------------------------------------------------------------------ 1240# ------------------------------------------------------------------------------
1109# @ebuild-function java-pkg_javac-args 1241# @ebuild-function java-pkg_javac-args
1110# 1242#
1111# If an ebuild uses javac directly, instead of using ejavac, it should call this 1243# If an ebuild uses javac directly, instead of using ejavac, it should call this
1112# to know what -source/-target to use. 1244# to know what -source/-target to use.
1113# 1245#
1114# @return string - arguments to pass to javac, complete with -target and -source 1246# @return string - arguments to pass to javac, complete with -target and -source
1117 debug-print-function ${FUNCNAME} $* 1249 debug-print-function ${FUNCNAME} $*
1118 1250
1119 local want_source="$(java-pkg_get-source)" 1251 local want_source="$(java-pkg_get-source)"
1120 local want_target="$(java-pkg_get-target)" 1252 local want_target="$(java-pkg_get-target)"
1121 1253
1122 local source_str="-source ${want_source}" 1254 local source_str="-source ${want_source}"
1123 local target_str="-target ${want_target}" 1255 local target_str="-target ${want_target}"
1124 1256
1125 debug-print "want source: ${want_source}" 1257 debug-print "want source: ${want_source}"
1126 debug-print "want target: ${want_target}" 1258 debug-print "want target: ${want_target}"
1127 1259
1128 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1260 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1129 debug-print "could not find valid -source/-target values" 1261 debug-print "could not find valid -source/-target values for javac"
1130 die "Could not find valid -source/-target values" 1262 echo "Could not find valid -source/-target values for javac"
1263 return 1
1131 else 1264 else
1132 if java-pkg_is-vm-version-ge "1.4"; then 1265 if java-pkg_is-vm-version-ge "1.4"; then
1133 echo "${source_str} ${target_str}" 1266 echo "${source_str} ${target_str}"
1134 else 1267 else
1135 echo "${target_str}" 1268 echo "${target_str}"
1139 1272
1140# TODO document 1273# TODO document
1141java-pkg_get-jni-cflags() { 1274java-pkg_get-jni-cflags() {
1142 local flags="-I${JAVA_HOME}/include" 1275 local flags="-I${JAVA_HOME}/include"
1143 1276
1144 # TODO figure out how to cope with other things than linux... 1277 local platform="linux"
1278 use elibc_FreeBSD && platform="freebsd"
1279
1280 # TODO do a check that the directories are valid
1145 flags="${flags} -I${JAVA_HOME}/include/linux" 1281 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1146 1282
1147 echo ${flags} 1283 echo ${flags}
1284}
1285
1286java-pkg_ensure-gcj() {
1287 if ! built_with_use sys-devel/gcc gcj ; then
1288 ewarn
1289 ewarn "You must build gcc with the gcj support to build with gcj"
1290 ewarn
1291 ebeep 5
1292 die "No GCJ support found!"
1293 fi
1294}
1295
1296java-pkg_ensure-test() {
1297 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then
1298 eerror "You specified FEATURES=test, but USE=test is needed"
1299 eerror "to pull in the additional dependencies for testing"
1300 die "Need USE=test enabled"
1301 fi
1148} 1302}
1149 1303
1150# ------------------------------------------------------------------------------ 1304# ------------------------------------------------------------------------------
1151# @section-end helper 1305# @section-end helper
1152# ------------------------------------------------------------------------------ 1306# ------------------------------------------------------------------------------
1166# compiler. 1320# compiler.
1167# 1321#
1168# ------------------------------------------------------------------------------ 1322# ------------------------------------------------------------------------------
1169eant() { 1323eant() {
1170 debug-print-function ${FUNCNAME} $* 1324 debug-print-function ${FUNCNAME} $*
1325
1326 # FIXME get this working
1327# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1328# java-pkg_announce-qa-violation \
1329# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1330# fi
1171 1331
1172 local antflags 1332 local antflags
1173 java-pkg_init-compiler_ 1333 java-pkg_init-compiler_
1174 local compiler="${GENTOO_COMPILER}" 1334 local compiler="${GENTOO_COMPILER}"
1175 1335
1189 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1349 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1190 if [[ -n ${build_compiler_deps} ]]; then 1350 if [[ -n ${build_compiler_deps} ]]; then
1191 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1351 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1192 fi 1352 fi
1193 fi 1353 fi
1194 1354
1355 if is-java-strict; then
1356 einfo "Disabling system classpath for ant"
1357 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1358 fi
1359
1195 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1360 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1196 antflags="${antflags} -debug" 1361 antflags="${antflags} -debug"
1197 fi 1362 fi
1198 1363
1199 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1364 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1200 ant ${antflags} "${@}" || die "eant failed" 1365 ant ${antflags} "${@}" || die "eant failed"
1201 1366
1202} 1367}
1203 1368
1204# ------------------------------------------------------------------------------ 1369# ------------------------------------------------------------------------------
1205# @ebuild-function ejavac 1370# @ebuild-function ejavac
1206# 1371#
1207# Javac wrapper function. Will use the appropriate compiler, based on 1372# Javac wrapper function. Will use the appropriate compiler, based on
1208# /etc/java-config/compilers.conf 1373# /etc/java-config/compilers.conf
1209# 1374#
1210# @param $@ - Arguments to be passed to the compiler 1375# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 1376# ------------------------------------------------------------------------------
1212ejavac() { 1377ejavac() {
1213 debug-print-function ${FUNCNAME} $* 1378 debug-print-function ${FUNCNAME} $*
1214 1379
1380 java-pkg_init-compiler_
1381
1382 local compiler_executable
1215 local compiler_executable=$(java-pkg_get-javac) 1383 compiler_executable=$(java-pkg_get-javac)
1384 if [[ ${?} != 0 ]]; then
1385 eerror "There was a problem determining compiler: ${compiler_executable}"
1386 die "get-javac failed"
1387 fi
1216 1388
1389 local javac_args
1390 javac_args="$(java-pkg_javac-args)"
1391 if [[ ${?} != 0 ]]; then
1392 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1393 die "java-pkg_javac-args failed"
1394 fi
1395
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1396 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1397 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1219} 1398}
1220 1399
1221# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
1222# @ebuild-function java-pkg_filter-compiler 1401# @ebuild-function java-pkg_filter-compiler
1223# 1402#
1224# Used to prevent the use of some compilers. Should be used in src_compile. 1403# Used to prevent the use of some compilers. Should be used in src_compile.
1225# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1404# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1226# 1405#
1227# @param $@ - compilers to filter 1406# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 1407# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 1408java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1409 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1231} 1410}
1232 1411
1233# ------------------------------------------------------------------------------ 1412# ------------------------------------------------------------------------------
1413# @ebuild-function java-pkg_force-compiler
1414#
1415# Used to force the use of particular compilers. Should be used in src_compile.
1416# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1417# OutOfMemoryErrors that may come up.
1418#
1419# @param $@ - compilers to force
1420# ------------------------------------------------------------------------------
1421java-pkg_force-compiler() {
1422 JAVA_PKG_FORCE_COMPILER="$@"
1423}
1424
1425# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 1426# @ebuild-function use_doc
1235# 1427#
1236# Helper function for getting ant to build javadocs. If the user has USE=doc, 1428# Helper function for getting ant to build javadocs. If the user has USE=doc,
1237# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1429# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1238# 1430#
1239# The output of this should be passed to ant. 1431# The output of this should be passed to ant.
1240# 1432#
1241# Example: build javadocs by calling 'javadoc' target 1433# Example: build javadocs by calling 'javadoc' target
1242# eant $(use_doc) 1434# eant $(use_doc)
1243# Example: build javadocs by calling 'apidoc' target 1435# Example: build javadocs by calling 'apidoc' target
1251} 1443}
1252 1444
1253# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1254# @section-end build 1446# @section-end build
1255# ------------------------------------------------------------------------------ 1447# ------------------------------------------------------------------------------
1256 1448
1257# ------------------------------------------------------------------------------ 1449# ------------------------------------------------------------------------------
1258# @section-begin internal 1450# @section-begin internal
1259# @section-summary Internal functions 1451# @section-summary Internal functions
1260# 1452#
1261# Do __NOT__ use any of these from an ebuild! These are only to be used from 1453# Do __NOT__ use any of these from an ebuild! These are only to be used from
1262# within the java eclasses. 1454# within the java eclasses.
1263# ------------------------------------------------------------------------------ 1455# ------------------------------------------------------------------------------
1264 1456
1265# ----------------------------------------------------------------------------- 1457# -----------------------------------------------------------------------------
1266# @function-internal java-pkg_init 1458# @function-internal java-pkg_init
1267# 1459#
1268# The purpose of this function, as the name might imply, is to initialize the 1460# The purpose of this function, as the name might imply, is to initialize the
1269# Java environment. It ensures that that there aren't any environment variables 1461# Java environment. It ensures that that there aren't any environment variables
1270# that'll muss things up. It initializes some variables, which are used 1462# that'll muss things up. It initializes some variables, which are used
1271# internally. And most importantly, it'll switch the VM if necessary. 1463# internally. And most importantly, it'll switch the VM if necessary.
1272# 1464#
1284 # TODO we will probably want to set JAVAC and JAVACFLAGS 1476 # TODO we will probably want to set JAVAC and JAVACFLAGS
1285 1477
1286 # Do some QA checks 1478 # Do some QA checks
1287 java-pkg_check-jikes 1479 java-pkg_check-jikes
1288 1480
1289 # When users have crazy classpaths some packages can fail to compile. 1481 # When users have crazy classpaths some packages can fail to compile.
1290 # and everything should work with empty CLASSPATH. 1482 # and everything should work with empty CLASSPATH.
1291 # This also helps prevent unexpected dependencies on random things 1483 # This also helps prevent unexpected dependencies on random things
1292 # from the CLASSPATH. 1484 # from the CLASSPATH.
1293 unset CLASSPATH 1485 unset CLASSPATH
1294} 1486}
1295 1487
1296# ------------------------------------------------------------------------------ 1488# ------------------------------------------------------------------------------
1297# @function-internal java-pkg-init-compiler_ 1489# @function-internal java-pkg-init-compiler_
1298# 1490#
1299# This function attempts to figure out what compiler should be used. It does 1491# This function attempts to figure out what compiler should be used. It does
1300# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1492# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1301# COMPILERS variable defined there. 1493# COMPILERS variable defined there.
1302# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1494# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1303# 1495#
1304# It will go through the list of compilers, and verify that it supports the 1496# It will go through the list of compilers, and verify that it supports the
1305# target and source that are needed. If it is not suitable, then the next 1497# target and source that are needed. If it is not suitable, then the next
1306# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1498# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1307# isn't done. 1499# isn't done.
1308# 1500#
1330 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1522 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1331 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1523 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1332 else 1524 else
1333 compilers=${JAVA_PKG_FORCE_COMPILER} 1525 compilers=${JAVA_PKG_FORCE_COMPILER}
1334 fi 1526 fi
1335 1527
1336 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1528 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1337 1529
1338 # Figure out if we should announce what compiler we're using 1530 # Figure out if we should announce what compiler we're using
1339 local compiler 1531 local compiler
1340 for compiler in ${compilers}; do 1532 for compiler in ${compilers}; do
1343 if [[ ${compiler} = "javac" ]]; then 1535 if [[ ${compiler} = "javac" ]]; then
1344 debug-print "Found javac... breaking" 1536 debug-print "Found javac... breaking"
1345 export GENTOO_COMPILER="javac" 1537 export GENTOO_COMPILER="javac"
1346 break 1538 break
1347 fi 1539 fi
1348 1540
1349 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1541 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1350 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1542 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1351 einfo "Filtering ${compiler}" 1543 einfo "Filtering ${compiler}"
1352 continue 1544 continue
1353 fi 1545 fi
1354 fi 1546 fi
1355 1547
1356 # for non-javac, we need to make sure it supports the right target and 1548 # for non-javac, we need to make sure it supports the right target and
1357 # source 1549 # source
1358 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1550 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1359 if [[ -f ${compiler_env} ]]; then 1551 if [[ -f ${compiler_env} ]]; then
1360 local desired_target="$(java-pkg_get-target)" 1552 local desired_target="$(java-pkg_get-target)"
1442# Writes the package.env out to disk. 1634# Writes the package.env out to disk.
1443# 1635#
1444# ------------------------------------------------------------------------------ 1636# ------------------------------------------------------------------------------
1445# TODO change to do-write, to match everything else 1637# TODO change to do-write, to match everything else
1446java-pkg_do_write_() { 1638java-pkg_do_write_() {
1639 java-pkg_init_paths_
1447 # Create directory for package.env 1640 # Create directory for package.env
1448 dodir "${JAVA_PKG_SHAREPATH}" 1641 dodir "${JAVA_PKG_SHAREPATH}"
1449 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1642 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1450 # Create package.env 1643 # Create package.env
1451 ( 1644 (
1456 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1649 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1457 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1650 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1458 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1651 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1459 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1652 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1460 ) > "${JAVA_PKG_ENV}" 1653 ) > "${JAVA_PKG_ENV}"
1461 1654
1462 # register target/source 1655 # register target/source
1463 local target="$(java-pkg_get-target)" 1656 local target="$(java-pkg_get-target)"
1464 local source="$(java-pkg_get-source)" 1657 local source="$(java-pkg_get-source)"
1465 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1658 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1466 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1659 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1479 # Strip unnecessary leading and trailing colons 1672 # Strip unnecessary leading and trailing colons
1480 # TODO try to cleanup if possible 1673 # TODO try to cleanup if possible
1481 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1674 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1482 fi 1675 fi
1483} 1676}
1484
1485 1677
1486# ------------------------------------------------------------------------------ 1678# ------------------------------------------------------------------------------
1487# @internal-function java-pkg_record-jar_ 1679# @internal-function java-pkg_record-jar_
1488# 1680#
1489# Record a dependency to the package.env 1681# Record a dependency to the package.env
1533 fi 1725 fi
1534} 1726}
1535 1727
1536# ------------------------------------------------------------------------------ 1728# ------------------------------------------------------------------------------
1537# @internal-function java-pkg_expand_dir_ 1729# @internal-function java-pkg_expand_dir_
1538# 1730#
1539# Gets the full path of the file/directory's parent. 1731# Gets the full path of the file/directory's parent.
1540# @param $1 - file/directory to find parent directory for 1732# @param $1 - file/directory to find parent directory for
1541# @return - path to $1's parent directory 1733# @return - path to $1's parent directory
1542# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1543java-pkg_expand_dir_() { 1735java-pkg_expand_dir_() {
1570# ------------------------------------------------------------------------------ 1762# ------------------------------------------------------------------------------
1571java-pkg_setup-vm() { 1763java-pkg_setup-vm() {
1572 debug-print-function ${FUNCNAME} $* 1764 debug-print-function ${FUNCNAME} $*
1573 1765
1574 local vendor="$(java-pkg_get-vm-vendor)" 1766 local vendor="$(java-pkg_get-vm-vendor)"
1575 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1767 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1576 addpredict "/dev/random" 1768 addpredict "/dev/random"
1577 elif [[ "${vendor}" == "ibm" ]]; then 1769 elif [[ "${vendor}" == "ibm" ]]; then
1578 addpredict "/proc/self/maps" 1770 addpredict "/proc/self/maps"
1579 addpredict "/proc/cpuinfo" 1771 addpredict "/proc/cpuinfo"
1580 export LANG="C" LC_ALL="C" 1772 export LANG="C" LC_ALL="C"
1629# @return - The version of the current VM 1821# @return - The version of the current VM
1630# ------------------------------------------------------------------------------ 1822# ------------------------------------------------------------------------------
1631java-pkg_get-vm-version() { 1823java-pkg_get-vm-version() {
1632 debug-print-function ${FUNCNAME} $* 1824 debug-print-function ${FUNCNAME} $*
1633 1825
1634 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1826 java-config -g PROVIDES_VERSION
1635} 1827}
1636 1828
1637# ------------------------------------------------------------------------------ 1829# ------------------------------------------------------------------------------
1638# @internal-function java-pkg_switch-vm 1830# @internal-function java-pkg_switch-vm
1639# 1831#
1640# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1832# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1641# verify that the current VM is sufficient. 1833# verify that the current VM is sufficient.
1642# Setup the environment for the VM being used. 1834# Setup the environment for the VM being used.
1643# ------------------------------------------------------------------------------ 1835# ------------------------------------------------------------------------------
1644java-pkg_switch-vm() { 1836java-pkg_switch-vm() {
1645 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1649 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1841 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1650 # if we're allowed to switch the vm... 1842 # if we're allowed to switch the vm...
1651 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1843 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1652 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1844 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1653 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1845 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1654 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1846 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1655 else 1847 else
1656 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1848 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1849 fi
1850 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1851 eerror "Unable to determine VM for building from dependencies:"
1852 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1853 echo "VNEED: ${JAVA_PKG_VNEED}"
1854 die "Failed to determine VM for building."
1855 else
1856 export GENTOO_VM
1657 fi 1857 fi
1658 # otherwise just make sure the current VM is sufficient 1858 # otherwise just make sure the current VM is sufficient
1659 else 1859 else
1660 java-pkg_ensure-vm-version-sufficient 1860 java-pkg_ensure-vm-version-sufficient
1661 fi 1861 fi
1662 debug-print "Using: $(java-config -f)" 1862 debug-print "Using: $(java-config -f)"
1663 1863
1664 java-pkg_setup-vm 1864 java-pkg_setup-vm
1665 1865
1666 export JAVA=$(java-config --java) 1866 export JAVA=$(java-config --java)
1667 export JAVAC=$(java-config --javac) 1867 export JAVAC=$(java-config --javac)
1668 export JAVACFLAGS="$(java-pkg_javac-args)" 1868 JAVACFLAGS="$(java-pkg_javac-args)"
1869 if [[ ${?} != 0 ]]; then
1870 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1871 die "java-pkg_javac-args failed"
1872 fi
1669 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1873 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1874 export JAVACFLAGS
1670 1875
1671 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1876 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1672 export JDK_HOME=${JAVA_HOME} 1877 export JDK_HOME=${JAVA_HOME}
1673 1878
1674 #TODO If you know a better solution let us know. 1879 #TODO If you know a better solution let us know.
1675 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1880 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1676 1881
1677 local tann="${T}/announced-vm" 1882 local tann="${T}/announced-vm"
1678 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1883 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1679 # Add a check for setup/preinst phase... to avoid duplicate outputs 1884 # Add a check for setup/preinst phase... to avoid duplicate outputs
1680 # for when FEATURES=buildpkg 1885 # for when FEATURES=buildpkg
1681 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1886 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1706 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1911 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1707 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1912 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1708 echo "and of course, the output of emerge --info" >&2 1913 echo "and of course, the output of emerge --info" >&2
1709} 1914}
1710 1915
1916
1917# TODO document
1918# List jars in the source directory, ${S}
1919java-pkg_jar-list() {
1920 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1921 einfo "Linked Jars"
1922 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1923 einfo "Jars"
1924 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1925 einfo "Classes"
1926 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1927 fi
1928}
1929
1930# TODO document
1931# Verify that the classes were compiled for the right source / target
1932java-pkg_verify-classes() {
1933 ebegin "Verifying java class versions"
1934 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1935 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1936 result=$?
1937 eend ${result}
1938 if [[ ${result} == 0 ]]; then
1939 einfo "All good"
1940 else
1941 ewarn "Possible problem"
1942 die "Bad class files found"
1943 fi
1944}
1945
1711# ------------------------------------------------------------------------------ 1946# ------------------------------------------------------------------------------
1712# @section-end internal 1947# @section-end internal
1713# ------------------------------------------------------------------------------ 1948# ------------------------------------------------------------------------------
1714 1949
1715java-pkg_check-phase() { 1950java-pkg_check-phase() {
1716 local phase=${1} 1951 local phase=${1}
1717 local funcname=${2} 1952 local funcname=${2}
1718 # TODO add check for java-stricter
1719 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1953 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1720 java-pkg_announce-qa-violation \ 1954 java-pkg_announce-qa-violation \
1721 "${funcname} used outside of src_${phase}" 1955 "${funcname} used outside of src_${phase}"
1722 fi 1956 fi
1723} 1957}
1724 1958
1735 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1969 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1736 fi 1970 fi
1737} 1971}
1738 1972
1739java-pkg_announce-qa-violation() { 1973java-pkg_announce-qa-violation() {
1740 if hasq java-strict ${FEATURES}; then 1974 if is-java-strict; then
1741 echo "Java QA Notice: $@" >&2 1975 echo "Java QA Notice: $@" >&2
1742 increment-qa-violations 1976 increment-qa-violations
1743 fi 1977 fi
1744} 1978}
1745 1979
1746increment-qa-violations() { 1980increment-qa-violations() {
1747 let "JAVA_PKG_QA_VIOLATIONS+=1" 1981 let "JAVA_PKG_QA_VIOLATIONS+=1"
1748 export JAVA_PKG_QA_VIOLATIONS 1982 export JAVA_PKG_QA_VIOLATIONS
1749} 1983}
1750 1984
1985is-java-strict() {
1986 [[ -n ${JAVA_PKG_STRICT} ]]
1987 return $?
1988}
1989
1751# ------------------------------------------------------------------------------ 1990# ------------------------------------------------------------------------------
1752# @eclass-end 1991# @eclass-end
1753# ------------------------------------------------------------------------------ 1992# ------------------------------------------------------------------------------

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20