/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.8
33# ----------------------------------------------------------------------------- 33# -----------------------------------------------------------------------------
34 34
35# Make sure we use java-config-2 35# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 36export WANT_JAVA_CONFIG="2"
37 37
38# TODO document
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40
38# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 42# @variable-internal JAVA_PKG_E_DEPEND
40# 43#
41# This is a convience variable to be used from the other java eclasses. This is 44# This is a convience variable to be used from the other java eclasses. This is
42# the version of java-config we want to use. We also need a recent version 45# the version of java-config we want to use. We also need a recent version
43# portage, that includes phase hooks. 46# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 47# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 49
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 52# @variable-default yes
50# 53#
206# Records an already installed jar in the package.env 209# Records an already installed jar in the package.env
207# This would mostly be used if the package has make or a custom script to 210# This would mostly be used if the package has make or a custom script to
208# install things. 211# install things.
209# 212#
210# Example: 213# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 214# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
215#
216# WARNING:
217# if you want to use shell expansion, you have to use ${D}/... as the for in
218# this function will not be able to expand the path, here's an example:
219#
220# java-pkg_regjar /opt/my-java/lib/*.jar
221#
222# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist
227#
228# you have to use it as:
229#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 231#
213# @param $@ - jars to record 232# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 233# ------------------------------------------------------------------------------
215# TODO fix me! 234# TODO fix me!
216java-pkg_regjar() { 235java-pkg_regjar() {
224 243
225 local jar jar_dir jar_file 244 local jar jar_dir jar_file
226 for jar in "$@"; do 245 for jar in "$@"; do
227 # TODO use java-pkg_check-versioned-jar 246 # TODO use java-pkg_check-versioned-jar
228 if [[ -e "${jar}" ]]; then 247 if [[ -e "${jar}" ]]; then
248 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env
229 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}" 253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
230 elif [[ -e "${D}${jar}" ]]; then 254 elif [[ -e "${D}${jar}" ]]; then
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 256 else
233 die "${jar} does not exist" 257 die "${jar} does not exist"
234 fi 258 fi
255 local original_jar="${1}" 279 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 280 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 281 local new_jar_dest="${T}/${new_jar}"
258 282
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 283 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
261 285
262 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
263 cp "${original_jar}" "${new_jar_dest}" \ 287 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 288 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 289 java-pkg_dojar "${new_jar_dest}"
1210# @param $@ - Arguments to be passed to the compiler 1234# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 1235# ------------------------------------------------------------------------------
1212ejavac() { 1236ejavac() {
1213 debug-print-function ${FUNCNAME} $* 1237 debug-print-function ${FUNCNAME} $*
1214 1238
1239 # FIXME using get-javac ends up printing stuff with einfo
1215 local compiler_executable=$(java-pkg_get-javac) 1240# local compiler_executable=$(java-pkg_get-javac)
1241 local compiler_executable="javac"
1216 1242
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1243 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1244 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1219} 1245}
1220 1246
1226# 1252#
1227# @param $@ - compilers to filter 1253# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 1254# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 1255java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1256 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1257}
1258
1259# ------------------------------------------------------------------------------
1260# @ebuild-function java-pkg_force-compiler
1261#
1262# Used to force the use of particular compilers. Should be used in src_compile.
1263# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1264# OutOfMemoryErrors that may come up.
1265#
1266# @param $@ - compilers to force
1267# ------------------------------------------------------------------------------
1268java-pkg_force-compiler() {
1269 JAVA_PKG_FORCE_COMPILER="$@"
1231} 1270}
1232 1271
1233# ------------------------------------------------------------------------------ 1272# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 1273# @ebuild-function use_doc
1235# 1274#
1324 if [[ -n ${GENTOO_COMPILER} ]]; then 1363 if [[ -n ${GENTOO_COMPILER} ]]; then
1325 debug-print "GENTOO_COMPILER already set" 1364 debug-print "GENTOO_COMPILER already set"
1326 return 1365 return
1327 fi 1366 fi
1328 1367
1368 local compilers;
1369 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1329 local compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1370 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1371 else
1372 compilers=${JAVA_PKG_FORCE_COMPILER}
1373 fi
1374
1330 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1375 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1331 1376
1332 # Figure out if we should announce what compiler we're using 1377 # Figure out if we should announce what compiler we're using
1333 local compiler 1378 local compiler
1334 for compiler in ${compilers}; do 1379 for compiler in ${compilers}; do
1655 fi 1700 fi
1656 debug-print "Using: $(java-config -f)" 1701 debug-print "Using: $(java-config -f)"
1657 1702
1658 java-pkg_setup-vm 1703 java-pkg_setup-vm
1659 1704
1705 export JAVA=$(java-config --java)
1706 export JAVAC=$(java-config --javac)
1660 export JAVACFLAGS="$(java-pkg_javac-args)" 1707 export JAVACFLAGS="$(java-pkg_javac-args)"
1661 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1708 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1662 1709
1663 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1710 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1664 export JDK_HOME=${JAVA_HOME} 1711 export JDK_HOME=${JAVA_HOME}
1698 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1745 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1699 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1746 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1700 echo "and of course, the output of emerge --info" >&2 1747 echo "and of course, the output of emerge --info" >&2
1701} 1748}
1702 1749
1750
1751# TODO document
1752# List jars in the source directory, ${S}
1753java-pkg_jar-list() {
1754 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1755 einfo "Linked Jars"
1756 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1757 einfo "Jars"
1758 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1759 einfo "Classes"
1760 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1761 fi
1762}
1763
1764# TODO document
1765# Verify that the classes were compiled for the right source / target
1766java-pkg_verify-classes() {
1767 ebegin "Verifying java class versions"
1768 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1769 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1770 result=$?
1771 eend ${result}
1772 if [[ ${result} == 0 ]]; then
1773 einfo "All good"
1774 else
1775 ewarn "Possible problem"
1776 die "Bad class files found"
1777 fi
1778}
1779
1780
1703# ------------------------------------------------------------------------------ 1781# ------------------------------------------------------------------------------
1704# @section-end internal 1782# @section-end internal
1705# ------------------------------------------------------------------------------ 1783# ------------------------------------------------------------------------------
1706 1784
1707java-pkg_check-phase() { 1785java-pkg_check-phase() {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20