/[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.37 - (hide annotations) (download)
Tue Dec 27 17:55:12 2011 UTC (3 years ago) by fauli
Branch: MAIN
Changes since 1.36: +2 -2 lines
Update copyright years in headers

1 nichoj 1.1 # Eclass for Java packages
2     #
3     # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4 fauli 1.37 # Copyright (c) 2004-2011, Gentoo Foundation
5 nichoj 1.1 #
6     # Licensed under the GNU General Public License, v2
7     #
8 fauli 1.37 # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.36 2011/07/08 11:35:01 ssuominen 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 caster 1.35 case "${EAPI:-0}" in
53     0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;;
54     *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;;
55     esac
56 nichoj 1.1
57     # ------------------------------------------------------------------------------
58     # @eclass-pkg_setup
59     #
60     # pkg_setup initializes the Java environment
61     # ------------------------------------------------------------------------------
62     java-pkg-2_pkg_setup() {
63     java-pkg_init
64 betelgeuse 1.5 java-pkg_ensure-test
65 nichoj 1.1 }
66    
67     # ------------------------------------------------------------------------------
68 caster 1.30 # @eclass-src_prepare
69     #
70     # wrapper for java-utils-2_src_prepare
71     # ------------------------------------------------------------------------------
72     java-pkg-2_src_prepare() {
73     java-utils-2_src_prepare
74     }
75    
76     # ------------------------------------------------------------------------------
77 betelgeuse 1.6 # @eclass-src_compile
78     #
79     # Default src_compile for java packages
80     # variables:
81     # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
82 betelgeuse 1.10 # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
83 betelgeuse 1.6 # EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
84     # EANT_DOC_TARGET - the target to build extra docs under the doc use flag
85 caster 1.22 # (default: javadoc; declare empty to disable completely)
86 betelgeuse 1.12 # EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
87 betelgeuse 1.16 # EANT_EXTRA_ARGS - extra arguments to pass to eant
88 betelgeuse 1.17 # EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
89 betelgeuse 1.15 # param: Parameters are passed to ant verbatim
90 betelgeuse 1.6 # ------------------------------------------------------------------------------
91     java-pkg-2_src_compile() {
92     if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
93 betelgeuse 1.10 [[ "${EANT_FILTER_COMPILER}" ]] && \
94     java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
95 betelgeuse 1.6 local antflags="${EANT_BUILD_TARGET:=jar}"
96 ssuominen 1.36 if has doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
97 caster 1.22 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
98     fi
99 betelgeuse 1.20 local tasks
100     [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
101 betelgeuse 1.21 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
102 betelgeuse 1.17 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
103 betelgeuse 1.6 else
104 betelgeuse 1.18 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
105 betelgeuse 1.6 fi
106     }
107    
108 betelgeuse 1.34 java-pkg-2_supports-test() {
109     python << EOF
110     from xml.dom.minidom import parse
111     import sys
112     dom = parse("${1}")
113     for elem in dom.getElementsByTagName('target'):
114     if elem.getAttribute('name') == 'test':
115     sys.exit(0)
116     sys.exit(1)
117     EOF
118     return $?
119     }
120    
121     java-pkg-2_src_test() {
122     [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
123    
124     if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
125     local opts task
126    
127     if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
128     java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
129     fi
130    
131     ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
132    
133     if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
134    
135     if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
136     ANT_TASKS="${ANT_TASKS} ant-junit"
137     else
138     ANT_TASKS="ant-junit"
139     fi
140    
141     task=true
142     fi
143    
144     if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
145     opts="-Djunit.jar=\"$(java-pkg_getjar junit junit.jar)\""
146     if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
147     EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH},junit"
148     elif [[ ${EANT_GENTOO_CLASSPATH} ]]; then
149     EANT_GENTOO_CLASSPATH+=',junit'
150     else
151     EANT_GENTOO_CLASSPATH=junit
152     fi
153     fi
154    
155     eant ${opts} -f "${EANT_BUILD_XML}" \
156     ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
157    
158     else
159     echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
160     fi
161     }
162    
163 serkan 1.33 # ------------------------------------------------------------------------------
164     # @eclass-pkg_preinst
165     #
166     # wrapper for java-utils-2_pkg_preinst
167     # ------------------------------------------------------------------------------
168 betelgeuse 1.29 java-pkg-2_pkg_preinst() {
169 serkan 1.33 java-utils-2_pkg_preinst
170 betelgeuse 1.29 }
171    
172 betelgeuse 1.6 # ------------------------------------------------------------------------------
173 nichoj 1.1 # @eclass-end
174     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20