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

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

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

Revision 1.3 Revision 1.27
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004-2005, Gentoo Foundation 4# Copyright (c) 2004-2005, Gentoo Foundation
5# 5#
6# Licensed under the GNU General Public License, v2 6# Licensed under the GNU General Public License, v2
7# 7#
8# $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.27 2008/07/07 16:48:45 betelgeuse Exp $
8 9
9inherit java-utils-2 10inherit java-utils-2
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-summary Eclass for Java Packages 14# @eclass-summary Eclass for Java Packages
14# 15#
15# This eclass should be inherited for pure Java packages, or by packages which 16# This eclass should be inherited for pure Java packages, or by packages which
16# need to use Java. 17# need to use Java.
17# ----------------------------------------------------------------------------- 18# -----------------------------------------------------------------------------
19
20# ------------------------------------------------------------------------------
21# @IUSE
22#
23# Use JAVA_PKG_IUSE instead of IUSE for doc, source and examples so that
24# the eclass can automatically add the needed dependencies for the java-pkg_do*
25# functions.
26#
27# ------------------------------------------------------------------------------
28IUSE="${JAVA_PKG_IUSE}"
18 29
19# ------------------------------------------------------------------------------ 30# ------------------------------------------------------------------------------
20# @depend 31# @depend
21# 32#
22# Java packages need java-config, and a fairly new release of Portage. 33# Java packages need java-config, and a fairly new release of Portage.
30# 41#
31# Nothing special for RDEPEND... just the same as DEPEND. 42# Nothing special for RDEPEND... just the same as DEPEND.
32# ------------------------------------------------------------------------------ 43# ------------------------------------------------------------------------------
33RDEPEND="${DEPEND}" 44RDEPEND="${DEPEND}"
34 45
35EXPORT_FUNCTIONS pkg_setup 46# Commons packages follow the same rules so do it here
47if [[ ${CATEGORY} = dev-java && ${PN} = commons-* ]]; then
48 HOMEPAGE="http://commons.apache.org/${PN#commons-}/"
49 SRC_URI="mirror://apache/${PN/-///}/source/${P}-src.tar.gz"
50fi
51
52EXPORT_FUNCTIONS pkg_setup src_compile src_test
36 53
37# ------------------------------------------------------------------------------ 54# ------------------------------------------------------------------------------
38# @eclass-pkg_setup 55# @eclass-pkg_setup
39# 56#
40# pkg_setup initializes the Java environment 57# pkg_setup initializes the Java environment
41# ------------------------------------------------------------------------------ 58# ------------------------------------------------------------------------------
42java-pkg-2_pkg_setup() { 59java-pkg-2_pkg_setup() {
43 java-pkg_init 60 java-pkg_init
61 java-pkg_ensure-test
44} 62}
45 63
46# ------------------------------------------------------------------------------ 64# ------------------------------------------------------------------------------
47# @note 65# @eclass-src_compile
48# 66#
49# We need to initialize the environment in every function because Portage 67# Default src_compile for java packages
50# will source /etc/profile between phases and trample all over the env. 68# variables:
51# This is accomplished by phase hooks, which is available with newer versions of 69# EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
52# portage. 70# EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
71# EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
72# EANT_DOC_TARGET - the target to build extra docs under the doc use flag
73# (default: javadoc; declare empty to disable completely)
74# EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
75# EANT_EXTRA_ARGS - extra arguments to pass to eant
76# EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
77# param: Parameters are passed to ant verbatim
53# ------------------------------------------------------------------------------ 78# ------------------------------------------------------------------------------
54 79java-pkg-2_src_compile() {
55pre_pkg_setup() { 80 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
56 java-pkg-2_pkg_setup 81 [[ "${EANT_FILTER_COMPILER}" ]] && \
82 java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
83 local antflags="${EANT_BUILD_TARGET:=jar}"
84 if hasq doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
85 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
86 fi
87 local tasks
88 [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
89 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
90 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
91 else
92 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
93 fi
57} 94}
58 95
59pre_src_unpack() { 96java-pkg-2_supports-test() {
60 java-pkg-2_pkg_setup 97 python << EOF
98from xml.dom.minidom import parse
99import sys
100dom = parse("${1}")
101for elem in dom.getElementsByTagName('target'):
102 if elem.getAttribute('name') == 'test':
103 sys.exit(0)
104sys.exit(1)
105EOF
106 return $?
61} 107}
62 108
63pre_src_compile() { 109java-pkg-2_src_test() {
64 java-pkg-2_pkg_setup 110 [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
65}
66 111
67pre_src_install() { 112 if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
68 java-pkg-2_pkg_setup 113 local opts task
69}
70 114
71pre_src_test() { 115 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
72 java-pkg-2_pkg_setup 116 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
73} 117 fi
74 118
75pre_pkg_preinst() { 119 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
76 java-pkg-2_pkg_setup
77}
78 120
79pre_pkg_postinst() { 121 if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
80 java-pkg-2_pkg_setup 122
123 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
124 ANT_TASKS="${ANT_TASKS} ant-junit"
125 else
126 ANT_TASKS="ant-junit"
127 fi
128
129 task=true
130 fi
131
132 if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
133 opts="-Djunit.jar=\"$(java-pkg_getjar --build-only junit junit.jar)\""
134 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
135 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH},junit"
136 elif [[ ${EANT_GENTOO_CLASSPATH} ]]; then
137 EANT_GENTOO_CLASSPATH+=',junit'
138 else
139 EANT_GENTOO_CLASSPATH=junit
140 fi
141 fi
142 eant ${opts} -f "${EANT_BUILD_XML}" \
143 ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
144
145 else
146 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
147 fi
81} 148}
82 149
83# ------------------------------------------------------------------------------ 150# ------------------------------------------------------------------------------
84# @eclass-end 151# @eclass-end
85# ------------------------------------------------------------------------------ 152# ------------------------------------------------------------------------------

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.20