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

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

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

Revision 1.154 Revision 1.155
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2011, Gentoo Foundation 5# Copyright (c) 2004-2011, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.154 2013/08/27 05:32:28 radhermit Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.155 2013/10/06 14:37:31 caster Exp $
10 10
11# ----------------------------------------------------------------------------- 11# @ECLASS: java-utils-2.eclass
12# @eclass-begin 12# @MAINTAINER:
13# @eclass-shortdesc Java Utility eclass 13# java@gentoo.org
14# @eclass-maintainer java@gentoo.org 14# @AUTHOR:
15# 15# Thomas Matthijs <axxo@gentoo.org>, Karl Trygve Kalleberg <karltk@gentoo.org>
16# @BLURB: Base eclass for Java packages
17# @DESCRIPTION:
16# This eclass provides functionality which is used by 18# This eclass provides functionality which is used by java-pkg-2.eclass,
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 19# java-pkg-opt-2.eclass and java-ant-2 eclass, as well as from ebuilds.
18# 20#
19# @warning 21# This eclass should not be inherited this directly from an ebuild. Instead,
20# You probably don't want to inherit this directly from an ebuild. Instead, 22# you should inherit java-pkg-2 for Java packages or java-pkg-opt-2 for packages
21# you should inherit java-ant for Ant-based Java packages, java-pkg for other 23# that have optional Java support. In addition you can inherit java-ant-2 for
22# Java packages, or java-pkg-opt for packages that have optional Java support. 24# Ant-based packages.
23#
24# -----------------------------------------------------------------------------
25
26inherit eutils versionator multilib 25inherit eutils versionator multilib
27 26
28IUSE="elibc_FreeBSD" 27IUSE="elibc_FreeBSD"
29
30# -----------------------------------------------------------------------------
31# @section-begin variables
32# @section-title Variables
33#
34# Summary of variables which control the behavior of building Java packges.
35# -----------------------------------------------------------------------------
36 28
37# Make sure we use java-config-2 29# Make sure we use java-config-2
38export WANT_JAVA_CONFIG="2" 30export WANT_JAVA_CONFIG="2"
39 31
40# ----------------------------------------------------------------------------- 32# @VARIABLE: JAVA_PKG_PORTAGE_DEP
41# @variable-external WANT_ANT_TASKS 33# @INTERNAL
42# @variable-default "" 34# @DESCRIPTION:
43#
44# An $IFS separated list of ant tasks.
45# Ebuild can specify this variable before inheriting java-ant-2 eclass to
46# determine ANT_TASKS it needs. They will be automatically translated to
47# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
48# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
49# Ebuilds that need to depend conditionally on certain tasks and specify them
50# differently for different eant calls can't use this simplified approach.
51# You also cannot specify version or anything else than ant-*.
52#
53# @example WANT_ANT_TASKS="ant-junit ant-trax"
54#
55# @seealso JAVA_PKG_FORCE_ANT_TASKS
56# -----------------------------------------------------------------------------
57#WANT_ANT_TASKS
58
59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. Previously it was 35# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 36# portage with phase hooks support but now we use a version with proper env
64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps. 37# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# -----------------------------------------------------------------------------
66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 38has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 39
68# ----------------------------------------------------------------------------- 40# @VARIABLE: JAVA_PKG_E_DEPEND
69# @variable-internal JAVA_PKG_E_DEPEND 41# @INTERNAL
70# 42# @DESCRIPTION:
71# This is a convience variable to be used from the other java eclasses. This is 43# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 44# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 45# so that ebuilds can use new features without depending on specific versions.
74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}" 46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 47has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77 48
78# ----------------------------------------------------------------------------- 49# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH 50# @DEFAULT_UNSET
80# 51# @DESCRIPTION:
81# The version of bootclasspath the package needs to work. Translates to a proper 52# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath 53# dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then 54if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then 55 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98" 56 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else 57 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH" 58 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail 59 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH" 60 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi 61 fi
93fi 62fi
94 63
95# ----------------------------------------------------------------------------- 64# @ECLASS-VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE
96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 65# @DESCRIPTION:
97# @variable-default yes
98#
99# Allow this eclass to change the active VM? 66# Allow this eclass to change the active VM?
100# If your system VM isn't sufficient for the package, the build will fail. 67# If your system VM isn't sufficient for the package, the build will fail
101# @note This is useful for testing specific VMs. 68# instead of trying to switch to another VM.
102# ----------------------------------------------------------------------------- 69#
70# Overriding the default can be useful for testing specific VMs locally, but
71# should not be used in the final ebuild.
103JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} 72JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
104 73
105# ----------------------------------------------------------------------------- 74# @ECLASS-VARIABLE: JAVA_PKG_FORCE_VM
106# @variable-external JAVA_PKG_FORCE_VM 75# @DEFAULT_UNSET
107# 76# @DESCRIPTION:
108# Explicitly set a particular VM to use. If its not valid, it'll fall back to 77# Explicitly set a particular VM to use. If its not valid, it'll fall back to
109# whatever /etc/java-config-2/build/jdk.conf would elect to use. 78# whatever /etc/java-config-2/build/jdk.conf would elect to use.
110# 79#
111# Should only be used for testing and debugging. 80# Should only be used for testing and debugging.
112# 81#
113# @example Use sun-jdk-1.5 to emerge foo 82# Example: use sun-jdk-1.5 to emerge foo:
83# @CODE
114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 84# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
115# 85# @CODE
116# -----------------------------------------------------------------------------
117 86
118# ----------------------------------------------------------------------------- 87# @ECLASS-VARIABLE: JAVA_PKG_WANT_BUILD_VM
119# @variable-external JAVA_PKG_WANT_BUILD_VM 88# @DEFAULT_UNSET
120# 89# @DESCRIPTION:
121# A list of VM handles to choose a build VM from. If the list contains the 90# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a 91# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found. 92# usable/installed VM is found.
124# 93#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual. 94# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is 95# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND. 96# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well. 97# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
129# -----------------------------------------------------------------------------
130 98
131# ----------------------------------------------------------------------------- 99# @ECLASS-VARIABLE: JAVA_PKG_WANT_SOURCE
132# @variable-external JAVA_PKG_WANT_SOURCE 100# @DEFAULT_UNSET
133# 101# @DESCRIPTION:
134# Specify a specific VM version to compile for to use for -source. 102# Specify a non-standard Java source version for compilation (via javac -source
135# Normally this is determined from DEPEND. 103# parameter or Ant equivalent via build.xml rewriting done by java-ant-2 eclass).
104# Normally this is determined from the jdk version specified in DEPEND.
136# See java-pkg_get-source function below. 105# See java-pkg_get-source function below.
137# 106#
138# Should only be used for testing and debugging. 107# Should generally only be used for testing and debugging.
139# 108#
140# @seealso java-pkg_get-source
141#
142# @example Use 1.4 source to emerge baz 109# Use 1.4 source to emerge baz
110# @CODE
143# JAVA_PKG_WANT_SOURCE=1.4 emerge baz 111# JAVA_PKG_WANT_SOURCE=1.4 emerge baz
144# ----------------------------------------------------------------------------- 112# @CODE
145 113
146# ----------------------------------------------------------------------------- 114# @ECLASS-VARIABLE: JAVA_PKG_WANT_TARGET
147# @variable-external JAVA_PKG_WANT_TARGET 115# @DEFAULT_UNSET
148# 116# @DESCRIPTION:
149# Same as JAVA_PKG_WANT_SOURCE above but for -target. 117# Same as JAVA_PKG_WANT_SOURCE (see above) but for javac -target parameter,
118# which affects the version of generated bytecode.
119# Normally this is determined from the jre/jdk version specified in RDEPEND.
150# See java-pkg_get-target function below. 120# See java-pkg_get-target function below.
151# 121#
152# Should only be used for testing and debugging. 122# Should generallyonly be used for testing and debugging.
153# 123#
154# @seealso java-pkg_get-target
155#
156# @example emerge bar to be compatible with 1.3 124# emerge bar to be compatible with 1.3
125# @CODE
157# JAVA_PKG_WANT_TARGET=1.3 emerge bar 126# JAVA_PKG_WANT_TARGET=1.3 emerge bar
158# ----------------------------------------------------------------------------- 127# @CODE
159 128
160# ----------------------------------------------------------------------------- 129# @VARIABLE: JAVA_PKG_COMPILER_DIR
161# @variable-internal JAVA_PKG_COMPILER_DIR 130# @INTERNAL
162# @default /usr/share/java-config-2/compiler 131# @DESCRIPTION:
163#
164# Directory where compiler settings are saved, without trailing slash. 132# Directory where compiler settings are saved, without trailing slash.
165# Probably shouldn't touch this variable. 133# You probably shouldn't touch this variable except local testing.
166# -----------------------------------------------------------------------------
167JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 134JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
168 135
169 136# @VARIABLE: JAVA_PKG_COMPILERS_CONF
170# ----------------------------------------------------------------------------- 137# @INTERNAL
171# @variable-internal JAVA_PKG_COMPILERS_CONF 138# @DESCRIPTION:
172# @variable-default /etc/java-config-2/build/compilers.conf
173#
174# Path to file containing information about which compiler to use. 139# Path to file containing information about which compiler to use.
175# Can be overloaded, but it should be overloaded for testing. 140# Can be overloaded, but it should be overloaded only for local testing.
176# -----------------------------------------------------------------------------
177JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"} 141JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"}
178 142
179# ----------------------------------------------------------------------------- 143# @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER
180# @variable-external JAVA_PKG_FORCE_COMPILER 144# @INTERNAL
181# 145# @DEFAULT_UNSET
146# @DESCRIPTION:
182# Explicitly set a list of compilers to use. This is normally read from 147# Explicitly set a list of compilers to choose from. This is normally read from
183# JAVA_PKG_COMPILERS_CONF. 148# JAVA_PKG_COMPILERS_CONF.
184# 149#
185# @note This should only be used internally or for testing. 150# Useful for local testing.
151#
186# @example Use jikes and javac, in that order 152# Use jikes and javac, in that order
153# @CODE
187# JAVA_PKG_FORCE_COMPILER="jikes javac" 154# JAVA_PKG_FORCE_COMPILER="jikes javac"
188# ----------------------------------------------------------------------------- 155# @CODE
189 156
190# ----------------------------------------------------------------------------- 157# @ECLASS-VARIABLE: JAVA_PKG_FORCE_ANT_TASKS
191# @variable-external JAVA_PKG_FORCE_ANT_TASKS 158# @DEFAULT_UNSET
192# 159# @DESCRIPTION:
193# An $IFS separated list of ant tasks. Can be set in environment before calling 160# An $IFS separated list of ant tasks. Can be set in environment before calling
194# emerge/ebuild to override variables set in ebuild, mainly for testing before 161# emerge/ebuild to override variables set in ebuild, mainly for testing before
195# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in 162# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
196# eant() call, not the dependencies specified in WANT_ANT_TASKS. 163# eant() call, not the dependencies specified in WANT_ANT_TASKS.
197# 164#
165# @CODE
198# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \ 166# JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
199# ebuild foo.ebuild compile 167# ebuild foo.ebuild compile
200# 168# @CODE
201# @seealso WANT_ANT_TASKS
202# -----------------------------------------------------------------------------
203 169
204# TODO document me 170# TODO document me
205JAVA_PKG_QA_VIOLATIONS=0 171JAVA_PKG_QA_VIOLATIONS=0
206 172
207# ----------------------------------------------------------------------------- 173# @FUNCTION: java-pkg_doexamples
208# @section-end variables 174# @USAGE: [--subdir <subdir>] <file1/dir1> [<file2> ...]
209# ----------------------------------------------------------------------------- 175# @DESCRIPTION:
210
211
212# -----------------------------------------------------------------------------
213# @section-begin install
214# @section-summary Install functions
215#
216# These are used to install Java-related things, such as jars, Javadocs, JNI
217# libraries, etc.
218# -----------------------------------------------------------------------------
219
220# -----------------------------------------------------------------------------
221# @ebuild-function java-pkg_doexamples
222#
223# Installs given arguments to /usr/share/doc/${PF}/examples 176# Installs given arguments to /usr/share/doc/${PF}/examples
224# If you give it only one parameter and it is a directory it will install 177# If you give it only one parameter and it is a directory it will install
225# everything in that directory to the examples directory. 178# everything in that directory to the examples directory.
226# 179#
180# @CODE
181# Parameters:
182# --subdir - If the examples need a certain directory structure
183# $* - list of files to install
184#
227# @example 185# Examples:
228# java-pkg_doexamples demo 186# java-pkg_doexamples demo
229# java-pkg_doexamples demo/* examples/* 187# java-pkg_doexamples demo/* examples/*
230# 188# @CODE
231# @param --subdir - If the examples need a certain directory structure
232# @param $* - list of files to install
233# ------------------------------------------------------------------------------
234java-pkg_doexamples() { 189java-pkg_doexamples() {
235 debug-print-function ${FUNCNAME} $* 190 debug-print-function ${FUNCNAME} $*
236 191
237 [[ ${#} -lt 1 ]] && die "At least one argument needed" 192 [[ ${#} -lt 1 ]] && die "At least one argument needed"
238 193
259 214
260 # Let's make a symlink to the directory we have everything else under 215 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die 216 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
262} 217}
263 218
264# ----------------------------------------------------------------------------- 219# @FUNCTION: java-pkg_dojar
265# @ebuild-function java-pkg_dojar 220# @USAGE: <jar1> [<jar2> ...]
266# 221# @DESCRIPTION:
267# Installs any number of jars. 222# Installs any number of jars.
268# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 223# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
269# You can use java-pkg_jarinto to change this path. 224# You can use java-pkg_jarinto to change this path.
270# You should never install a jar with a package version in the filename. 225# You should never install a jar with a package version in the filename.
271# Instead, use java-pkg_newjar defined below. 226# Instead, use java-pkg_newjar defined below.
272# 227#
273# @example 228# @CODE
274# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 229# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
230# @CODE
275# 231#
276# @param $* - list of jars to install 232# @param $* - list of jars to install
277# ------------------------------------------------------------------------------
278java-pkg_dojar() { 233java-pkg_dojar() {
279 debug-print-function ${FUNCNAME} $* 234 debug-print-function ${FUNCNAME} $*
280 235
281 [[ ${#} -lt 1 ]] && die "At least one argument needed" 236 [[ ${#} -lt 1 ]] && die "At least one argument needed"
282 237
324 done 279 done
325 280
326 java-pkg_do_write_ 281 java-pkg_do_write_
327} 282}
328 283
329# ------------------------------------------------------------------------------ 284# @FUNCTION: depend-java-query
330# @internal-function depend-java-query 285# @INTERNAL
331# 286# @DESCRIPTION:
332# Wrapper for the depend-java-query binary to enable passing USE in env. 287# Wrapper for the depend-java-query binary to enable passing USE in env.
333# Using env variables keeps this eclass working with java-config versions that 288# Using env variables keeps this eclass working with java-config versions that
334# do not handle use flags. 289# do not handle use flags.
335# ------------------------------------------------------------------------------
336
337depend-java-query() { 290depend-java-query() {
338 # Used to have a which call here but it caused endless loops for some people 291 # Used to have a which call here but it caused endless loops for some people
339 # that had some weird bashrc voodoo for which. 292 # that had some weird bashrc voodoo for which.
340 USE="${USE}" /usr/bin/depend-java-query "${@}" 293 USE="${USE}" /usr/bin/depend-java-query "${@}"
341} 294}
342 295
343# ------------------------------------------------------------------------------ 296# @FUNCTION: java-pkg_regjar
344# @ebuild-function java-pkg_regjar 297# @USAGE: </path/to/installed/jar>
345# 298# @DESCRIPTION:
346# Records an already installed jar in the package.env 299# Records an already installed (in ${D}) jar in the package.env
347# This would mostly be used if the package has make or a custom script to 300# This would mostly be used if the package has make or a custom script to
348# install things. 301# install things.
349# 302#
350# Example:
351# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
352#
353# WARNING: 303# WARNING:
354# if you want to use shell expansion, you have to use ${D}/... as the for in 304# if you want to use shell expansion, you have to use ${D}/... as the for in
355# this function will not be able to expand the path, here's an example: 305# this function will not be able to expand the path, here's an example:
356# 306#
357# java-pkg_regjar /opt/my-java/lib/*.jar 307# @CODE
358#
359# will not work, because:
360# * the `for jar in "$@"` can't expand the path to jar file names, as they
361# don't exist yet
362# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
363# doesn't exist
364#
365# you have to use it as:
366#
367# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 308# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
309# @CODE
368# 310#
369# @param $@ - jars to record 311
370# ------------------------------------------------------------------------------
371# TODO should we be making sure the jar is present on ${D} or wherever? 312# TODO should we be making sure the jar is present on ${D} or wherever?
372java-pkg_regjar() { 313java-pkg_regjar() {
373 debug-print-function ${FUNCNAME} $* 314 debug-print-function ${FUNCNAME} $*
374 315
375 java-pkg_check-phase install 316 java-pkg_check-phase install
406 done 347 done
407 348
408 java-pkg_do_write_ 349 java-pkg_do_write_
409} 350}
410 351
411# ------------------------------------------------------------------------------ 352# @FUNCTION: java-pkg_newjar
412# @ebuild-function java-pkg_newjar 353# @USAGE: <path/to/oldname.jar> [<newname.jar>]
354# @DESCRIPTION:
355# Installs a jar with a new name (defaults to $PN.jar)
413# 356#
414# Installs a jar with a new name
415#
416# @example: install a versioned jar without the version 357# For example, installs a versioned jar without the version
417# java-pkg_newjar dist/${P}.jar ${PN}.jar
418#
419# @param $1 - jar to install
420# @param $2 - new name for jar - defaults to ${PN}.jar if not specified
421# ------------------------------------------------------------------------------
422java-pkg_newjar() { 358java-pkg_newjar() {
423 debug-print-function ${FUNCNAME} $* 359 debug-print-function ${FUNCNAME} $*
424 360
425 local original_jar="${1}" 361 local original_jar="${1}"
426 local new_jar="${2:-${PN}.jar}" 362 local new_jar="${2:-${PN}.jar}"
434 cp "${original_jar}" "${new_jar_dest}" \ 370 cp "${original_jar}" "${new_jar_dest}" \
435 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 371 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
436 java-pkg_dojar "${new_jar_dest}" 372 java-pkg_dojar "${new_jar_dest}"
437} 373}
438 374
439# ------------------------------------------------------------------------------ 375# @FUNCTION: java-pkg_addcp
440# @ebuild-function java-pkg_addcp 376# @USAGE: <classpath>
441# 377# @DESCRIPTION:
442# Add something to the package's classpath. For jars, you should use dojar, 378# Add something to the package's classpath. For jars, you should use dojar,
443# newjar, or regjar. This is typically used to add directories to the classpath. 379# newjar, or regjar. This is typically used to add directories to the classpath.
444# 380# The parameters of this function are appended to JAVA_PKG_CLASSPATH
445# TODO add example
446# @param $@ - value to append to JAVA_PKG_CLASSPATH
447# ------------------------------------------------------------------------------
448java-pkg_addcp() { 381java-pkg_addcp() {
449 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 382 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
450 java-pkg_do_write_ 383 java-pkg_do_write_
451} 384}
452 385
453# ------------------------------------------------------------------------------ 386# @FUNCTION: java-pkg_doso
454# @ebuild-function java-pkg_doso 387# @USAGE: <path/to/file1.so> [...]
455# 388# @DESCRIPTION:
456# Installs any number of JNI libraries 389# Installs any number of JNI libraries
457# They will be installed into /usr/lib by default, but java-pkg_sointo 390# They will be installed into /usr/lib by default, but java-pkg_sointo
458# can be used change this path 391# can be used change this path
459# 392#
393# @CODE
460# Example: 394# Example:
461# java-pkg_doso *.so 395# java-pkg_doso *.so
462# 396# @CODE
463# @param $@ - JNI libraries to install
464# ------------------------------------------------------------------------------
465java-pkg_doso() { 397java-pkg_doso() {
466 debug-print-function ${FUNCNAME} $* 398 debug-print-function ${FUNCNAME} $*
467 399
468 java-pkg_check-phase install 400 java-pkg_check-phase install
469 401
495 done 427 done
496 428
497 java-pkg_do_write_ 429 java-pkg_do_write_
498} 430}
499 431
500# ------------------------------------------------------------------------------ 432# @FUNCTION: java-pkg_regso
501# @ebuild-function java-pkg_regso 433# @USAGE: <file1.so> [...]
502# 434# @DESCRIPTION:
503# Registers an already JNI library in package.env. 435# Registers an already installed JNI library in package.env.
436#
437# @CODE
438# Parameters:
439# $@ - JNI libraries to register
504# 440#
505# Example: 441# Example:
506# java-pkg_regso *.so /path/*.so 442# java-pkg_regso *.so /path/*.so
507# 443# @CODE
508# @param $@ - JNI libraries to register
509# ------------------------------------------------------------------------------
510java-pkg_regso() { 444java-pkg_regso() {
511 debug-print-function ${FUNCNAME} $* 445 debug-print-function ${FUNCNAME} $*
512 446
513 java-pkg_check-phase install 447 java-pkg_check-phase install
514 448
532 done 466 done
533 467
534 java-pkg_do_write_ 468 java-pkg_do_write_
535} 469}
536 470
537# ------------------------------------------------------------------------------ 471# @FUNCTION: java-pkg_jarinto
538# @ebuild-function java-pkg_jarinto 472# @USAGE: </path/to/install/jars/into>
539# 473# @DESCRIPTION:
540# Changes the path jars are installed into 474# Changes the path jars are installed into via subsequent java-pkg_dojar calls.
541#
542# @param $1 - new location to install jars into.
543# -----------------------------------------------------------------------------
544java-pkg_jarinto() { 475java-pkg_jarinto() {
545 debug-print-function ${FUNCNAME} $* 476 debug-print-function ${FUNCNAME} $*
546 477
547 JAVA_PKG_JARDEST="${1}" 478 JAVA_PKG_JARDEST="${1}"
548} 479}
549 480
550# ------------------------------------------------------------------------------ 481# @FUNCTION: java-pkg_sointo
551# @ebuild-function java-pkg_sointo 482# @USAGE: </path/to/install/sofiles/into>
552# 483# @DESCRIPTION:
553# Changes the path that JNI libraries are installed into. 484# Changes the path that JNI libraries are installed into via subsequent
554# 485# java-pkg_doso calls.
555# @param $1 - new location to install JNI libraries into.
556# ------------------------------------------------------------------------------
557java-pkg_sointo() { 486java-pkg_sointo() {
558 debug-print-function ${FUNCNAME} $* 487 debug-print-function ${FUNCNAME} $*
559 488
560 JAVA_PKG_LIBDEST="${1}" 489 JAVA_PKG_LIBDEST="${1}"
561} 490}
562 491
563# ------------------------------------------------------------------------------ 492# @FUNCTION: java-pkg_dohtml
564# @ebuild-function java-pkg_dohtml 493# @USAGE: <path/to/javadoc/documentation> [...]
494# @DESCRIPTION:
495# Install Javadoc HTML documentation. Usage of java-pkg_dojavadoc is preferred.
565# 496#
566# Install Javadoc HTML documentation 497# @CODE
567#
568# @example
569# java-pkg_dohtml dist/docs/ 498# java-pkg_dohtml dist/docs/
570# 499# @CODE
571# ------------------------------------------------------------------------------
572java-pkg_dohtml() { 500java-pkg_dohtml() {
573 debug-print-function ${FUNCNAME} $* 501 debug-print-function ${FUNCNAME} $*
574 502
575 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 503 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
576 504
582 # a reasonable way to catch # docs for all of the 510 # a reasonable way to catch # docs for all of the
583 # old ebuilds. 511 # old ebuilds.
584 java-pkg_recordjavadoc 512 java-pkg_recordjavadoc
585} 513}
586 514
587# ------------------------------------------------------------------------------ 515# @FUNCTION: java-pkg_dojavadoc
588# @ebuild-function java-pkg_dojavadoc 516# @USAGE: [--symlink destination] <path/to/javadocs/root>
589# 517# @DESCRIPTION:
590# Installs javadoc documentation. This should be controlled by the doc use flag. 518# Installs javadoc documentation. This should be controlled by the doc use flag.
591# 519#
520# @CODE
521# Parameters:
592# @param $1: optional --symlink creates to symlink like this for html 522# $1: optional --symlink creates to symlink like this for html
593# documentation bundles. 523# documentation bundles.
594# @param $2: - The javadoc root directory. 524# $2: - The javadoc root directory.
595# 525#
596# @example: 526# Examples:
597# java-pkg_dojavadoc docs/api 527# java-pkg_dojavadoc docs/api
598# java-pkg_dojavadoc --symlink apidocs docs/api 528# java-pkg_dojavadoc --symlink apidocs docs/api
599# 529# @CODE
600# ------------------------------------------------------------------------------
601java-pkg_dojavadoc() { 530java-pkg_dojavadoc() {
602 debug-print-function ${FUNCNAME} $* 531 debug-print-function ${FUNCNAME} $*
603 532
604 # For html documentation bundles that link to Javadoc 533 # For html documentation bundles that link to Javadoc
605 local symlink 534 local symlink
648 debug-print "symlinking ${dest}/{api,${symlink}}" 577 debug-print "symlinking ${dest}/{api,${symlink}}"
649 dosym ${dest}/{api,${symlink}} || die 578 dosym ${dest}/{api,${symlink}} || die
650 fi 579 fi
651} 580}
652 581
653# ------------------------------------------------------------------------------ 582# @FUNCTION: java-pkg_dosrc
654# @ebuild-function java-pkg_dosrc 583# @USAGE: <path/to/sources> [...]
655# 584# @DESCRIPTION:
656# Installs a zip containing the source for a package, so it can used in 585# Installs a zip containing the source for a package, so it can used in
657# from IDEs like eclipse and netbeans. 586# from IDEs like eclipse and netbeans.
587# Ebuild needs to DEPEND on app-arch/zip to use this. It also should be controlled by USE=source.
658# 588#
659# Ebuild needs to DEPEND on app-arch/zip to use this. 589# @CODE
660#
661# It also should be controlled by USE=source.
662#
663# @example: 590# Example:
664# java-pkg_dosrc src/* 591# java-pkg_dosrc src/*
665# 592# @CODE
666# ------------------------------------------------------------------------------ 593
667# TODO change so it the arguments it takes are the base directories containing 594# TODO change so it the arguments it takes are the base directories containing
668# source -nichoj 595# source -nichoj
596#
669# TODO should we be able to handle multiple calls to dosrc? -nichoj 597# TODO should we be able to handle multiple calls to dosrc? -nichoj
598#
670# TODO maybe we can take an existing zip/jar? -nichoj 599# TODO maybe we can take an existing zip/jar? -nichoj
600#
671# FIXME apparently this fails if you give it an empty directories 601# FIXME apparently this fails if you give it an empty directories
672java-pkg_dosrc() { 602java-pkg_dosrc() {
673 debug-print-function ${FUNCNAME} $* 603 debug-print-function ${FUNCNAME} $*
674 604
675 [ ${#} -lt 1 ] && die "At least one argument needed" 605 [ ${#} -lt 1 ] && die "At least one argument needed"
707 637
708 JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}" 638 JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
709 java-pkg_do_write_ 639 java-pkg_do_write_
710} 640}
711 641
712# ------------------------------------------------------------------------------ 642# @FUNCTION: java-pkg_dolauncher
713# @ebuild-function java-pkg_dolauncher 643# @USAGE: <filename> [options]
714# 644# @DESCRIPTION:
715# Make a wrapper script to lauch/start this package 645# Make a wrapper script to lauch/start this package
716# If necessary, the wrapper will switch to the appropriate VM. 646# If necessary, the wrapper will switch to the appropriate VM.
717# 647#
718# Can be called without parameters if the package installs only one jar 648# Can be called without parameters if the package installs only one jar
719# that has the Main-class attribute set. The wrapper will be named ${PN}. 649# that has the Main-class attribute set. The wrapper will be named ${PN}.
720# 650#
651# @CODE
652# Parameters:
721# @param $1 - filename of launcher to create 653# $1 - filename of launcher to create
722# @param $2 - options, as follows: 654# $2 - options, as follows:
723# --main the.main.class.too.start 655# --main the.main.class.to.start
724# --jar /the/jar/too/launch.jar or just <name>.jar 656# --jar /the/jar/too/launch.jar or just <name>.jar
725# --java_args 'Extra arguments to pass to java' 657# --java_args 'Extra arguments to pass to java'
726# --pkg_args 'Extra arguments to pass to the package' 658# --pkg_args 'Extra arguments to pass to the package'
727# --pwd Directory the launcher changes to before executing java 659# --pwd Directory the launcher changes to before executing java
728# -into Directory to install the launcher to, instead of /usr/bin 660# -into Directory to install the launcher to, instead of /usr/bin
729# -pre Prepend contents of this file to the launcher 661# -pre Prepend contents of this file to the launcher
730# ------------------------------------------------------------------------------ 662# @CODE
731java-pkg_dolauncher() { 663java-pkg_dolauncher() {
732 debug-print-function ${FUNCNAME} $* 664 debug-print-function ${FUNCNAME} $*
733 665
734 java-pkg_check-phase install 666 java-pkg_check-phase install
735 java-pkg_init_paths_ 667 java-pkg_init_paths_
796 else 728 else
797 dobin "${target}" 729 dobin "${target}"
798 fi 730 fi
799} 731}
800 732
801# ------------------------------------------------------------------------------ 733# @FUNCTION: java-pkg_dowar
734# @DESCRIPTION:
802# Install war files. 735# Install war files.
803# TODO document 736# TODO document
804# ------------------------------------------------------------------------------
805java-pkg_dowar() { 737java-pkg_dowar() {
806 debug-print-function ${FUNCNAME} $* 738 debug-print-function ${FUNCNAME} $*
807 739
808 # Check for arguments 740 # Check for arguments
809 [[ ${#} -lt 1 ]] && die "At least one argument needed" 741 [[ ${#} -lt 1 ]] && die "At least one argument needed"
833 INSDESTTREE=${JAVA_PKG_WARDEST} \ 765 INSDESTTREE=${JAVA_PKG_WARDEST} \
834 doins ${warpath} 766 doins ${warpath}
835 done 767 done
836} 768}
837 769
838# ------------------------------------------------------------------------------ 770# @FUNCTION: java-pkg_recordjavadoc
839# @internal-function java-pkg_recordjavadoc 771# @INTERNAL
772# @DESCRIPTION:
840# Scan for JavaDocs, and record their existence in the package.env file 773# Scan for JavaDocs, and record their existence in the package.env file
841# 774
842# TODO make sure this in the proper section 775# TODO make sure this in the proper section
843# ------------------------------------------------------------------------------
844java-pkg_recordjavadoc() 776java-pkg_recordjavadoc()
845{ 777{
846 debug-print-function ${FUNCNAME} $* 778 debug-print-function ${FUNCNAME} $*
847 # the find statement is important 779 # the find statement is important
848 # as some packages include multiple trees of javadoc 780 # as some packages include multiple trees of javadoc
855 else 787 else
856 debug-print "No javadocs found" 788 debug-print "No javadocs found"
857 fi 789 fi
858} 790}
859 791
860# ------------------------------------------------------------------------------
861# @section-end install
862# ------------------------------------------------------------------------------
863 792
864# ------------------------------------------------------------------------------ 793# @FUNCTION: java-pkg_jar-from
865# @begin-section query 794# @USAGE: [--build-only] [--with-dependencies] [--virtual] [--into dir] <package> [<package.jar>] [<destination.jar>]
866# Use these to build the classpath for building a package. 795# @DESCRIPTION:
867# ------------------------------------------------------------------------------
868
869# ------------------------------------------------------------------------------
870# @ebuild-function java-pkg_jar-from
871#
872# Makes a symlink to a jar from a certain package 796# Makes a symlink to a jar from a certain package
873# A lot of java packages include dependencies in a lib/ directory 797# A lot of java packages include dependencies in a lib/ directory
874# You can use this function to replace these bundled dependencies. 798# You can use this function to replace these bundled dependencies.
875# The dependency is recorded into package.env DEPEND line, unless "--build-only" 799# The dependency is recorded into package.env DEPEND line, unless "--build-only"
876# is passed as the very first argument, for jars that have to be present only 800# is passed as the very first argument, for jars that have to be present only
877# at build time and are not needed on runtime (junit testing etc). 801# at build time and are not needed on runtime (junit testing etc).
878# 802#
803# @CODE
879# Example: get all jars from xerces slot 2 804# Example: get all jars from xerces slot 2
880# java-pkg_jar-from xerces-2 805# java-pkg_jar-from xerces-2
806#
881# Example: get a specific jar from xerces slot 2 807# Example: get a specific jar from xerces slot 2
882# java-pkg_jar-from xerces-2 xml-apis.jar 808# java-pkg_jar-from xerces-2 xml-apis.jar
809#
883# Example: get a specific jar from xerces slot 2, and name it diffrently 810# Example: get a specific jar from xerces slot 2, and name it diffrently
884# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 811# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
812#
885# Example: get junit.jar which is needed only for building 813# Example: get junit.jar which is needed only for building
886# java-pkg_jar-from --build-only junit junit.jar 814# java-pkg_jar-from --build-only junit junit.jar
815# @CODE
887# 816#
888# @param $opt 817# @CODE
818# Parameters
889# --build-only - makes the jar(s) not added into package.env DEPEND line. 819# --build-only - makes the jar(s) not added into package.env DEPEND line.
890# (assumed automatically when called inside src_test) 820# (assumed automatically when called inside src_test)
891# --with-dependencies - get jars also from requested package's dependencies 821# --with-dependencies - get jars also from requested package's dependencies
892# transitively. 822# transitively.
893# --virtual - Packages passed to this function are to be handled as virtuals 823# --virtual - Packages passed to this function are to be handled as virtuals
894# and will not have individual jar dependencies recorded. 824# and will not have individual jar dependencies recorded.
895# --into $dir - symlink jar(s) into $dir (must exist) instead of . 825# --into $dir - symlink jar(s) into $dir (must exist) instead of .
896# @param $1 - Package to get jars from, or comma-separated list of packages in 826# $1 - Package to get jars from, or comma-separated list of packages in
897# case other parameters are not used. 827# case other parameters are not used.
898# @param $2 - jar from package. If not specified, all jars will be used. 828# $2 - jar from package. If not specified, all jars will be used.
899# @param $3 - When a single jar is specified, destination filename of the 829# $3 - When a single jar is specified, destination filename of the
900# symlink. Defaults to the name of the jar. 830# symlink. Defaults to the name of the jar.
901# ------------------------------------------------------------------------------ 831# @CODE
832
902# TODO could probably be cleaned up a little 833# TODO could probably be cleaned up a little
903java-pkg_jar-from() { 834java-pkg_jar-from() {
904 debug-print-function ${FUNCNAME} $* 835 debug-print-function ${FUNCNAME} $*
905 836
906 local build_only="" 837 local build_only=""
1011 else 942 else
1012 die "Failed to find ${target_jar:-jar} in ${target_pkg}" 943 die "Failed to find ${target_jar:-jar} in ${target_pkg}"
1013 fi 944 fi
1014} 945}
1015 946
1016# ------------------------------------------------------------------------------ 947# @FUNCTION: java-pkg_jarfrom
1017# @ebuild-function java-pkg_jarfrom 948# @DESCRIPTION:
1018#
1019# See java-pkg_jar-from 949# See java-pkg_jar-from
1020# ------------------------------------------------------------------------------
1021java-pkg_jarfrom() { 950java-pkg_jarfrom() {
1022 java-pkg_jar-from "$@" 951 java-pkg_jar-from "$@"
1023} 952}
1024 953
1025# ------------------------------------------------------------------------------ 954# @FUNCTION: java-pkg_getjars
1026# @ebuild-function java-pkg_getjars 955# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
1027# 956# @DESCRIPTION:
1028# Get the classpath provided by any number of packages 957# Get the classpath provided by any number of packages
1029# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 958# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
1030# The providing packages are recorded as dependencies into package.env DEPEND 959# The providing packages are recorded as dependencies into package.env DEPEND
1031# line, unless "--build-only" is passed as the very first argument, for jars 960# line, unless "--build-only" is passed as the very first argument, for jars
1032# that have to be present only at build time and are not needed on runtime 961# that have to be present only at build time and are not needed on runtime
1033# (junit testing etc). 962# (junit testing etc).
1034# 963#
964# @CODE
1035# Example: Get the classpath for xerces-2 and xalan, 965# Example: Get the classpath for xerces-2 and xalan,
1036# java-pkg_getjars xerces-2,xalan 966# java-pkg_getjars xerces-2,xalan
967#
1037# Example Return: 968# Example Return:
1038# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 969# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
1039# 970#
1040# @param $opt 971#
972# Parameters:
1041# --build-only - makes the jar(s) not added into package.env DEPEND line. 973# --build-only - makes the jar(s) not added into package.env DEPEND line.
1042# (assumed automatically when called inside src_test) 974# (assumed automatically when called inside src_test)
1043# --with-dependencies - get jars also from requested package's dependencies 975# --with-dependencies - get jars also from requested package's dependencies
1044# transitively. 976# transitively.
1045# @param $1 - list of packages to get jars from 977# $1 - list of packages to get jars from
1046# (passed to java-config --classpath) 978# (passed to java-config --classpath)
1047# ------------------------------------------------------------------------------ 979# @CODE
1048java-pkg_getjars() { 980java-pkg_getjars() {
1049 debug-print-function ${FUNCNAME} $* 981 debug-print-function ${FUNCNAME} $*
1050 982
1051 local build_only="" 983 local build_only=""
1052 local deep="" 984 local deep=""
1090 done 1022 done
1091 1023
1092 echo "${jars}" 1024 echo "${jars}"
1093} 1025}
1094 1026
1095# ------------------------------------------------------------------------------ 1027# @FUNCTION: java-pkg_getjar
1096# @ebuild-function java-pkg_getjar 1028# @USAGE: [--build-only] [--virtual] <package> <jarfile>
1097# 1029# @DESCRIPTION:
1098# Get the filename of a single jar from a package 1030# Get the complete path of a single jar from a package
1099# The providing package is recorded as runtime dependency into package.env 1031# The providing package is recorded as runtime dependency into package.env
1100# DEPEND line, unless "--build-only" is passed as the very first argument, for 1032# DEPEND line, unless "--build-only" is passed as the very first argument, for
1101# jars that have to be present only at build time and are not needed on runtime 1033# jars that have to be present only at build time and are not needed on runtime
1102# (junit testing etc). 1034# (junit testing etc).
1103# 1035#
1036# @CODE
1104# @example 1037# Example:
1105# java-pkg_getjar xerces-2 xml-apis.jar 1038# java-pkg_getjar xerces-2 xml-apis.jar
1106# @example-return 1039# returns
1107# /usr/share/xerces-2/lib/xml-apis.jar 1040# /usr/share/xerces-2/lib/xml-apis.jar
1108# 1041#
1109# @param $opt 1042# Parameters:
1110# --build-only - makes the jar not added into package.env DEPEND line. 1043# --build-only - makes the jar not added into package.env DEPEND line.
1111# --virtual - Packages passed to this function are to be handled as virtuals 1044# --virtual - Packages passed to this function are to be handled as virtuals
1112# and will not have individual jar dependencies recorded. 1045# and will not have individual jar dependencies recorded.
1113# @param $1 - package to use 1046# $1 - package to use
1114# @param $2 - jar to get 1047# $2 - jar to get
1115# ------------------------------------------------------------------------------ 1048# @CODE
1116java-pkg_getjar() { 1049java-pkg_getjar() {
1117 debug-print-function ${FUNCNAME} $* 1050 debug-print-function ${FUNCNAME} $*
1118 1051
1119 local build_only="" 1052 local build_only=""
1120 local virtual="" 1053 local virtual=""
1183 1116
1184 die "Could not find ${target_jar} in ${pkg}" 1117 die "Could not find ${target_jar} in ${pkg}"
1185 return 1 1118 return 1
1186} 1119}
1187 1120
1188# ------------------------------------------------------------------------------ 1121# @FUNCTION: java-pkg_register-dependency
1189# @ebuild-function java-pkg_register-dependency 1122# @USAGE: <package>[,<package2>...] [<jarfile>]
1190# 1123# @DESCRIPTION:
1191# Registers runtime dependency on a package, list of packages, or a single jar 1124# Registers runtime dependency on a package, list of packages, or a single jar
1192# from a package, into package.env DEPEND line. Can only be called in 1125# from a package, into package.env DEPEND line. Can only be called in
1193# src_install phase. 1126# src_install phase.
1194# Intended for binary packages where you don't need to symlink the jars or get 1127# Intended for binary packages where you don't need to symlink the jars or get
1195# their classpath during build. As such, the dependencies only need to be 1128# their classpath during build. As such, the dependencies only need to be
1196# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1129# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1197# 1130#
1131# @CODE
1132# Parameters:
1198# @param $1 - comma-separated list of packages, or a single package 1133# $1 - comma-separated list of packages, or a single package
1199# @param $2 - if param $1 is a single package, optionally specify the jar 1134# $2 - if param $1 is a single package, optionally specify the jar
1200# to depend on 1135# to depend on
1201# 1136#
1137# Examples:
1202# Example: Record the dependency on whole xerces-2 and xalan, 1138# Record the dependency on whole xerces-2 and xalan,
1203# java-pkg_register-dependency xerces-2,xalan 1139# java-pkg_register-dependency xerces-2,xalan
1140#
1204# Example: Record the dependency on ant.jar from ant-core 1141# Record the dependency on ant.jar from ant-core
1205# java-pkg_register-dependency ant-core ant.jar 1142# java-pkg_register-dependency ant-core ant.jar
1143# @CODE
1206# 1144#
1207# Note: Passing both list of packages as the first parameter AND specifying the 1145# Note: Passing both list of packages as the first parameter AND specifying the
1208# jar as the second is not allowed and will cause the function to die. We assume 1146# jar as the second is not allowed and will cause the function to die. We assume
1209# that there's more chance one passes such combination as a mistake, than that 1147# that there's more chance one passes such combination as a mistake, than that
1210# there are more packages providing identically named jar without class 1148# there are more packages providing identically named jar without class
1211# collisions. 1149# collisions.
1212# ------------------------------------------------------------------------------
1213java-pkg_register-dependency() { 1150java-pkg_register-dependency() {
1214 debug-print-function ${FUNCNAME} $* 1151 debug-print-function ${FUNCNAME} $*
1215 1152
1216 java-pkg_check-phase install 1153 java-pkg_check-phase install
1217 1154
1239 fi 1176 fi
1240 1177
1241 java-pkg_do_write_ 1178 java-pkg_do_write_
1242} 1179}
1243 1180
1244# ------------------------------------------------------------------------------
1245# @ebuild-function java-pkg_register-optional-dependency 1181# @FUNCTION: java-pkg_register-optional-dependency
1246# 1182# @USAGE: <package>[,<package2>...] [<jarfile>]
1183# @DESCRIPTION:
1247# Registers optional runtime dependency on a package, list of packages, or a 1184# Registers optional runtime dependency on a package, list of packages, or a
1248# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be 1185# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1249# called in src_install phase. 1186# called in src_install phase.
1250# Intended for packages that can use other packages when those are in classpath. 1187# Intended for packages that can use other packages when those are in classpath.
1251# Will be put on classpath by launcher if they are installed. Typical case is 1188# Will be put on classpath by launcher if they are installed. Typical case is
1252# JDBC implementations for various databases. It's better than having USE flag 1189# JDBC implementations for various databases. It's better than having USE flag
1253# for each implementation triggering hard dependency. 1190# for each implementation triggering hard dependency.
1254# 1191#
1192# @CODE
1193# Parameters:
1255# @param $1 - comma-separated list of packages, or a single package 1194# $1 - comma-separated list of packages, or a single package
1256# @param $2 - if param $1 is a single package, optionally specify the jar 1195# $2 - if param $1 is a single package, optionally specify the jar to depend on
1257# to depend on
1258# 1196#
1197# Example:
1259# Example: Record the optional dependency on some jdbc providers 1198# Record the optional dependency on some jdbc providers
1260# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql 1199# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1200# @CODE
1261# 1201#
1262# Note: Passing both list of packages as the first parameter AND specifying the 1202# Note: Passing both list of packages as the first parameter AND specifying the
1263# jar as the second is not allowed and will cause the function to die. We assume 1203# jar as the second is not allowed and will cause the function to die. We assume
1264# that there's more chance one passes such combination as a mistake, than that 1204# that there's more chance one passes such combination as a mistake, than that
1265# there are more packages providing identically named jar without class 1205# there are more packages providing identically named jar without class
1266# collisions. 1206# collisions.
1267# ------------------------------------------------------------------------------
1268java-pkg_register-optional-dependency() { 1207java-pkg_register-optional-dependency() {
1269 debug-print-function ${FUNCNAME} $* 1208 debug-print-function ${FUNCNAME} $*
1270 1209
1271 java-pkg_check-phase install 1210 java-pkg_check-phase install
1272 1211
1292 fi 1231 fi
1293 1232
1294 java-pkg_do_write_ 1233 java-pkg_do_write_
1295} 1234}
1296 1235
1297# ------------------------------------------------------------------------------
1298# @ebuild-function java-pkg_register-environment-variable 1236# @FUNCTION: java-pkg_register-environment-variable
1299# 1237# @USAGE: <name> <value>
1238# @DESCRIPTION:
1300# Register an arbitrary environment variable into package.env. The gjl launcher 1239# Register an arbitrary environment variable into package.env. The gjl launcher
1301# for this package or any package depending on this will export it into 1240# for this package or any package depending on this will export it into
1302# environement before executing java command. 1241# environement before executing java command.
1303# Must only be called in src_install phase. 1242# Must only be called in src_install phase.
1304#
1305# @param $1 - variable name
1306# @param $2 - variable value
1307# ------------------------------------------------------------------------------
1308JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env" 1243JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1309JAVA_PKG_EXTRA_ENV_VARS="" 1244JAVA_PKG_EXTRA_ENV_VARS=""
1310java-pkg_register-environment-variable() { 1245java-pkg_register-environment-variable() {
1311 debug-print-function ${FUNCNAME} $* 1246 debug-print-function ${FUNCNAME} $*
1312 1247
1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1253 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1319 1254
1320 java-pkg_do_write_ 1255 java-pkg_do_write_
1321} 1256}
1322 1257
1323# ------------------------------------------------------------------------------ 1258# @FUNCTION: java-pkg_get-bootclasspath
1324# @ebuild-function java-pkg_get-bootclasspath 1259# @USAGE: <version>
1325# 1260# @DESCRIPTION:
1326# Returns classpath of a given bootclasspath-providing package version. 1261# Returns classpath of a given bootclasspath-providing package version.
1327# 1262#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath 1263# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK 1264# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() { 1265java-pkg_get-bootclasspath() {
1333 local version="${1}" 1266 local version="${1}"
1334 1267
1335 local bcp 1268 local bcp
1336 case "${version}" in 1269 case "${version}" in
1384# 1317#
1385# read line 1318# read line
1386# done 1319# done
1387#} 1320#}
1388 1321
1389# ------------------------------------------------------------------------------ 1322# @FUNCTION: java-pkg_find-normal-jars
1390# @section-end query 1323# @USAGE: [<path/to/directory>]
1391# ------------------------------------------------------------------------------ 1324# @DESCRIPTION:
1392
1393# ------------------------------------------------------------------------------
1394# @section-begin helper
1395# @section-summary Helper functions
1396#
1397# Various other functions to use from an ebuild
1398# ------------------------------------------------------------------------------
1399
1400# ------------------------------------------------------------------------------
1401# @ebuild-function java-pkg_find-normal-jars
1402#
1403# Find the files with suffix .jar file in the given directory or $WORKDIR 1325# Find the files with suffix .jar file in the given directory (default: $WORKDIR)
1404#
1405# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1406# ------------------------------------------------------------------------------
1407java-pkg_find-normal-jars() { 1326java-pkg_find-normal-jars() {
1408 local dir=$1 1327 local dir=$1
1409 [[ "${dir}" ]] || dir="${WORKDIR}" 1328 [[ "${dir}" ]] || dir="${WORKDIR}"
1410 local found 1329 local found
1411 for jar in $(find "${dir}" -name "*.jar" -type f); do 1330 for jar in $(find "${dir}" -name "*.jar" -type f); do
1414 done 1333 done
1415 [[ "${found}" ]] 1334 [[ "${found}" ]]
1416 return $? 1335 return $?
1417} 1336}
1418 1337
1419# ------------------------------------------------------------------------------ 1338# @FUNCTION: java-pkg_ensure-no-bundled-jars
1420# @ebuild-function java-pkg_ensure-no-bundled-jars 1339# @DESCRIPTION:
1421#
1422# Try to locate bundled jar files in ${WORKDIR} and die if found. 1340# Try to locate bundled jar files in ${WORKDIR} and die if found.
1423# This function should be called after WORKDIR has been populated with symlink 1341# This function should be called after WORKDIR has been populated with symlink
1424# to system jar files or bundled jars removed. 1342# to system jar files or bundled jars removed.
1425# ------------------------------------------------------------------------------
1426java-pkg_ensure-no-bundled-jars() { 1343java-pkg_ensure-no-bundled-jars() {
1427 debug-print-function ${FUNCNAME} $* 1344 debug-print-function ${FUNCNAME} $*
1428 1345
1429 local bundled_jars=$(java-pkg_find-normal-jars) 1346 local bundled_jars=$(java-pkg_find-normal-jars)
1430 if [[ -n ${bundled_jars} ]]; then 1347 if [[ -n ${bundled_jars} ]]; then
1435 done 1352 done
1436 die "Bundled jars found!" 1353 die "Bundled jars found!"
1437 fi 1354 fi
1438} 1355}
1439 1356
1440# ------------------------------------------------------------------------------
1441# @internal-function java-pkg_ensure-vm-version-sufficient 1357# @FUNCTION: java-pkg_ensure-vm-version-sufficient
1442# 1358# @INTERNAL
1359# @DESCRIPTION:
1443# Checks if we have a sufficient VM and dies if we don't. 1360# Checks if we have a sufficient VM and dies if we don't.
1444#
1445# ------------------------------------------------------------------------------
1446java-pkg_ensure-vm-version-sufficient() { 1361java-pkg_ensure-vm-version-sufficient() {
1447 debug-print-function ${FUNCNAME} $* 1362 debug-print-function ${FUNCNAME} $*
1448 1363
1449 if ! java-pkg_is-vm-version-sufficient; then 1364 if ! java-pkg_is-vm-version-sufficient; then
1450 debug-print "VM is not suffient" 1365 debug-print "VM is not suffient"
1452 einfo "Please use java-config -S to set the correct one" 1367 einfo "Please use java-config -S to set the correct one"
1453 die "Active Java VM cannot build this package" 1368 die "Active Java VM cannot build this package"
1454 fi 1369 fi
1455} 1370}
1456 1371
1457# ------------------------------------------------------------------------------ 1372# @FUNCTION: java-pkg_is-vm-version-sufficient
1458# @internal-function java-pkg_is-vm-version-sufficient 1373# @INTERNAL
1459# 1374# @DESCRIPTION:
1460# @return zero - VM is sufficient 1375# @RETURN: zero - VM is sufficient; non-zero - VM is not sufficient
1461# @return non-zero - VM is not sufficient
1462# ------------------------------------------------------------------------------
1463java-pkg_is-vm-version-sufficient() { 1376java-pkg_is-vm-version-sufficient() {
1464 debug-print-function ${FUNCNAME} $* 1377 debug-print-function ${FUNCNAME} $*
1465 1378
1466 depend-java-query --is-sufficient "${DEPEND}" > /dev/null 1379 depend-java-query --is-sufficient "${DEPEND}" > /dev/null
1467 return $? 1380 return $?
1468} 1381}
1469 1382
1470# ------------------------------------------------------------------------------ 1383# @FUNCTION: java-pkg_ensure-vm-version-eq
1471# @internal-function java-pkg_ensure-vm-version-eq 1384# @INTERNAL
1472# 1385# @DESCRIPTION:
1473# Die if the current VM is not equal to the argument passed. 1386# Die if the current VM is not equal to the argument passed.
1474# 1387#
1475# @param $@ - Desired VM version to ensure 1388# @param $@ - Desired VM version to ensure
1476# ------------------------------------------------------------------------------
1477java-pkg_ensure-vm-version-eq() { 1389java-pkg_ensure-vm-version-eq() {
1478 debug-print-function ${FUNCNAME} $* 1390 debug-print-function ${FUNCNAME} $*
1479 1391
1480 if ! java-pkg_is-vm-version-eq $@ ; then 1392 if ! java-pkg_is-vm-version-eq $@ ; then
1481 debug-print "VM is not suffient" 1393 debug-print "VM is not suffient"
1483 einfo "Please use java-config -S to set the correct one" 1395 einfo "Please use java-config -S to set the correct one"
1484 die "Active Java VM too old" 1396 die "Active Java VM too old"
1485 fi 1397 fi
1486} 1398}
1487 1399
1488# ------------------------------------------------------------------------------ 1400# @FUNCTION: java-pkg_is-vm-version-eq
1489# @internal-function java-pkg_is-vm-version-eq 1401# @USAGE: <version>
1490# 1402# @INTERNAL
1491# @param $@ - VM version to compare current VM to 1403# @RETURN: zero - VM versions are equal; non-zero - VM version are not equal
1492# @return zero - VM versions are equal
1493# @return non-zero - VM version are not equal
1494# ------------------------------------------------------------------------------
1495java-pkg_is-vm-version-eq() { 1404java-pkg_is-vm-version-eq() {
1496 debug-print-function ${FUNCNAME} $* 1405 debug-print-function ${FUNCNAME} $*
1497 1406
1498 local needed_version="$@" 1407 local needed_version="$@"
1499 1408
1516 return 1 1425 return 1
1517 fi 1426 fi
1518 fi 1427 fi
1519} 1428}
1520 1429
1521# ------------------------------------------------------------------------------ 1430# @FUNCTION: java-pkg_ensure-vm-version-ge
1522# @internal-function java-pkg_ensure-vm-version-ge 1431# @INTERNAL
1523# 1432# @DESCRIPTION:
1524# Die if the current VM is not greater than the desired version 1433# Die if the current VM is not greater than the desired version
1525# 1434#
1526# @param $@ - VM version to compare current to 1435# @param $@ - VM version to compare current to
1527# ------------------------------------------------------------------------------
1528java-pkg_ensure-vm-version-ge() { 1436java-pkg_ensure-vm-version-ge() {
1529 debug-print-function ${FUNCNAME} $* 1437 debug-print-function ${FUNCNAME} $*
1530 1438
1531 if ! java-pkg_is-vm-version-ge "$@" ; then 1439 if ! java-pkg_is-vm-version-ge "$@" ; then
1532 debug-print "vm is not suffient" 1440 debug-print "vm is not suffient"
1534 einfo "Please use java-config -S to set the correct one" 1442 einfo "Please use java-config -S to set the correct one"
1535 die "Active Java VM too old" 1443 die "Active Java VM too old"
1536 fi 1444 fi
1537} 1445}
1538 1446
1539# ------------------------------------------------------------------------------ 1447# @FUNCTION: java-pkg_is-vm-version-ge
1540# @internal-function java-pkg_is-vm-version-ge 1448# @INTERNAL
1541# 1449# @DESCRIPTION:
1450# @CODE
1451# Parameters:
1542# @param $@ - VM version to compare current VM to 1452# $@ - VM version to compare current VM to
1453# @CODE
1543# @return zero - current VM version is greater than checked version 1454# @RETURN: zero - current VM version is greater than checked version;
1544# @return non-zero - current VM version is not greater than checked version 1455# non-zero - current VM version is not greater than checked version
1545# ------------------------------------------------------------------------------
1546java-pkg_is-vm-version-ge() { 1456java-pkg_is-vm-version-ge() {
1547 debug-print-function ${FUNCNAME} $* 1457 debug-print-function ${FUNCNAME} $*
1548 1458
1549 local needed_version=$@ 1459 local needed_version=$@
1550 local vm_version=$(java-pkg_get-vm-version) 1460 local vm_version=$(java-pkg_get-vm-version)
1573java-pkg_current-vm-matches() { 1483java-pkg_current-vm-matches() {
1574 has $(java-pkg_get-current-vm) ${@} 1484 has $(java-pkg_get-current-vm) ${@}
1575 return $? 1485 return $?
1576} 1486}
1577 1487
1578# ------------------------------------------------------------------------------ 1488# @FUNCTION: java-pkg_get-source
1579# @ebuild-function java-pkg_get-source 1489# @DESCRIPTION:
1580#
1581# Determines what source version should be used, for passing to -source. 1490# Determines what source version should be used, for passing to -source.
1582# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1491# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1583# 1492#
1584# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1493# @RETURN: string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1585# ------------------------------------------------------------------------------
1586java-pkg_get-source() { 1494java-pkg_get-source() {
1587 echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")} 1495 echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1588} 1496}
1589 1497
1590# ------------------------------------------------------------------------------ 1498# @FUNCTION: java-pkg_get-target
1591# @ebuild-function java-pkg_get-target 1499# @DESCRIPTION:
1592#
1593# Determines what target version should be used, for passing to -target. 1500# Determines what target version should be used, for passing to -target.
1594# If you don't care about lower versions, you can set _WANT_TARGET to the 1501# If you don't care about lower versions, you can set _WANT_TARGET to the
1595# version of your JDK. 1502# version of your JDK.
1596# 1503#
1597# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1504# @RETURN: string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1598# ------------------------------------------------------------------------------
1599java-pkg_get-target() { 1505java-pkg_get-target() {
1600 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")} 1506 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1601} 1507}
1602 1508
1509# @FUNCTION: java-pkg_get-javac
1510# @DESCRIPTION:
1511# Returns the compiler executable
1603java-pkg_get-javac() { 1512java-pkg_get-javac() {
1604 debug-print-function ${FUNCNAME} $* 1513 debug-print-function ${FUNCNAME} $*
1605 1514
1606 1515
1607 local compiler="${GENTOO_COMPILER}" 1516 local compiler="${GENTOO_COMPILER}"
1637 fi 1546 fi
1638 fi 1547 fi
1639 echo ${compiler_executable} 1548 echo ${compiler_executable}
1640} 1549}
1641 1550
1642# ------------------------------------------------------------------------------ 1551# @FUNCTION: java-pkg_javac-args
1643# @ebuild-function java-pkg_javac-args 1552# @DESCRIPTION:
1644#
1645# If an ebuild uses javac directly, instead of using ejavac, it should call this 1553# If an ebuild uses javac directly, instead of using ejavac, it should call this
1646# to know what -source/-target to use. 1554# to know what -source/-target to use.
1647# 1555#
1648# @return string - arguments to pass to javac, complete with -target and -source 1556# @RETURN: string - arguments to pass to javac, complete with -target and -source
1649# ------------------------------------------------------------------------------
1650java-pkg_javac-args() { 1557java-pkg_javac-args() {
1651 debug-print-function ${FUNCNAME} $* 1558 debug-print-function ${FUNCNAME} $*
1652 1559
1653 local want_source="$(java-pkg_get-source)" 1560 local want_source="$(java-pkg_get-source)"
1654 local want_target="$(java-pkg_get-target)" 1561 local want_target="$(java-pkg_get-target)"
1670 echo "${target_str}" 1577 echo "${target_str}"
1671 fi 1578 fi
1672 fi 1579 fi
1673} 1580}
1674 1581
1675# TODO document 1582# @FUNCTION: java-pkg_get-jni-cflags
1583# @DESCRIPTION:
1584# Echos the CFLAGS for JNI compilations
1676java-pkg_get-jni-cflags() { 1585java-pkg_get-jni-cflags() {
1677 local flags="-I${JAVA_HOME}/include" 1586 local flags="-I${JAVA_HOME}/include"
1678 1587
1679 local platform="linux" 1588 local platform="linux"
1680 use elibc_FreeBSD && platform="freebsd" 1589 use elibc_FreeBSD && platform="freebsd"
1693java-pkg_ensure-test() { 1602java-pkg_ensure-test() {
1694 # was enforcing USE=test if FEATURES=test 1603 # was enforcing USE=test if FEATURES=test
1695 die "${FUNCNAME} was removed. Package mangers handle this already. #278965" 1604 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1696} 1605}
1697 1606
1698# ------------------------------------------------------------------------------ 1607# @FUNCTION: java-pkg_register-ant-task
1699# @ebuild-function java-pkg_register-ant-task 1608# @USAGE: [--version x.y] [<name>]
1700# 1609# @DESCRIPTION:
1701# Register this package as ant task, so that ant will load it when no specific 1610# Register this package as ant task, so that ant will load it when no specific
1702# ANT_TASKS are specified. Note that even without this registering, all packages 1611# ANT_TASKS are specified. Note that even without this registering, all packages
1703# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks 1612# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1704# packages, but can be also used by other ebuilds that used to symlink their 1613# packages, but can be also used by other ebuilds that used to symlink their
1705# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards 1614# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1706# compatibility. 1615# compatibility.
1707# 1616#
1617# @CODE
1618# Parameters
1708# @param --version x.y Register only for ant version x.y (otherwise for any ant 1619# --version x.y Register only for ant version x.y (otherwise for any ant
1709# version). Used by the ant-* packages to prevent loading of mismatched 1620# version). Used by the ant-* packages to prevent loading of mismatched
1710# ant-core ant tasks after core was updated, before the tasks are updated, 1621# ant-core ant tasks after core was updated, before the tasks are updated,
1711# without a need for blockers. 1622# without a need for blockers.
1712# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT]) 1623# $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1713# ------------------------------------------------------------------------------ 1624# @CODE
1714java-pkg_register-ant-task() { 1625java-pkg_register-ant-task() {
1715 local TASKS_DIR="tasks" 1626 local TASKS_DIR="tasks"
1716 1627
1717 # check for --version x.y parameters 1628 # check for --version x.y parameters
1718 while [[ -n "${1}" && -n "${2}" ]]; do 1629 while [[ -n "${1}" && -n "${2}" ]]; do
1730 1641
1731 dodir /usr/share/ant/${TASKS_DIR} 1642 dodir /usr/share/ant/${TASKS_DIR}
1732 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1643 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1733} 1644}
1734 1645
1735# ------------------------------------------------------------------------------ 1646# @FUNCTION: java-pkg_ant-tasks-depend
1736# @internal-function java-pkg_ant-tasks-depend 1647# @INTERNAL
1737# 1648# @DESCRIPTION:
1738# Translates the WANT_ANT_TASKS variable into valid dependencies. 1649# Translates the WANT_ANT_TASKS variable into valid dependencies.
1739# ------------------------------------------------------------------------------
1740java-pkg_ant-tasks-depend() { 1650java-pkg_ant-tasks-depend() {
1741 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS} 1651 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1742 1652
1743 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1653 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1744 local DEP="" 1654 local DEP=""
1759 return 0 1669 return 0
1760 fi 1670 fi
1761} 1671}
1762 1672
1763 1673
1764# ------------------------------------------------------------------------------ 1674# @FUNCTION: ejunit_
1765# @internal-function ejunit_ 1675# @INTERNAL
1766# 1676# @DESCRIPTION:
1767# Internal Junit wrapper function. Makes it easier to run the tests and checks for 1677# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1768# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1678# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1769# 1679# @CODE
1680# Parameters:
1770# @param $1 - junit package (junit or junit-4) 1681# $1 - junit package (junit or junit-4)
1771# @param $2 - -cp or -classpath 1682# $2 - -cp or -classpath
1772# @param $3 - classpath; junit and recorded dependencies get appended 1683# $3 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java 1684# $@ - the rest of the parameters are passed to java
1685# @CODE
1774ejunit_() { 1686ejunit_() {
1775 debug-print-function ${FUNCNAME} $* 1687 debug-print-function ${FUNCNAME} $*
1776 1688
1777 local pkgs 1689 local pkgs
1778 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1690 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1798 fi 1710 fi
1799 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1711 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1800 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1712 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1801} 1713}
1802 1714
1803# ------------------------------------------------------------------------------ 1715# @FUNCTION: ejunit
1804# @ebuild-function ejunit 1716# @DESCRIPTION:
1805#
1806# Junit wrapper function. Makes it easier to run the tests and checks for 1717# Junit wrapper function. Makes it easier to run the tests and checks for
1807# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore. 1718# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1719#
1720# @CODE
1721# Parameters:
1722# $1 - -cp or -classpath
1723# $2 - classpath; junit and recorded dependencies get appended
1724# $@ - the rest of the parameters are passed to java
1808# 1725#
1809# Examples: 1726# Examples:
1810# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests 1727# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1811# ejunit org.blinkenlights.jid3.test.AllTests 1728# ejunit org.blinkenlights.jid3.test.AllTests
1812# ejunit org.blinkenlights.jid3.test.FirstTest \ 1729# ejunit org.blinkenlights.jid3.test.FirstTest org.blinkenlights.jid3.test.SecondTest
1813# org.blinkenlights.jid3.test.SecondTest 1730# @CODE
1814#
1815# @param $1 - -cp or -classpath
1816# @param $2 - classpath; junit and recorded dependencies get appended
1817# @param $@ - the rest of the parameters are passed to java
1818# ------------------------------------------------------------------------------
1819ejunit() { 1731ejunit() {
1820 debug-print-function ${FUNCNAME} $* 1732 debug-print-function ${FUNCNAME} $*
1821 1733
1822 ejunit_ "junit" "${@}" 1734 ejunit_ "junit" "${@}"
1823} 1735}
1824 1736
1825# ------------------------------------------------------------------------------ 1737# @FUNCTION: ejunit4
1826# @ebuild-function ejunit4 1738# @DESCRIPTION:
1827#
1828# Junit4 wrapper function. Makes it easier to run the tests and checks for 1739# Junit4 wrapper function. Makes it easier to run the tests and checks for
1829# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner. 1740# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1741#
1742# @CODE
1743# Parameters:
1744# $1 - -cp or -classpath
1745# $2 - classpath; junit and recorded dependencies get appended
1746# $@ - the rest of the parameters are passed to java
1830# 1747#
1831# Examples: 1748# Examples:
1832# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests 1749# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1833# ejunit4 org.blinkenlights.jid3.test.AllTests 1750# ejunit4 org.blinkenlights.jid3.test.AllTests
1834# ejunit4 org.blinkenlights.jid3.test.FirstTest \ 1751# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1835# org.blinkenlights.jid3.test.SecondTest 1752# org.blinkenlights.jid3.test.SecondTest
1836# 1753# @CODE
1837# @param $1 - -cp or -classpath
1838# @param $2 - classpath; junit and recorded dependencies get appended
1839# @param $@ - the rest of the parameters are passed to java
1840# ------------------------------------------------------------------------------
1841ejunit4() { 1754ejunit4() {
1842 debug-print-function ${FUNCNAME} $* 1755 debug-print-function ${FUNCNAME} $*
1843 1756
1844 ejunit_ "junit-4" "${@}" 1757 ejunit_ "junit-4" "${@}"
1845} 1758}
1846 1759
1847# ------------------------------------------------------------------------------ 1760# @FUNCTION: java-utils-2_src_prepare
1848# @section-end helper 1761# @DESCRIPTION:
1849# ------------------------------------------------------------------------------
1850
1851# ------------------------------------------------------------------------------
1852# @eclass-src_prepare
1853#
1854# src_prepare Searches for bundled jars 1762# src_prepare Searches for bundled jars
1855# Don't call directly, but via java-pkg-2_src_prepare! 1763# Don't call directly, but via java-pkg-2_src_prepare!
1856# ------------------------------------------------------------------------------
1857
1858java-utils-2_src_prepare() { 1764java-utils-2_src_prepare() {
1859 [[ ${EBUILD_PHASE} == prepare ]] && 1765 [[ ${EBUILD_PHASE} == prepare ]] &&
1860 java-pkg_func-exists java_prepare && java_prepare 1766 java-pkg_func-exists java_prepare && java_prepare
1861 1767
1862 # Remember that eant will call this unless called via Portage 1768 # Remember that eant will call this unless called via Portage
1868 echo "Search done." 1774 echo "Search done."
1869 fi 1775 fi
1870 touch "${T}/java-utils-2_src_prepare-run" 1776 touch "${T}/java-utils-2_src_prepare-run"
1871} 1777}
1872 1778
1873# ------------------------------------------------------------------------------ 1779# @FUNCTION: java-utils-2_pkg_preinst
1874# @eclass-pkg_preinst 1780# @DESCRIPTION:
1875#
1876# pkg_preinst Searches for missing and unneeded dependencies 1781# pkg_preinst Searches for missing and unneeded dependencies
1877# Don't call directly, but via java-pkg-2_pkg_preinst! 1782# Don't call directly, but via java-pkg-2_pkg_preinst!
1878# ------------------------------------------------------------------------------
1879
1880java-utils-2_pkg_preinst() { 1783java-utils-2_pkg_preinst() {
1881 if is-java-strict; then 1784 if is-java-strict; then
1882 if has_version dev-java/java-dep-check; then 1785 if has_version dev-java/java-dep-check; then
1883 [[ -e "${JAVA_PKG_ENV}" ]] || return 1786 [[ -e "${JAVA_PKG_ENV}" ]] || return
1884 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}") 1787 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1895 eerror "Install dev-java/java-dep-check for dependency checking" 1798 eerror "Install dev-java/java-dep-check for dependency checking"
1896 fi 1799 fi
1897 fi 1800 fi
1898} 1801}
1899 1802
1900# ------------------------------------------------------------------------------ 1803# @FUNCTION: eant
1901# @section-begin build 1804# @USAGE: <ant_build_target(s)>
1902# @section-summary Build functions 1805# @DESCRIPTION:
1903#
1904# These are some functions for building a package. In particular, it consists of
1905# wrappers for javac and ant.
1906# ------------------------------------------------------------------------------
1907
1908# ------------------------------------------------------------------------------
1909# @ebuild-function eant
1910#
1911# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1806# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1912# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1807# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1913# variables: 1808# variables:
1809#
1810# @CODE
1811# Variables:
1914# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1812# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1915# gentoo.classpath property. Be sure to call 1813# gentoo.classpath property. Be sure to call java-ant_rewrite-classpath in src_unpack.
1916# java-ant_rewrite-classpath in src_unpack.
1917# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used 1814# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1918# for build-time purposes, the dependency is not recorded to 1815# for build-time purposes, the dependency is not recorded to
1919# package.env! 1816# package.env!
1920# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1817# ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1921# ------------------------------------------------------------------------------ 1818# @CODE
1922eant() { 1819eant() {
1923 debug-print-function ${FUNCNAME} $* 1820 debug-print-function ${FUNCNAME} $*
1924 1821
1925 if [[ ${EBUILD_PHASE} = compile ]]; then 1822 if [[ ${EBUILD_PHASE} = compile ]]; then
1926 java-ant-2_src_configure 1823 java-ant-2_src_configure
2035 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1932 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
2036 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1933 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
2037 ant ${antflags} "${@}" || die "eant failed" 1934 ant ${antflags} "${@}" || die "eant failed"
2038} 1935}
2039 1936
2040# ------------------------------------------------------------------------------ 1937# @FUNCTION: ejavac
2041# @ebuild-function ejavac 1938# @USAGE: <javac_arguments>
2042# 1939# @DESCRIPTION:
2043# Javac wrapper function. Will use the appropriate compiler, based on 1940# Javac wrapper function. Will use the appropriate compiler, based on
2044# /etc/java-config/compilers.conf 1941# /etc/java-config/compilers.conf
2045#
2046# @param $@ - Arguments to be passed to the compiler
2047# ------------------------------------------------------------------------------
2048ejavac() { 1942ejavac() {
2049 debug-print-function ${FUNCNAME} $* 1943 debug-print-function ${FUNCNAME} $*
2050 1944
2051 java-pkg_init-compiler_ 1945 java-pkg_init-compiler_
2052 1946
2066 1960
2067 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}" 1961 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
2068 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed" 1962 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
2069} 1963}
2070 1964
2071# ------------------------------------------------------------------------------ 1965# @FUNCTION: java-pkg_filter-compiler
2072# @ebuild-function java-pkg_filter-compiler 1966# @USAGE: <compiler(s)_to_filter>
2073# 1967# @DESCRIPTION:
2074# Used to prevent the use of some compilers. Should be used in src_compile. 1968# Used to prevent the use of some compilers. Should be used in src_compile.
2075# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1969# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
2076#
2077# @param $@ - compilers to filter
2078# ------------------------------------------------------------------------------
2079java-pkg_filter-compiler() { 1970java-pkg_filter-compiler() {
2080 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1971 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
2081} 1972}
2082 1973
2083# ------------------------------------------------------------------------------ 1974# @FUNCTION: java-pkg_force-compiler
2084# @ebuild-function java-pkg_force-compiler 1975# @USAGE: <compiler(s)_to_force>
2085# 1976# @DESCRIPTION:
2086# Used to force the use of particular compilers. Should be used in src_compile. 1977# Used to force the use of particular compilers. Should be used in src_compile.
2087# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid 1978# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
2088# OutOfMemoryErrors that may come up. 1979# OutOfMemoryErrors that may come up.
2089#
2090# @param $@ - compilers to force
2091# ------------------------------------------------------------------------------
2092java-pkg_force-compiler() { 1980java-pkg_force-compiler() {
2093 JAVA_PKG_FORCE_COMPILER="$@" 1981 JAVA_PKG_FORCE_COMPILER="$@"
2094} 1982}
2095 1983
2096# ------------------------------------------------------------------------------ 1984# @FUNCTION: use_doc
2097# @ebuild-function use_doc 1985# @DESCRIPTION:
2098# 1986#
2099# Helper function for getting ant to build javadocs. If the user has USE=doc, 1987# Helper function for getting ant to build javadocs. If the user has USE=doc,
2100# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1988# then 'javadoc' or the argument are returned. Otherwise, there is no return.
2101# 1989#
2102# The output of this should be passed to ant. 1990# The output of this should be passed to ant.
1991# @CODE
1992# Parameters:
1993# $@ - Option value to return. Defaults to 'javadoc'
2103# 1994#
1995# Examples:
2104# Example: build javadocs by calling 'javadoc' target 1996# build javadocs by calling 'javadoc' target
2105# eant $(use_doc) 1997# eant $(use_doc)
1998#
2106# Example: build javadocs by calling 'apidoc' target 1999# build javadocs by calling 'apidoc' target
2107# eant $(use_doc apidoc) 2000# eant $(use_doc apidoc)
2108# 2001# @CODE
2109# @param $@ - Option value to return. Defaults to 'javadoc'
2110# @return string - Name of the target to create javadocs 2002# @RETURN string - Name of the target to create javadocs
2111# ------------------------------------------------------------------------------
2112use_doc() { 2003use_doc() {
2113 use doc && echo ${@:-javadoc} 2004 use doc && echo ${@:-javadoc}
2114} 2005}
2115 2006
2116 2007
2117# ------------------------------------------------------------------------------ 2008# @FUNCTION: java-pkg_init
2118# @section-end build 2009# @INTERNAL
2119# ------------------------------------------------------------------------------ 2010# @DESCRIPTION:
2120
2121# ------------------------------------------------------------------------------
2122# @section-begin internal
2123# @section-summary Internal functions
2124#
2125# Do __NOT__ use any of these from an ebuild! These are only to be used from
2126# within the java eclasses.
2127# ------------------------------------------------------------------------------
2128
2129# -----------------------------------------------------------------------------
2130# @function-internal java-pkg_init
2131#
2132# The purpose of this function, as the name might imply, is to initialize the 2011# The purpose of this function, as the name might imply, is to initialize the
2133# Java environment. It ensures that that there aren't any environment variables 2012# Java environment. It ensures that that there aren't any environment variables
2134# that'll muss things up. It initializes some variables, which are used 2013# that'll muss things up. It initializes some variables, which are used
2135# internally. And most importantly, it'll switch the VM if necessary. 2014# internally. And most importantly, it'll switch the VM if necessary.
2136# 2015#
2137# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2016# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2138# call it during each of the phases of the merge process. 2017# call it during each of the phases of the merge process.
2139#
2140# -----------------------------------------------------------------------------
2141java-pkg_init() { 2018java-pkg_init() {
2142 debug-print-function ${FUNCNAME} $* 2019 debug-print-function ${FUNCNAME} $*
2143 2020
2144 # Don't set up build environment if installing from binary. #206024 #258423 2021 # Don't set up build environment if installing from binary. #206024 #258423
2145 [[ "${MERGE_TYPE}" == "binary" ]] && return 2022 [[ "${MERGE_TYPE}" == "binary" ]] && return
2205 export ANT_TASKS= 2082 export ANT_TASKS=
2206 export ANT_OPTS= 2083 export ANT_OPTS=
2207 export ANT_RESPECT_JAVA_HOME= 2084 export ANT_RESPECT_JAVA_HOME=
2208} 2085}
2209 2086
2210# ------------------------------------------------------------------------------ 2087# @FUNCTION: java-pkg-init-compiler_
2211# @function-internal java-pkg-init-compiler_ 2088# @INTERNAL
2212# 2089# @DESCRIPTION:
2213# This function attempts to figure out what compiler should be used. It does 2090# This function attempts to figure out what compiler should be used. It does
2214# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 2091# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
2215# COMPILERS variable defined there. 2092# COMPILERS variable defined there.
2216# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 2093# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
2217# 2094#
2228# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no 2105# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
2229# suitable compiler was found there, then the default is to use javac provided 2106# suitable compiler was found there, then the default is to use javac provided
2230# by the current VM. 2107# by the current VM.
2231# 2108#
2232# 2109#
2233# @return name of the compiler to use 2110# @RETURN name of the compiler to use
2234# ------------------------------------------------------------------------------
2235java-pkg_init-compiler_() { 2111java-pkg_init-compiler_() {
2236 debug-print-function ${FUNCNAME} $* 2112 debug-print-function ${FUNCNAME} $*
2237 2113
2238 if [[ -n ${GENTOO_COMPILER} ]]; then 2114 if [[ -n ${GENTOO_COMPILER} ]]; then
2239 debug-print "GENTOO_COMPILER already set" 2115 debug-print "GENTOO_COMPILER already set"
2319 einfo "Using ${GENTOO_COMPILER} for compilation" 2195 einfo "Using ${GENTOO_COMPILER} for compilation"
2320 fi 2196 fi
2321 2197
2322} 2198}
2323 2199
2324# ------------------------------------------------------------------------------ 2200# @FUNCTION: init_paths_
2325# @internal-function init_paths_ 2201# @INTERNAL
2326# 2202# @DESCRIPTION:
2327# Initializes some variables that will be used. These variables are mostly used 2203# Initializes some variables that will be used. These variables are mostly used
2328# to determine where things will eventually get installed. 2204# to determine where things will eventually get installed.
2329# ------------------------------------------------------------------------------
2330java-pkg_init_paths_() { 2205java-pkg_init_paths_() {
2331 debug-print-function ${FUNCNAME} $* 2206 debug-print-function ${FUNCNAME} $*
2332 2207
2333 local pkg_name 2208 local pkg_name
2334 if [[ "${SLOT%/*}" == "0" ]] ; then 2209 if [[ "${SLOT%/*}" == "0" ]] ; then
2354 debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}" 2229 debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
2355 debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}" 2230 debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
2356 debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}" 2231 debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
2357} 2232}
2358 2233
2359# ------------------------------------------------------------------------------ 2234# @FUNCTION: java-pkg_do_write_
2360# @internal-function java-pkg_do_write_ 2235# @INTERNAL
2361# 2236# @DESCRIPTION:
2362# Writes the package.env out to disk. 2237# Writes the package.env out to disk.
2363# 2238#
2364# ------------------------------------------------------------------------------
2365# TODO change to do-write, to match everything else 2239# TODO change to do-write, to match everything else
2366java-pkg_do_write_() { 2240java-pkg_do_write_() {
2367 debug-print-function ${FUNCNAME} $* 2241 debug-print-function ${FUNCNAME} $*
2368 java-pkg_init_paths_ 2242 java-pkg_init_paths_
2369 # Create directory for package.env 2243 # Create directory for package.env
2424 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't" 2298 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2425 debug-print "write package.env." 2299 debug-print "write package.env."
2426 fi 2300 fi
2427} 2301}
2428 2302
2429# ------------------------------------------------------------------------------ 2303# @FUNCTION: java-pkg_record-jar_
2430# @internal-function java-pkg_record-jar_ 2304# @INTERNAL
2431# 2305# @DESCRIPTION:
2432# Record an (optional) dependency to the package.env 2306# Record an (optional) dependency to the package.env
2307# @CODE
2308# Parameters:
2433# @param --optional - record dependency as optional 2309# --optional - record dependency as optional
2434# @param --build - record dependency as build_only 2310# --build - record dependency as build_only
2435# @param $1 - package to record 2311# $1 - package to record
2436# @param $2 - (optional) jar of package to record 2312# $2 - (optional) jar of package to record
2437# ------------------------------------------------------------------------------ 2313# @CODE
2438JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2314JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2439JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2315JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2440JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend" 2316JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2441 2317
2442java-pkg_record-jar_() { 2318java-pkg_record-jar_() {
2456 fi 2332 fi
2457 2333
2458 echo "${append}" >> "${depend_file}" 2334 echo "${append}" >> "${depend_file}"
2459} 2335}
2460 2336
2461# ------------------------------------------------------------------------------ 2337# @FUNCTION: java-pkg_append_
2462# @internal-function java-pkg_append_ 2338# @INTERNAL
2463# 2339# @DESCRIPTION:
2464# Appends a value to a variable 2340# Appends a value to a variable
2465# 2341#
2466# Example: java-pkg_append_ CLASSPATH foo.jar 2342# @CODE
2343# Parameters:
2467# @param $1 variable name to modify 2344# $1 variable name to modify
2468# @param $2 value to append 2345# $2 value to append
2469# ------------------------------------------------------------------------------ 2346#
2347# Examples:
2348# java-pkg_append_ CLASSPATH foo.jar
2349# @CODE
2470java-pkg_append_() { 2350java-pkg_append_() {
2471 debug-print-function ${FUNCNAME} $* 2351 debug-print-function ${FUNCNAME} $*
2472 2352
2473 local var="${1}" value="${2}" 2353 local var="${1}" value="${2}"
2474 if [[ -z "${!var}" ]] ; then 2354 if [[ -z "${!var}" ]] ; then
2485 [[ -z ${haveit} ]] && export ${var}="${!var}:${value}" 2365 [[ -z ${haveit} ]] && export ${var}="${!var}:${value}"
2486 IFS=${oldIFS} 2366 IFS=${oldIFS}
2487 fi 2367 fi
2488} 2368}
2489 2369
2490# ------------------------------------------------------------------------------ 2370# @FUNCTION: java-pkg_expand_dir_
2491# @internal-function java-pkg_expand_dir_ 2371# @INTERNAL
2492# 2372# @DESCRIPTION:
2493# Gets the full path of the file/directory's parent. 2373# Gets the full path of the file/directory's parent.
2374# @CODE
2375# Parameters:
2494# @param $1 - file/directory to find parent directory for 2376# $1 - file/directory to find parent directory for
2377# @CODE
2495# @return - path to $1's parent directory 2378# @RETURN: path to $1's parent directory
2496# ------------------------------------------------------------------------------
2497java-pkg_expand_dir_() { 2379java-pkg_expand_dir_() {
2498 pushd "$(dirname "${1}")" >/dev/null 2>&1 2380 pushd "$(dirname "${1}")" >/dev/null 2>&1
2499 pwd 2381 pwd
2500 popd >/dev/null 2>&1 2382 popd >/dev/null 2>&1
2501} 2383}
2502 2384
2503# ------------------------------------------------------------------------------ 2385# @FUNCTION: java-pkg_func-exists
2504# @internal-function java-pkg_func-exists 2386# @INTERNAL
2505# 2387# @DESCRIPTION:
2506# Does the indicated function exist? 2388# Does the indicated function exist?
2507# 2389# @RETURN: 0 - function is declared, 1 - function is undeclared
2508# @return 0 - function is declared
2509# @return 1 - function is undeclared
2510# ------------------------------------------------------------------------------
2511java-pkg_func-exists() { 2390java-pkg_func-exists() {
2512 declare -F ${1} > /dev/null 2391 declare -F ${1} > /dev/null
2513} 2392}
2514 2393
2515# ------------------------------------------------------------------------------ 2394# @FUNCTION: java-pkg_setup-vm
2516# @internal-function java-pkg_setup-vm 2395# @INTERNAL
2517# 2396# @DESCRIPTION:
2518# Sets up the environment for a specific VM 2397# Sets up the environment for a specific VM
2519#
2520# ------------------------------------------------------------------------------
2521java-pkg_setup-vm() { 2398java-pkg_setup-vm() {
2522 debug-print-function ${FUNCNAME} $* 2399 debug-print-function ${FUNCNAME} $*
2523 2400
2524 local vendor="$(java-pkg_get-vm-vendor)" 2401 local vendor="$(java-pkg_get-vm-vendor)"
2525 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2402 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2537 elif [[ "${vendor}" == "jrockit" ]]; then 2414 elif [[ "${vendor}" == "jrockit" ]]; then
2538 addpredict "/proc/cpuinfo" 2415 addpredict "/proc/cpuinfo"
2539 fi 2416 fi
2540} 2417}
2541 2418
2542# ------------------------------------------------------------------------------ 2419# @FUNCTION: java-pkg_needs-vm
2543# @internal-function java-pkg_needs-vm 2420# @INTERNAL
2544# 2421# @DESCRIPTION:
2545# Does the current package depend on virtual/jdk or does it set 2422# Does the current package depend on virtual/jdk or does it set
2546# JAVA_PKG_WANT_BUILD_VM? 2423# JAVA_PKG_WANT_BUILD_VM?
2547# 2424#
2548# @return 0 - Package depends on virtual/jdk 2425# @RETURN: 0 - Package depends on virtual/jdk; 1 - Package does not depend on virtual/jdk
2549# @return 1 - Package does not depend on virtual/jdk
2550# ------------------------------------------------------------------------------
2551java-pkg_needs-vm() { 2426java-pkg_needs-vm() {
2552 debug-print-function ${FUNCNAME} $* 2427 debug-print-function ${FUNCNAME} $*
2553 2428
2554 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then 2429 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2555 return 0 2430 return 0
2558 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0 2433 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2559 2434
2560 return 1 2435 return 1
2561} 2436}
2562 2437
2563# ------------------------------------------------------------------------------ 2438# @FUNCTION: java-pkg_get-current-vm
2564# @internal-function java-pkg_get-current-vm 2439# @INTERNAL
2565#
2566# @return - The current VM being used 2440# @RETURN - The current VM being used
2567# ------------------------------------------------------------------------------
2568java-pkg_get-current-vm() { 2441java-pkg_get-current-vm() {
2569 java-config -f 2442 java-config -f
2570} 2443}
2571 2444
2572# ------------------------------------------------------------------------------ 2445# @FUNCTION: java-pkg_get-vm-vendor
2573# @internal-function java-pkg_get-vm-vendor 2446# @INTERNAL
2574#
2575# @return - The vendor of the current VM 2447# @RETURN - The vendor of the current VM
2576# ------------------------------------------------------------------------------
2577java-pkg_get-vm-vendor() { 2448java-pkg_get-vm-vendor() {
2578 debug-print-function ${FUNCNAME} $* 2449 debug-print-function ${FUNCNAME} $*
2579 2450
2580 local vm="$(java-pkg_get-current-vm)" 2451 local vm="$(java-pkg_get-current-vm)"
2581 vm="${vm/-*/}" 2452 vm="${vm/-*/}"
2582 echo "${vm}" 2453 echo "${vm}"
2583} 2454}
2584 2455
2585# ------------------------------------------------------------------------------ 2456# @FUNCTION: java-pkg_get-vm-version
2586# @internal-function java-pkg_get-vm-version 2457# @INTERNAL
2587#
2588# @return - The version of the current VM 2458# @RETURN - The version of the current VM
2589# ------------------------------------------------------------------------------
2590java-pkg_get-vm-version() { 2459java-pkg_get-vm-version() {
2591 debug-print-function ${FUNCNAME} $* 2460 debug-print-function ${FUNCNAME} $*
2592 2461
2593 java-config -g PROVIDES_VERSION 2462 java-config -g PROVIDES_VERSION
2594} 2463}
2595 2464
2596# ------------------------------------------------------------------------------ 2465# @FUNCTION: java-pkg_build-vm-from-handle
2597# @internal-function java-pkg_build-vm-from-handle 2466# @INTERNAL
2598# 2467# @DESCRIPTION:
2599# Selects a build vm from a list of vm handles. First checks for the system-vm 2468# Selects a build vm from a list of vm handles. First checks for the system-vm
2600# beeing usable, then steps through the listed handles till a suitable vm is 2469# beeing usable, then steps through the listed handles till a suitable vm is
2601# found. 2470# found.
2602# 2471#
2603# @return - VM handle of an available JDK 2472# @RETURN - VM handle of an available JDK
2604# ------------------------------------------------------------------------------
2605java-pkg_build-vm-from-handle() { 2473java-pkg_build-vm-from-handle() {
2606 debug-print-function ${FUNCNAME} "$*" 2474 debug-print-function ${FUNCNAME} "$*"
2607 2475
2608 local vm 2476 local vm
2609 vm=$(java-pkg_get-current-vm 2>/dev/null) 2477 vm=$(java-pkg_get-current-vm 2>/dev/null)
2623 2491
2624 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}" 2492 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2625 return 1 2493 return 1
2626} 2494}
2627 2495
2628# ------------------------------------------------------------------------------ 2496# @FUNCTION: java-pkg_switch-vm
2629# @internal-function java-pkg_switch-vm 2497# @INTERNAL
2630# 2498# @DESCRIPTION:
2631# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2499# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
2632# verify that the current VM is sufficient. 2500# verify that the current VM is sufficient.
2633# Setup the environment for the VM being used. 2501# Setup the environment for the VM being used.
2634# ------------------------------------------------------------------------------
2635java-pkg_switch-vm() { 2502java-pkg_switch-vm() {
2636 debug-print-function ${FUNCNAME} $* 2503 debug-print-function ${FUNCNAME} $*
2637 2504
2638 if java-pkg_needs-vm; then 2505 if java-pkg_needs-vm; then
2639 # Use the VM specified by JAVA_PKG_FORCE_VM 2506 # Use the VM specified by JAVA_PKG_FORCE_VM
2707 else 2574 else
2708 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2575 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2709 fi 2576 fi
2710} 2577}
2711 2578
2712# ------------------------------------------------------------------------------ 2579# @FUNCTION: java-pkg_die
2713# @internal-function java-pkg_die 2580# @INTERNAL
2714# 2581# @DESCRIPTION:
2715# Enhanced die for Java packages, which displays some information that may be 2582# Enhanced die for Java packages, which displays some information that may be
2716# useful for debugging bugs on bugzilla. 2583# useful for debugging bugs on bugzilla.
2717# ------------------------------------------------------------------------------
2718#register_die_hook java-pkg_die 2584#register_die_hook java-pkg_die
2719if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2585if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2720 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2586 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2721fi 2587fi
2722 2588
2739 einfo "Classes" 2605 einfo "Classes"
2740 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2606 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2741 fi 2607 fi
2742} 2608}
2743 2609
2744# ------------------------------------------------------------------------------ 2610# @FUNCTION: java-pkg_verify-classes
2745# @internal-function java-pkg_verify-classes 2611# @INTERNAL
2746# 2612# @DESCRIPTION:
2747# Verify that the classes were compiled for the right source / target. Dies if 2613# Verify that the classes were compiled for the right source / target. Dies if
2748# not. 2614# not.
2615# @CODE
2749# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2616# $1 (optional) - the file to check, otherwise checks whole ${D}
2750# ------------------------------------------------------------------------------ 2617# @CODE
2751java-pkg_verify-classes() { 2618java-pkg_verify-classes() {
2752 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2619 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2753 2620
2754 local version_verify="/usr/bin/class-version-verify.py" 2621 local version_verify="/usr/bin/class-version-verify.py"
2755 2622
2783 eerror "See ${log} for more details." 2650 eerror "See ${log} for more details."
2784 die "Incorrect bytecode found" 2651 die "Incorrect bytecode found"
2785 fi 2652 fi
2786} 2653}
2787 2654
2788# ---------------------------------------------------------------------------- 2655# @FUNCTION: java-pkg_ensure-dep
2789# @internal-function java-pkg_ensure-dep 2656# @INTERNAL
2657# @DESCRIPTION:
2790# Check that a package being used in jarfrom, getjars and getjar is contained 2658# Check that a package being used in jarfrom, getjars and getjar is contained
2791# within DEPEND or RDEPEND. 2659# within DEPEND or RDEPEND.
2660# @CODE
2661# Parameters:
2792# @param $1 - empty - check both vars; "runtime" or "build" - check only 2662# $1 - empty - check both vars; "runtime" or "build" - check only
2793# RDEPEND, resp. DEPEND 2663# RDEPEND, resp. DEPEND
2794# @param $2 - Package name and slot. 2664# $2 - Package name and slot.
2795 2665# @CODE
2796java-pkg_ensure-dep() { 2666java-pkg_ensure-dep() {
2797 debug-print-function ${FUNCNAME} $* 2667 debug-print-function ${FUNCNAME} $*
2798 2668
2799 local limit_to="${1}" 2669 local limit_to="${1}"
2800 local target_pkg="${2}" 2670 local target_pkg="${2}"
2838 fi 2708 fi
2839 fi 2709 fi
2840 fi 2710 fi
2841} 2711}
2842 2712
2843# ------------------------------------------------------------------------------
2844# @section-end internal
2845# ------------------------------------------------------------------------------
2846
2847java-pkg_check-phase() { 2713java-pkg_check-phase() {
2848 local phase=${1} 2714 local phase=${1}
2849 local funcname=${FUNCNAME[1]} 2715 local funcname=${FUNCNAME[1]}
2850 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 2716 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2851 local msg="${funcname} used outside of src_${phase}" 2717 local msg="${funcname} used outside of src_${phase}"
2885 2751
2886is-java-strict() { 2752is-java-strict() {
2887 [[ -n ${JAVA_PKG_STRICT} ]] 2753 [[ -n ${JAVA_PKG_STRICT} ]]
2888 return $? 2754 return $?
2889} 2755}
2890
2891
2892# ------------------------------------------------------------------------------
2893# @eclass-end
2894# ------------------------------------------------------------------------------

Legend:
Removed from v.1.154  
changed lines
  Added in v.1.155

  ViewVC Help
Powered by ViewVC 1.1.20