public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH v2] java-pkg-simple.eclass: improve MANIFEST.MF manipulation
@ 2022-10-05 10:34 Volkmar W. Pogatzki
  0 siblings, 0 replies; 2+ messages in thread
From: Volkmar W. Pogatzki @ 2022-10-05 10:34 UTC (permalink / raw
  To: gentoo-dev

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.

Closes: https://bugs.gentoo.org/874924
Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
---
 eclass/java-pkg-simple.eclass | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass
index 7a9582393dd..9b50b5dc075 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 [[ -e ${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
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-dev] [PATCH v2] java-pkg-simple.eclass: improve MANIFEST.MF manipulation
@ 2022-10-06  7:59 Volkmar W. Pogatzki
  0 siblings, 0 replies; 2+ messages in thread
From: Volkmar W. Pogatzki @ 2022-10-06  7:59 UTC (permalink / raw
  To: gentoo-dev

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>
---
 eclass/java-pkg-simple.eclass | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass
index 7a9582393dd..abac18ca03f 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
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-06  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-06  7:59 [gentoo-dev] [PATCH v2] java-pkg-simple.eclass: improve MANIFEST.MF manipulation Volkmar W. Pogatzki
  -- strict thread matches above, loose matches on Subject: below --
2022-10-05 10:34 Volkmar W. Pogatzki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox