Changes to java-util-2.eclass to support virtuals

Alistair Bush <[email protected]>
Newsgroups gmane.linux.gentoo.java
Message-ID <[email protected]>
Ok, so what is going on in this patch,  simply :) both

java-pkg_jar-from
java-pkg_getjar

get a new option

--virtual

when passed to these functions they will record the package as a whole
(ie not the individual jars).  The rational for this is that virtuals
may provide/package functionality within multiple jars, we should
therefore never depend on an individual jar from a virtual.


A few more paths in java-pkg_init_paths

A function java-pkg_do_virtuals_write() that is called _ONLY_ by the
java-virtuals-2.eclass.  It installs the virtuals "environment" file.


Is everyone happy with the --virtual option, This could be conceivably
used for 'normal' packages so maybe there is a better
verb/noun/adjective/adverb/etc/etc/etc


Alistair
java-utils-2.eclass.virtual-support (text/plain, 5 KB)
--- cvs/gentoo-x86/eclass/java-utils-2.eclass	2007-09-28 18:26:27.000000000 +1200
+++ overlays/java-virtuals/eclass/java-utils-2.eclass	2007-10-02 12:56:28.000000000 +1300
@@ -840,6 +840,8 @@
 #	  (assumed automatically when called inside src_test)
 #	--with-dependencies - get jars also from requested package's dependencies
 #	  transitively.
+#	--virtual - Packages passed to this function are to be handled as virtuals
+#	  and will not have individual jar dependencies recorded.
 #	--into $dir - symlink jar(s) into $dir (must exist) instead of .
 # @param $1 - Package to get jars from, or comma-separated list of packages in
 #	case other parameters are not used.
@@ -854,6 +856,7 @@
 	local build_only=""
 	local destdir="."
 	local deep=""
+	local virtual=""
 
 	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
 
@@ -862,6 +865,8 @@
 			build_only="build"
 		elif [[ "${1}" = "--with-dependencies" ]]; then
 			deep="--with-dependencies"
+		elif [[ "${1}" = "--virtual" ]]; then
+			virtual="true"
 		elif [[ "${1}" = "--into" ]]; then
 			destdir="${2}"
 			shift
@@ -897,6 +902,14 @@
 		java-pkg_ensure-dep "${build_only}" "${target_pkg}"
 	fi
 
+	# Record the entire virtual as a dependency so that
+	# no jars are missed.
+	if [[ -z "${build_only}" && -n "${virtual}" ]]; then
+		java-pkg_record-jar_ "${target_pkg}"
+		# setting this disables further record-jars_ calls later
+		build_only="build"
+	fi
+
 	pushd ${destdir} > /dev/null \
 		|| die "failed to change directory to ${destdir}"
 
@@ -1028,6 +1041,8 @@
 #
 # @param $opt
 #	--build-only - makes the jar not added into package.env DEPEND line.
+#	--virtual - Packages passed to this function are to be handled as virtuals
+#	  and will not have individual jar dependencies recorded.
 # @param $1 - package to use
 # @param $2 - jar to get
 # ------------------------------------------------------------------------------
@@ -1035,12 +1050,15 @@
 	debug-print-function ${FUNCNAME} $*
 
 	local build_only=""
+	local virtual=""
 
 	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
 
 	while [[ "${1}" == --* ]]; do
 		if [[ "${1}" = "--build-only" ]]; then
 			build_only="build"
+		elif [[ "${1}" == --* ]]; then
+			virtual="true"
 		else
 			die "java-pkg_jar-from called with unknown parameter: ${1}"
 		fi
@@ -1060,6 +1078,13 @@
 
 	java-pkg_ensure-dep "${build_only}" "${pkg}"
 
+	# Record the package(Virtual) as a dependency and then set build_only
+	# So that individual jars are not recorded.
+	if [[ -n "${virtual}" ]]; then
+		java-pkg_record-jar_ "${pkg}"
+		build_only="true"
+	fi
+
 	for jar in ${classpath//:/ }; do
 		if [[ ! -f "${jar}" ]] ; then
 			die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
@@ -2054,6 +2079,9 @@
 		java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
 	fi
 
+	# Initializing the JAVA_PKG_VNEED var from DEPEND
+	java-pkg_parse-virtuals
+
 	java-pkg_init_paths_
 	java-pkg_switch-vm
 	PATH=${JAVA_HOME}/bin:${PATH}
@@ -2074,6 +2102,21 @@
 	unset ANT_OPTS
 }
 
+# -----------------------------------------------------------------------------
+# @function-internal java-pkg_parse-virtuals
+#
+# -----------------------------------------------------------------------------
+
+java-pkg_parse-virtuals() {
+	debug-print-function ${FUNCNAME} $*
+
+	for dep in ${DEPEND}; do
+		if [[ -n "$(grep java-virtuals/* <<< ${dep})" ]]; then
+			JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${dep}"
+		fi	
+	done
+}
+
 # ------------------------------------------------------------------------------
 # @function-internal java-pkg-init-compiler_
 #
@@ -2203,6 +2246,8 @@
 	JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
 	JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
 	JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
+	JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
+	JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
 
 	[[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
 	[[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
@@ -2218,6 +2263,33 @@
 }
 
 # ------------------------------------------------------------------------------
+# @internal-function java-pkg_do_virtuals_write
+#
+# Writes the package.env out to disk.
+#
+# ------------------------------------------------------------------------------
+java-pkg_do_virtuals_write() {
+	java-pkg_init_paths_
+
+	dodir "${JAVA_PKG_VIRTUALS_PATH}"
+	if [[ -n "${JAVA_VIRTUAL_PROVIDES}" ]]; then
+		echo "PROVIDERS=\"${JAVA_VIRTUAL_PROVIDES}\"" \
+			>> ${JAVA_PKG_VIRTUAL_PROVIDER}
+	fi
+
+	if [[ -n "${JAVA_VIRTUAL_VM}" ]]; then
+		echo "VM=\"${JAVA_VIRTUAL_VM}\"" \
+			>> ${JAVA_PKG_VIRTUAL_PROVIDER}
+	fi
+	
+	if [[ -n "${JAVA_VIRTUAL_VM_CLASSPATH}" ]]; then
+		echo "VM_CLASSPATH=\"${JAVA_VIRTUAL_VM_CLASSPATH}\"" \
+		>> ${JAVA_PKG_VIRTUAL_PROVIDER}
+	fi
+}
+
+
+# ------------------------------------------------------------------------------
 # @internal-function java-pkg_do_write_
 #
 # Writes the package.env out to disk.
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHAZLzj0U8B+iUlwsRAqy3AJ9F/ZUMkRHlXu4EE2c0UI67qkZ7rACfUkPp
qoMIiL6VtU+Ymr4ZWhJ+CS0=
=oelo
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.