Skip to content

Commit

Permalink
eclass/java-utils-2: sync with gx86
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Groffen <[email protected]>
  • Loading branch information
grobian committed Aug 10, 2024
1 parent b19b1c1 commit ad71d59
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions eclass/java-utils-2.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,15 @@ java-pkg_doexamples() {
# arguments are passed through to find.
#
# @CODE
# Parameters:
# $1 - jar file
# $2 - resource tree directory
# $* - arguments to pass to find
#
# Example:
# java-pkg_addres ${PN}.jar resources ! -name "*.html"
# @CODE
#
# @param $1 - jar file
# @param $2 - resource tree directory
# @param $* - arguments to pass to find
java-pkg_addres() {
debug-print-function ${FUNCNAME} $*

Expand Down Expand Up @@ -1134,7 +1137,7 @@ java-pkg_jarfrom() {
}

# @FUNCTION: java-pkg_getjars
# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
# @USAGE: [--build-only] [--runtime-only] [--with-dependencies] <package1>[,<package2>...]
# @DESCRIPTION:
# Get the classpath provided by any number of packages
# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
Expand All @@ -1154,6 +1157,7 @@ java-pkg_jarfrom() {
# Parameters:
# --build-only - makes the jar(s) not added into package.env DEPEND line.
# (assumed automatically when called inside src_test)
# --runtime-only - marks the jar(s) not added into package.env RDEPEND line.
# --with-dependencies - get jars also from requested package's dependencies
# transitively.
# $1 - list of packages to get jars from
Expand All @@ -1162,6 +1166,7 @@ java-pkg_jarfrom() {
java-pkg_getjars() {
debug-print-function ${FUNCNAME} $*

local dep_constraint
local build_only=""
local deep=""

Expand All @@ -1170,6 +1175,9 @@ java-pkg_getjars() {
while [[ "${1}" == --* ]]; do
if [[ "${1}" = "--build-only" ]]; then
build_only="build"
dep_constraint="build"
elif [[ "${1}" = "--runtime-only" ]]; then
dep_constraint="runtime"
elif [[ "${1}" = "--with-dependencies" ]]; then
deep="--with-dependencies"
else
Expand All @@ -1188,7 +1196,7 @@ java-pkg_getjars() {
debug-print "${pkgs}:${jars}"

for pkg in ${pkgs//,/ }; do
java-pkg_ensure-dep "${build_only}" "${pkg}"
java-pkg_ensure-dep "${dep_constraint}" "${pkg}"
done

for pkg in ${pkgs//,/ }; do
Expand Down Expand Up @@ -1637,10 +1645,6 @@ java-pkg_set-current-vm() {
export GENTOO_VM=${1}
}

java-pkg_get-current-vm() {
echo ${GENTOO_VM}
}

java-pkg_current-vm-matches() {
has $(java-pkg_get-current-vm) ${@}
return $?
Expand Down Expand Up @@ -1816,7 +1820,6 @@ java-pkg_ant-tasks-depend() {
fi
}


# @FUNCTION: ejunit_
# @INTERNAL
# @DESCRIPTION:
Expand All @@ -1842,7 +1845,7 @@ ejunit_() {
local junit=${1}
shift 1

local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
local cp=$(java-pkg_getjars --build-only --with-dependencies ${junit}${pkgs})
if [[ ${1} = -cp || ${1} = -classpath ]]; then
cp="${2}:${cp}"
shift 2
Expand Down Expand Up @@ -1930,7 +1933,7 @@ etestng() {

local runner=org.testng.TestNG
if [[ ${PN} != testng ]]; then
local cp=$(java-pkg_getjars --with-dependencies testng)
local cp=$(java-pkg_getjars --build-only --with-dependencies testng)
else
local cp=testng.jar
fi
Expand Down Expand Up @@ -2037,13 +2040,23 @@ java-utils-2_pkg_preinst() {
eant() {
debug-print-function ${FUNCNAME} $*

if [[ ${EBUILD_PHASE} = compile ]]; then
java-ant-2_src_configure
fi
if [[ ${!JAVA_PKG_BSFIX*} ]] \
|| [[ ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \
|| [[ ${JAVA_ANT_CLASSPATH_TAGS} ]] \
|| [[ ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]] \
|| [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] \
|| [[ ${EANT_BUILD_XML} ]] \
|| [[ ${!EANT_GENTOO_CLASSPATH*} ]] \
|| [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]
then
if [[ ${EBUILD_PHASE} = compile ]]; then
java-ant-2_src_configure
fi

if ! has java-ant-2 ${INHERITED}; then
local msg="You should inherit java-ant-2 when using eant"
java-pkg_announce-qa-violation "${msg}"
if ! has java-ant-2 ${INHERITED}; then
local msg="You should inherit java-ant-2 when using eant"
java-pkg_announce-qa-violation "${msg}"
fi
fi

local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
Expand Down Expand Up @@ -2502,6 +2515,9 @@ java-pkg_do_write_() {
echo "SLOT=\"${SLOT}\""
echo "CATEGORY=\"${CATEGORY}\""
echo "PVR=\"${PVR}\""
# Record LIBDIR so that gjl can set java.library.path
# accordingly. Bug #917326.
echo "LIBDIR=\"$(get_libdir)\""

[[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
[[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
Expand Down Expand Up @@ -2716,7 +2732,13 @@ java-pkg_build-vm-from-handle() {
fi

for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
if java-config-2 --select-vm=${vm} 2>/dev/null; then
local java_config
for java_config in java-config{,-2}; do
type -p ${java_config} >/dev/null && break
done
[[ -z ${java_config} ]] && die "No java-config binary in PATH"

if ${java_config} --select-vm=${vm} 2>/dev/null; then
echo ${vm}
return 0
fi
Expand Down Expand Up @@ -2819,7 +2841,7 @@ java-pkg_die() {
echo "!!! When you file a bug report, please include the following information:" >&2
echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
echo "and of course, the output of emerge --info =${P}" >&2
echo "and of course, the output of emerge --info =${CATEGORY}/${PF}" >&2
}


Expand Down Expand Up @@ -2937,7 +2959,7 @@ java-pkg_ensure-dep() {
# if is-java-strict; then
# die "${dev_error}"
# else
eqawarn "java-pkg_ensure-dep: ${dev_error}"
eqawarn "QA Notice: java-pkg_ensure-dep: ${dev_error}"
# eerror "Because you have ${target_pkg} installed,"
# eerror "the package will build without problems, but please"
# eerror "report this to https://bugs.gentoo.org."
Expand All @@ -2948,7 +2970,7 @@ java-pkg_ensure-dep() {
# if is-java-strict; then
# die "${dev_error}"
# else
eqawarn "java-pkg_ensure-dep: ${dev_error}"
eqawarn "QA Notice: java-pkg_ensure-dep: ${dev_error}"
# eerror "The package will build without problems, but may fail to run"
# eerror "if you don't have ${target_pkg} installed,"
# eerror "so please report this to https://bugs.gentoo.org."
Expand Down

0 comments on commit ad71d59

Please sign in to comment.