Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-java
Navigation:
Lists: gentoo-java: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-java@g.o
From: Alistair Bush <ali_bush@g.o>
Subject: java-utils-2.eclass patch. Support for BUILD_DEPEND being recorded within package.env.
Date: Thu, 04 Jun 2009 23:37:50 +1200
Firstly, fellow developer please review this eclass patch and read on if
you are interested in what it actually does.

Java developers:

The following patch adds 3 new values to our package.env

PVR and CATEGORY being the easy ones.  These are being added because I
think they should be there and they will help with implementing a
paludis re-emerge-everything-java script.

the 3rd BUILD_DEPEND records the packages/jars that have been passed as
parameters to our java functions ( jar-from, getjars, getjar ) and also
have --build-only specified.  The format is exactly like package.env's
DEPEND variable. The main reason for this patch is to allow Serkan to
add --build-only dependencies to the classpath for java-dep-check.
java-config support is not currently planned but this may change if need be.

Here are some example package.env files.

# more
/var/tmp/portage/app-office/hourglass-0.7.2/image/usr/share/hourglass/package.env
DESCRIPTION="A PSP (personal software process) time tracking utility
written in Java"
GENERATION="2"
SLOT="0"
CATEGORY="app-office"
PVR="0.7.2"
CLASSPATH="/usr/share/hourglass/lib/hourglass.jar"
DEPEND="log4j.jar@log4j:jcommon.jar@...:jdom.jar@..."
VM=">=virtual/jre-1.5"
BUILD_DEPEND="ant.jar@ant-core"
TARGET="1.5"
SOURCE="1.5"
JAVADOC_PATH="/usr/share/doc/hourglass-0.7.2/html/api"
JAVA_SOURCES="/usr/share/hourglass/sources//hourglass-src.zip"
MERGE_VM="sun-jdk-1.7"
MERGE_COMPILER="javac"

 # more /var/tmp/portage/dev-java/sbaz-1.25/image/usr/share/sbaz/package.env
DESCRIPTION="A system used by Scala enthusiasts to share computer files
with each other."
GENERATION="2"
SLOT="0"
CATEGORY="dev-java"
PVR="1.25"
CLASSPATH="/usr/share/sbaz/lib/sbaz.jar"
DEPEND="scala-library.jar@scala"
VM=">=virtual/jre-1.5"
BUILD_DEPEND="servlet-api.jar@...:ant-contrib"
TARGET="1.5"
SOURCE="1.5"
MERGE_VM="sun-jdk-1.7"
MERGE_COMPILER="javac
--- java-utils-2.eclass.old	2009-06-04 19:46:37.711668962 +1200
+++ java-utils-2.eclass	2009-06-04 22:13:22.694684085 +1200
@@ -874,6 +874,7 @@
 	local destdir="."
 	local deep=""
 	local virtual=""
+	local record_jar=""
 
 	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
 
@@ -918,7 +919,7 @@
 			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
 		done
 		# setting this disables further record-jar_ calls later
-		build_only="build"
+		record_jar="true"
 	else
 		java-pkg_ensure-dep "${build_only}" "${target_pkg}"
 	fi
@@ -928,7 +929,7 @@
 	if [[ -z "${build_only}" && -n "${virtual}" ]]; then
 		java-pkg_record-jar_ "${target_pkg}"
 		# setting this disables further record-jars_ calls later
-		build_only="build"
+		record_jar="true"
 	fi
 
 	pushd ${destdir} > /dev/null \
@@ -946,13 +947,25 @@
 			[[ -f "${target_jar}" ]]  && rm "${target_jar}"
 			ln -snf "${jar}" \
 				|| die "Failed to make symlink from ${jar} to ${jar_name}"
-			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
-		# otherwise, if the current jar is the target jar, link it
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${target_pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
+				fi
+			fi
+			# otherwise, if the current jar is the target jar, link it
 		elif [[ "${jar_name}" == "${target_jar}" ]] ; then
 			[[ -f "${destjar}" ]]  && rm "${destjar}"
 			ln -snf "${jar}" "${destjar}" \
 				|| die "Failed to make symlink from ${jar} to ${destjar}"
-			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${target_pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
+				fi
+			fi
 			popd > /dev/null
 			return 0
 		fi
@@ -1035,12 +1048,13 @@
 		java-pkg_ensure-dep "${build_only}" "${pkg}"
 	done
 
-	# Only record jars that aren't build-only
-	if [[ -z "${build_only}" ]]; then
-		for pkg in ${pkgs//,/ }; do
+	for pkg in ${pkgs//,/ }; do
+		if [[ -z "${build_only}" ]]; then
 			java-pkg_record-jar_ "${pkg}"
-		done
-	fi
+		else
+			java-pkg_record-jar_ --build-only "${pkg}"
+		fi
+	done
 
 	echo "${jars}"
 }
@@ -1071,6 +1085,7 @@
 
 	local build_only=""
 	local virtual=""
+	local record_jar=""
 
 	[[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
 
@@ -1106,8 +1121,12 @@
 	# 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"
+		if [[ -z "${build_only}" ]]; then
+			java-pkg_record-jar_ "${pkg}"
+		else
+			java-pkg_record-jar_ --build-only "${pkg}"
+		fi
+		record_jar="true"
 	fi
 
 	for jar in ${classpath//:/ }; do
@@ -1117,7 +1136,13 @@
 
 		if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
 			# Only record jars that aren't build-only
-			[[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
+			if [[ -z "${record_jar}" ]]; then
+				if [[ -z "${build_only}" ]]; then
+					java-pkg_record-jar_ "${pkg}" "${jar}"
+				else
+					java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
+				fi
+			fi
 			echo "${jar}"
 			return 0
 		fi
@@ -2243,6 +2268,8 @@
 			echo "DESCRIPTION=\"${DESCRIPTION}\""
 			echo "GENERATION=\"2\""
 			echo "SLOT=\"${SLOT}\""
+			echo "CATEGORY=\"${CATEGORY}\""
+			echo "PVR=\"${PVR}\""
 
 			[[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
 			[[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
@@ -2252,6 +2279,8 @@
 			[[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
 				&& echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
 			echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
+			[[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
+				&& echo "BUILD_DEPEND=\"$(cat "${JAVA_PKG_BUILD_DEPEND_FILE}" | uniq | tr '\n' ':')\""
 		) > "${JAVA_PKG_ENV}"
 
 		# register target/source
@@ -2294,20 +2323,26 @@
 #
 # Record an (optional) dependency to the package.env
 # @param --optional - record dependency as optional
+# @param --build - record dependency as build_only
 # @param $1 - package to record
 # @param $2 - (optional) jar of package to record
 # ------------------------------------------------------------------------------
 JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
 JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
+JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
 
 java-pkg_record-jar_() {
 	debug-print-function ${FUNCNAME} $*
 
 	local depend_file="${JAVA_PKG_DEPEND_FILE}"
-	if [[ "${1}" == "--optional" ]]; then
-		depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
-		shift
-	fi
+	case "${1}" in
+		"--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
+		"--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
+	esac
+	#if [[ "${1}" == "--optional" ]]; then
+	#	depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
+	#	shift
+	#fi
 
 	local pkg=${1} jar=${2} append
 	if [[ -z "${jar}" ]]; then
Navigation:
Lists: gentoo-java: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Patch to remove JAVA_PKG_VNEED support from java-utils-2.eclass
Next by thread:
Meeting today
Previous by date:
Patch to remove JAVA_PKG_VNEED support from java-utils-2.eclass
Next by date:
Meeting today


Updated Jun 17, 2009

Summary: Archive of the gentoo-java mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.