From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C9C9C15838C for ; Sun, 21 Jan 2024 13:47:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0A584E29D2; Sun, 21 Jan 2024 13:47:08 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D30A5E29D2 for ; Sun, 21 Jan 2024 13:47:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B31E23431EC for ; Sun, 21 Jan 2024 13:47:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2D7F813AA for ; Sun, 21 Jan 2024 13:47:05 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1705844812.42766d37044e2479bee6c9e885238bc9703eddd6.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: eclass/java-utils-2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 42766d37044e2479bee6c9e885238bc9703eddd6 X-VCS-Branch: master Date: Sun, 21 Jan 2024 13:47:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 43e9b9ab-5cb4-4740-b57b-c19ffe6c9a95 X-Archives-Hash: b14a478bf0c2ef65ec7fb1fc99c47b84 commit: 42766d37044e2479bee6c9e885238bc9703eddd6 Author: Fabian Groffen gentoo org> AuthorDate: Sun Jan 21 13:46:52 2024 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Jan 21 13:46:52 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=42766d37 eclass/java-utils-2: sync with gx86 Signed-off-by: Fabian Groffen gentoo.org> eclass/java-utils-2.eclass | 158 +++++++++++++++++++++++++++++++++------------ 1 file changed, 116 insertions(+), 42 deletions(-) diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index fa46b72b3d..a84f7c3002 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -1,4 +1,4 @@ -# 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 @@ -6,7 +6,7 @@ # java@gentoo.org # @AUTHOR: # Thomas Matthijs , Karl Trygve Kalleberg -# @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: [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] [] # @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