/[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.27 - (hide annotations) (download)
Mon Jul 7 16:48:45 2008 UTC (7 years, 1 month ago) by betelgeuse
Branch: MAIN
Changes since 1.26: +55 -1 lines
Always put junit to gentoo.classpath when ANT_TASKS has ant-junit. Fixes bug #225981.

1 nichoj 1.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 betelgeuse 1.26 # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.25 2007/11/13 19:36:50 betelgeuse Exp $
9 nichoj 1.1
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 betelgeuse 1.13 # @IUSE
22     #
23 betelgeuse 1.25 # 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 betelgeuse 1.13 #
27     # ------------------------------------------------------------------------------
28     IUSE="${JAVA_PKG_IUSE}"
29    
30     # ------------------------------------------------------------------------------
31 nichoj 1.1 # @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 betelgeuse 1.26 # 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 betelgeuse 1.27 EXPORT_FUNCTIONS pkg_setup src_compile src_test
53 nichoj 1.1
54     # ------------------------------------------------------------------------------
55     # @eclass-pkg_setup
56     #
57     # pkg_setup initializes the Java environment
58     # ------------------------------------------------------------------------------
59     java-pkg-2_pkg_setup() {
60     java-pkg_init
61 betelgeuse 1.5 java-pkg_ensure-test
62 nichoj 1.1 }
63    
64     # ------------------------------------------------------------------------------
65 betelgeuse 1.6 # @eclass-src_compile
66     #
67     # Default src_compile for java packages
68     # variables:
69     # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
70 betelgeuse 1.10 # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
71 betelgeuse 1.6 # 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 caster 1.22 # (default: javadoc; declare empty to disable completely)
74 betelgeuse 1.12 # EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
75 betelgeuse 1.16 # EANT_EXTRA_ARGS - extra arguments to pass to eant
76 betelgeuse 1.17 # EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
77 betelgeuse 1.15 # param: Parameters are passed to ant verbatim
78 betelgeuse 1.6 # ------------------------------------------------------------------------------
79     java-pkg-2_src_compile() {
80     if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
81 betelgeuse 1.10 [[ "${EANT_FILTER_COMPILER}" ]] && \
82     java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
83 betelgeuse 1.6 local antflags="${EANT_BUILD_TARGET:=jar}"
84 caster 1.22 if hasq doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
85     antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
86     fi
87 betelgeuse 1.20 local tasks
88     [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
89 betelgeuse 1.21 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
90 betelgeuse 1.17 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
91 betelgeuse 1.6 else
92 betelgeuse 1.18 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
93 betelgeuse 1.6 fi
94     }
95    
96 betelgeuse 1.27 java-pkg-2_supports-test() {
97     python << EOF
98     from xml.dom.minidom import parse
99     import sys
100     dom = parse("${1}")
101     for elem in dom.getElementsByTagName('target'):
102     if elem.getAttribute('name') == 'test':
103     sys.exit(0)
104     sys.exit(1)
105     EOF
106     return $?
107     }
108    
109     java-pkg-2_src_test() {
110     [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
111    
112     if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
113     local opts task
114    
115     if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
116     java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
117     fi
118    
119     ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
120    
121     if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
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
148     }
149    
150 betelgeuse 1.6 # ------------------------------------------------------------------------------
151 nichoj 1.1 # @eclass-end
152     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20