/[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.41 - (show annotations) (download)
Wed Jun 17 09:48:12 2015 UTC (6 weeks, 3 days ago) by chewi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.40: +2 -21 lines
Remove eclass dependency on python[xml] and replace with some ugly
grep that should suffice. Closes #552332.

1 # Eclass for Java packages
2 #
3 # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4 # Copyright (c) 2004-2015, 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.40 2015/04/28 20:35:40 chewi 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 # @FUNCTION: java-pkg-2_src_test
100 # @DESCRIPTION:
101 # src_test, not exported.
102
103 java-pkg-2_src_test() {
104 [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
105
106 if [[ ${EANT_TEST_TARGET} ]] || < "${EANT_BUILD_XML}" tr -d "\n" | grep -Eq "<target\b[^>]*\bname=[\"']test[\"']"; then
107 local opts task_re junit_re pkg
108
109 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
110 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
111 fi
112
113 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
114 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH}"
115 fi
116
117 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
118
119 task_re="\bdev-java/ant-junit(4)?(-[^:]+)?(:\S+)\b"
120 junit_re="\bdev-java/junit(-[^:]+)?(:\S+)\b"
121
122 if [[ ${DEPEND} =~ ${task_re} ]]; then
123 pkg="ant-junit${BASH_REMATCH[1]}${BASH_REMATCH[3]}"
124 pkg="${pkg%:0}"
125
126 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
127 ANT_TASKS="${ANT_TASKS} ${pkg}"
128 else
129 ANT_TASKS="${pkg}"
130 fi
131 elif [[ ${DEPEND} =~ ${junit_re} ]]; then
132 pkg="junit${BASH_REMATCH[2]}"
133 pkg="${pkg%:0}"
134
135 opts="-Djunit.jar=\"$(java-pkg_getjar ${pkg} junit.jar)\""
136
137 if [[ ${EANT_GENTOO_CLASSPATH} ]]; then
138 EANT_GENTOO_CLASSPATH+=",${pkg}"
139 else
140 EANT_GENTOO_CLASSPATH="${pkg}"
141 fi
142 fi
143
144 eant ${opts} -f "${EANT_BUILD_XML}" \
145 ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
146
147 else
148 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
149 fi
150 }
151
152 # @FUNCTION: java-pkg-2_pkg_preinst
153 # @DESCRIPTION:
154 # wrapper for java-utils-2_pkg_preinst
155
156 java-pkg-2_pkg_preinst() {
157 java-utils-2_pkg_preinst
158 }

  ViewVC Help
Powered by ViewVC 1.1.20