Gentoo Archives: gentoo-dev

From: "Volkmar W. Pogatzki" <gentoo@××××××××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH v2] java-pkg-simple.eclass: allow to compile with sources.lst empty
Date: Thu, 06 Oct 2022 11:22:45
Message-Id: 20221006112232.24868-1-gentoo@pogatzki.net
1 Compilation of ${sources} fails with error if ${sources} is empty.
2 This is the case when a package (or a module in case of a multi-jar
3 package) has only module-info.java to get compiled.
4
5 Signed-off-by: Volkmar W. Pogatzki <gentoo@××××××××.net>
6 ---
7 eclass/java-pkg-simple.eclass | 28 ++++++++++++++++------------
8 1 file changed, 16 insertions(+), 12 deletions(-)
9
10 diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass
11 index abac18ca03f..dddee3a9610 100644
12 --- a/eclass/java-pkg-simple.eclass
13 +++ b/eclass/java-pkg-simple.eclass
14 @@ -377,13 +377,15 @@ java-pkg-simple_src_compile() {
15 java-pkg-simple_getclasspath
16 java-pkg-simple_prepend_resources ${classes} "${JAVA_RESOURCE_DIRS[@]}"
17
18 - if [[ -n ${moduleinfo} ]] || [[ java-pkg_get-target -lt 9 ]]; then
19 - ejavac -d ${classes} -encoding ${JAVA_ENCODING}\
20 - ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS} @${sources}
21 - else
22 - ejavac -d ${classes} -encoding ${JAVA_ENCODING}\
23 - ${classpath:+--module-path ${classpath}} --module-version ${PV}\
24 - ${JAVAC_ARGS} @${sources}
25 + if [[ -s "${sources}" ]]; then
26 + if [[ -n ${moduleinfo} ]] || [[ java-pkg_get-target -lt 9 ]]; then
27 + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\
28 + ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS} @${sources}
29 + else
30 + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\
31 + ${classpath:+--module-path ${classpath}} --module-version ${PV}\
32 + ${JAVAC_ARGS} @${sources}
33 + fi
34 fi
35
36 # handle module-info.java separately as it needs at least JDK 9
37 @@ -407,11 +409,13 @@ java-pkg-simple_src_compile() {
38
39 # javadoc
40 if has doc ${JAVA_PKG_IUSE} && use doc; then
41 - mkdir -p ${apidoc}
42 - ejavadoc -d ${apidoc} \
43 - -encoding ${JAVA_ENCODING} -docencoding UTF-8 -charset UTF-8 \
44 - ${classpath:+-classpath ${classpath}} ${JAVADOC_ARGS:- -quiet} \
45 - @${sources} || die "javadoc failed"
46 + if [[ -s "${sources}" ]]; then
47 + mkdir -p ${apidoc}
48 + ejavadoc -d ${apidoc} \
49 + -encoding ${JAVA_ENCODING} -docencoding UTF-8 -charset UTF-8 \
50 + ${classpath:+-classpath ${classpath}} ${JAVADOC_ARGS:- -quiet} \
51 + @${sources} || die "javadoc failed"
52 + fi
53 fi
54
55 # package
56 --
57 2.35.1