… | |
… | |
3 | # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> |
3 | # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> |
4 | # Copyright (c) 2004-2005, Gentoo Foundation |
4 | # Copyright (c) 2004-2005, Gentoo Foundation |
5 | # |
5 | # |
6 | # Licensed under the GNU General Public License, v2 |
6 | # Licensed under the GNU General Public License, v2 |
7 | # |
7 | # |
8 | # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.10 2007/01/10 09:59:21 betelgeuse Exp $ |
8 | # $Header: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v 1.36 2011/07/08 11:35:01 ssuominen Exp $ |
9 | |
9 | |
10 | inherit java-utils-2 |
10 | inherit java-utils-2 |
11 | |
11 | |
12 | # ----------------------------------------------------------------------------- |
12 | # ----------------------------------------------------------------------------- |
13 | # @eclass-begin |
13 | # @eclass-begin |
14 | # @eclass-summary Eclass for Java Packages |
14 | # @eclass-summary Eclass for Java Packages |
15 | # |
15 | # |
16 | # This eclass should be inherited for pure Java packages, or by packages which |
16 | # This eclass should be inherited for pure Java packages, or by packages which |
17 | # need to use Java. |
17 | # need to use Java. |
18 | # ----------------------------------------------------------------------------- |
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}" |
19 | |
29 | |
20 | # ------------------------------------------------------------------------------ |
30 | # ------------------------------------------------------------------------------ |
21 | # @depend |
31 | # @depend |
22 | # |
32 | # |
23 | # Java packages need java-config, and a fairly new release of Portage. |
33 | # Java packages need java-config, and a fairly new release of Portage. |
… | |
… | |
31 | # |
41 | # |
32 | # Nothing special for RDEPEND... just the same as DEPEND. |
42 | # Nothing special for RDEPEND... just the same as DEPEND. |
33 | # ------------------------------------------------------------------------------ |
43 | # ------------------------------------------------------------------------------ |
34 | RDEPEND="${DEPEND}" |
44 | RDEPEND="${DEPEND}" |
35 | |
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 | case "${EAPI:-0}" in |
36 | EXPORT_FUNCTIONS pkg_setup src_compile |
53 | 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;; |
|
|
54 | *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;; |
|
|
55 | esac |
37 | |
56 | |
38 | # ------------------------------------------------------------------------------ |
57 | # ------------------------------------------------------------------------------ |
39 | # @eclass-pkg_setup |
58 | # @eclass-pkg_setup |
40 | # |
59 | # |
41 | # pkg_setup initializes the Java environment |
60 | # pkg_setup initializes the Java environment |
… | |
… | |
44 | java-pkg_init |
63 | java-pkg_init |
45 | java-pkg_ensure-test |
64 | java-pkg_ensure-test |
46 | } |
65 | } |
47 | |
66 | |
48 | # ------------------------------------------------------------------------------ |
67 | # ------------------------------------------------------------------------------ |
|
|
68 | # @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 | # ------------------------------------------------------------------------------ |
49 | # @eclass-src_compile |
77 | # @eclass-src_compile |
50 | # |
78 | # |
51 | # Default src_compile for java packages |
79 | # Default src_compile for java packages |
52 | # variables: |
80 | # variables: |
53 | # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml) |
81 | # EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml) |
54 | # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value |
82 | # EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value |
55 | # EANT_BUILD_TARGET - the ant target/targets to execute (default: jar) |
83 | # EANT_BUILD_TARGET - the ant target/targets to execute (default: jar) |
56 | # EANT_DOC_TARGET - the target to build extra docs under the doc use flag |
84 | # EANT_DOC_TARGET - the target to build extra docs under the doc use flag |
57 | # (default: the one provided by use_doc in |
85 | # (default: javadoc; declare empty to disable completely) |
58 | # java-utils-2.eclass) |
86 | # EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass |
|
|
87 | # EANT_EXTRA_ARGS - extra arguments to pass to eant |
|
|
88 | # EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment |
|
|
89 | # param: Parameters are passed to ant verbatim |
59 | # ------------------------------------------------------------------------------ |
90 | # ------------------------------------------------------------------------------ |
60 | java-pkg-2_src_compile() { |
91 | java-pkg-2_src_compile() { |
61 | if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then |
92 | if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then |
62 | [[ "${EANT_FILTER_COMPILER}" ]] && \ |
93 | [[ "${EANT_FILTER_COMPILER}" ]] && \ |
63 | java-pkg_filter-compiler ${EANT_FILTER_COMPILER} |
94 | java-pkg_filter-compiler ${EANT_FILTER_COMPILER} |
|
|
95 | local antflags="${EANT_BUILD_TARGET:=jar}" |
|
|
96 | if has doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then |
|
|
97 | antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})" |
|
|
98 | fi |
|
|
99 | local tasks |
|
|
100 | [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}" |
|
|
101 | ANT_TASKS="${tasks:-${ANT_TASKS}}" \ |
|
|
102 | eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}" |
|
|
103 | else |
|
|
104 | echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do." |
|
|
105 | fi |
|
|
106 | } |
64 | |
107 | |
65 | local antflags="${EANT_BUILD_TARGET:=jar}" |
108 | java-pkg-2_supports-test() { |
66 | hasq doc ${IUSE} && antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})" |
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 | |
67 | eant ${antflags} -f "${EANT_BUILD_XML}" |
155 | eant ${opts} -f "${EANT_BUILD_XML}" \ |
|
|
156 | ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test} |
|
|
157 | |
68 | else |
158 | else |
69 | echo "${FUNCNAME}: No build.xml found so nothing to do." |
159 | echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}" |
70 | fi |
160 | fi |
71 | } |
161 | } |
72 | |
162 | |
73 | # ------------------------------------------------------------------------------ |
163 | # ------------------------------------------------------------------------------ |
74 | # @note |
164 | # @eclass-pkg_preinst |
75 | # |
165 | # |
76 | # We need to initialize the environment in every function because Portage |
166 | # wrapper for java-utils-2_pkg_preinst |
77 | # will source /etc/profile between phases and trample all over the env. |
|
|
78 | # This is accomplished by phase hooks, which is available with newer versions of |
|
|
79 | # portage. |
|
|
80 | # ------------------------------------------------------------------------------ |
167 | # ------------------------------------------------------------------------------ |
81 | |
|
|
82 | pre_pkg_setup() { |
|
|
83 | java-pkg-2_pkg_setup |
|
|
84 | } |
|
|
85 | |
|
|
86 | pre_src_unpack() { |
|
|
87 | java-pkg-2_pkg_setup |
|
|
88 | } |
|
|
89 | |
|
|
90 | pre_src_compile() { |
|
|
91 | if is-java-strict; then |
|
|
92 | echo "Searching for bundled jars:" |
|
|
93 | java-pkg_find-normal-jars || echo "None found." |
|
|
94 | fi |
|
|
95 | java-pkg-2_pkg_setup |
|
|
96 | } |
|
|
97 | |
|
|
98 | pre_src_install() { |
|
|
99 | java-pkg-2_pkg_setup |
|
|
100 | } |
|
|
101 | |
|
|
102 | pre_src_test() { |
|
|
103 | java-pkg-2_pkg_setup |
|
|
104 | } |
|
|
105 | |
|
|
106 | pre_pkg_preinst() { |
168 | java-pkg-2_pkg_preinst() { |
107 | java-pkg-2_pkg_setup |
169 | java-utils-2_pkg_preinst |
108 | } |
|
|
109 | |
|
|
110 | pre_pkg_postinst() { |
|
|
111 | java-pkg-2_pkg_setup |
|
|
112 | } |
170 | } |
113 | |
171 | |
114 | # ------------------------------------------------------------------------------ |
172 | # ------------------------------------------------------------------------------ |
115 | # @eclass-end |
173 | # @eclass-end |
116 | # ------------------------------------------------------------------------------ |
174 | # ------------------------------------------------------------------------------ |