/[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.45 Revision 1.46
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.45 2007/01/20 20:50:33 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.46 2007/01/21 01:20:21 caster 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
36# ----------------------------------------------------------------------------- 36# -----------------------------------------------------------------------------
37 37
38# Make sure we use java-config-2 38# Make sure we use java-config-2
39export WANT_JAVA_CONFIG="2" 39export WANT_JAVA_CONFIG="2"
40 40
41# TODO document 41# -----------------------------------------------------------------------------
42# @variable-external WANT_ANT_TASKS
43# @variable-default ""
44#
45# An $IFS separated list of ant tasks.
46# Ebuild can specify this variable before inheriting java-ant-2 eclass to
47# determine ANT_TASKS it needs. They will be automatically translated to
48# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
49# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
50# Ebuilds that need to depend conditionally on certain tasks and specify them
51# differently for different eant calls can't use this simplified approach.
52# You also cannot specify version or anything else than ant-*.
53#
54# @example WANT_ANT_TASKS="ant-junit ant-trax"
55#
56# @seealso JAVA_PKG_FORCE_ANT_TASKS
57# -----------------------------------------------------------------------------
58#WANT_ANT_TASKS
59
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. At this moment it's
63# portage with phase hooks support.
64# -----------------------------------------------------------------------------
42JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
43 66
44# ----------------------------------------------------------------------------- 67# -----------------------------------------------------------------------------
45# @variable-internal JAVA_PKG_E_DEPEND 68# @variable-internal JAVA_PKG_E_DEPEND
46# 69#
128# JAVA_PKG_COMPILERS_CONF. 151# JAVA_PKG_COMPILERS_CONF.
129# 152#
130# @note This should only be used internally or for testing. 153# @note This should only be used internally or for testing.
131# @example Use jikes and javac, in that order 154# @example Use jikes and javac, in that order
132# JAVA_PKG_FORCE_COMPILER="jikes javac" 155# JAVA_PKG_FORCE_COMPILER="jikes javac"
156# -----------------------------------------------------------------------------
157
158# -----------------------------------------------------------------------------
159# @variable-external JAVA_PKG_FORCE_ANT_TASKS
160#
161# An $IFS separated list of ant tasks. Can be set in environment before calling
162# emerge/ebuild to override variables set in ebuild, mainly for testing before
163# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
164# eant() call, not the dependencies specified in WANT_ANT_TASKS.
165#
166# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
167# ebuild foo.ebuild compile
168#
169# @seealso WANT_ANT_TASKS
133# ----------------------------------------------------------------------------- 170# -----------------------------------------------------------------------------
134 171
135# TODO document me 172# TODO document me
136JAVA_PKG_QA_VIOLATIONS=0 173JAVA_PKG_QA_VIOLATIONS=0
137 174
1342 die "Need USE=test enabled" 1379 die "Need USE=test enabled"
1343 fi 1380 fi
1344} 1381}
1345 1382
1346# ------------------------------------------------------------------------------ 1383# ------------------------------------------------------------------------------
1384# @ebuild-function java-pkg_register-ant-task
1385#
1386# Register this package as ant task, so that ant will load it when no specific
1387# ANT_TASKS are specified. Note that even without this registering, all packages
1388# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1389# packages, but can be also used by other ebuilds that used to symlink their
1390# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1391# compatibility.
1392#
1393# @param --version x.y Register only for ant version x.y (otherwise for any ant
1394# version). Used by the ant-* packages to prevent loading of mismatched
1395# ant-core ant tasks after core was updated, before the tasks are updated,
1396# without a need for blockers.
1397# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1398# ------------------------------------------------------------------------------
1399java-pkg_register-ant-task() {
1400 local TASKS_DIR="tasks"
1401
1402 # check for --version x.y parameters
1403 while [[ -n "${1}" && -n "${2}" ]]; do
1404 local var="${1#--}"
1405 local val="${2}"
1406 if [[ "${var}" == "version" ]]; then
1407 TASKS_DIR="tasks-${val}"
1408 else
1409 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1410 fi
1411 shift 2
1412 done
1413
1414 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1415
1416 dodir /usr/share/ant/${TASKS_DIR}
1417 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1418}
1419
1420# ------------------------------------------------------------------------------
1421# @internal-function java-pkg_ant-tasks-from-deps
1422#
1423# Function to determine ANT_TASKS from DEPEND variable for backwards
1424# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1425# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1426# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1427# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1428# be a problem, the worst it can do is activace all tasks when not needed.
1429# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1430# insufficient dependencies, otherwise all available tasks are used for
1431# backwards compatilbility.
1432#
1433# @return "all" or "none"
1434# ------------------------------------------------------------------------------
1435java-pkg_ant-tasks-from-deps() {
1436 local found_ant found_ant_tasks
1437
1438 for dep in ${DEPEND}
1439 do
1440 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1441 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1442 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1443 done
1444
1445 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1446 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1447 echo "all"
1448 else
1449 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1450 # so we deactivate all tasks that may be installed
1451 echo "none"
1452 fi
1453}
1454
1455# ------------------------------------------------------------------------------
1456# @internal-function java-pkg_ant-tasks-depend
1457#
1458# Translates the WANT_ANT_TASKS variable into valid dependencies.
1459# ------------------------------------------------------------------------------
1460java-pkg_ant-tasks-depend() {
1461 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1462
1463 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1464 local DEP=""
1465 for i in ${WANT_ANT_TASKS}
1466 do
1467 if [[ ${i} != ant-* ]]; then
1468 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1469 return 1
1470 fi
1471 DEP="${DEP}dev-java/${i} "
1472 done
1473 echo ${DEP}
1474 return 0
1475 else
1476 return 0
1477 fi
1478}
1479
1480# ------------------------------------------------------------------------------
1347# @section-end helper 1481# @section-end helper
1348# ------------------------------------------------------------------------------ 1482# ------------------------------------------------------------------------------
1349 1483
1350# ------------------------------------------------------------------------------ 1484# ------------------------------------------------------------------------------
1351# @section-begin build 1485# @section-begin build
1357 1491
1358# ------------------------------------------------------------------------------ 1492# ------------------------------------------------------------------------------
1359# @ebuild-function eant 1493# @ebuild-function eant
1360# 1494#
1361# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1495# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1362# compiler. 1496# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1363# variables: 1497# variables:
1364# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1498# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1365# gentoo.classpath property. Be sure to call 1499# gentoo.classpath property. Be sure to call
1366# java-ant_rewrite-classpath in src_unpack. 1500# java-ant_rewrite-classpath in src_unpack.
1367# 1501# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1368# ------------------------------------------------------------------------------ 1502# ------------------------------------------------------------------------------
1369eant() { 1503eant() {
1370 debug-print-function ${FUNCNAME} $* 1504 debug-print-function ${FUNCNAME} $*
1371 1505
1372 # FIXME get this working 1506 # FIXME get this working
1401 if is-java-strict; then 1535 if is-java-strict; then
1402 einfo "Disabling system classpath for ant" 1536 einfo "Disabling system classpath for ant"
1403 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1537 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1404 fi 1538 fi
1405 1539
1540 if has_version ">=dev-java/ant-core-1.7.0"; then
1541 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1542 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1543
1544 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1545 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1546
1547 if is-java-strict; then
1548 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1549 if [[ -z "${ANT_TASKS}" ]]; then
1550 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1551 fi
1552 else
1553 # if ant-tasks is not set by ebuild or forced, activate all of them
1554 ANT_TASKS="${ANT_TASKS:-all}"
1555 fi
1556
1557 # at this point, ANT_TASKS should be "all", "none" or explicit list
1558 if [[ "${ANT_TASKS}" == "all" ]]; then
1559 einfo "Using all available ANT_TASKS"
1560 elif [[ "${ANT_TASKS}" == "none" ]]; then
1561 einfo "Disabling all optional ANT_TASKS"
1562 else
1563 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1564 fi
1565
1566 export ANT_TASKS
1567 fi
1568
1406 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} -debug" 1569 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1407 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q" 1570 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1408 1571
1409 local gcp="${EANT_GENTOO_CLASSPATH}" 1572 local gcp="${EANT_GENTOO_CLASSPATH}"
1410 1573
1411 if [[ "${gcp}" ]]; then 1574 if [[ "${gcp}" ]]; then
1536 # When users have crazy classpaths some packages can fail to compile. 1699 # When users have crazy classpaths some packages can fail to compile.
1537 # and everything should work with empty CLASSPATH. 1700 # and everything should work with empty CLASSPATH.
1538 # This also helps prevent unexpected dependencies on random things 1701 # This also helps prevent unexpected dependencies on random things
1539 # from the CLASSPATH. 1702 # from the CLASSPATH.
1540 unset CLASSPATH 1703 unset CLASSPATH
1704
1705 # Unset external ANT_ stuff
1706 unset ANT_TASKS
1707 unset ANT_OPTS
1541} 1708}
1542 1709
1543# ------------------------------------------------------------------------------ 1710# ------------------------------------------------------------------------------
1544# @function-internal java-pkg-init-compiler_ 1711# @function-internal java-pkg-init-compiler_
1545# 1712#

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.46

  ViewVC Help
Powered by ViewVC 1.1.20