/[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.3 Revision 1.39
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-2011, 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.39 2012/07/21 11:57:30 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.
8 19
9inherit java-utils-2 20inherit java-utils-2
10 21
11# ----------------------------------------------------------------------------- 22# @ECLASS-VARIABLE: JAVA_PKG_IUSE
12# @eclass-begin 23# @DEFAULT_UNSET
13# @eclass-summary Eclass for Java Packages 24# @DESCRIPTION:
14# 25# Use JAVA_PKG_IUSE instead of IUSE for doc, source and examples so that
15# 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*
16# need to use Java. 27# functions.
17# ----------------------------------------------------------------------------- 28IUSE="${JAVA_PKG_IUSE}"
18 29
19# ------------------------------------------------------------------------------
20# @depend
21#
22# 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.
23#
24# JAVA_PKG_E_DEPEND is defined in java-utils.eclass. 31# JAVA_PKG_E_DEPEND is defined in java-utils.eclass.
25# ------------------------------------------------------------------------------
26DEPEND="${JAVA_PKG_E_DEPEND}" 32DEPEND="${JAVA_PKG_E_DEPEND}"
27 33
28# ------------------------------------------------------------------------------
29# @rdepend
30#
31# Nothing special for RDEPEND... just the same as DEPEND. 34# Nothing special for RDEPEND... just the same as DEPEND.
32# ------------------------------------------------------------------------------
33RDEPEND="${DEPEND}" 35RDEPEND="${DEPEND}"
34 36
35EXPORT_FUNCTIONS pkg_setup 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
36 42
37# ------------------------------------------------------------------------------ 43case "${EAPI:-0}" in
38# @eclass-pkg_setup 44 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;;
39# 45 *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;;
46esac
47
48# @FUNCTION: java-pkg-2_pkg_setup
49# @DESCRIPTION:
40# pkg_setup initializes the Java environment 50# pkg_setup initializes the Java environment
41# ------------------------------------------------------------------------------ 51
42java-pkg-2_pkg_setup() { 52java-pkg-2_pkg_setup() {
43 java-pkg_init 53 java-pkg_init
44} 54}
45 55
46# ------------------------------------------------------------------------------
47# @note
48#
49# We need to initialize the environment in every function because Portage
50# will source /etc/profile between phases and trample all over the env.
51# This is accomplished by phase hooks, which is available with newer versions of
52# portage.
53# ------------------------------------------------------------------------------
54 56
55pre_pkg_setup() { 57# @FUNCTION: java-pkg-2_src_prepare
56 java-pkg-2_pkg_setup 58# @DESCRIPTION:
59# wrapper for java-utils-2_src_prepare
60
61java-pkg-2_src_prepare() {
62 java-utils-2_src_prepare
57} 63}
58 64
59pre_src_unpack() { 65
60 java-pkg-2_pkg_setup 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
82java-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
61} 97}
62 98
63pre_src_compile() { 99
64 java-pkg-2_pkg_setup 100# @FUNCTION: java-pkg-2_supports-test
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 $?
65} 116}
66 117
67pre_src_install() { 118# @FUNCTION: java-pkg-2_src_test
68 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
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
69} 162}
70 163
71pre_src_test() { 164# @FUNCTION: java-pkg-2_pkg_preinst
72 java-pkg-2_pkg_setup 165# @DESCRIPTION:
166# wrapper for java-utils-2_pkg_preinst
167
168java-pkg-2_pkg_preinst() {
169 java-utils-2_pkg_preinst
73} 170}
74
75pre_pkg_preinst() {
76 java-pkg-2_pkg_setup
77}
78
79pre_pkg_postinst() {
80 java-pkg-2_pkg_setup
81}
82
83# ------------------------------------------------------------------------------
84# @eclass-end
85# ------------------------------------------------------------------------------

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.39

  ViewVC Help
Powered by ViewVC 1.1.20