• [gentoo-dev] [PATCH 1/3] java-utils-2.eclass: new JAVADOC_CLASSPATH, JA

    From Volkmar W. Pogatzki@21:1/5 to All on Sun Dec 31 17:30:01 2023
    Several multi-jar packages built with java-pkg-simple.eclass use a
    workaround to avoid passing arguments to ejavadoc. That workaround
    runs another java-pkg-simple_src_compile which builds an unneeded
    jar file usually called "ignoreme.jar".

    This patch defines the JAVADOC_SRC_DIRS eclass variable needed by the java-pkg-simple.eclass to decide whether to call ejavadoc or not.
    The other new eclass variable is JAVADOC_CLASSPATH. It can be used for multi-jar packages to pass dependencies's classpath to ejavadoc.

    Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
    ---
    eclass/java-utils-2.eclass | 40 ++++++++++++++++++++++++++++++++++++++
    1 file changed, 40 insertions(+)

    diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
    index 31b8ab8df60a..814b4957d52c 100644
    --- a/eclass/java-utils-2.eclass
    +++ b/eclass/java-utils-2.eclass
    @@ -218,6 +218,46 @@ JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/com
    # 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 need
  • From Volkmar W. Pogatzki@21:1/5 to All on Sun Dec 31 17:30:01 2023
    This patch helps to avoid useless runs of ejavadoc in multi-jar
    packages where java-pkg-simple_src_compile is called for each jar file. JAVADOC_SRC_DIRS can be set in the ebuild in global scope and
    "use doc && ejavadoc" be called at the end of src_compile. And it no
    longer needs to build a useless "ignoreme.jar".

    Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
    ---
    eclass/java-pkg-simple.eclass | 14 +++++++++-----
    1 file changed, 9 insertions(+), 5 deletions(-)

    diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index 143efa707751..97bad414afb7 100644
    --- a/eclass/java-pkg-simple.eclass
    +++ b/eclass/java-pkg-simple.eclass
    @@ -412,11 +412,15 @@ java-pkg-simple_src_compile() {

    # javadoc
    if has doc ${JAVA_PKG_IUSE} && use doc; then
    - mkdir -p ${apidoc}
    - ejavadoc -d ${apidoc} \
    - -encoding ${JAVA_ENCODING} -docencoding UTF-8 -charset UTF-8 \
    - ${classpath:+-classpath ${classpath}} ${JAVADOC_ARGS:- -quiet} \
    - @${sources} || die "javadoc failed"
    + if [[ ${JAVADOC_SRC_DIRS} ]]; then
    + einfo "JAVADOC_SRC_DIRS exists, you need to call ejavadoc separately"
    + else
    + mkdir -p ${apidoc}
    + ejavadoc -d ${apidoc} \
    + -encoding ${JAVA_ENCODING} -docencoding UTF-8 -charset UTF-8 \
    + ${classpath:+-classpath ${classpath}} ${JAVADOC_ARGS:- -quiet} \
    + @${sources} || die "javadoc failed"
    + fi
    fi
  • From Volkmar W. Pogatzki@21:1/5 to All on Sun Dec 31 17:30:02 2023
    This patch enhances the ejavadoc function so that it can be called
    without arguments if the JAVADOC_SRC_DIRS array is set in the ebuild.

    Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
    ---
    eclass/java-utils-2.eclass | 24 +++++++++++++++++++++---
    1 file changed, 21 insertions(+), 3 deletions(-)

    diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
    index 814b4957d52c..31f7932a16fd 100644
    --- a/eclass/java-utils-2.eclass
    +++ b/eclass/java-utils-2.eclass
    @@ -2192,9 +2192,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=( javado