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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.34 - (show annotations) (download)
Wed Sep 2 21:41:29 2009 UTC (4 years, 11 months ago) by betelgeuse
Branch: MAIN
Changes since 1.33: +56 -1 lines
add java-pkg-2_src_test but don't export it so it can be used but doesn't break things that haven't been made to work with it

1 # Eclass for Java packages
2 #
3 # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4 # Copyright (c) 2004-2005, Gentoo Foundation
5 #
6 # Licensed under the GNU General Public License, v2
7 #
8 # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.33 2009/02/19 05:10:37 serkan Exp $
9
10 inherit java-utils-2
11
12 # -----------------------------------------------------------------------------
13 # @eclass-begin
14 # @eclass-summary Eclass for Java Packages
15 #
16 # This eclass should be inherited for pure Java packages, or by packages which
17 # need to use Java.
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 # ------------------------------------------------------------------------------
28 IUSE="${JAVA_PKG_IUSE}"
29
30 # ------------------------------------------------------------------------------
31 # @depend
32 #
33 # Java packages need java-config, and a fairly new release of Portage.
34 #
35 # JAVA_PKG_E_DEPEND is defined in java-utils.eclass.
36 # ------------------------------------------------------------------------------
37 DEPEND="${JAVA_PKG_E_DEPEND}"
38
39 # ------------------------------------------------------------------------------
40 # @rdepend
41 #
42 # Nothing special for RDEPEND... just the same as DEPEND.
43 # ------------------------------------------------------------------------------
44 RDEPEND="${DEPEND}"
45
46 # Commons packages follow the same rules so do it here
47 if [[ ${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"
50 fi
51
52 EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst
53 [[ "${EAPI:-0}" == "2" ]] && EXPORT_FUNCTIONS src_prepare
54
55 # ------------------------------------------------------------------------------
56 # @eclass-pkg_setup
57 #
58 # pkg_setup initializes the Java environment
59 # ------------------------------------------------------------------------------
60 java-pkg-2_pkg_setup() {
61 java-pkg_init
62 java-pkg_ensure-test
63 }
64
65 # ------------------------------------------------------------------------------
66 # @eclass-src_prepare
67 #
68 # wrapper for java-utils-2_src_prepare
69 # ------------------------------------------------------------------------------
70 java-pkg-2_src_prepare() {
71 java-utils-2_src_prepare
72 }
73
74 # ------------------------------------------------------------------------------
75 # @eclass-src_compile
76 #
77 # Default src_compile for java packages
78 # variables:
79 # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
80 # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
81 # EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
82 # EANT_DOC_TARGET - the target to build extra docs under the doc use flag
83 # (default: javadoc; declare empty to disable completely)
84 # EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
85 # EANT_EXTRA_ARGS - extra arguments to pass to eant
86 # EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
87 # param: Parameters are passed to ant verbatim
88 # ------------------------------------------------------------------------------
89 java-pkg-2_src_compile() {
90 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
91 [[ "${EANT_FILTER_COMPILER}" ]] && \
92 java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
93 local antflags="${EANT_BUILD_TARGET:=jar}"
94 if hasq doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
95 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
96 fi
97 local tasks
98 [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
99 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
100 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
101 else
102 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
103 fi
104 }
105
106 java-pkg-2_supports-test() {
107 python << EOF
108 from xml.dom.minidom import parse
109 import sys
110 dom = parse("${1}")
111 for elem in dom.getElementsByTagName('target'):
112 if elem.getAttribute('name') == 'test':
113 sys.exit(0)
114 sys.exit(1)
115 EOF
116 return $?
117 }
118
119 java-pkg-2_src_test() {
120 [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
121
122 if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
123 local opts task
124
125 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
126 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
127 fi
128
129 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
130
131 if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
132
133 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
134 ANT_TASKS="${ANT_TASKS} ant-junit"
135 else
136 ANT_TASKS="ant-junit"
137 fi
138
139 task=true
140 fi
141
142 if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
143 opts="-Djunit.jar=\"$(java-pkg_getjar junit junit.jar)\""
144 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
145 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH},junit"
146 elif [[ ${EANT_GENTOO_CLASSPATH} ]]; then
147 EANT_GENTOO_CLASSPATH+=',junit'
148 else
149 EANT_GENTOO_CLASSPATH=junit
150 fi
151 fi
152
153 eant ${opts} -f "${EANT_BUILD_XML}" \
154 ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
155
156 else
157 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
158 fi
159 }
160
161 # ------------------------------------------------------------------------------
162 # @eclass-pkg_preinst
163 #
164 # wrapper for java-utils-2_pkg_preinst
165 # ------------------------------------------------------------------------------
166 java-pkg-2_pkg_preinst() {
167 java-utils-2_pkg_preinst
168 }
169
170 # ------------------------------------------------------------------------------
171 # @eclass-end
172 # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20