/[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.33 Revision 1.40
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2005, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.33 2006/12/07 02:27:22 flameeyes Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.40 2007/01/10 09:52:51 betelgeuse Exp $
10 10
11 11
12# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
13# @eclass-begin 13# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
174 # Create JARDEST if it doesn't exist 174 # Create JARDEST if it doesn't exist
175 dodir ${JAVA_PKG_JARDEST} 175 dodir ${JAVA_PKG_JARDEST}
176 176
177 local jar 177 local jar
178 # for each jar 178 # for each jar
179 for jar in "$@"; do 179 for jar in ${@}; do
180 local jar_basename=$(basename "${jar}") 180 local jar_basename=$(basename "${jar}")
181 181
182 java-pkg_check-versioned-jar ${jar_basename} 182 java-pkg_check-versioned-jar ${jar_basename}
183 183
184 # check if it exists 184 # check if it exists
203 203
204 java-pkg_do_write_ 204 java-pkg_do_write_
205} 205}
206 206
207 207
208# ------------------------------------------------------------------------------
209# @internal-function depend-java-query
210#
211# Wrapper for the depend-java-query binary to enable passing USE in env.
212# Using env variables keeps this eclass working with java-config versions that
213# do not handle use flags.
214# ------------------------------------------------------------------------------
215
216depend-java-query() {
217 USE="${USE}" $(which depend-java-query) "${@}"
218}
208 219
209# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
210# @ebuild-function java-pkg_regjar 221# @ebuild-function java-pkg_regjar
211# 222#
212# Records an already installed jar in the package.env 223# Records an already installed jar in the package.env
243 [[ ${#} -lt 1 ]] && die "at least one argument needed" 254 [[ ${#} -lt 1 ]] && die "at least one argument needed"
244 255
245 java-pkg_init_paths_ 256 java-pkg_init_paths_
246 257
247 local jar jar_dir jar_file 258 local jar jar_dir jar_file
248 for jar in "$@"; do 259 for jar in ${@}; do
249 # TODO use java-pkg_check-versioned-jar 260 # TODO use java-pkg_check-versioned-jar
250 if [[ -e "${jar}" ]]; then 261 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
262 [[ -d "${jar}" || -d "${D}${jar}" ]] \
263 && die "Called ${FUNCNAME} on a directory $*"
251 # nelchael: we should strip ${D} in this case too, here's why: 264 # nelchael: we should strip ${D} in this case too, here's why:
252 # imagine such call: 265 # imagine such call:
253 # java-pkg_regjar ${D}/opt/java/*.jar 266 # java-pkg_regjar ${D}/opt/java/*.jar
254 # such call will fall into this case (-e ${jar}) and will 267 # such call will fall into this case (-e ${jar}) and will
255 # record paths with ${D} in package.env 268 # record paths with ${D} in package.env
256 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 269 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
257 elif [[ -e "${D}${jar}" ]]; then
258 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
259 else 270 else
260 die "${jar} does not exist" 271 die "${jar} does not exist"
261 fi 272 fi
262 done 273 done
263 274
264 java-pkg_do_write_ 275 java-pkg_do_write_
265} 276}
266
267 277
268# ------------------------------------------------------------------------------ 278# ------------------------------------------------------------------------------
269# @ebuild-function java-pkg_newjar 279# @ebuild-function java-pkg_newjar
270# 280#
271# Installs a jar with a new name 281# Installs a jar with a new name
565 local var_tmp="${T}/launcher_variables_tmp" 575 local var_tmp="${T}/launcher_variables_tmp"
566 local target_dir pre 576 local target_dir pre
567 577
568 # Process the other the rest of the arguments 578 # Process the other the rest of the arguments
569 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
570 local var=${1} value=${2} 580 local var="${1}" value="${2}"
571 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
572 local var=${var:2} 582 local var=${var:2}
573 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
574 local gjl_${var}="${value}" 584 local gjl_${var}="${value}"
575 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
789# (passed to java-config --classpath) 799# (passed to java-config --classpath)
790# ------------------------------------------------------------------------------ 800# ------------------------------------------------------------------------------
791java-pkg_getjars() { 801java-pkg_getjars() {
792 debug-print-function ${FUNCNAME} $* 802 debug-print-function ${FUNCNAME} $*
793 803
794 [[ ${#} -lt 1 || ${#} -gt 2 ]] && die "${FUNCNAME} takes only one or two arguments"
795
796 if [[ "${1}" = "--build-only" ]]; then 804 if [[ "${1}" = "--build-only" ]]; then
797 local build_only="true" 805 local build_only="true"
798 shift 806 shift
799 fi 807 fi
808
809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
800 810
801 local classpath pkgs="${1}" 811 local classpath pkgs="${1}"
802 jars="$(java-config --classpath=${pkgs})" 812 jars="$(java-config --classpath=${pkgs})"
803 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed" 813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
804 debug-print "${pkgs}:${jars}" 814 debug-print "${pkgs}:${jars}"
999# 1009#
1000# export DEPEND="${DEPEND} ${depstr}" 1010# export DEPEND="${DEPEND} ${depstr}"
1001# export RDEPEND="${RDEPEND} ${depstr}" 1011# export RDEPEND="${RDEPEND} ${depstr}"
1002#} 1012#}
1003 1013
1014# ------------------------------------------------------------------------------
1015# @ebuild-function java-pkg_find-normal-jars
1016#
1017# Find the files with suffix .jar file in the given directory or $WORKDIR
1018#
1019# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1020# ------------------------------------------------------------------------------
1021java-pkg_find-normal-jars() {
1022 local dir=$1
1023 [[ "${dir}" ]] || dir="${WORKDIR}"
1024 local found
1025 for jar in $(find "${dir}" -name "*.jar" -type f); do
1026 echo "${jar}"
1027 found="true"
1028 done
1029 [[ "${found}" ]]
1030 return $?
1031}
1032
1033# ------------------------------------------------------------------------------
1034# @ebuild-function java-pkg_ensure-no-bundled-jars
1035#
1036# Try to locate bundled jar files in ${WORKDIR} and die if found.
1004# This should be used after S has been populated with symlinks to jars 1037# This function should be called after WORKDIR has been populated with symlink
1005# TODO document 1038# to system jar files or bundled jars removed.
1039# ------------------------------------------------------------------------------
1006java-pkg_ensure-no-bundled-jars() { 1040java-pkg_ensure-no-bundled-jars() {
1007 debug-print-function ${FUNCNAME} $* 1041 debug-print-function ${FUNCNAME} $*
1008 pushd ${WORKDIR} >/dev/null 2>/dev/null
1009 1042
1010 local bundled_jars=$(find . -name "*.jar" -type f) 1043 local bundled_jars=$(java-pkg_find-normal-jars)
1011 if [[ -n ${bundled_jars} ]]; then 1044 if [[ -n ${bundled_jars} ]]; then
1012 echo "Bundled jars found:" 1045 echo "Bundled jars found:"
1013 local jar 1046 local jar
1014 for jar in ${bundled_jars}; do 1047 for jar in ${bundled_jars}; do
1015 echo $(pwd)${jar/./} 1048 echo $(pwd)${jar/./}
1016 done 1049 done
1017 die "Bundled jars found!" 1050 die "Bundled jars found!"
1018
1019 fi 1051 fi
1020 popd >/dev/null 2>/dev/null
1021} 1052}
1022 1053
1023# ------------------------------------------------------------------------------ 1054# ------------------------------------------------------------------------------
1024# @internal-function java-pkg_ensure-vm-version-sufficient 1055# @internal-function java-pkg_ensure-vm-version-sufficient
1025# 1056#
1174# @ebuild-function java-pkg_get-target 1205# @ebuild-function java-pkg_get-target
1175# 1206#
1176# Determines what target version should be used, for passing to -target. 1207# Determines what target version should be used, for passing to -target.
1177# If you don't care about lower versions, you can set _WANT_TARGET to the 1208# If you don't care about lower versions, you can set _WANT_TARGET to the
1178# version of your JDK. 1209# version of your JDK.
1179# Remember doing this will mostly like cause things to break.
1180# Doesn't allow it to be lower then the one in depend.
1181# Doesn't allow it to be higher then the active vm.
1182# 1210#
1183# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1211# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1184# ------------------------------------------------------------------------------ 1212# ------------------------------------------------------------------------------
1185java-pkg_get-target() { 1213java-pkg_get-target() {
1186 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1187 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1188 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1189 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1190 echo ${JAVA_PKG_WANT_TARGET}
1191 else
1192 echo ${min}
1193 fi
1194 else
1195 echo ${min}
1196 fi
1197
1198 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1214 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1199} 1215}
1200 1216
1201java-pkg_get-javac() { 1217java-pkg_get-javac() {
1202 debug-print-function ${FUNCNAME} $* 1218 debug-print-function ${FUNCNAME} $*
1203 1219
1292 die "No GCJ support found!" 1308 die "No GCJ support found!"
1293 fi 1309 fi
1294} 1310}
1295 1311
1296java-pkg_ensure-test() { 1312java-pkg_ensure-test() {
1297 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1313 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1314 && hasq test ${IUSE} && ! use test;
1315 then
1298 eerror "You specified FEATURES=test, but USE=test is needed" 1316 eerror "You specified FEATURES=test, but USE=test is needed"
1299 eerror "to pull in the additional dependencies for testing" 1317 eerror "to pull in the additional dependencies for testing"
1300 die "Need USE=test enabled" 1318 die "Need USE=test enabled"
1301 fi 1319 fi
1302} 1320}
1327# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1345# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1328# java-pkg_announce-qa-violation \ 1346# java-pkg_announce-qa-violation \
1329# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1347# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1330# fi 1348# fi
1331 1349
1332 local antflags 1350 local antflags="-Dnoget=true"
1333 java-pkg_init-compiler_ 1351 java-pkg_init-compiler_
1334 local compiler="${GENTOO_COMPILER}" 1352 local compiler="${GENTOO_COMPILER}"
1335 1353
1336 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1354 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1337 1355
1339 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1357 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1340 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1358 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1341 fi 1359 fi
1342 1360
1343 if [[ ${compiler} != "javac" ]]; then 1361 if [[ ${compiler} != "javac" ]]; then
1344 antflags="-Dbuild.compiler=${build_compiler}" 1362 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1345 # Figure out any extra stuff to put on the classpath for compilers aside 1363 # Figure out any extra stuff to put on the classpath for compilers aside
1346 # from javac 1364 # from javac
1347 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1365 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1348 # java-config -p 1366 # java-config -p
1349 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1367 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1439# @return string - Name of the target to create javadocs 1457# @return string - Name of the target to create javadocs
1440# ------------------------------------------------------------------------------ 1458# ------------------------------------------------------------------------------
1441use_doc() { 1459use_doc() {
1442 use doc && echo ${@:-javadoc} 1460 use doc && echo ${@:-javadoc}
1443} 1461}
1462
1444 1463
1445# ------------------------------------------------------------------------------ 1464# ------------------------------------------------------------------------------
1446# @section-end build 1465# @section-end build
1447# ------------------------------------------------------------------------------ 1466# ------------------------------------------------------------------------------
1448 1467
1832# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1851# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1833# verify that the current VM is sufficient. 1852# verify that the current VM is sufficient.
1834# Setup the environment for the VM being used. 1853# Setup the environment for the VM being used.
1835# ------------------------------------------------------------------------------ 1854# ------------------------------------------------------------------------------
1836java-pkg_switch-vm() { 1855java-pkg_switch-vm() {
1856 debug-print-function ${FUNCNAME} $*
1857
1837 if java-pkg_needs-vm; then 1858 if java-pkg_needs-vm; then
1838 # Use the VM specified by JAVA_PKG_FORCE_VM 1859 # Use the VM specified by JAVA_PKG_FORCE_VM
1839 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1860 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1840 # If you're forcing the VM, I hope you know what your doing... 1861 # If you're forcing the VM, I hope you know what your doing...
1862 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1841 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1863 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1842 # if we're allowed to switch the vm... 1864 # if we're allowed to switch the vm...
1843 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1865 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1844 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1866 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1845 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1867 if [[ -n ${JAVA_PKG_VNEED} ]]; then

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.20