/[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.6 Revision 1.20
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
15# 15#
16# This eclass provides functionality which is used by 16# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 18#
19# @warning 19# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 20# You probably don't want to inherit this directly from an ebuild. Instead,
21# you should inherit java-ant for Ant-based Java packages, java-pkg for other 21# you should inherit java-ant for Ant-based Java packages, java-pkg for other
22# Java packages, or java-pkg-opt for packages that have optional Java support. 22# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 23#
24# ----------------------------------------------------------------------------- 24# -----------------------------------------------------------------------------
25 25
26inherit eutils versionator multilib 26inherit eutils versionator multilib
33# ----------------------------------------------------------------------------- 33# -----------------------------------------------------------------------------
34 34
35# Make sure we use java-config-2 35# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 36export WANT_JAVA_CONFIG="2"
37 37
38# TODO document
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40
38# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 42# @variable-internal JAVA_PKG_E_DEPEND
40# 43#
41# This is a convience variable to be used from the other java eclasses. This is 44# This is a convience variable to be used from the other java eclasses. This is
42# the version of java-config we want to use. We also need a recent version 45# the version of java-config we want to use. We also need a recent version
43# portage, that includes phase hooks. 46# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 47# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 49
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 52# @variable-default yes
50# 53#
97# ----------------------------------------------------------------------------- 100# -----------------------------------------------------------------------------
98 101
99# ----------------------------------------------------------------------------- 102# -----------------------------------------------------------------------------
100# @variable-internal JAVA_PKG_COMPILER_DIR 103# @variable-internal JAVA_PKG_COMPILER_DIR
101# @default /usr/share/java-config-2/compiler 104# @default /usr/share/java-config-2/compiler
102# 105#
103# Directory where compiler settings are saved, without trailing slash. 106# Directory where compiler settings are saved, without trailing slash.
104# Probably shouldn't touch this variable. 107# Probably shouldn't touch this variable.
105# ----------------------------------------------------------------------------- 108# -----------------------------------------------------------------------------
106JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
107 110
117 120
118# ----------------------------------------------------------------------------- 121# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_FORCE_COMPILER 122# @variable-external JAVA_PKG_FORCE_COMPILER
120# 123#
121# Explicitly set a list of compilers to use. This is normally read from 124# Explicitly set a list of compilers to use. This is normally read from
122# JAVA_PKG_COMPILERS_CONF. 125# JAVA_PKG_COMPILERS_CONF.
123# 126#
124# @note This should only be used internally or for testing. 127# @note This should only be used internally or for testing.
125# @example Use jikes and javac, in that order 128# @example Use jikes and javac, in that order
126# JAVA_PKG_FORCE_COMPILER="jikes javac" 129# JAVA_PKG_FORCE_COMPILER="jikes javac"
127# ----------------------------------------------------------------------------- 130# -----------------------------------------------------------------------------
147# @ebuild-function java-pkg_dojar 150# @ebuild-function java-pkg_dojar
148# 151#
149# Installs any number of jars. 152# Installs any number of jars.
150# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
151# You can use java-pkg_jarinto to change this path. 154# You can use java-pkg_jarinto to change this path.
152# You should never install a jar with a package version in the filename. 155# You should never install a jar with a package version in the filename.
153# Instead, use java-pkg_newjar defined below. 156# Instead, use java-pkg_newjar defined below.
154# 157#
155# @example 158# @example
156# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
157# 160#
219# will not work, because: 222# will not work, because:
220# * the `for jar in "$@"` can't expand the path to jar file names, as they 223# * the `for jar in "$@"` can't expand the path to jar file names, as they
221# don't exist yet 224# don't exist yet
222# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
223# doesn't exist 226# doesn't exist
224# 227#
225# you have to use it as: 228# you have to use it as:
226# 229#
227# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
228# 231#
229# @param $@ - jars to record 232# @param $@ - jars to record
230# ------------------------------------------------------------------------------ 233# ------------------------------------------------------------------------------
231# TODO fix me! 234# TODO should we be making sure the jar is present on ${D} or wherever?
232java-pkg_regjar() { 235java-pkg_regjar() {
233 debug-print-function ${FUNCNAME} $* 236 debug-print-function ${FUNCNAME} $*
234 237
235 java-pkg_check-phase install 238 java-pkg_check-phase install
236 239
302} 305}
303 306
304 307
305# ------------------------------------------------------------------------------ 308# ------------------------------------------------------------------------------
306# @ebuild-function java-pkg_doso 309# @ebuild-function java-pkg_doso
307# 310#
308# Installs any number of JNI libraries 311# Installs any number of JNI libraries
309# They will be installed into /usr/lib by default, but java-pkg_sointo 312# They will be installed into /usr/lib by default, but java-pkg_sointo
310# can be used change this path 313# can be used change this path
311# 314#
312# Example: 315# Example:
367 java-pkg_check-phase install 370 java-pkg_check-phase install
368 371
369 [[ ${#} -lt 1 ]] && "at least one argument needed" 372 [[ ${#} -lt 1 ]] && "at least one argument needed"
370 373
371 java-pkg_init_paths_ 374 java-pkg_init_paths_
372 375
373 local lib target_dir 376 local lib target_dir
374 for lib in "$@" ; do 377 for lib in "$@" ; do
375 # Check the absolute path of the lib 378 # Check the absolute path of the lib
376 if [[ -e "${lib}" ]] ; then 379 if [[ -e "${lib}" ]] ; then
377 target_dir="$(java-pkg_expand_dir_ ${lib})" 380 target_dir="$(java-pkg_expand_dir_ ${lib})"
455} 458}
456 459
457# ------------------------------------------------------------------------------ 460# ------------------------------------------------------------------------------
458# @ebuild-function java-pkg_dosrc 461# @ebuild-function java-pkg_dosrc
459# 462#
460# Installs a zip containing the source for a package, so it can used in 463# Installs a zip containing the source for a package, so it can used in
461# from IDEs like eclipse and netbeans. 464# from IDEs like eclipse and netbeans.
462# 465#
463# Ebuild needs to DEPEND on app-arch/zip to use this. 466# Ebuild needs to DEPEND on app-arch/zip to use this.
464# 467#
465# It also should be controlled by USE=source. 468# It also should be controlled by USE=source.
466# 469#
467# @example: 470# @example:
468# java-pkg_dosrc src/* 471# java-pkg_dosrc src/*
469# 472#
470# ------------------------------------------------------------------------------ 473# ------------------------------------------------------------------------------
471# TODO change so it the arguments it takes are the base directories containing 474# TODO change so it the arguments it takes are the base directories containing
472# source -nichoj 475# source -nichoj
473# TODO should we be able to handle multiple calls to dosrc? -nichoj 476# TODO should we be able to handle multiple calls to dosrc? -nichoj
474# TODO maybe we can take an existing zip/jar? -nichoj 477# TODO maybe we can take an existing zip/jar? -nichoj
475# FIXME apparently this fails if you give it an empty directories 478# FIXME apparently this fails if you give it an empty directories
476java-pkg_dosrc() { 479java-pkg_dosrc() {
477 debug-print-function ${FUNCNAME} $* 480 debug-print-function ${FUNCNAME} $*
478 481
479 [ ${#} -lt 1 ] && die "At least one argument needed" 482 [ ${#} -lt 1 ] && die "At least one argument needed"
480 if ! hasq source ${IUSE}; then 483 if ! hasq source ${IUSE}; then
481 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
482 fi 485 fi
483 486
484 java-pkg_check-phase install 487 java-pkg_check-phase install
485 488
486 [[ ${#} -lt 1 ]] && die "At least one argument needed" 489 [[ ${#} -lt 1 ]] && die "At least one argument needed"
487 490
488 java-pkg_init_paths_ 491 java-pkg_init_paths_
489 492
490 local zip_name="${PN}-src.zip" 493 local zip_name="${PN}-src.zip"
491 local zip_path="${T}/${zip_name}" 494 local zip_path="${T}/${zip_name}"
519# 522#
520# @param $1 - filename of launcher to create 523# @param $1 - filename of launcher to create
521# @param $2 - options, as follows: 524# @param $2 - options, as follows:
522# --main the.main.class.too.start 525# --main the.main.class.too.start
523# --jar /the/jar/too/launch.jar 526# --jar /the/jar/too/launch.jar
524# --java_args 'Extra arguments to pass too jave' 527# --java_args 'Extra arguments to pass to java'
525# --pkg_args 'extra arguments too pass too the package' 528# --pkg_args 'Extra arguments too pass to the package'
526# --pwd 529# --pwd
527# -into 530# -into
528# -pre 531# -pre
529# ------------------------------------------------------------------------------ 532# ------------------------------------------------------------------------------
530java-pkg_dolauncher() { 533java-pkg_dolauncher() {
537 java-pkg_init_paths_ 540 java-pkg_init_paths_
538 541
539 local name="${1}" 542 local name="${1}"
540 # TODO rename to launcher 543 # TODO rename to launcher
541 local target="${T}/${name}" 544 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp"
542 local target_dir pre 546 local target_dir pre
543 shift 547 shift
544 548
545 echo "#!/bin/bash" > "${target}" 549 # Process the other the rest of the arguments
546 while [[ -n "${1}" && -n "${2}" ]]; do 550 while [[ -n "${1}" && -n "${2}" ]]; do
547 local var=${1} value=${2} 551 local var=${1} value=${2}
548 if [[ "${var:0:2}" == "--" ]]; then 552 if [[ "${var:0:2}" == "--" ]]; then
549 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}"
550 elif [[ "${var}" == "-into" ]]; then 554 elif [[ "${var}" == "-into" ]]; then
551 target_dir="${value}" 555 target_dir="${value}"
552 elif [[ "${var}" == "-pre" ]]; then 556 elif [[ "${var}" == "-pre" ]]; then
553 pre="${value}" 557 pre="${value}"
554 fi 558 fi
555 shift 2 559 shift 2
556 done 560 done
561
562 # Write the actual script
563 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
557 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
558 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 566 cat "${var_tmp}" >> "${target}"
559 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 567 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
560 568
561 if [[ -n "${into}" ]]; then 569 if [[ -n "${target_dir}" ]]; then
562 DESTTREE="${target_dir}" dobin "${target}" 570 DESTTREE="${target_dir}" dobin "${target}"
563 local ret=$? 571 local ret=$?
564 return ${ret} 572 return ${ret}
565 else 573 else
566 dobin "${target}" 574 dobin "${target}"
594 echo "dowar: warning, skipping directory ${war}" 602 echo "dowar: warning, skipping directory ${war}"
595 continue 603 continue
596 else 604 else
597 warpath="${war}" 605 warpath="${war}"
598 fi 606 fi
599 607
600 # Install those files like you mean it 608 # Install those files like you mean it
601 INSOPTIONS="-m 0644" \ 609 INSOPTIONS="-m 0644" \
602 INSDESTTREE=${JAVA_PKG_WARDEST} \ 610 INSDESTTREE=${JAVA_PKG_WARDEST} \
603 doins ${warpath} 611 doins ${warpath}
604 done 612 done
639# @ebuild-function java-pkg_jar-from 647# @ebuild-function java-pkg_jar-from
640# 648#
641# Makes a symlink to a jar from a certain package 649# Makes a symlink to a jar from a certain package
642# A lot of java packages include dependencies in a lib/ directory 650# A lot of java packages include dependencies in a lib/ directory
643# You can use this function to replace these bundled dependencies. 651# You can use this function to replace these bundled dependencies.
652# The dependency is recorded into package.env DEPEND line, unless "--build-only"
653# is passed as the very first argument, for jars that have to be present only
654# at build time and are not needed on runtime (junit testing etc).
644# 655#
645# Example: get all jars from xerces slot 2 656# Example: get all jars from xerces slot 2
646# java-pkg_jar-from xerces-2 657# java-pkg_jar-from xerces-2
647# Example: get a specific jar from xerces slot 2 658# Example: get a specific jar from xerces slot 2
648# java-pkg_jar-from xerces-2 xml-apis.jar 659# java-pkg_jar-from xerces-2 xml-apis.jar
649# Example get a specific jar from xerces slot 2, and name it diffrently 660# 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 661# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
662# Example: get junit.jar which is needed only for building
663# java-pkg_jar-from --build-only junit junit.jar
651# 664#
665# @param $1 - (optional) "--build-only" makes the jar(s) not added into
666# package.env DEPEND line.
652# @param $1 - Package to get jars from. 667# @param $1 - Package to get jars from.
653# @param $2 - jar from package. If not specified, all jars will be used. 668# @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 669# @param $3 - When a single jar is specified, destination filename of the
655# symlink. Defaults to the name of the jar. 670# symlink. Defaults to the name of the jar.
656# ------------------------------------------------------------------------------ 671# ------------------------------------------------------------------------------
657# TODO could probably be cleaned up a little 672# TODO could probably be cleaned up a little
658java-pkg_jar-from() { 673java-pkg_jar-from() {
659 debug-print-function ${FUNCNAME} $* 674 debug-print-function ${FUNCNAME} $*
660 675
676 local build_only=""
677
678 if [[ "${1}" = "--build-only" ]]; then
679 build_only="true"
680 shift
681 fi
682
661 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 683 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
662 684
663 [[ -z ${target_pkg} ]] && die "Must specify a package" 685 [[ -z ${target_pkg} ]] && die "Must specify a package"
664 686
665 # default destjar to the target jar 687 # default destjar to the target jar
666 [[ -z "${destjar}" ]] && destjar="${target_jar}" 688 [[ -z "${destjar}" ]] && destjar="${target_jar}"
667 689
690 local error_msg="There was a problem getting the classpath for ${target_pkg}."
691 local classpath
668 local classpath="$(java-config --classpath=${target_pkg})" 692 classpath="$(java-config --classpath=${target_pkg})"
669 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 693 [[ $? != 0 ]] && die ${error_msg}
670 694
671 local jar 695 local jar
672 for jar in ${classpath//:/ }; do 696 for jar in ${classpath//:/ }; do
673 local jar_name=$(basename "${jar}") 697 local jar_name=$(basename "${jar}")
674 if [[ ! -f "${jar}" ]] ; then 698 if [[ ! -f "${jar}" ]] ; then
678 # If no specific target jar was indicated, link it 702 # If no specific target jar was indicated, link it
679 if [[ -z "${target_jar}" ]] ; then 703 if [[ -z "${target_jar}" ]] ; then
680 [[ -f "${target_jar}" ]] && rm "${target_jar}" 704 [[ -f "${target_jar}" ]] && rm "${target_jar}"
681 ln -snf "${jar}" \ 705 ln -snf "${jar}" \
682 || die "Failed to make symlink from ${jar} to ${jar_name}" 706 || die "Failed to make symlink from ${jar} to ${jar_name}"
683 java-pkg_record-jar_ "${target_pkg}" "${jar}" 707 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
684 # otherwise, if the current jar is the target jar, link it 708 # otherwise, if the current jar is the target jar, link it
685 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 709 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
686 [[ -f "${destjar}" ]] && rm "${destjar}" 710 [[ -f "${destjar}" ]] && rm "${destjar}"
687 ln -snf "${jar}" "${destjar}" \ 711 ln -snf "${jar}" "${destjar}" \
688 || die "Failed to make symlink from ${jar} to ${destjar}" 712 || die "Failed to make symlink from ${jar} to ${destjar}"
689 java-pkg_record-jar_ "${target_pkg}" "${jar}" 713 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
690 return 0 714 return 0
691 fi 715 fi
692 done 716 done
693 # if no target was specified, we're ok 717 # if no target was specified, we're ok
694 if [[ -z "${target_jar}" ]] ; then 718 if [[ -z "${target_jar}" ]] ; then
711# ------------------------------------------------------------------------------ 735# ------------------------------------------------------------------------------
712# @ebuild-function java-pkg_getjars 736# @ebuild-function java-pkg_getjars
713# 737#
714# Get the classpath provided by any number of packages 738# Get the classpath provided by any number of packages
715# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 739# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
740# The providing packages are recorded as dependencies into package.env DEPEND
741# line, unless "--build-only" is passed as the very first argument, for jars
742# that have to be present only at build time and are not needed on runtime
743# (junit testing etc).
716# 744#
717# Example: Get the classpath for xerces-2, 745# Example: Get the classpath for xerces-2,
718# java-pkg_getjars xerces-2 xalan 746# java-pkg_getjars xerces-2 xalan
719# Example Return: 747# Example Return:
720# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 748# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
721# 749#
750# @param $1 - (optional) "--build-only" makes the jar(s) not added into
751# package.env DEPEND line.
722# @param $@ - list of packages to get jars from 752# @param $@ - list of packages to get jars from
723# ------------------------------------------------------------------------------ 753# ------------------------------------------------------------------------------
724java-pkg_getjars() { 754java-pkg_getjars() {
725 debug-print-function ${FUNCNAME} $* 755 debug-print-function ${FUNCNAME} $*
756
757 local build_only=""
758
759 if [[ "${1}" = "--build-only" ]]; then
760 build_only="true"
761 shift
762 fi
726 763
727 [[ ${#} -lt 1 ]] && die "At least one argument needed" 764 [[ ${#} -lt 1 ]] && die "At least one argument needed"
728 765
729 # NOTE could probably just pass $@ to java-config --classpath. and return it 766 # NOTE could probably just pass $@ to java-config --classpath. and return it
730 local classpath pkg 767 local classpath pkg
731 for pkg in ${@//,/ }; do 768 for pkg in ${@//,/ }; do
732 #for pkg in $(echo "$@" | tr ',' ' '); do 769 #for pkg in $(echo "$@" | tr ',' ' '); do
733 jars="$(java-config --classpath=${pkg})" 770 jars="$(java-config --classpath=${pkg})"
771 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
734 debug-print "${pkg}:${jars}" 772 debug-print "${pkg}:${jars}"
735 # TODO should we ensure jars exist? 773
736 if [[ -z "${classpath}" ]]; then 774 if [[ -z "${classpath}" ]]; then
737 classpath="${jars}" 775 classpath="${jars}"
738 else 776 else
739 classpath="${classpath}:${jars}" 777 classpath="${classpath}:${jars}"
740 fi 778 fi
741 java-pkg_record-jar_ "${pkg}" 779 # Only record jars that aren't build-only
780 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
742 done 781 done
743 echo "${classpath}" 782 echo "${classpath}"
744} 783}
745 784
746# ------------------------------------------------------------------------------ 785# ------------------------------------------------------------------------------
747# @ebuild-function java-pkg_getjar 786# @ebuild-function java-pkg_getjar
748# 787#
749# Get the filename of a single jar from a package 788# Get the filename of a single jar from a package
789# The providing package is recorded as runtime dependency into package.env
790# DEPEND line, unless "--build-only" is passed as the very first argument, for
791# jars that have to be present only at build time and are not needed on runtime
792# (junit testing etc).
750# 793#
751# @example 794# @example
752# java-pkg_getjar xerces-2 xml-apis.jar 795# java-pkg_getjar xerces-2 xml-apis.jar
753# @example-return 796# @example-return
754# /usr/share/xerces-2/lib/xml-apis.jar 797# /usr/share/xerces-2/lib/xml-apis.jar
755# 798#
799# @param $1 - (optional) "--build-only" makes the jar not added into
800# package.env DEPEND line.
756# @param $1 - package to use 801# @param $1 - package to use
757# @param $2 - jar to get 802# @param $2 - jar to get
758# ------------------------------------------------------------------------------ 803# ------------------------------------------------------------------------------
759java-pkg_getjar() { 804java-pkg_getjar() {
760 debug-print-function ${FUNCNAME} $* 805 debug-print-function ${FUNCNAME} $*
806
807 local build_only=""
808
809 if [[ "${1}" = "--build-only" ]]; then
810 build_only="true"
811 shift
812 fi
761 813
762 local pkg="${1}" target_jar="${2}" jar 814 local pkg="${1}" target_jar="${2}" jar
763 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 815 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
764 [[ -z ${target_jar} ]] && die "Must specify jar to get" 816 [[ -z ${target_jar} ]] && die "Must specify jar to get"
765 817
766 # TODO check that package is actually installed 818 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
819 local classpath
767 local classpath=$(java-config --classpath=${pkg}) 820 classpath=$(java-config --classpath=${pkg})
768 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 821 [[ $? != 0 ]] && die ${error_msg}
822
769 for jar in ${classpath//:/ }; do 823 for jar in ${classpath//:/ }; do
770 if [[ ! -f "${jar}" ]] ; then 824 if [[ ! -f "${jar}" ]] ; then
771 die "Installation problems with jars in ${pkg} - is it installed?" 825 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
772 fi 826 fi
773 827
774 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 828 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
775 java-pkg_record-jar_ "${pkg}" "${jar}" 829 # Only record jars that aren't build-only
830 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
776 echo "${jar}" 831 echo "${jar}"
777 return 0 832 return 0
778 fi 833 fi
779 done 834 done
780 835
781 die "Could not find ${target_jar} in ${pkg}" 836 die "Could not find ${target_jar} in ${pkg}"
782 return 1 837 return 1
783} 838}
784 839
785# This function reads stdin, and based on that input, figures out how to 840# This function reads stdin, and based on that input, figures out how to
799# line="${line// /}" 854# line="${line// /}"
800# 855#
801# # format: path=jarinfo 856# # format: path=jarinfo
802# local path=${line%%=*} 857# local path=${line%%=*}
803# local jarinfo=${line##*=} 858# local jarinfo=${line##*=}
804# 859#
805# # format: jar@package 860# # format: jar@package
806# local jar=${jarinfo%%@*}.jar 861# local jar=${jarinfo%%@*}.jar
807# local package=${jarinfo##*@} 862# local package=${jarinfo##*@}
808# if [[ -n ${replace_only} ]]; then 863# if [[ -n ${replace_only} ]]; then
809# [[ ! -f $path ]] && die "No jar exists at ${path}" 864# [[ ! -f $path ]] && die "No jar exists at ${path}"
822# @section-end query 877# @section-end query
823# ------------------------------------------------------------------------------ 878# ------------------------------------------------------------------------------
824 879
825# ------------------------------------------------------------------------------ 880# ------------------------------------------------------------------------------
826# @section-begin helper 881# @section-begin helper
827# @section-summary Helper functions 882# @section-summary Helper functions
828# 883#
829# Various other functions to use from an ebuild 884# Various other functions to use from an ebuild
830# ------------------------------------------------------------------------------ 885# ------------------------------------------------------------------------------
831 886
832# ------------------------------------------------------------------------------ 887# ------------------------------------------------------------------------------
838# jdbc-stdext 893# jdbc-stdext
839# jaf 894# jaf
840# jdbc-rowset 895# jdbc-rowset
841# jms 896# jms
842# 897#
843# @param $1 - Optionally indicate that the dependencies are controlled by 898# @param $1 - Optionally indicate that the dependencies are controlled by
844# a use flag by specifying '--use' Requires $2. 899# a use flag by specifying '--use' Requires $2.
845# @param $2 - USE flag which will enable the dependencies. 900# @param $2 - USE flag which will enable the dependencies.
846# @param $@ - virtual packages to add depenedencies for 901# @param $@ - virtual packages to add depenedencies for
847# ------------------------------------------------------------------------------ 902# ------------------------------------------------------------------------------
848# TODO rewrite to parse a line based declaration file instead -- karltk 903# TODO rewrite to parse a line based declaration file instead -- karltk
942 fi 997 fi
943} 998}
944 999
945# ------------------------------------------------------------------------------ 1000# ------------------------------------------------------------------------------
946# @internal-function java-pkg_is-vm-version-sufficient 1001# @internal-function java-pkg_is-vm-version-sufficient
947# 1002#
948# @return zero - VM is sufficient 1003# @return zero - VM is sufficient
949# @return non-zero - VM is not sufficient 1004# @return non-zero - VM is not sufficient
950# ------------------------------------------------------------------------------ 1005# ------------------------------------------------------------------------------
951java-pkg_is-vm-version-sufficient() { 1006java-pkg_is-vm-version-sufficient() {
952 debug-print-function ${FUNCNAME} $* 1007 debug-print-function ${FUNCNAME} $*
972 die "Active Java VM too old" 1027 die "Active Java VM too old"
973 fi 1028 fi
974} 1029}
975 1030
976# ------------------------------------------------------------------------------ 1031# ------------------------------------------------------------------------------
977# @internal-function java-pkg_is-vm-version-eq 1032# @internal-function java-pkg_is-vm-version-eq
978# 1033#
979# @param $@ - VM version to compare current VM to 1034# @param $@ - VM version to compare current VM to
980# @return zero - VM versions are equal 1035# @return zero - VM versions are equal
981# @return non-zero - VM version are not equal 1036# @return non-zero - VM version are not equal
982# ------------------------------------------------------------------------------ 1037# ------------------------------------------------------------------------------
983java-pkg_is-vm-version-eq() { 1038java-pkg_is-vm-version-eq() {
1013# 1068#
1014# @param $@ - VM version to compare current to 1069# @param $@ - VM version to compare current to
1015# ------------------------------------------------------------------------------ 1070# ------------------------------------------------------------------------------
1016java-pkg_ensure-vm-version-ge() { 1071java-pkg_ensure-vm-version-ge() {
1017 debug-print-function ${FUNCNAME} $* 1072 debug-print-function ${FUNCNAME} $*
1018 1073
1019 if ! java-pkg_is-vm-version-ge "$@" ; then 1074 if ! java-pkg_is-vm-version-ge "$@" ; then
1020 debug-print "vm is not suffient" 1075 debug-print "vm is not suffient"
1021 eerror "This package requires a Java VM version >= $@" 1076 eerror "This package requires a Java VM version >= $@"
1022 einfo "Please use java-config -S to set the correct one" 1077 einfo "Please use java-config -S to set the correct one"
1023 die "Active Java VM too old" 1078 die "Active Java VM too old"
1024 fi 1079 fi
1025} 1080}
1026 1081
1027# ------------------------------------------------------------------------------ 1082# ------------------------------------------------------------------------------
1028# @internal-function java-pkg_is-vm-version-ge 1083# @internal-function java-pkg_is-vm-version-ge
1029# 1084#
1030# @param $@ - VM version to compare current VM to 1085# @param $@ - VM version to compare current VM to
1031# @return zero - current VM version is greater than checked version 1086# @return zero - current VM version is greater than checked version
1032# @return non-zero - current VM version is not greater than checked version 1087# @return non-zero - current VM version is not greater than checked version
1033# ------------------------------------------------------------------------------ 1088# ------------------------------------------------------------------------------
1034java-pkg_is-vm-version-ge() { 1089java-pkg_is-vm-version-ge() {
1048 return 1 1103 return 1
1049 fi 1104 fi
1050 fi 1105 fi
1051} 1106}
1052 1107
1108java-pkg_set-current-vm() {
1109 export GENTOO_VM=${1}
1110}
1111
1112java-pkg_get-current-vm() {
1113 echo ${GENTOO_VM}
1114}
1115
1116java-pkg_current-vm-matches() {
1117 hasq $(java-pkg_get-current-vm) ${@}
1118 return $?
1119}
1120
1053# ------------------------------------------------------------------------------ 1121# ------------------------------------------------------------------------------
1054# @ebuild-function java-pkg_get-source 1122# @ebuild-function java-pkg_get-source
1055# 1123#
1056# Determines what source version should be used, for passing to -source. 1124# 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 1125# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1058# 1126#
1059# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1127# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1060# ------------------------------------------------------------------------------ 1128# ------------------------------------------------------------------------------
1065# ------------------------------------------------------------------------------ 1133# ------------------------------------------------------------------------------
1066# @ebuild-function java-pkg_get-target 1134# @ebuild-function java-pkg_get-target
1067# 1135#
1068# Determines what target version should be used, for passing to -target. 1136# 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 1137# If you don't care about lower versions, you can set _WANT_TARGET to the
1070# version of your JDK. 1138# version of your JDK.
1071# Remember doing this will mostly like cause things to break. 1139# Remember doing this will mostly like cause things to break.
1072# Doesn't allow it to be lower then the one in depend. 1140# Doesn't allow it to be lower then the one in depend.
1073# Doesn't allow it to be higher then the active vm. 1141# Doesn't allow it to be higher then the active vm.
1074# 1142#
1075# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1143# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1076# ------------------------------------------------------------------------------ 1144# ------------------------------------------------------------------------------
1077java-pkg_get-target() { 1145java-pkg_get-target() {
1078 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") 1146 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1079 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then 1147 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1080 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" 1148 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 1149 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} 1150 echo ${JAVA_PKG_WANT_TARGET}
1083 else 1151 else
1110 # try to get value of JAVAC 1178 # try to get value of JAVAC
1111 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1179 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1112 export JAVAC=${old_javac} 1180 export JAVAC=${old_javac}
1113 1181
1114 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1182 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}"
1115 1183
1116 # check that it's executable 1184 # check that it's executable
1117 if [[ ! -x ${compiler_executable} ]]; then 1185 if [[ ! -x ${compiler_executable} ]]; then
1118 eerror "Could not find ${compiler_executable}!" 1186 eerror "Could not find ${compiler_executable}!"
1119 die "${compiler_executable} doesn't exist, or isn't executable" 1187 die "${compiler_executable} doesn't exist, or isn't executable"
1120 fi 1188 fi
1125 fi 1193 fi
1126 echo ${compiler_executable} 1194 echo ${compiler_executable}
1127} 1195}
1128 1196
1129# ------------------------------------------------------------------------------ 1197# ------------------------------------------------------------------------------
1130# @ebuild-function java-pkg_javac-args 1198# @ebuild-function java-pkg_javac-args
1131# 1199#
1132# If an ebuild uses javac directly, instead of using ejavac, it should call this 1200# If an ebuild uses javac directly, instead of using ejavac, it should call this
1133# to know what -source/-target to use. 1201# to know what -source/-target to use.
1134# 1202#
1135# @return string - arguments to pass to javac, complete with -target and -source 1203# @return string - arguments to pass to javac, complete with -target and -source
1138 debug-print-function ${FUNCNAME} $* 1206 debug-print-function ${FUNCNAME} $*
1139 1207
1140 local want_source="$(java-pkg_get-source)" 1208 local want_source="$(java-pkg_get-source)"
1141 local want_target="$(java-pkg_get-target)" 1209 local want_target="$(java-pkg_get-target)"
1142 1210
1143 local source_str="-source ${want_source}" 1211 local source_str="-source ${want_source}"
1144 local target_str="-target ${want_target}" 1212 local target_str="-target ${want_target}"
1145 1213
1146 debug-print "want source: ${want_source}" 1214 debug-print "want source: ${want_source}"
1147 debug-print "want target: ${want_target}" 1215 debug-print "want target: ${want_target}"
1148 1216
1160 1228
1161# TODO document 1229# TODO document
1162java-pkg_get-jni-cflags() { 1230java-pkg_get-jni-cflags() {
1163 local flags="-I${JAVA_HOME}/include" 1231 local flags="-I${JAVA_HOME}/include"
1164 1232
1233 # TODO do a check that the directories are valid
1165 # TODO figure out how to cope with other things than linux... 1234 # TODO figure out how to cope with other things than linux...
1166 flags="${flags} -I${JAVA_HOME}/include/linux" 1235 flags="${flags} -I${JAVA_HOME}/include/linux"
1167 1236
1168 echo ${flags} 1237 echo ${flags}
1169} 1238}
1170 1239
1240java-pkg_ensure-gcj() {
1241 if ! built_with_use sys-devel/gcc gcj ; then
1242 ewarn
1243 ewarn "You must build gcc with the gcj support to build with gcj"
1244 ewarn
1245 ebeep 5
1246 die "No GCJ support found!"
1247 fi
1248}
1249
1250java-pkg_ensure-test() {
1251 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then
1252 eerror "You specified FEATURES=test, but USE=test is needed"
1253 eerror "to pull in the additional dependencies for testing"
1254 die "Need USE=test enabled"
1255 fi
1256}
1257
1171# ------------------------------------------------------------------------------ 1258# ------------------------------------------------------------------------------
1172# @section-end helper 1259# @section-end helper
1173# ------------------------------------------------------------------------------ 1260# ------------------------------------------------------------------------------
1174 1261
1175# ------------------------------------------------------------------------------ 1262# ------------------------------------------------------------------------------
1187# compiler. 1274# compiler.
1188# 1275#
1189# ------------------------------------------------------------------------------ 1276# ------------------------------------------------------------------------------
1190eant() { 1277eant() {
1191 debug-print-function ${FUNCNAME} $* 1278 debug-print-function ${FUNCNAME} $*
1279
1280 # FIXME get this working
1281# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1282# java-pkg_announce-qa-violation \
1283# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1284# fi
1192 1285
1193 local antflags 1286 local antflags
1194 java-pkg_init-compiler_ 1287 java-pkg_init-compiler_
1195 local compiler="${GENTOO_COMPILER}" 1288 local compiler="${GENTOO_COMPILER}"
1196 1289
1210 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1303 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 1304 if [[ -n ${build_compiler_deps} ]]; then
1212 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1305 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1213 fi 1306 fi
1214 fi 1307 fi
1215 1308
1309 if is-java-strict; then
1310 einfo "Disabling system classpath for ant"
1311 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1312 fi
1313
1216 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1314 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1217 antflags="${antflags} -debug" 1315 antflags="${antflags} -debug"
1218 fi 1316 fi
1219 1317
1220 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1318 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1221 ant ${antflags} "${@}" || die "eant failed" 1319 ant ${antflags} "${@}" || die "eant failed"
1222 1320
1223} 1321}
1224 1322
1225# ------------------------------------------------------------------------------ 1323# ------------------------------------------------------------------------------
1226# @ebuild-function ejavac 1324# @ebuild-function ejavac
1227# 1325#
1228# Javac wrapper function. Will use the appropriate compiler, based on 1326# Javac wrapper function. Will use the appropriate compiler, based on
1229# /etc/java-config/compilers.conf 1327# /etc/java-config/compilers.conf
1230# 1328#
1231# @param $@ - Arguments to be passed to the compiler 1329# @param $@ - Arguments to be passed to the compiler
1232# ------------------------------------------------------------------------------ 1330# ------------------------------------------------------------------------------
1233ejavac() { 1331ejavac() {
1241 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1339 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1242} 1340}
1243 1341
1244# ------------------------------------------------------------------------------ 1342# ------------------------------------------------------------------------------
1245# @ebuild-function java-pkg_filter-compiler 1343# @ebuild-function java-pkg_filter-compiler
1246# 1344#
1247# Used to prevent the use of some compilers. Should be used in src_compile. 1345# Used to prevent the use of some compilers. Should be used in src_compile.
1248# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1346# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1249# 1347#
1250# @param $@ - compilers to filter 1348# @param $@ - compilers to filter
1251# ------------------------------------------------------------------------------ 1349# ------------------------------------------------------------------------------
1252java-pkg_filter-compiler() { 1350java-pkg_filter-compiler() {
1253 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1351 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1254} 1352}
1255 1353
1256# ------------------------------------------------------------------------------ 1354# ------------------------------------------------------------------------------
1355# @ebuild-function java-pkg_force-compiler
1356#
1357# Used to force the use of particular compilers. Should be used in src_compile.
1358# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1359# OutOfMemoryErrors that may come up.
1360#
1361# @param $@ - compilers to force
1362# ------------------------------------------------------------------------------
1363java-pkg_force-compiler() {
1364 JAVA_PKG_FORCE_COMPILER="$@"
1365}
1366
1367# ------------------------------------------------------------------------------
1257# @ebuild-function use_doc 1368# @ebuild-function use_doc
1258# 1369#
1259# Helper function for getting ant to build javadocs. If the user has USE=doc, 1370# Helper function for getting ant to build javadocs. If the user has USE=doc,
1260# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1371# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1261# 1372#
1262# The output of this should be passed to ant. 1373# The output of this should be passed to ant.
1263# 1374#
1264# Example: build javadocs by calling 'javadoc' target 1375# Example: build javadocs by calling 'javadoc' target
1265# eant $(use_doc) 1376# eant $(use_doc)
1266# Example: build javadocs by calling 'apidoc' target 1377# Example: build javadocs by calling 'apidoc' target
1274} 1385}
1275 1386
1276# ------------------------------------------------------------------------------ 1387# ------------------------------------------------------------------------------
1277# @section-end build 1388# @section-end build
1278# ------------------------------------------------------------------------------ 1389# ------------------------------------------------------------------------------
1279 1390
1280# ------------------------------------------------------------------------------ 1391# ------------------------------------------------------------------------------
1281# @section-begin internal 1392# @section-begin internal
1282# @section-summary Internal functions 1393# @section-summary Internal functions
1283# 1394#
1284# Do __NOT__ use any of these from an ebuild! These are only to be used from 1395# Do __NOT__ use any of these from an ebuild! These are only to be used from
1285# within the java eclasses. 1396# within the java eclasses.
1286# ------------------------------------------------------------------------------ 1397# ------------------------------------------------------------------------------
1287 1398
1288# ----------------------------------------------------------------------------- 1399# -----------------------------------------------------------------------------
1289# @function-internal java-pkg_init 1400# @function-internal java-pkg_init
1290# 1401#
1291# The purpose of this function, as the name might imply, is to initialize the 1402# The purpose of this function, as the name might imply, is to initialize the
1292# Java environment. It ensures that that there aren't any environment variables 1403# Java environment. It ensures that that there aren't any environment variables
1293# that'll muss things up. It initializes some variables, which are used 1404# that'll muss things up. It initializes some variables, which are used
1294# internally. And most importantly, it'll switch the VM if necessary. 1405# internally. And most importantly, it'll switch the VM if necessary.
1295# 1406#
1307 # TODO we will probably want to set JAVAC and JAVACFLAGS 1418 # TODO we will probably want to set JAVAC and JAVACFLAGS
1308 1419
1309 # Do some QA checks 1420 # Do some QA checks
1310 java-pkg_check-jikes 1421 java-pkg_check-jikes
1311 1422
1312 # When users have crazy classpaths some packages can fail to compile. 1423 # When users have crazy classpaths some packages can fail to compile.
1313 # and everything should work with empty CLASSPATH. 1424 # and everything should work with empty CLASSPATH.
1314 # This also helps prevent unexpected dependencies on random things 1425 # This also helps prevent unexpected dependencies on random things
1315 # from the CLASSPATH. 1426 # from the CLASSPATH.
1316 unset CLASSPATH 1427 unset CLASSPATH
1317} 1428}
1318 1429
1319# ------------------------------------------------------------------------------ 1430# ------------------------------------------------------------------------------
1320# @function-internal java-pkg-init-compiler_ 1431# @function-internal java-pkg-init-compiler_
1321# 1432#
1322# This function attempts to figure out what compiler should be used. It does 1433# This function attempts to figure out what compiler should be used. It does
1323# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1434# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1324# COMPILERS variable defined there. 1435# COMPILERS variable defined there.
1325# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1436# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1326# 1437#
1327# It will go through the list of compilers, and verify that it supports the 1438# It will go through the list of compilers, and verify that it supports the
1328# target and source that are needed. If it is not suitable, then the next 1439# target and source that are needed. If it is not suitable, then the next
1329# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1440# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1330# isn't done. 1441# isn't done.
1331# 1442#
1353 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1464 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1354 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1465 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1355 else 1466 else
1356 compilers=${JAVA_PKG_FORCE_COMPILER} 1467 compilers=${JAVA_PKG_FORCE_COMPILER}
1357 fi 1468 fi
1358 1469
1359 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1470 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1360 1471
1361 # Figure out if we should announce what compiler we're using 1472 # Figure out if we should announce what compiler we're using
1362 local compiler 1473 local compiler
1363 for compiler in ${compilers}; do 1474 for compiler in ${compilers}; do
1366 if [[ ${compiler} = "javac" ]]; then 1477 if [[ ${compiler} = "javac" ]]; then
1367 debug-print "Found javac... breaking" 1478 debug-print "Found javac... breaking"
1368 export GENTOO_COMPILER="javac" 1479 export GENTOO_COMPILER="javac"
1369 break 1480 break
1370 fi 1481 fi
1371 1482
1372 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1483 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1373 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1484 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1374 einfo "Filtering ${compiler}" 1485 einfo "Filtering ${compiler}"
1375 continue 1486 continue
1376 fi 1487 fi
1377 fi 1488 fi
1378 1489
1379 # for non-javac, we need to make sure it supports the right target and 1490 # for non-javac, we need to make sure it supports the right target and
1380 # source 1491 # source
1381 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1492 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1382 if [[ -f ${compiler_env} ]]; then 1493 if [[ -f ${compiler_env} ]]; then
1383 local desired_target="$(java-pkg_get-target)" 1494 local desired_target="$(java-pkg_get-target)"
1479 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1590 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1480 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1591 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1481 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1592 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1482 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1593 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1483 ) > "${JAVA_PKG_ENV}" 1594 ) > "${JAVA_PKG_ENV}"
1484 1595
1485 # register target/source 1596 # register target/source
1486 local target="$(java-pkg_get-target)" 1597 local target="$(java-pkg_get-target)"
1487 local source="$(java-pkg_get-source)" 1598 local source="$(java-pkg_get-source)"
1488 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1599 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1489 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1600 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1556 fi 1667 fi
1557} 1668}
1558 1669
1559# ------------------------------------------------------------------------------ 1670# ------------------------------------------------------------------------------
1560# @internal-function java-pkg_expand_dir_ 1671# @internal-function java-pkg_expand_dir_
1561# 1672#
1562# Gets the full path of the file/directory's parent. 1673# Gets the full path of the file/directory's parent.
1563# @param $1 - file/directory to find parent directory for 1674# @param $1 - file/directory to find parent directory for
1564# @return - path to $1's parent directory 1675# @return - path to $1's parent directory
1565# ------------------------------------------------------------------------------ 1676# ------------------------------------------------------------------------------
1566java-pkg_expand_dir_() { 1677java-pkg_expand_dir_() {
1658} 1769}
1659 1770
1660# ------------------------------------------------------------------------------ 1771# ------------------------------------------------------------------------------
1661# @internal-function java-pkg_switch-vm 1772# @internal-function java-pkg_switch-vm
1662# 1773#
1663# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1774# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1664# verify that the current VM is sufficient. 1775# verify that the current VM is sufficient.
1665# Setup the environment for the VM being used. 1776# Setup the environment for the VM being used.
1666# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1667java-pkg_switch-vm() { 1778java-pkg_switch-vm() {
1668 if java-pkg_needs-vm; then 1779 if java-pkg_needs-vm; then
1681 # otherwise just make sure the current VM is sufficient 1792 # otherwise just make sure the current VM is sufficient
1682 else 1793 else
1683 java-pkg_ensure-vm-version-sufficient 1794 java-pkg_ensure-vm-version-sufficient
1684 fi 1795 fi
1685 debug-print "Using: $(java-config -f)" 1796 debug-print "Using: $(java-config -f)"
1686 1797
1687 java-pkg_setup-vm 1798 java-pkg_setup-vm
1688 1799
1689 export JAVA=$(java-config --java) 1800 export JAVA=$(java-config --java)
1690 export JAVAC=$(java-config --javac) 1801 export JAVAC=$(java-config --javac)
1691 export JAVACFLAGS="$(java-pkg_javac-args)" 1802 export JAVACFLAGS="$(java-pkg_javac-args)"
1692 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1803 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1693 1804
1694 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1805 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1695 export JDK_HOME=${JAVA_HOME} 1806 export JDK_HOME=${JAVA_HOME}
1696 1807
1697 #TODO If you know a better solution let us know. 1808 #TODO If you know a better solution let us know.
1698 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1809 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1699 1810
1700 local tann="${T}/announced-vm" 1811 local tann="${T}/announced-vm"
1701 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1812 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1702 # Add a check for setup/preinst phase... to avoid duplicate outputs 1813 # Add a check for setup/preinst phase... to avoid duplicate outputs
1703 # for when FEATURES=buildpkg 1814 # for when FEATURES=buildpkg
1704 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1815 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1729 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1840 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1730 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1841 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1731 echo "and of course, the output of emerge --info" >&2 1842 echo "and of course, the output of emerge --info" >&2
1732} 1843}
1733 1844
1845
1846# TODO document
1847# List jars in the source directory, ${S}
1848java-pkg_jar-list() {
1849 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1850 einfo "Linked Jars"
1851 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1852 einfo "Jars"
1853 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1854 einfo "Classes"
1855 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1856 fi
1857}
1858
1859# TODO document
1860# Verify that the classes were compiled for the right source / target
1861java-pkg_verify-classes() {
1862 ebegin "Verifying java class versions"
1863 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1864 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1865 result=$?
1866 eend ${result}
1867 if [[ ${result} == 0 ]]; then
1868 einfo "All good"
1869 else
1870 ewarn "Possible problem"
1871 die "Bad class files found"
1872 fi
1873}
1874
1875
1734# ------------------------------------------------------------------------------ 1876# ------------------------------------------------------------------------------
1735# @section-end internal 1877# @section-end internal
1736# ------------------------------------------------------------------------------ 1878# ------------------------------------------------------------------------------
1737 1879
1738java-pkg_check-phase() { 1880java-pkg_check-phase() {
1739 local phase=${1} 1881 local phase=${1}
1740 local funcname=${2} 1882 local funcname=${2}
1741 # TODO add check for java-stricter
1742 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1883 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1743 java-pkg_announce-qa-violation \ 1884 java-pkg_announce-qa-violation \
1744 "${funcname} used outside of src_${phase}" 1885 "${funcname} used outside of src_${phase}"
1745 fi 1886 fi
1746} 1887}
1747 1888
1758 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1899 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1759 fi 1900 fi
1760} 1901}
1761 1902
1762java-pkg_announce-qa-violation() { 1903java-pkg_announce-qa-violation() {
1763 if hasq java-strict ${FEATURES}; then 1904 if is-java-strict; then
1764 echo "Java QA Notice: $@" >&2 1905 echo "Java QA Notice: $@" >&2
1765 increment-qa-violations 1906 increment-qa-violations
1766 fi 1907 fi
1767} 1908}
1768 1909
1769increment-qa-violations() { 1910increment-qa-violations() {
1770 let "JAVA_PKG_QA_VIOLATIONS+=1" 1911 let "JAVA_PKG_QA_VIOLATIONS+=1"
1771 export JAVA_PKG_QA_VIOLATIONS 1912 export JAVA_PKG_QA_VIOLATIONS
1772} 1913}
1773 1914
1915is-java-strict() {
1916 [[ -n ${JAVA_PKG_STRICT} ]]
1917 return $?
1918}
1919
1774# ------------------------------------------------------------------------------ 1920# ------------------------------------------------------------------------------
1775# @eclass-end 1921# @eclass-end
1776# ------------------------------------------------------------------------------ 1922# ------------------------------------------------------------------------------

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20