-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Fabian Groffen <[email protected]>
- Loading branch information
Showing
1 changed file
with
116 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# Copyright 2004-2022 Gentoo Authors | ||
# Copyright 2004-2024 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
# @ECLASS: java-utils-2.eclass | ||
# @MAINTAINER: | ||
# [email protected] | ||
# @AUTHOR: | ||
# Thomas Matthijs <[email protected]>, Karl Trygve Kalleberg <[email protected]> | ||
# @SUPPORTED_EAPIS: 5 6 7 8 | ||
# @SUPPORTED_EAPIS: 6 7 8 | ||
# @BLURB: Base eclass for Java packages | ||
# @DESCRIPTION: | ||
# This eclass provides functionality which is used by java-pkg-2.eclass, | ||
|
@@ -17,17 +17,17 @@ | |
# that have optional Java support. In addition you can inherit java-ant-2 for | ||
# Ant-based packages. | ||
|
||
case ${EAPI:-0} in | ||
[5678]) ;; | ||
case ${EAPI} in | ||
6|7|8) ;; | ||
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; | ||
esac | ||
|
||
if [[ -z ${_JAVA_UTILS_2_ECLASS} ]] ; then | ||
_JAVA_UTILS_2_ECLASS=1 | ||
|
||
# EAPI 7 has version functions built-in. Use eapi7-ver for all earlier eclasses. | ||
# EAPI 7 has version functions built-in. Use eapi7-ver for all earlier EAPIs. | ||
# Keep versionator inheritance in case consumers are using it implicitly. | ||
[[ ${EAPI} == [56] ]] && inherit eapi7-ver eutils multilib versionator | ||
[[ ${EAPI} == 6 ]] && inherit eapi7-ver eqawarn multilib versionator | ||
|
||
# Make sure we use java-config-2 | ||
export WANT_JAVA_CONFIG="2" | ||
|
@@ -37,7 +37,7 @@ has test ${JAVA_PKG_IUSE} && RESTRICT+=" !test? ( test )" | |
# @VARIABLE: JAVA_PKG_E_DEPEND | ||
# @INTERNAL | ||
# @DESCRIPTION: | ||
# This is a convience variable to be used from the other java eclasses. This is | ||
# This is a convenience variable to be used from the other java eclasses. This is | ||
# the version of java-config we want to use. Usually the latest stable version | ||
# so that ebuilds can use new features without depending on specific versions. | ||
JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3" | ||
|
@@ -66,6 +66,21 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} | |
# JAVA_PKG_FORCE_VM=openjdk-11 emerge foo | ||
# @CODE | ||
|
||
# @ECLASS_VARIABLE: JAVA_PKG_NO_CLEAN | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
# An array of expressions to match *.class or *.jar files in order to protect | ||
# them against deletion by java-pkg_clean. | ||
# | ||
# @CODE | ||
# JAVA_PKG_NO_CLEAN=( | ||
# "*/standard.jar" | ||
# "*/launch4j.jar" | ||
# "*/apps/jetty/apache-tomcat*" | ||
# "*/lib/jetty*" | ||
# ) | ||
# @CODE | ||
|
||
# @ECLASS_VARIABLE: JAVA_PKG_WANT_BUILD_VM | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
|
@@ -124,7 +139,7 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} | |
# ) | ||
# @CODE | ||
|
||
# @ECLASS-VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS | ||
# @ECLASS_VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
# Array of extra arguments that should be passed to the test runner when running tests. | ||
|
@@ -203,6 +218,46 @@ JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="${EPREFIX}/etc/java-config-2 | |
# ebuild foo.ebuild compile | ||
# @CODE | ||
|
||
# @ECLASS_VARIABLE: JAVADOC_CLASSPATH | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
# Comma or space separated list of java packages that are needed for generating | ||
# javadocs. Can be used to avoid overloading the compile classpath in multi-jar | ||
# packages if there are jar files which have different dependencies. | ||
# | ||
# @CODE | ||
# Example: | ||
# JAVADOC_CLASSPATH=" | ||
# jna-4 | ||
# jsch | ||
# " | ||
# @CODE | ||
|
||
# @ECLASS_VARIABLE: JAVADOC_SRC_DIRS | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
# An array of directories relative to ${S} which contain the sources of | ||
# the application. It needs to sit in global scope; if put in src_compile() | ||
# it would not work. | ||
# It is needed by the java-pkg-simple.eclass to decide whether to call ejavadoc | ||
# or not. If this variable is defined then java-pkg-simple_src_compile will not | ||
# call ejavadoc automatically. ejavadoc has then to be called explicitly from | ||
# the ebuild. It is meant for usage in multi-jar packages in order to avoid an | ||
# extra compilation run only for producing the javadocs. | ||
# | ||
# @CODE | ||
# Example: | ||
# JAVADOC_SRC_DIRS=( | ||
# "${PN}-core" | ||
# "${PN}-jsch" | ||
# "${PN}-pageant" | ||
# "${PN}-sshagent" | ||
# "${PN}-usocket-jna" | ||
# "${PN}-usocket-nc" | ||
# "${PN}-connector-factory" | ||
# ) | ||
# @CODE | ||
|
||
# TODO document me | ||
JAVA_PKG_QA_VIOLATIONS=0 | ||
|
||
|
@@ -316,7 +371,6 @@ java-pkg_rm_files() { | |
[[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting." | ||
einfo "Removing unneeded file ${filename}" | ||
rm -f "${S}/${filename}" || die "cannot remove ${filename}" | ||
eend $? | ||
done | ||
} | ||
|
||
|
@@ -769,7 +823,7 @@ java-pkg_dosrc() { | |
# @FUNCTION: java-pkg_dolauncher | ||
# @USAGE: <filename> [options] | ||
# @DESCRIPTION: | ||
# Make a wrapper script to lauch/start this package | ||
# Make a wrapper script to launch/start this package | ||
# If necessary, the wrapper will switch to the appropriate VM. | ||
# | ||
# Can be called without parameters if the package installs only one jar | ||
|
@@ -939,7 +993,7 @@ java-pkg_recordjavadoc() | |
# Example: get a specific jar from xerces slot 2 | ||
# java-pkg_jar-from xerces-2 xml-apis.jar | ||
# | ||
# Example: get a specific jar from xerces slot 2, and name it diffrently | ||
# Example: get a specific jar from xerces slot 2, and name it differently | ||
# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar | ||
# | ||
# Example: get junit.jar which is needed only for building | ||
|
@@ -1350,7 +1404,7 @@ java-pkg_register-optional-dependency() { | |
# @DESCRIPTION: | ||
# Register an arbitrary environment variable into package.env. The gjl launcher | ||
# for this package or any package depending on this will export it into | ||
# environement before executing java command. | ||
# environment before executing java command. | ||
# Must only be called in src_install phase. | ||
JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env" | ||
JAVA_PKG_EXTRA_ENV_VARS="" | ||
|
@@ -1696,16 +1750,6 @@ java-pkg_get-jni-cflags() { | |
echo ${flags} | ||
} | ||
|
||
java-pkg_ensure-gcj() { | ||
# was enforcing sys-devel/gcc[gcj] | ||
die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562" | ||
} | ||
|
||
java-pkg_ensure-test() { | ||
# was enforcing USE=test if FEATURES=test | ||
die "${FUNCNAME} was removed. Package mangers handle this already. #278965" | ||
} | ||
|
||
# @FUNCTION: java-pkg_register-ant-task | ||
# @USAGE: [--version x.y] [<name>] | ||
# @DESCRIPTION: | ||
|
@@ -1879,13 +1923,17 @@ ejunit4() { | |
# @CODE | ||
# $1 - -cp or -classpath | ||
# $2 - the classpath passed to it | ||
# $@ - test classes for testng to run. | ||
# $@ - test classes or testng.xml for testng to run. | ||
# @CODE | ||
etestng() { | ||
debug-print-function ${FUNCNAME} $* | ||
|
||
local runner=org.testng.TestNG | ||
local cp=$(java-pkg_getjars --with-dependencies testng) | ||
if [[ ${PN} != testng ]]; then | ||
local cp=$(java-pkg_getjars --with-dependencies testng) | ||
else | ||
local cp=testng.jar | ||
fi | ||
local tests | ||
|
||
if [[ ${1} = -cp || ${1} = -classpath ]]; then | ||
|
@@ -1903,14 +1951,24 @@ etestng() { | |
-cp ${cp} | ||
-Djava.io.tmpdir="${T}" | ||
-Djava.awt.headless=true | ||
-Dtest.resources.dir="${JAVA_TEST_RESOURCE_DIRS}" | ||
${JAVA_TEST_EXTRA_ARGS[@]} | ||
${runner} | ||
${JAVA_TEST_RUNNER_EXTRA_ARGS[@]} | ||
) | ||
|
||
[[ ! "${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}" =~ "-usedefaultlisteners" ]] && args+=( -usedefaultlisteners false ) | ||
if [[ ! "${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}" =~ "-usedefaultlisteners" ]]; then | ||
args+=( | ||
-verbose 3 | ||
-usedefaultlisteners true | ||
) | ||
fi | ||
|
||
args+=( -testclass ${tests} ) | ||
if [[ "${test%.xml}" == "${test}" ]]; then | ||
args+=( -testclass ${tests} ) | ||
else | ||
args+=( ${tests%,} ) | ||
fi | ||
|
||
debug-print "java ${args[@]}" | ||
java ${args[@]} || die "Running TestNG failed." | ||
|
@@ -1921,13 +1979,9 @@ etestng() { | |
# src_prepare Searches for bundled jars | ||
# Don't call directly, but via java-pkg-2_src_prepare! | ||
java-utils-2_src_prepare() { | ||
case ${EAPI:-0} in | ||
5) | ||
java-pkg_func-exists java_prepare && java_prepare ;; | ||
*) | ||
java-pkg_func-exists java_prepare && | ||
eqawarn "java_prepare is no longer called, define src_prepare instead." | ||
eapply_user ;; | ||
case ${EAPI} in | ||
[678]) eapply_user ;; | ||
*) default_src_prepare ;; | ||
esac | ||
|
||
# Check for files in JAVA_RM_FILES array. | ||
|
@@ -2148,9 +2202,27 @@ ejavadoc() { | |
einfo "javadoc ${javadoc_args} ${@}" | ||
fi | ||
|
||
local args=( javadoc ${javadoc_args} "${@}" ) | ||
echo "${args[@]}" >&2 | ||
"${args[@]}" || die "ejavadoc failed" | ||
if [[ "${JAVADOC_SRC_DIRS[@]}" ]]; then | ||
mkdir -p target/api || die "cannot create target/api" | ||
local dependency | ||
for dependency in ${JAVADOC_CLASSPATH}; do | ||
classpath="${classpath}:$(java-pkg_getjars \ | ||
--build-only \ | ||
--with-dependencies \ | ||
${dependency})" | ||
done | ||
find "${JAVADOC_SRC_DIRS[@]}" -name '*.java' > sources | ||
javadoc \ | ||
"${javadoc_args}" \ | ||
-d target/api \ | ||
-cp "${classpath}" \ | ||
-quiet \ | ||
@sources || die "ejavadoc failed" | ||
else | ||
local args=( javadoc ${javadoc_args} "${@}" ) | ||
echo "${args[@]}" >&2 | ||
"${args[@]}" || die "ejavadoc failed" | ||
fi | ||
} | ||
|
||
# @FUNCTION: java-pkg_filter-compiler | ||
|
@@ -2378,7 +2450,7 @@ java-pkg_init-compiler_() { | |
|
||
} | ||
|
||
# @FUNCTION: init_paths_ | ||
# @FUNCTION: java-pkg_init_paths_ | ||
# @INTERNAL | ||
# @DESCRIPTION: | ||
# Initializes some variables that will be used. These variables are mostly used | ||
|
@@ -2628,7 +2700,7 @@ java-pkg_get-vm-version() { | |
# @RETURN: VM handle of an available JDK | ||
# @DESCRIPTION: | ||
# Selects a build vm from a list of vm handles. First checks for the system-vm | ||
# beeing usable, then steps through the listed handles till a suitable vm is | ||
# being usable, then steps through the listed handles till a suitable vm is | ||
# found. | ||
# | ||
java-pkg_build-vm-from-handle() { | ||
|
@@ -2931,11 +3003,13 @@ is-java-strict() { | |
# @FUNCTION: java-pkg_clean | ||
# @DESCRIPTION: | ||
# Java package cleaner function. This will remove all *.class and *.jar | ||
# files, removing any bundled dependencies. | ||
# files, except those specified by expressions in JAVA_PKG_NO_CLEAN. | ||
java-pkg_clean() { | ||
if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then | ||
find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die | ||
fi | ||
NO_DELETE=() | ||
for keep in ${JAVA_PKG_NO_CLEAN[@]}; do | ||
NO_DELETE+=( '!' '-path' ${keep} ) | ||
done | ||
find "${@}" '(' -name '*.class' -o -name '*.jar' ${NO_DELETE[@]} ')' -type f -delete -print || die | ||
} | ||
|
||
# @FUNCTION: java-pkg_gen-cp | ||
|