/[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.94 Revision 1.127
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.94 2007/10/04 09:59:29 ali_bush Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.127 2009/05/19 21:23:32 caster Exp $
10 10
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
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66hasq "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.6 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
76 77
77# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 80# @variable-default yes
80# 81#
290 done 291 done
291 292
292 java-pkg_do_write_ 293 java-pkg_do_write_
293} 294}
294 295
295
296# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
297# @internal-function depend-java-query 297# @internal-function depend-java-query
298# 298#
299# Wrapper for the depend-java-query binary to enable passing USE in env. 299# Wrapper for the depend-java-query binary to enable passing USE in env.
300# Using env variables keeps this eclass working with java-config versions that 300# Using env variables keeps this eclass working with java-config versions that
365 if [[ ${jar} = *\** ]]; then 365 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 366 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 367 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 368 eerror '${D} add ${D} to the argument.'
369 fi 369 fi
370 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 371 die "${jar} does not exist"
371 fi 372 fi
372 done 373 done
373 374
374 java-pkg_do_write_ 375 java-pkg_do_write_
429# @param $@ - JNI libraries to install 430# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 431# ------------------------------------------------------------------------------
431java-pkg_doso() { 432java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 433 debug-print-function ${FUNCNAME} $*
433 434
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 435 java-pkg_check-phase install
436 436
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 437 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 438
439 java-pkg_init_paths_ 439 java-pkg_init_paths_
440 440
441 local lib 441 local lib
442 # for each lib 442 # for each lib
445 if [[ -e "${lib}" ]] ; then 445 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 446 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 447 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 449 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 450 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 453 # otherwise make a symlink to the symlink's origin
454 else 454 else
455 # TODO use dosym 455 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 456 debug-print "${lib} is a symlink, linking accordantly"
459 fi 457 fi
460 # otherwise die 458 # otherwise die
461 else 459 else
462 die "${lib} does not exist" 460 die "${lib} does not exist"
463 fi 461 fi
479java-pkg_regso() { 477java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 478 debug-print-function ${FUNCNAME} $*
481 479
482 java-pkg_check-phase install 480 java-pkg_check-phase install
483 481
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 482 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 483
486 java-pkg_init_paths_ 484 java-pkg_init_paths_
487 485
488 local lib target_dir 486 local lib target_dir
489 for lib in "$@" ; do 487 for lib in "$@" ; do
556# ------------------------------------------------------------------------------ 554# ------------------------------------------------------------------------------
557# @ebuild-function java-pkg_dojavadoc 555# @ebuild-function java-pkg_dojavadoc
558# 556#
559# Installs javadoc documentation. This should be controlled by the doc use flag. 557# Installs javadoc documentation. This should be controlled by the doc use flag.
560# 558#
559# @param $1: optional --symlink creates to symlink like this for html
560# documentation bundles.
561# @param $1: - The javadoc root directory. 561# @param $2: - The javadoc root directory.
562# 562#
563# @example: 563# @example:
564# java-pkg_dojavadoc docs/api 564# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api
565# 566#
566# ------------------------------------------------------------------------------ 567# ------------------------------------------------------------------------------
567java-pkg_dojavadoc() { 568java-pkg_dojavadoc() {
568 debug-print-function ${FUNCNAME} $* 569 debug-print-function ${FUNCNAME} $*
570
571 # For html documentation bundles that link to Javadoc
572 local symlink
573 if [[ ${1} = --symlink ]]; then
574 symlink=${2}
575 shift 2
576 fi
577
569 local dir="$1" 578 local dir="$1"
579 local dest=/usr/share/doc/${PF}/html
570 580
571 # QA checks 581 # QA checks
572 582
573 java-pkg_check-phase install 583 java-pkg_check-phase install
574 584
578 local msg="No index.html in javadoc directory" 588 local msg="No index.html in javadoc directory"
579 ewarn "${msg}" 589 ewarn "${msg}"
580 is-java-strict && die "${msg}" 590 is-java-strict && die "${msg}"
581 fi 591 fi
582 592
593 if [[ -e ${D}/${dest}/api ]]; then
594 eerror "${dest} already exists. Will not overwrite."
595 die "${dest}"
596 fi
597
583 # Renaming to match our directory layout 598 # Renaming to match our directory layout
584 599
585 local dir_to_install="${dir}" 600 local dir_to_install="${dir}"
586 if [[ "$(basename "${dir}")" != "api" ]]; then 601 if [[ "$(basename "${dir}")" != "api" ]]; then
587 dir_to_install="${T}/api" 602 dir_to_install="${T}/api"
589 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 604 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
590 fi 605 fi
591 606
592 # Actual installation 607 # Actual installation
593 608
594 java-pkg_dohtml -r ${dir_to_install} 609 java-pkg_dohtml -r "${dir_to_install}"
610
611 # Let's make a symlink to the directory we have everything else under
612 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
613
614 if [[ ${symlink} ]]; then
615 debug-print "symlinking ${dest}/{api,${symlink}}"
616 dosym ${dest}/{api,${symlink}} || die
617 fi
595} 618}
596 619
597# ------------------------------------------------------------------------------ 620# ------------------------------------------------------------------------------
598# @ebuild-function java-pkg_dosrc 621# @ebuild-function java-pkg_dosrc
599# 622#
622 645
623 [[ ${#} -lt 1 ]] && die "At least one argument needed" 646 [[ ${#} -lt 1 ]] && die "At least one argument needed"
624 647
625 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then 648 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
626 local msg="${FUNCNAME} called without app-arch/zip in DEPEND" 649 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
627 if is-java-strict; then 650 java-pkg_announce-qa-violation ${msg}
628 eerror "${msg}"
629 die "${msg}"
630 else
631 echo "${msg}"
632 echo "Please report this to http://bugs.gentoo.org."
633 fi
634 fi 651 fi
635 652
636 java-pkg_init_paths_ 653 java-pkg_init_paths_
637 654
638 local zip_name="${PN}-src.zip" 655 local zip_name="${PN}-src.zip"
878 895
879 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 896 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
880 897
881 [[ -z ${target_pkg} ]] && die "Must specify a package" 898 [[ -z ${target_pkg} ]] && die "Must specify a package"
882 899
900 if [[ "${EAPI}" == "1" ]]; then
901 target_pkg="${target_pkg//:/-}"
902 fi
903
883 # default destjar to the target jar 904 # default destjar to the target jar
884 [[ -z "${destjar}" ]] && destjar="${target_jar}" 905 [[ -z "${destjar}" ]] && destjar="${target_jar}"
885 906
886 local error_msg="There was a problem getting the classpath for ${target_pkg}." 907 local error_msg="There was a problem getting the classpath for ${target_pkg}."
887 local classpath 908 local classpath
998 done 1019 done
999 1020
1000 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*" 1021 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1001 1022
1002 1023
1003 local classpath pkgs="${1}" 1024 local pkgs="${1}"
1025
1026 if [[ "${EAPI}" == "1" ]]; then
1027 pkgs="${pkgs//:/-}"
1028 fi
1029
1004 jars="$(java-config ${deep} --classpath=${pkgs})" 1030 jars="$(java-config ${deep} --classpath=${pkgs})"
1005 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 1031 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1006 debug-print "${pkgs}:${jars}" 1032 debug-print "${pkgs}:${jars}"
1007 1033
1008 for pkg in ${pkgs//,/ }; do 1034 for pkg in ${pkgs//,/ }; do
1009 java-pkg_ensure-dep "${build_only}" "${pkg}" 1035 java-pkg_ensure-dep "${build_only}" "${pkg}"
1010 done 1036 done
1011
1012 if [[ -z "${classpath}" ]]; then
1013 classpath="${jars}"
1014 else
1015 classpath="${classpath}:${jars}"
1016 fi
1017 1037
1018 # Only record jars that aren't build-only 1038 # Only record jars that aren't build-only
1019 if [[ -z "${build_only}" ]]; then 1039 if [[ -z "${build_only}" ]]; then
1020 for pkg in ${pkgs//,/ }; do 1040 for pkg in ${pkgs//,/ }; do
1021 java-pkg_record-jar_ "${pkg}" 1041 java-pkg_record-jar_ "${pkg}"
1022 done 1042 done
1023 fi 1043 fi
1024 1044
1025 echo "${classpath}" 1045 echo "${jars}"
1026} 1046}
1027 1047
1028# ------------------------------------------------------------------------------ 1048# ------------------------------------------------------------------------------
1029# @ebuild-function java-pkg_getjar 1049# @ebuild-function java-pkg_getjar
1030# 1050#
1055 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1056 1076
1057 while [[ "${1}" == --* ]]; do 1077 while [[ "${1}" == --* ]]; do
1058 if [[ "${1}" = "--build-only" ]]; then 1078 if [[ "${1}" = "--build-only" ]]; then
1059 build_only="build" 1079 build_only="build"
1060 elif [[ "${1}" == --* ]]; then 1080 elif [[ "${1}" == "--virtual" ]]; then
1061 virtual="true" 1081 virtual="true"
1062 else 1082 else
1063 die "java-pkg_jar-from called with unknown parameter: ${1}" 1083 die "java-pkg_getjar called with unknown parameter: ${1}"
1064 fi 1084 fi
1065 shift 1085 shift
1066 done 1086 done
1067 1087
1068 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*" 1088 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1069 1089
1070 local pkg="${1}" target_jar="${2}" jar 1090 local pkg="${1}" target_jar="${2}" jar
1091
1092 if [[ "${EAPI}" == "1" ]]; then
1093 pkg="${pkg//:/-}"
1094 fi
1095
1071 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1072 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1097 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1073 1098
1074 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1099 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1075 local classpath 1100 local classpath
1136 1161
1137 local pkgs="${1}" 1162 local pkgs="${1}"
1138 local jar="${2}" 1163 local jar="${2}"
1139 1164
1140 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1165 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1166
1167 if [[ "${EAPI}" == "1" ]]; then
1168 pkgs="${pkgs//:/-}"
1169 fi
1141 1170
1142 if [[ -z "${jar}" ]]; then 1171 if [[ -z "${jar}" ]]; then
1143 for pkg in ${pkgs//,/ }; do 1172 for pkg in ${pkgs//,/ }; do
1144 java-pkg_ensure-dep runtime "${pkg}" 1173 java-pkg_ensure-dep runtime "${pkg}"
1145 java-pkg_record-jar_ "${pkg}" 1174 java-pkg_record-jar_ "${pkg}"
1187 1216
1188 local pkgs="${1}" 1217 local pkgs="${1}"
1189 local jar="${2}" 1218 local jar="${2}"
1190 1219
1191 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified" 1220 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1221
1222 if [[ "${EAPI}" == "1" ]]; then
1223 pkgs="${pkgs//:/-}"
1224 fi
1192 1225
1193 if [[ -z "${jar}" ]]; then 1226 if [[ -z "${jar}" ]]; then
1194 for pkg in ${pkgs//,/ }; do 1227 for pkg in ${pkgs//,/ }; do
1195 java-pkg_record-jar_ --optional "${pkg}" 1228 java-pkg_record-jar_ --optional "${pkg}"
1196 done 1229 done
1697 dodir /usr/share/ant/${TASKS_DIR} 1730 dodir /usr/share/ant/${TASKS_DIR}
1698 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1731 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1699} 1732}
1700 1733
1701# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1702# @internal-function java-pkg_ant-tasks-from-deps
1703#
1704# Function to determine ANT_TASKS from DEPEND variable for backwards
1705# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1706# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1707# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1708# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1709# be a problem, the worst it can do is activace all tasks when not needed.
1710# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1711# insufficient dependencies, otherwise all available tasks are used for
1712# backwards compatilbility.
1713#
1714# @return "all" or "none"
1715# ------------------------------------------------------------------------------
1716java-pkg_ant-tasks-from-deps() {
1717 local found_ant found_ant_tasks
1718
1719 for dep in ${DEPEND}
1720 do
1721 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1722 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1723 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1724 done
1725
1726 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1727 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1728 echo "all"
1729 else
1730 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1731 # so we deactivate all tasks that may be installed
1732 echo "none"
1733 fi
1734}
1735
1736# ------------------------------------------------------------------------------
1737# @internal-function java-pkg_ant-tasks-depend 1735# @internal-function java-pkg_ant-tasks-depend
1738# 1736#
1739# Translates the WANT_ANT_TASKS variable into valid dependencies. 1737# Translates the WANT_ANT_TASKS variable into valid dependencies.
1740# ------------------------------------------------------------------------------ 1738# ------------------------------------------------------------------------------
1741java-pkg_ant-tasks-depend() { 1739java-pkg_ant-tasks-depend() {
1743 1741
1744 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1745 local DEP="" 1743 local DEP=""
1746 for i in ${WANT_ANT_TASKS} 1744 for i in ${WANT_ANT_TASKS}
1747 do 1745 do
1748 if [[ ${i} != ant-* ]]; then 1746 if [[ ${i} = ant-* ]]; then
1747 DEP="${DEP}dev-java/${i} "
1748 elif [[ ${i} = */*:* ]]; then
1749 DEP="${DEP}${i} "
1750 else
1749 echo "Invalid atom in WANT_ANT_TASKS: ${i}" 1751 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1750 return 1 1752 return 1
1751 fi 1753 fi
1752 DEP="${DEP}dev-java/${i} "
1753 done 1754 done
1754 echo ${DEP} 1755 echo ${DEP}
1755 return 0 1756 return 0
1756 else 1757 else
1757 return 0 1758 return 0
1774# ------------------------------------------------------------------------------ 1775# ------------------------------------------------------------------------------
1775ejunit() { 1776ejunit() {
1776 debug-print-function ${FUNCNAME} $* 1777 debug-print-function ${FUNCNAME} $*
1777 1778
1778 local pkgs 1779 local pkgs
1780 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1779 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1781 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1780 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1782 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1781 done 1783 done
1784 fi
1782 1785
1783 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1786 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1784 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1787 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1785 cp="${2}:${cp}" 1788 cp="${2}:${cp}"
1786 shift 2 1789 shift 2
1796# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1797# @section-end helper 1800# @section-end helper
1798# ------------------------------------------------------------------------------ 1801# ------------------------------------------------------------------------------
1799 1802
1800# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1804# @eclass-src_prepare
1805#
1806# src_prepare Searches for bundled jars
1807# Don't call directly, but via java-pkg-2_src_prepare!
1808# ------------------------------------------------------------------------------
1809
1810java-utils-2_src_prepare() {
1811 [[ ${EBUILD_PHASE} == prepare ]] &&
1812 java-pkg_func-exists java_prepare && java_prepare
1813
1814 # Remember that eant will call this unless called via Portage
1815 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1816 echo "Searching for bundled jars:"
1817 java-pkg_find-normal-jars || echo "None found."
1818 echo "Searching for bundled classes (no output if none found):"
1819 find "${WORKDIR}" -name "*.class"
1820 echo "Search done."
1821 fi
1822 touch "${T}/java-utils-2_src_prepare-run"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @eclass-pkg_preinst
1827#
1828# pkg_preinst Searches for missing and unneeded dependencies
1829# Don't call directly, but via java-pkg-2_pkg_preinst!
1830# ------------------------------------------------------------------------------
1831
1832java-utils-2_pkg_preinst() {
1833 if is-java-strict; then
1834 if has_version dev-java/java-dep-check; then
1835 [[ -e "${JAVA_PKG_ENV}" ]] || return
1836 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1837 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1838 ewarn "Possibly unneeded dependencies found in package.env:"
1839 for dep in ${output}; do
1840 ewarn "\t${dep}"
1841 done
1842 fi
1843 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1844 ewarn "${output}"
1845 fi
1846 else
1847 eerror "Install dev-java/java-dep-check for dependency checking"
1848 fi
1849 fi
1850}
1851
1852# ------------------------------------------------------------------------------
1801# @section-begin build 1853# @section-begin build
1802# @section-summary Build functions 1854# @section-summary Build functions
1803# 1855#
1804# These are some functions for building a package. In particular, it consists of 1856# These are some functions for building a package. In particular, it consists of
1805# wrappers for javac and ant. 1857# wrappers for javac and ant.
1812# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1864# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1813# variables: 1865# variables:
1814# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1866# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1815# gentoo.classpath property. Be sure to call 1867# gentoo.classpath property. Be sure to call
1816# java-ant_rewrite-classpath in src_unpack. 1868# java-ant_rewrite-classpath in src_unpack.
1869# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1870# for build-time purposes, the dependency is not recorded to
1871# package.env!
1817# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1872# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1818# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1819# ------------------------------------------------------------------------------ 1874# ------------------------------------------------------------------------------
1820eant() { 1875eant() {
1821 debug-print-function ${FUNCNAME} $* 1876 debug-print-function ${FUNCNAME} $*
1822 1877
1823 if [[ ${EBUILD_PHASE} = compile ]]; then 1878 if [[ ${EBUILD_PHASE} = compile ]]; then
1824 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1879 java-ant-2_src_configure
1825 # finally get rid of the hooks without breaking stuff 1880 java-utils-2_src_prepare
1826
1827 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1828 && java-ant_ignore-system-classes "${S}/build.xml"
1829
1830 if hasq java-ant-2 ${INHERITED}; then
1831 java-ant_bsfix
1832 fi
1833
1834 # eant can be called multiple times
1835 JAVA_PKG_BSFIX="off"
1836
1837 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1838 echo "Searching for bundled jars:"
1839 java-pkg_find-normal-jars || echo "None found."
1840 echo "Searching for bundled classes (no output if none found):"
1841 find "${WORKDIR}" -name "*.class"
1842 echo "Search done."
1843 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1844 fi
1845 fi 1881 fi
1846 1882
1847 if ! hasq java-ant-2 ${INHERITED}; then 1883 if ! hasq java-ant-2 ${INHERITED}; then
1848 local msg="You should inherit java-ant-2 when using eant" 1884 local msg="You should inherit java-ant-2 when using eant"
1849 java-pkg_announce-qa-violation "${msg}" 1885 java-pkg_announce-qa-violation "${msg}"
1850 fi 1886 fi
1851 1887
1852 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1888 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1853 1889
1854 java-pkg_init-compiler_ 1890 java-pkg_init-compiler_
1855 local compiler="${GENTOO_COMPILER}" 1891 local compiler="${GENTOO_COMPILER}"
1856 1892
1857 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1893 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1868 # java-config -p 1904 # java-config -p
1869 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1905 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1870 if [[ -n ${build_compiler_deps} ]]; then 1906 if [[ -n ${build_compiler_deps} ]]; then
1871 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1907 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1872 fi 1908 fi
1873 fi
1874
1875 if is-java-strict; then
1876 einfo "Disabling system classpath for ant"
1877 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1878 fi 1909 fi
1879 1910
1880 for arg in "${@}"; do 1911 for arg in "${@}"; do
1881 if [[ ${arg} = -lib ]]; then 1912 if [[ ${arg} = -lib ]]; then
1882 if is-java-strict; then 1913 if is-java-strict; then
1891 echo "more info." 1922 echo "more info."
1892 fi 1923 fi
1893 fi 1924 fi
1894 done 1925 done
1895 1926
1896 # we use this in src_* so we run ant from / 1927 # parse WANT_ANT_TASKS for atoms
1897 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then 1928 local want_ant_tasks
1898 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1929 for i in ${WANT_ANT_TASKS}; do
1899 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1930 if [[ ${i} = */*:* ]]; then
1900 1931 i=${i#*/}
1901 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1932 i=${i%:0}
1902 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1933 want_ant_tasks+="${i/:/-} "
1903
1904 if is-java-strict; then
1905 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1906 if [[ -z "${ANT_TASKS}" ]]; then
1907 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1908 fi
1909 else 1934 else
1935 want_ant_tasks+="${i} "
1936 fi
1937 done
1938 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1939 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1940
1941 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1942 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1943
1910 # if ant-tasks is not set by ebuild or forced, activate all of them 1944 # if ant-tasks is not set by ebuild or forced, use none
1911 ANT_TASKS="${ANT_TASKS:-all}" 1945 ANT_TASKS="${ANT_TASKS:-none}"
1912 fi
1913 1946
1914 # at this point, ANT_TASKS should be "all", "none" or explicit list 1947 # at this point, ANT_TASKS should be "all", "none" or explicit list
1915 if [[ "${ANT_TASKS}" == "all" ]]; then 1948 if [[ "${ANT_TASKS}" == "all" ]]; then
1916 einfo "Using all available ANT_TASKS" 1949 einfo "Using all available ANT_TASKS"
1917 elif [[ "${ANT_TASKS}" == "none" ]]; then 1950 elif [[ "${ANT_TASKS}" == "none" ]]; then
1918 einfo "Disabling all optional ANT_TASKS" 1951 einfo "Disabling all optional ANT_TASKS"
1919 else 1952 else
1920 einfo "Using following ANT_TASKS: ${ANT_TASKS}" 1953 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1921 fi 1954 fi
1922 1955
1923 export ANT_TASKS 1956 export ANT_TASKS
1924 fi
1925 1957
1926 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug" 1958 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1927 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1959 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1928 1960
1929 local gcp="${EANT_GENTOO_CLASSPATH}" 1961 local gcp="${EANT_GENTOO_CLASSPATH}"
1930 local getjarsarg="" 1962 local getjarsarg=""
1931 1963
1932 if [[ ${EBUILD_PHASE} = "test" ]]; then 1964 if [[ ${EBUILD_PHASE} = "test" ]]; then
1933 antflags="${antflags} -DJunit.present=true" 1965 antflags="${antflags} -DJunit.present=true"
1934 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1935 getjarsarg="--with-dependencies" 1967 getjarsarg="--with-dependencies"
1936 fi 1968 fi
1937 1969
1938 local cp 1970 local cp
1939 1971
1940 for atom in ${gcp}; do 1972 for atom in ${gcp}; do
1941 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1942 done 1974 done
1943 1975
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
1977
1944 if [[ ${cp} ]]; then 1978 if [[ ${cp} ]]; then
1945 # It seems ant does not like single quotes around ${cp} 1979 # It seems ant does not like single quotes around ${cp}
1980 cp=${cp#:}
1981 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1982 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1946 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1947 fi 1984 fi
1948 1985
1949 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1950 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1951 ant ${antflags} "${@}" || die "eant failed" 1988 ant ${antflags} "${@}" || die "eant failed"
2051# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2088# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2052# call it during each of the phases of the merge process. 2089# call it during each of the phases of the merge process.
2053# 2090#
2054# ----------------------------------------------------------------------------- 2091# -----------------------------------------------------------------------------
2055java-pkg_init() { 2092java-pkg_init() {
2093 debug-print-function ${FUNCNAME} $*
2056 unset JAVAC 2094 unset JAVAC
2057 unset JAVA_HOME 2095 unset JAVA_HOME
2096
2097 java-config --help >/dev/null || {
2098 eerror ""
2099 eerror "Can't run java-config --help"
2100 eerror "Have you upgraded python recently but haven't"
2101 eerror "run python-updater yet?"
2102 die "Can't run java-config --help"
2103 }
2058 2104
2059 # People do all kinds of weird things. 2105 # People do all kinds of weird things.
2060 # http://forums.gentoo.org/viewtopic-p-3943166.html 2106 # http://forums.gentoo.org/viewtopic-p-3943166.html
2061 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2107 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2062 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2108 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2068 ewarn "make.conf for example) to silence this warning or" 2114 ewarn "make.conf for example) to silence this warning or"
2069 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it." 2115 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2070 fi 2116 fi
2071 2117
2072 if [[ -z ${accept} ]]; then 2118 if [[ -z ${accept} ]]; then
2119 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2120 # -version output
2073 unset _JAVA_OPTIONS 2121 unset _JAVA_OPTIONS
2074 # phase hooks make this run many times without this 2122 # phase hooks make this run many times without this
2075 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2123 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2076 fi 2124 fi
2077 2125
2085 2133
2086 # TODO we will probably want to set JAVAC and JAVACFLAGS 2134 # TODO we will probably want to set JAVAC and JAVACFLAGS
2087 2135
2088 # Do some QA checks 2136 # Do some QA checks
2089 java-pkg_check-jikes 2137 java-pkg_check-jikes
2138
2139 # Can't use unset here because Portage does not save the unset
2140 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2090 2141
2091 # When users have crazy classpaths some packages can fail to compile. 2142 # When users have crazy classpaths some packages can fail to compile.
2092 # and everything should work with empty CLASSPATH. 2143 # and everything should work with empty CLASSPATH.
2093 # This also helps prevent unexpected dependencies on random things 2144 # This also helps prevent unexpected dependencies on random things
2094 # from the CLASSPATH. 2145 # from the CLASSPATH.
2095 unset CLASSPATH 2146 export CLASSPATH=
2096 2147
2097 # Unset external ANT_ stuff 2148 # Unset external ANT_ stuff
2098 unset ANT_TASKS 2149 export ANT_TASKS=
2099 unset ANT_OPTS 2150 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME=
2100} 2152}
2101 2153
2102# ------------------------------------------------------------------------------ 2154# ------------------------------------------------------------------------------
2103# @function-internal java-pkg-init-compiler_ 2155# @function-internal java-pkg-init-compiler_
2104# 2156#
2195 done 2247 done
2196 2248
2197 # If it hasn't been defined already, default to javac 2249 # If it hasn't been defined already, default to javac
2198 if [[ -z ${GENTOO_COMPILER} ]]; then 2250 if [[ -z ${GENTOO_COMPILER} ]]; then
2199 if [[ -n ${compilers} ]]; then 2251 if [[ -n ${compilers} ]]; then
2200 einfo "No suitable compiler found: defaulting javac for compilation" 2252 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2201 else 2253 else
2202 # probably don't need to notify users about the default. 2254 # probably don't need to notify users about the default.
2203 :;#einfo "Defaulting to javac for compilation" 2255 :;#einfo "Defaulting to javac for compilation"
2204 fi 2256 fi
2257 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2258 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2259 else
2205 export GENTOO_COMPILER=javac 2260 export GENTOO_COMPILER=javac
2261 fi
2206 else 2262 else
2207 einfo "Using ${GENTOO_COMPILER} for compilation" 2263 einfo "Using ${GENTOO_COMPILER} for compilation"
2208 fi 2264 fi
2209 2265
2210} 2266}
2261 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then 2317 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2262 # Create package.env 2318 # Create package.env
2263 ( 2319 (
2264 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2320 echo "DESCRIPTION=\"${DESCRIPTION}\""
2265 echo "GENERATION=\"2\"" 2321 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\""
2266 2323
2267 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2268 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2269 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2270 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2388# 2445#
2389# @return 0 - function is declared 2446# @return 0 - function is declared
2390# @return 1 - function is undeclared 2447# @return 1 - function is undeclared
2391# ------------------------------------------------------------------------------ 2448# ------------------------------------------------------------------------------
2392java-pkg_func-exists() { 2449java-pkg_func-exists() {
2393 if [[ -n "$(declare -f ${1})" ]]; then 2450 declare -F ${1} > /dev/null
2394 return 0
2395 else
2396 return 1
2397 fi
2398} 2451}
2399 2452
2400# ------------------------------------------------------------------------------ 2453# ------------------------------------------------------------------------------
2401# @internal-function java-pkg_setup-vm 2454# @internal-function java-pkg_setup-vm
2402# 2455#
2578# not. 2631# not.
2579# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2632# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2580# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2581java-pkg_verify-classes() { 2634java-pkg_verify-classes() {
2582 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2635 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2636
2637 local version_verify="/usr/bin/class-version-verify.py"
2638
2639 if [[ ! -x "${version_verify}" ]]; then
2640 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2641 fi
2642
2643 if [[ ! -x "${version_verify}" ]]; then
2644 ewarn "Unable to perform class version checks as"
2645 ewarn "class-version-verify.py is unavailable"
2646 ewarn "Please install dev-java/javatoolkit."
2647 return
2648 fi
2649
2583 local target=$(java-pkg_get-target) 2650 local target=$(java-pkg_get-target)
2584 local result 2651 local result
2585 local log="${T}/class-version-verify.log" 2652 local log="${T}/class-version-verify.log"
2586 if [[ -n "${1}" ]]; then 2653 if [[ -n "${1}" ]]; then
2587 class-version-verify.py -v -t ${target} "${1}" > "${log}" 2654 ${version_verify} -v -t ${target} "${1}" > "${log}"
2588 result=$? 2655 result=$?
2589 else 2656 else
2590 ebegin "Verifying java class versions (target: ${target})" 2657 ebegin "Verifying java class versions (target: ${target})"
2591 class-version-verify.py -v -t ${target} -r "${D}" > "${log}" 2658 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2592 result=$? 2659 result=$?
2593 eend ${result} 2660 eend ${result}
2594 fi 2661 fi
2595 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}" 2662 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2596 if [[ ${result} != 0 ]]; then 2663 if [[ ${result} != 0 ]]; then
2701is-java-strict() { 2768is-java-strict() {
2702 [[ -n ${JAVA_PKG_STRICT} ]] 2769 [[ -n ${JAVA_PKG_STRICT} ]]
2703 return $? 2770 return $?
2704} 2771}
2705 2772
2773
2706# ------------------------------------------------------------------------------ 2774# ------------------------------------------------------------------------------
2707# @eclass-end 2775# @eclass-end
2708# ------------------------------------------------------------------------------ 2776# ------------------------------------------------------------------------------

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.127

  ViewVC Help
Powered by ViewVC 1.1.20