/[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.38
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.38 2012/06/04 08:27:42 sera Exp $
8 9
9inherit java-utils-2 10inherit java-utils-2
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-summary Eclass for Java Packages 14# @eclass-summary Eclass for Java Packages
14# 15#
15# 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
16# need to use Java. 17# need to use Java.
17# ----------------------------------------------------------------------------- 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# ------------------------------------------------------------------------------
28IUSE="${JAVA_PKG_IUSE}"
18 29
19# ------------------------------------------------------------------------------ 30# ------------------------------------------------------------------------------
20# @depend 31# @depend
21# 32#
22# 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.
30# 41#
31# Nothing special for RDEPEND... just the same as DEPEND. 42# Nothing special for RDEPEND... just the same as DEPEND.
32# ------------------------------------------------------------------------------ 43# ------------------------------------------------------------------------------
33RDEPEND="${DEPEND}" 44RDEPEND="${DEPEND}"
34 45
35EXPORT_FUNCTIONS pkg_setup 46# Commons packages follow the same rules so do it here
47if [[ ${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"
50fi
51
52case "${EAPI:-0}" in
53 0|1) EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst ;;
54 *) EXPORT_FUNCTIONS pkg_setup src_prepare src_compile pkg_preinst ;;
55esac
36 56
37# ------------------------------------------------------------------------------ 57# ------------------------------------------------------------------------------
38# @eclass-pkg_setup 58# @eclass-pkg_setup
39# 59#
40# pkg_setup initializes the Java environment 60# pkg_setup initializes the Java environment
42java-pkg-2_pkg_setup() { 62java-pkg-2_pkg_setup() {
43 java-pkg_init 63 java-pkg_init
44} 64}
45 65
46# ------------------------------------------------------------------------------ 66# ------------------------------------------------------------------------------
47# @note 67# @eclass-src_prepare
48# 68#
49# We need to initialize the environment in every function because Portage 69# wrapper for java-utils-2_src_prepare
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# ------------------------------------------------------------------------------ 70# ------------------------------------------------------------------------------
54 71java-pkg-2_src_prepare() {
55pre_pkg_setup() { 72 java-utils-2_src_prepare
56 java-pkg-2_pkg_setup
57} 73}
58 74
59pre_src_unpack() { 75# ------------------------------------------------------------------------------
60 java-pkg-2_pkg_setup 76# @eclass-src_compile
77#
78# Default src_compile for java packages
79# variables:
80# EANT_BUILD_XML - controls the location of the build.xml (default: ./build.xml)
81# EANT_FILTER_COMPILER - Calls java-pkg_filter-compiler with the value
82# EANT_BUILD_TARGET - the ant target/targets to execute (default: jar)
83# EANT_DOC_TARGET - the target to build extra docs under the doc use flag
84# (default: javadoc; declare empty to disable completely)
85# EANT_GENTOO_CLASSPATH - @see eant documention in java-utils-2.eclass
86# EANT_EXTRA_ARGS - extra arguments to pass to eant
87# EANT_ANT_TASKS - modifies the ANT_TASKS variable in the eant environment
88# param: Parameters are passed to ant verbatim
89# ------------------------------------------------------------------------------
90java-pkg-2_src_compile() {
91 if [[ -e "${EANT_BUILD_XML:=build.xml}" ]]; then
92 [[ "${EANT_FILTER_COMPILER}" ]] && \
93 java-pkg_filter-compiler ${EANT_FILTER_COMPILER}
94 local antflags="${EANT_BUILD_TARGET:=jar}"
95 if has doc ${IUSE} && [[ -n "${EANT_DOC_TARGET=javadoc}" ]]; then
96 antflags="${antflags} $(use_doc ${EANT_DOC_TARGET})"
97 fi
98 local tasks
99 [[ ${EANT_ANT_TASKS} ]] && tasks="${ANT_TASKS} ${EANT_ANT_TASKS}"
100 ANT_TASKS="${tasks:-${ANT_TASKS}}" \
101 eant ${antflags} -f "${EANT_BUILD_XML}" ${EANT_EXTRA_ARGS} "${@}"
102 else
103 echo "${FUNCNAME}: ${EANT_BUILD_XML} not found so nothing to do."
104 fi
61} 105}
62 106
63pre_src_compile() { 107java-pkg-2_supports-test() {
64 java-pkg-2_pkg_setup 108 python << EOF
109from xml.dom.minidom import parse
110import sys
111dom = parse("${1}")
112for elem in dom.getElementsByTagName('target'):
113 if elem.getAttribute('name') == 'test':
114 sys.exit(0)
115sys.exit(1)
116EOF
117 return $?
65} 118}
66 119
67pre_src_install() { 120java-pkg-2_src_test() {
68 java-pkg-2_pkg_setup 121 [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
122
123 if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
124 local opts task
125
126 if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
127 java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
128 fi
129
130 ANT_TASKS=${EANT_TEST_ANT_TASKS:-${ANT_TASKS:-${EANT_ANT_TASKS}}}
131
132 if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
133
134 if [[ ${ANT_TASKS} && "${ANT_TASKS}" != none ]]; then
135 ANT_TASKS="${ANT_TASKS} ant-junit"
136 else
137 ANT_TASKS="ant-junit"
138 fi
139
140 task=true
141 fi
142
143 if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
144 opts="-Djunit.jar=\"$(java-pkg_getjar junit junit.jar)\""
145 if [[ ${EANT_TEST_GENTOO_CLASSPATH} ]]; then
146 EANT_GENTOO_CLASSPATH="${EANT_TEST_GENTOO_CLASSPATH},junit"
147 elif [[ ${EANT_GENTOO_CLASSPATH} ]]; then
148 EANT_GENTOO_CLASSPATH+=',junit'
149 else
150 EANT_GENTOO_CLASSPATH=junit
151 fi
152 fi
153
154 eant ${opts} -f "${EANT_BUILD_XML}" \
155 ${EANT_EXTRA_ARGS} ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
156
157 else
158 echo "${FUNCNAME}: No test target in ${EANT_BUILD_XML}"
159 fi
69} 160}
70 161
71pre_src_test() { 162# ------------------------------------------------------------------------------
72 java-pkg-2_pkg_setup 163# @eclass-pkg_preinst
73} 164#
74 165# wrapper for java-utils-2_pkg_preinst
166# ------------------------------------------------------------------------------
75pre_pkg_preinst() { 167java-pkg-2_pkg_preinst() {
76 java-pkg-2_pkg_setup 168 java-utils-2_pkg_preinst
77}
78
79pre_pkg_postinst() {
80 java-pkg-2_pkg_setup
81} 169}
82 170
83# ------------------------------------------------------------------------------ 171# ------------------------------------------------------------------------------
84# @eclass-end 172# @eclass-end
85# ------------------------------------------------------------------------------ 173# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20