/[gentoo-x86]/eclass/java-pkg-2.eclass
Gentoo

Diff of /eclass/java-pkg-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.18 Revision 1.40
1# Eclass for Java packages 1# Eclass for Java packages
2# 2#
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-2015, 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.18 2007/01/28 19:53:17 betelgeuse Exp $ 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.
9 19
10inherit java-utils-2 20inherit java-utils-2
11 21
12# ----------------------------------------------------------------------------- 22# @ECLASS-VARIABLE: JAVA_PKG_IUSE
13# @eclass-begin 23# @DEFAULT_UNSET
14# @eclass-summary Eclass for Java Packages 24# @DESCRIPTION:
15# 25# Use JAVA_PKG_IUSE instead of IUSE for doc, source and examples so that
16# This eclass should be inherited for pure Java packages, or by packages which 26# the eclass can automatically add the needed dependencies for the java-pkg_do*
17# need to use Java. 27# functions.
18# -----------------------------------------------------------------------------
19
20# ------------------------------------------------------------------------------
21# @IUSE
22#
23# ebuilds using this eclass can set JAVA_PKG_IUSE and then this eclass
24# will automatically add deps for them.
25#
26# ------------------------------------------------------------------------------
27IUSE="${JAVA_PKG_IUSE}" 28IUSE="${JAVA_PKG_IUSE}"
28 29
29# ------------------------------------------------------------------------------
30# @depend
31#
32# Java packages need java-config, and a fairly new release of Portage. 30# Java packages need java-config, and a fairly new release of Portage.
33#
34# JAVA_PKG_E_DEPEND is defined in java-utils.eclass. 31# JAVA_PKG_E_DEPEND is defined in java-utils.eclass.
35# ------------------------------------------------------------------------------
36DEPEND="${JAVA_PKG_E_DEPEND}" 32DEPEND="${JAVA_PKG_E_DEPEND}"
37 33
38hasq source ${JAVA_PKG_IUSE} && DEPEND="${DEPEND} source? ( app-arch/zip )"
39
40# ------------------------------------------------------------------------------
41# @rdepend
42#
43# Nothing special for RDEPEND... just the same as DEPEND. 34# Nothing special for RDEPEND... just the same as DEPEND.
44# ------------------------------------------------------------------------------
45RDEPEND="${DEPEND}" 35RDEPEND="${DEPEND}"
46 36
47EXPORT_FUNCTIONS pkg_setup src_compile 37# Commons packages follow the same rules so do it here
38if [[ ${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"
41fi
48 42
49# ------------------------------------------------------------------------------ 43case "${EAPI:-0}" in
50# @eclass-pkg_setup 44 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;;
51# 45 *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;;
46esac
47
48# @FUNCTION: java-pkg-2_pkg_setup
49# @DESCRIPTION:
52# pkg_setup initializes the Java environment 50# pkg_setup initializes the Java environment
53# ------------------------------------------------------------------------------ 51
54java-pkg-2_pkg_setup() { 52java-pkg-2_pkg_setup() {
55 java-pkg_init 53 java-pkg_init
56 java-pkg_ensure-test
57} 54}
58 55
59# ------------------------------------------------------------------------------ 56
60# @eclass-src_compile 57# @FUNCTION: java-pkg-2_src_prepare
58# @DESCRIPTION:
59# wrapper for java-utils-2_src_prepare
60
61java-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
61# 69#
62# Default src_compile for java packages 70# @CODE
63# variables: 71# Variables:
64# EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml) 72# EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
65# EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value 73# EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
66# EANT_BUILD_TARGET - the ant target/targets to execute (default: jar) 74# EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
67# EANT_DOC_TARGET - the target to build extra docs under the doc use flag 75# EANT_DOC_TARGET - the target to build extra docs under the doc use flag
68# (default: the one provided by use_doc in 76# (default: javadoc; declare empty to disable completely)
69# java-utils-2.eclass)
70# EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass 77# EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
71# EANT_EXTRA_ARGS - extra arguments to pass to eant 78# EANT_EXTRA_ARGS - extra arguments to pass to eant
72# EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment 79# EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
73# param: Parameters are passed to ant verbatim 80# @CODE
74# ------------------------------------------------------------------------------ 81
75java-pkg-2_src_compile() { 82java-pkg-2_src_compile() {
76 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then 83 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
77 if ! hasq java-ant-2 ${INHERITED}; then
78 msg="You should inherit java-ant-2 always when using eant"
79 ewarn ${msg}
80 is-java-strict && die ${msg}
81 fi
82 [[ "${EANT_FILTER_COMPILER}" ]] && \ 84 [[ "${EANT_FILTER_COMPILER}" ]] && \
83 java-pkg_filter-compiler ${EANT_FILTER_COMPILER} 85 java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
84
85 local antflags="${EANT_BUILD_TARGET:=jar}" 86 local antflags="${EANT_BUILD_TARGET:=jar}"
87 if has doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
86 hasq doc ${IUSE} && antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})" 88 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
89 fi
90 local tasks
87 ANT_TASKS="${ANT_TASKS} ${EANT_ANT_TASKS}" \ 91 [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
92 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
88 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}" 93 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
89 else 94 else
90 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do." 95 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
91 fi 96 fi
92} 97}
93 98
94# ------------------------------------------------------------------------------
95# @note
96#
97# We need to initialize the environment in every function because Portage
98# will source /etc/profile between phases and trample all over the env.
99# This is accomplished by phase hooks, which is available with newer versions of
100# portage.
101# ------------------------------------------------------------------------------
102 99
103pre_pkg_setup() { 100# @FUNCTION: java-pkg-2_supports-test
104 java-pkg-2_pkg_setup 101# @INTERNAL
102# @DESCRIPTION:
103# test whether a build.xml has a test target.
104
105java-pkg-2_supports-test() {
106 python << EOF
107from xml.dom.minidom import parse
108import sys
109dom = parse("${1}")
110for elem in dom.getElementsByTagName('target'):
111 if elem.getAttribute('name') == 'test':
112 sys.exit(0)
113sys.exit(1)
114EOF
115 return $?
105} 116}
106 117
107pre_src_unpack() { 118# @FUNCTION: java-pkg-2_src_test
108 java-pkg-2_pkg_setup 119# @DESCRIPTION:
120# src_test, not exported.
121
122java-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_re junit_re pkg
127
128 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
129 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
130 fi
131
132 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
133 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH}"
134 fi
135
136 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
137
138 task_re="\bdev-java/ant-junit(4)?(-[^:]+)?(:\S+)\b"
139 junit_re="\bdev-java/junit(-[^:]+)?(:\S+)\b"
140
141 if [[ ${DEPEND} =~ ${task_re} ]]; then
142 pkg="ant-junit${BASH_REMATCH[1]}${BASH_REMATCH[3]}"
143 pkg="${pkg%:0}"
144
145 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
146 ANT_TASKS="${ANT_TASKS} ${pkg}"
147 else
148 ANT_TASKS="${pkg}"
149 fi
150 elif [[ ${DEPEND} =~ ${junit_re} ]]; then
151 pkg="junit${BASH_REMATCH[2]}"
152 pkg="${pkg%:0}"
153
154 opts="-Djunit.jar=\"$(java-pkg_getjar ${pkg} junit.jar)\""
155
156 if [[ ${EANT_GENTOO_CLASSPATH} ]]; then
157 EANT_GENTOO_CLASSPATH+=",${pkg}"
158 else
159 EANT_GENTOO_CLASSPATH="${pkg}"
160 fi
161 fi
162
163 eant ${opts} -f "${EANT_BUILD_XML}" \
164 ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
165
166 else
167 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
168 fi
109} 169}
110 170
111pre_src_compile() { 171# @FUNCTION: java-pkg-2_pkg_preinst
112 if is-java-strict; then 172# @DESCRIPTION:
113 echo "Searching for bundled jars:" 173# wrapper for java-utils-2_pkg_preinst
114 java-pkg_find-normal-jars || echo "None found." 174
115 fi 175java-pkg-2_pkg_preinst() {
116 java-pkg-2_pkg_setup 176 java-utils-2_pkg_preinst
117} 177}
118
119pre_src_install() {
120 java-pkg-2_pkg_setup
121}
122
123pre_src_test() {
124 java-pkg-2_pkg_setup
125}
126
127pre_pkg_preinst() {
128 java-pkg-2_pkg_setup
129}
130
131pre_pkg_postinst() {
132 java-pkg-2_pkg_setup
133}
134
135# ------------------------------------------------------------------------------
136# @eclass-end
137# ------------------------------------------------------------------------------

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.20