public inbox for gentoo-java@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-java] Making the --jar argument to dolauncher optional
@ 2006-10-21  9:02 Petteri Räty
  2006-10-21  9:06 ` Petteri Räty
  0 siblings, 1 reply; 3+ messages in thread
From: Petteri Räty @ 2006-10-21  9:02 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 219 bytes --]

When a package only install one jar that has the Main-class attribute
set there should not be any need to specify the --jar argument to
java-pkg_dolauncher so I made the --jar argument optional.

Regards,
Petteri

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: java-utils-2.eclass.patch --]
[-- Type: text/x-patch; name="java-utils-2.eclass.patch", Size: 793 bytes --]

Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.24
diff -u -r1.24 java-utils-2.eclass
--- java-utils-2.eclass	27 Sep 2006 21:35:54 -0000	1.24
+++ java-utils-2.eclass	21 Oct 2006 08:59:59 -0000
@@ -563,8 +563,10 @@
 	echo "#!/bin/bash" > "${target}"
 	[[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
 	echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
-	cat "${var_tmp}" >> "${target}"
-	rm -f "${var_tmp}"
+	if [[ -f "${var_tmp}" ]]; then
+		cat "${var_tmp}" >> "${target}"
+		rm -f "${var_tmp}"
+	fi
 	echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
 
 	if [[ -n "${target_dir}" ]]; then

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: launcher.bash.patch --]
[-- Type: text/x-patch; name="launcher.bash.patch", Size: 596 bytes --]

Index: launcher.bash
===================================================================
--- launcher.bash	(revision 3104)
+++ launcher.bash	(working copy)
@@ -25,7 +25,13 @@
 elif [[ -n ${gjl_jar} ]]; then
 	request="${request} --get-jar ${gjl_jar}"
 else
-	abort "Need main or jar to start"
+	# Check if the installed package has only one jar and use that
+	jars=$(java-config --classpath=${gjl_package})
+	if [[ "${jars/:}" = "${jars}" ]]; then
+		request="${request} --get-jar ${jars}"
+	else
+		abort "Need main or jar to start"
+	fi
 fi
 
 if [[ -z ${GENTOO_VM} ]]; then

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

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

* Re: [gentoo-java] Making the --jar argument to dolauncher optional
  2006-10-21  9:02 [gentoo-java] Making the --jar argument to dolauncher optional Petteri Räty
@ 2006-10-21  9:06 ` Petteri Räty
  2006-10-21 10:14   ` Petteri Räty
  0 siblings, 1 reply; 3+ messages in thread
From: Petteri Räty @ 2006-10-21  9:06 UTC (permalink / raw
  To: gentoo-java

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Petteri Räty kirjoitti:
> When a package only install one jar that has the Main-class attribute
> set there should not be any need to specify the --jar argument to
> java-pkg_dolauncher so I made the --jar argument optional.
> 
> Regards,
> Petteri
> 
> 

Just to note that you can't use this yet, as nothing as has been
committed yet and will need to depend on the new java-config version in
your ebuild any way. Let's see if I can move all the magic to the eclass
so we would not need to depend on java-config directly.

Regards,
Petteri


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

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

* Re: [gentoo-java] Making the --jar argument to dolauncher optional
  2006-10-21  9:06 ` Petteri Räty
@ 2006-10-21 10:14   ` Petteri Räty
  0 siblings, 0 replies; 3+ messages in thread
From: Petteri Räty @ 2006-10-21 10:14 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 753 bytes --]

Petteri Räty kirjoitti:
> Petteri Räty kirjoitti:
>> When a package only install one jar that has the Main-class attribute
>> set there should not be any need to specify the --jar argument to
>> java-pkg_dolauncher so I made the --jar argument optional.
>>
>> Regards,
>> Petteri
>>
>>
> 
> Just to note that you can't use this yet, as nothing as has been
> committed yet and will need to depend on the new java-config version in
> your ebuild any way. Let's see if I can move all the magic to the eclass
> so we would not need to depend on java-config directly.
> 
> Regards,
> Petteri
> 

Attached is a version that only needs modifications to the eclass. Will
commit this if no-one objects today evening.

Regards,
Petteri

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: java-utils-2.eclass.patch --]
[-- Type: text/x-patch; name="java-utils-2.eclass.patch", Size: 1460 bytes --]

Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.24
diff -u -r1.24 java-utils-2.eclass
--- java-utils-2.eclass	27 Sep 2006 21:35:54 -0000	1.24
+++ java-utils-2.eclass	21 Oct 2006 10:12:55 -0000
@@ -550,7 +550,9 @@
 	while [[ -n "${1}" && -n "${2}" ]]; do
 		local var=${1} value=${2}
 		if [[ "${var:0:2}" == "--" ]]; then
-			echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}"
+			local var=${var:2}
+			echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
+			local gjl_${var}=${value}
 		elif [[ "${var}" == "-into" ]]; then
 			target_dir="${value}"
 		elif [[ "${var}" == "-pre" ]]; then
@@ -559,6 +561,20 @@
 		shift 2
 	done
 
+	# Test if no --jar and --main arguments were given and
+	# in that case check if the package only installs one jar
+	# and use that jar.
+	if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
+		local cp="${JAVA_PKG_CLASSPATH}"
+		if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
+			echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
+		else
+			local msg="Not enough information to create a launcher given."
+			msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
+			die "${msg}"
+		fi
+	fi
+
 	# Write the actual script
 	echo "#!/bin/bash" > "${target}"
 	[[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

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

end of thread, other threads:[~2006-10-21 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-21  9:02 [gentoo-java] Making the --jar argument to dolauncher optional Petteri Räty
2006-10-21  9:06 ` Petteri Räty
2006-10-21 10:14   ` Petteri Räty

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