/[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.39 - (show annotations) (download)
Sat Jul 21 11:57:30 2012 UTC (2 years, 3 months ago) by sera
Branch: MAIN
CVS Tags: HEAD
Changes since 1.38: +49 -52 lines
Convert documentation to eclass-manpages.

1 # Eclass for Java packages
2 #
3 # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4 # Copyright (c) 2004-2011, 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.38 2012/06/04 08:27:42 sera Exp $
9
10 # @ECLASS: java-pkg-2.eclass
11 # @MAINTAINER:
12 # java@gentoo.org
13 # @AUTHOR:
14 # Thomas Matthijs <axxo@gentoo.org>
15 # @BLURB: Eclass for Java Packages
16 # @DESCRIPTION:
17 # This eclass should be inherited for pure Java packages, or by packages which
18 # need to use Java.
19
20 inherit java-utils-2
21
22 # @ECLASS-VARIABLE: JAVA_PKG_IUSE
23 # @DEFAULT_UNSET
24 # @DESCRIPTION:
25 # Use JAVA_PKG_IUSE instead of IUSE for doc, source and examples so that
26 # the eclass can automatically add the needed dependencies for the java-pkg_do*
27 # functions.
28 IUSE="${JAVA_PKG_IUSE}"
29
30 # Java packages need java-config, and a fairly new release of Portage.
31 # JAVA_PKG_E_DEPEND is defined in java-utils.eclass.
32 DEPEND="${JAVA_PKG_E_DEPEND}"
33
34 # Nothing special for RDEPEND... just the same as DEPEND.
35 RDEPEND="${DEPEND}"
36
37 # Commons packages follow the same rules so do it here
38 if [[ ${CATEGORY} = dev-java && ${PN} = commons-* ]]; then
39 HOMEPAGE="http://commons.apache.org/${PN#commons-}/"
40 SRC_URI="mirror://apache/${PN/-///}/source/${P}-src.tar.gz"
41 fi
42
43 case "${EAPI:-0}" in
44 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;;
45 *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;;
46 esac
47
48 # @FUNCTION: java-pkg-2_pkg_setup
49 # @DESCRIPTION:
50 # pkg_setup initializes the Java environment
51
52 java-pkg-2_pkg_setup() {
53 java-pkg_init
54 }
55
56
57 # @FUNCTION: java-pkg-2_src_prepare
58 # @DESCRIPTION:
59 # wrapper for java-utils-2_src_prepare
60
61 java-pkg-2_src_prepare() {
62 java-utils-2_src_prepare
63 }
64
65
66 # @FUNCTION: java-pkg-2_src_compile
67 # @DESCRIPTION:
68 # Default src_compile for java packages
69 #
70 # @CODE
71 # Variables:
72 # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
73 # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
74 # EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
75 # EANT_DOC_TARGET - the target to build extra docs under the doc use flag
76 # (default: javadoc; declare empty to disable completely)
77 # EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
78 # EANT_EXTRA_ARGS - extra arguments to pass to eant
79 # EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
80 # @CODE
81
82 java-pkg-2_src_compile() {
83 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
84 [[ "${EANT_FILTER_COMPILER}" ]] && \
85 java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
86 local antflags="${EANT_BUILD_TARGET:=jar}"
87 if has doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
88 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
89 fi
90 local tasks
91 [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
92 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
93 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
94 else
95 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
96 fi
97 }
98
99
100 # @FUNCTION: java-pkg-2_supports-test
101 # @INTERNAL
102 # @DESCRIPTION:
103 # test whether a build.xml has a test target.
104
105 java-pkg-2_supports-test() {
106 python << EOF
107 from xml.dom.minidom import parse
108 import sys
109 dom = parse("${1}")
110 for elem in dom.getElementsByTagName('target'):
111 if elem.getAttribute('name') == 'test':
112 sys.exit(0)
113 sys.exit(1)
114 EOF
115 return $?
116 }
117
118 # @FUNCTION: java-pkg-2_src_test
119 # @DESCRIPTION:
120 # src_test, not exported.
121
122 java-pkg-2_src_test() {
123 [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
124
125 if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
126 local opts task
127
128 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
129 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
130 fi
131
132 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
133
134 if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
135
136 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
137 ANT_TASKS="${ANT_TASKS} ant-junit"
138 else
139 ANT_TASKS="ant-junit"
140 fi
141
142 task=true
143 fi
144
145 if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
146 opts="-Djunit.jar=\"$(java-pkg_getjar junit junit.jar)\""
147 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
148 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH},junit"
149 elif [[ ${EANT_GENTOO_CLASSPATH} ]]; then
150 EANT_GENTOO_CLASSPATH+=',junit'
151 else
152 EANT_GENTOO_CLASSPATH=junit
153 fi
154 fi
155
156 eant ${opts} -f "${EANT_BUILD_XML}" \
157 ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
158
159 else
160 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
161 fi
162 }
163
164 # @FUNCTION: java-pkg-2_pkg_preinst
165 # @DESCRIPTION:
166 # wrapper for java-utils-2_pkg_preinst
167
168 java-pkg-2_pkg_preinst() {
169 java-utils-2_pkg_preinst
170 }

  ViewVC Help
Powered by ViewVC 1.1.20