summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorVolkmar W. Pogatzki <gentoo@pogatzki.net>2022-10-04 20:23:03 +0200
committerMiroslav Šulc <fordfrog@gentoo.org>2022-10-11 15:14:18 +0200
commit47c02b58de852189e468cbd0baffb3f5447b212e (patch)
tree54bc819b3a8a3920a3524a45006ce3db79db0879 /eclass
parentapp-text/pdftk: drop 3.3.2 (diff)
downloadgentoo-47c02b58de852189e468cbd0baffb3f5447b212e.tar.gz
gentoo-47c02b58de852189e468cbd0baffb3f5447b212e.tar.bz2
gentoo-47c02b58de852189e468cbd0baffb3f5447b212e.zip
java-pkg-simple.eclass: improve MANIFEST.MF manipulation
For adding Main-class and/or Automatic-module-name to MANIFEST.MF it seems better to use "jar" functionality at the end of compilation. This does the necessary checks and issues warnings in case of duplicate entries. Erroneously used existence checks ( -v ) were causing wrong entries in MANIFEST.MF files in case of JAVA_MAIN_CLASS="" which is often used in multi-jar ebuilds. Closes: https://bugs.gentoo.org/874924 Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net> Closes: https://github.com/gentoo/gentoo/pull/27621 Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/java-pkg-simple.eclass22
1 files changed, 13 insertions, 9 deletions
diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass
index 7a9582393dd4..abac18ca03f8 100644
--- a/eclass/java-pkg-simple.eclass
+++ b/eclass/java-pkg-simple.eclass
@@ -415,15 +415,6 @@ java-pkg-simple_src_compile() {
fi
# package
- [[ ! -d ${classes}/META-INF ]] && mkdir ${classes}/META-INF
- if [[ -v JAVA_AUTOMATIC_MODULE_NAME ]]; then
- echo "Automatic-Module-Name: ${JAVA_AUTOMATIC_MODULE_NAME}" \
- >> ${classes}/META-INF/MANIFEST.MF || die "adding module name failed"
- fi
- if [[ -v JAVA_MAIN_CLASS ]]; then
- echo "Main-Class: ${JAVA_MAIN_CLASS}" \
- >> ${classes}/META-INF/MANIFEST.MF || die "adding main class failed"
- fi
local jar_args
if [[ -e ${classes}/META-INF/MANIFEST.MF ]]; then
jar_args="cfm ${JAVA_JAR_FILENAME} ${classes}/META-INF/MANIFEST.MF"
@@ -431,6 +422,19 @@ java-pkg-simple_src_compile() {
jar_args="cf ${JAVA_JAR_FILENAME}"
fi
jar ${jar_args} -C ${classes} . || die "jar failed"
+ if [[ -n "${JAVA_AUTOMATIC_MODULE_NAME}" ]]; then
+ echo "Automatic-Module-Name: ${JAVA_AUTOMATIC_MODULE_NAME}" \
+ >> "${T}/add-to-MANIFEST.MF" || die "adding module name failed"
+ fi
+ if [[ -n "${JAVA_MAIN_CLASS}" ]]; then
+ echo "Main-Class: ${JAVA_MAIN_CLASS}" \
+ >> "${T}/add-to-MANIFEST.MF" || die "adding main class failed"
+ fi
+ if [[ -f "${T}/add-to-MANIFEST.MF" ]]; then
+ jar ufmv ${JAVA_JAR_FILENAME} "${T}/add-to-MANIFEST.MF" \
+ || die "updating MANIFEST.MF failed"
+ rm -f "${T}/add-to-MANIFEST.MF" || die "cannot remove"
+ fi
}
# @FUNCTION: java-pkg-simple_src_install