public inbox for gentoo-java@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-java] new proposed enhancement to java-pkg_jarfrom()
@ 2007-01-25 10:31 Vlastimil Babka
  2007-01-25 11:19 ` Petteri Räty
  2007-01-29 18:39 ` Petteri Räty
  0 siblings, 2 replies; 4+ messages in thread
From: Vlastimil Babka @ 2007-01-25 10:31 UTC (permalink / raw
  To: gentoo-java

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Attached a patch, will commit if no-one objects.

Originally I just wanted to fix a bug that in src_test() it would shift
parameters (i.e. name of package) if the first parameter wasn't
- --build-only. Encountered this while improving commons-cli ebuild. Then
I decided to improve a bit more:

Fixes a theoretical situation where --build-only and --with-dependencies
would be both specified, but in the wrong order. Now there's a general
loop for resolving --* parameters.
Adds a new parameter: '--into $dir' which will symlink the jars into the
$dir instead of '.'
Consider this difference (again, commons-cli):

before the change:
src_test() {
	cd lib
	java-pkg_jar-from junit
	cd ..
        eant test
}


after the change:
src_test() {
	java-pkg_jar-from --into lib junit
        eant test
}

The directory must exist, but maybe it could be improved even more to
mkdir it if it doesn't?

BTW, I think deferring the test-specific jar-from/getjars calls until
src_test() is good idea, because you don't need to prefix them with "use
test &&", specify "--build-only" and you don't need to test package
twice (without and with test) to ensure those deps are really needed
only for testing.
- --
Vlastimil Babka (Caster)
Gentoo/Java
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFuIcPtbrAj05h3oQRAlFAAKCcqFsMsQzy77Do8pQfzoi9Kbws0QCeIEKV
wwMC9H8jBvysTsObWpGg8V0=
=WMKt
-----END PGP SIGNATURE-----

[-- Attachment #2: java-utils-2.eclass.patch --]
[-- Type: text/x-patch, Size: 2295 bytes --]

Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.48
diff -u -B -r1.48 java-utils-2.eclass
--- java-utils-2.eclass	21 Jan 2007 21:12:52 -0000	1.48
+++ java-utils-2.eclass	25 Jan 2007 10:22:19 -0000
@@ -759,8 +759,12 @@
 # Example: get junit.jar which is needed only for building
 #	java-pkg_jar-from --build-only junit junit.jar
 #
-# @param $1 - (optional) "--build-only" makes the jar(s) not added into
-#	package.env DEPEND line.
+# @param $opt 
+#	--build-only - makes the jar(s) not added into package.env DEPEND line.
+#	  (assumed automatically when called inside src_test)
+#	--with-dependencies - get jars also from requested package's dependencies
+#	  transitively.
+#	--into $dir - symlink jar(s) into $dir (must exist) instead of .
 # @param $1 - Package to get jars from.
 # @param $2 - jar from package. If not specified, all jars will be used.
 # @param $3 - When a single jar is specified, destination filename of the
@@ -771,16 +775,24 @@
 	debug-print-function ${FUNCNAME} $*
 
 	local build_only=""
+	local destdir="."
+	local deep=""
+	
+	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
 
-	if [[ "${1}" = "--build-only" || "${EBUILD_PHASE}" == "test" ]]; then
-		build_only="true"
-		shift
-	fi
-
-	if [[ "${1}" = "--with-dependencies" ]]; then
-		local deep="--with-dependencies"
+	while [[ "${1}" == --* ]]; do
+		if [[ "${1}" = "--build-only" ]]; then
+			build_only="true"
+		elif [[ "${1}" = "--with-dependencies" ]]; then
+			deep="--with-dependencies"
+		elif [[ "${1}" = "--into" ]]; then
+			destdir="${2}"
+			shift
+		else
+			die "java-pkg_jar-from called with unknown parameter: ${1}"
+		fi
 		shift
-	fi
+	done
 
 	local target_pkg="${1}" target_jar="${2}" destjar="${3}"
 
@@ -794,6 +806,8 @@
 	classpath="$(java-config ${deep} --classpath=${target_pkg})"
 	[[ $? != 0 ]] && die ${error_msg}
 
+	pushd ${destdir} > /dev/null \
+		|| die "failed to change directory to ${destdir}"
 	local jar
 	for jar in ${classpath//:/ }; do
 		local jar_name=$(basename "${jar}")
@@ -816,6 +830,7 @@
 			return 0
 		fi
 	done
+	popd > /dev/null
 	# if no target was specified, we're ok
 	if [[ -z "${target_jar}" ]] ; then
 		return 0

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

end of thread, other threads:[~2007-01-29 18:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-25 10:31 [gentoo-java] new proposed enhancement to java-pkg_jarfrom() Vlastimil Babka
2007-01-25 11:19 ` Petteri Räty
2007-01-25 11:53   ` Vlastimil Babka
2007-01-29 18:39 ` 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