/[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.127 Revision 1.165
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2015, 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.127 2009/05/19 21:23:32 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.165 2015/06/28 13:33:48 chewi 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# -----------------------------------------------------------------------------
66hasq "${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.6 ${JAVA_PKG_PORTAGE_DEP}" 46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0 ${JAVA_PKG_PORTAGE_DEP}"
76hasq 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-external JAVA_PKG_ALLOW_VM_CHANGE 50# @DEFAULT_UNSET
80# @variable-default yes 51# @DESCRIPTION:
81# 52# The version of bootclasspath the package needs to work. Translates to a proper
53# dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath
54if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
55 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
56 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
57 else
58 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
59 # since die in global scope doesn't work, this will make repoman fail
60 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
61 fi
62fi
63
64# @ECLASS-VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE
65# @DESCRIPTION:
82# Allow this eclass to change the active VM? 66# Allow this eclass to change the active VM?
83# 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
84# @note This is useful for testing specific VMs. 68# instead of trying to switch to another VM.
85# ----------------------------------------------------------------------------- 69#
70# Overriding the default can be useful for testing specific VMs locally, but
71# should not be used in the final ebuild.
86JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} 72JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
87 73
88# ----------------------------------------------------------------------------- 74# @ECLASS-VARIABLE: JAVA_PKG_FORCE_VM
89# @variable-external JAVA_PKG_FORCE_VM 75# @DEFAULT_UNSET
90# 76# @DESCRIPTION:
91# 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
92# 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.
93# 79#
94# Should only be used for testing and debugging. 80# Should only be used for testing and debugging.
95# 81#
96# @example Use sun-jdk-1.5 to emerge foo 82# Example: use sun-jdk-1.5 to emerge foo:
83# @CODE
97# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 84# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
98# 85# @CODE
99# -----------------------------------------------------------------------------
100 86
101# ----------------------------------------------------------------------------- 87# @ECLASS-VARIABLE: JAVA_PKG_WANT_BUILD_VM
102# @variable-external JAVA_PKG_WANT_SOURCE 88# @DEFAULT_UNSET
89# @DESCRIPTION:
90# A list of VM handles to choose a build VM from. If the list contains the
91# currently active VM use that one, otherwise step through the list till a
92# usable/installed VM is found.
103# 93#
104# Specify a specific VM version to compile for to use for -source. 94# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
105# Normally this is determined from DEPEND. 95# Users of this variable must make sure at least one of the listed handles is
96# covered by DEPEND.
97# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
98
99# @ECLASS-VARIABLE: JAVA_PKG_WANT_SOURCE
100# @DEFAULT_UNSET
101# @DESCRIPTION:
102# Specify a non-standard Java source version for compilation (via javac -source
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.
106# See java-pkg_get-source function below. 105# See java-pkg_get-source function below.
107# 106#
108# Should only be used for testing and debugging. 107# Should generally only be used for testing and debugging.
109# 108#
110# @seealso java-pkg_get-source
111#
112# @example Use 1.4 source to emerge baz 109# Use 1.4 source to emerge baz
110# @CODE
113# JAVA_PKG_WANT_SOURCE=1.4 emerge baz 111# JAVA_PKG_WANT_SOURCE=1.4 emerge baz
114# ----------------------------------------------------------------------------- 112# @CODE
115 113
116# ----------------------------------------------------------------------------- 114# @ECLASS-VARIABLE: JAVA_PKG_WANT_TARGET
117# @variable-external JAVA_PKG_WANT_TARGET 115# @DEFAULT_UNSET
118# 116# @DESCRIPTION:
119# 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.
120# See java-pkg_get-target function below. 120# See java-pkg_get-target function below.
121# 121#
122# Should only be used for testing and debugging. 122# Should generallyonly be used for testing and debugging.
123# 123#
124# @seealso java-pkg_get-target
125#
126# @example emerge bar to be compatible with 1.3 124# emerge bar to be compatible with 1.3
125# @CODE
127# JAVA_PKG_WANT_TARGET=1.3 emerge bar 126# JAVA_PKG_WANT_TARGET=1.3 emerge bar
128# ----------------------------------------------------------------------------- 127# @CODE
129 128
130# ----------------------------------------------------------------------------- 129# @VARIABLE: JAVA_PKG_COMPILER_DIR
131# @variable-internal JAVA_PKG_COMPILER_DIR 130# @INTERNAL
132# @default /usr/share/java-config-2/compiler 131# @DESCRIPTION:
133#
134# Directory where compiler settings are saved, without trailing slash. 132# Directory where compiler settings are saved, without trailing slash.
135# Probably shouldn't touch this variable. 133# You probably shouldn't touch this variable except local testing.
136# -----------------------------------------------------------------------------
137JAVA_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"}
138 135
139 136# @VARIABLE: JAVA_PKG_COMPILERS_CONF
140# ----------------------------------------------------------------------------- 137# @INTERNAL
141# @variable-internal JAVA_PKG_COMPILERS_CONF 138# @DESCRIPTION:
142# @variable-default /etc/java-config-2/build/compilers.conf
143#
144# Path to file containing information about which compiler to use. 139# Path to file containing information about which compiler to use.
145# Can be overloaded, but it should be overloaded for testing. 140# Can be overloaded, but it should be overloaded only for local testing.
146# -----------------------------------------------------------------------------
147JAVA_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"}
148 142
149# ----------------------------------------------------------------------------- 143# @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER
150# @variable-external JAVA_PKG_FORCE_COMPILER 144# @INTERNAL
151# 145# @DEFAULT_UNSET
146# @DESCRIPTION:
152# 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
153# JAVA_PKG_COMPILERS_CONF. 148# JAVA_PKG_COMPILERS_CONF.
154# 149#
155# @note This should only be used internally or for testing. 150# Useful for local testing.
151#
156# @example Use jikes and javac, in that order 152# Use jikes and javac, in that order
153# @CODE
157# JAVA_PKG_FORCE_COMPILER="jikes javac" 154# JAVA_PKG_FORCE_COMPILER="jikes javac"
158# ----------------------------------------------------------------------------- 155# @CODE
159 156
160# ----------------------------------------------------------------------------- 157# @ECLASS-VARIABLE: JAVA_PKG_FORCE_ANT_TASKS
161# @variable-external JAVA_PKG_FORCE_ANT_TASKS 158# @DEFAULT_UNSET
162# 159# @DESCRIPTION:
163# 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
164# 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
165# 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
166# eant() call, not the dependencies specified in WANT_ANT_TASKS. 163# eant() call, not the dependencies specified in WANT_ANT_TASKS.
167# 164#
165# @CODE
168# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \ 166# JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
169# ebuild foo.ebuild compile 167# ebuild foo.ebuild compile
170# 168# @CODE
171# @seealso WANT_ANT_TASKS
172# -----------------------------------------------------------------------------
173 169
174# TODO document me 170# TODO document me
175JAVA_PKG_QA_VIOLATIONS=0 171JAVA_PKG_QA_VIOLATIONS=0
176 172
177# ----------------------------------------------------------------------------- 173# @FUNCTION: java-pkg_doexamples
178# @section-end variables 174# @USAGE: [--subdir <subdir>] <file1/dir1> [<file2> ...]
179# ----------------------------------------------------------------------------- 175# @DESCRIPTION:
180
181
182# -----------------------------------------------------------------------------
183# @section-begin install
184# @section-summary Install functions
185#
186# These are used to install Java-related things, such as jars, Javadocs, JNI
187# libraries, etc.
188# -----------------------------------------------------------------------------
189
190# -----------------------------------------------------------------------------
191# @ebuild-function java-pkg_doexamples
192#
193# Installs given arguments to /usr/share/doc/${PF}/examples 176# Installs given arguments to /usr/share/doc/${PF}/examples
194# 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
195# everything in that directory to the examples directory. 178# everything in that directory to the examples directory.
196# 179#
180# @CODE
181# Parameters:
182# --subdir - If the examples need a certain directory structure
183# $* - list of files to install
184#
197# @example 185# Examples:
198# java-pkg_doexamples demo 186# java-pkg_doexamples demo
199# java-pkg_doexamples demo/* examples/* 187# java-pkg_doexamples demo/* examples/*
200# 188# @CODE
201# @param --subdir - If the examples need a certain directory structure
202# @param $* - list of files to install
203# ------------------------------------------------------------------------------
204java-pkg_doexamples() { 189java-pkg_doexamples() {
205 debug-print-function ${FUNCNAME} $* 190 debug-print-function ${FUNCNAME} $*
206 191
207 [[ ${#} -lt 1 ]] && die "At least one argument needed" 192 [[ ${#} -lt 1 ]] && die "At least one argument needed"
208 193
209 java-pkg_check-phase install 194 java-pkg_check-phase install
195 java-pkg_init_paths_
210 196
211 local dest=/usr/share/doc/${PF}/examples 197 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then 198 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2} 199 local dest=${dest}/${2}
214 dodir ${dest} 200 dodir ${dest}
224 ( # dont want to pollute calling env 210 ( # dont want to pollute calling env
225 insinto "${dest}" 211 insinto "${dest}"
226 doins -r "$@" 212 doins -r "$@"
227 ) || die "Installing examples failed" 213 ) || die "Installing examples failed"
228 fi 214 fi
229}
230 215
231# ----------------------------------------------------------------------------- 216 # Let's make a symlink to the directory we have everything else under
232# @ebuild-function java-pkg_dojar 217 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
218}
219
220# @FUNCTION: java-pkg_addres
221# @USAGE: <jar> <dir> [<find arguments> ...]
222# @DESCRIPTION:
223# Adds resource files to an existing jar.
224# It is important that the directory given is actually the root of the
225# corresponding resource tree. The target directory as well as
226# sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are
227# automatically excluded. Symlinks are always followed. Additional
228# arguments are passed through to find.
233# 229#
230# @CODE
231# java-pkg_addres ${PN}.jar resources ! -name "*.html"
232# @CODE
233#
234# @param $1 - jar file
235# @param $2 - resource tree directory
236# @param $* - arguments to pass to find
237java-pkg_addres() {
238 debug-print-function ${FUNCNAME} $*
239
240 [[ ${#} -lt 2 ]] && die "at least two arguments needed"
241
242 local jar=$(realpath "$1" || die "realpath $1 failed")
243 local dir="$2"
244 shift 2
245
246 pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
247 find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -0 jar uf "${jar}" || die "jar failed"
248 popd > /dev/null || die "popd failed"
249}
250
251# @FUNCTION: java-pkg_dojar
252# @USAGE: <jar1> [<jar2> ...]
253# @DESCRIPTION:
234# Installs any number of jars. 254# Installs any number of jars.
235# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 255# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
236# You can use java-pkg_jarinto to change this path. 256# You can use java-pkg_jarinto to change this path.
237# You should never install a jar with a package version in the filename. 257# You should never install a jar with a package version in the filename.
238# Instead, use java-pkg_newjar defined below. 258# Instead, use java-pkg_newjar defined below.
239# 259#
240# @example 260# @CODE
241# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 261# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
262# @CODE
242# 263#
243# @param $* - list of jars to install 264# @param $* - list of jars to install
244# ------------------------------------------------------------------------------
245java-pkg_dojar() { 265java-pkg_dojar() {
246 debug-print-function ${FUNCNAME} $* 266 debug-print-function ${FUNCNAME} $*
247 267
248 [[ ${#} -lt 1 ]] && die "At least one argument needed" 268 [[ ${#} -lt 1 ]] && die "At least one argument needed"
249 269
291 done 311 done
292 312
293 java-pkg_do_write_ 313 java-pkg_do_write_
294} 314}
295 315
296# ------------------------------------------------------------------------------ 316# @FUNCTION: java-pkg_regjar
297# @internal-function depend-java-query 317# @USAGE: </path/to/installed/jar>
298# 318# @DESCRIPTION:
299# Wrapper for the depend-java-query binary to enable passing USE in env.
300# Using env variables keeps this eclass working with java-config versions that
301# do not handle use flags.
302# ------------------------------------------------------------------------------
303
304depend-java-query() {
305 # Used to have a which call here but it caused endless loops for some people
306 # that had some weird bashrc voodoo for which.
307 USE="${USE}" /usr/bin/depend-java-query "${@}"
308}
309
310# ------------------------------------------------------------------------------
311# @ebuild-function java-pkg_regjar
312#
313# Records an already installed jar in the package.env 319# Records an already installed (in ${D}) jar in the package.env
314# This would mostly be used if the package has make or a custom script to 320# This would mostly be used if the package has make or a custom script to
315# install things. 321# install things.
316# 322#
317# Example:
318# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
319#
320# WARNING: 323# WARNING:
321# if you want to use shell expansion, you have to use ${D}/... as the for in 324# if you want to use shell expansion, you have to use ${D}/... as the for in
322# this function will not be able to expand the path, here's an example: 325# this function will not be able to expand the path, here's an example:
323# 326#
324# java-pkg_regjar /opt/my-java/lib/*.jar 327# @CODE
325#
326# will not work, because:
327# * the `for jar in "$@"` can't expand the path to jar file names, as they
328# don't exist yet
329# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
330# doesn't exist
331#
332# you have to use it as:
333#
334# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 328# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
329# @CODE
335# 330#
336# @param $@ - jars to record 331
337# ------------------------------------------------------------------------------
338# TODO should we be making sure the jar is present on ${D} or wherever? 332# TODO should we be making sure the jar is present on ${D} or wherever?
339java-pkg_regjar() { 333java-pkg_regjar() {
340 debug-print-function ${FUNCNAME} $* 334 debug-print-function ${FUNCNAME} $*
341 335
342 java-pkg_check-phase install 336 java-pkg_check-phase install
373 done 367 done
374 368
375 java-pkg_do_write_ 369 java-pkg_do_write_
376} 370}
377 371
378# ------------------------------------------------------------------------------ 372# @FUNCTION: java-pkg_newjar
379# @ebuild-function java-pkg_newjar 373# @USAGE: <path/to/oldname.jar> [<newname.jar>]
374# @DESCRIPTION:
375# Installs a jar with a new name (defaults to $PN.jar)
380# 376#
381# Installs a jar with a new name
382#
383# @example: install a versioned jar without the version 377# For example, installs a versioned jar without the version
384# java-pkg_newjar dist/${P}.jar ${PN}.jar
385#
386# @param $1 - jar to install
387# @param $2 - new name for jar - defaults to ${PN}.jar if not specified
388# ------------------------------------------------------------------------------
389java-pkg_newjar() { 378java-pkg_newjar() {
390 debug-print-function ${FUNCNAME} $* 379 debug-print-function ${FUNCNAME} $*
391 380
392 local original_jar="${1}" 381 local original_jar="${1}"
393 local new_jar="${2:-${PN}.jar}" 382 local new_jar="${2:-${PN}.jar}"
401 cp "${original_jar}" "${new_jar_dest}" \ 390 cp "${original_jar}" "${new_jar_dest}" \
402 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 391 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
403 java-pkg_dojar "${new_jar_dest}" 392 java-pkg_dojar "${new_jar_dest}"
404} 393}
405 394
406# ------------------------------------------------------------------------------ 395# @FUNCTION: java-pkg_addcp
407# @ebuild-function java-pkg_addcp 396# @USAGE: <classpath>
408# 397# @DESCRIPTION:
409# Add something to the package's classpath. For jars, you should use dojar, 398# Add something to the package's classpath. For jars, you should use dojar,
410# newjar, or regjar. This is typically used to add directories to the classpath. 399# newjar, or regjar. This is typically used to add directories to the classpath.
411# 400# The parameters of this function are appended to JAVA_PKG_CLASSPATH
412# TODO add example
413# @param $@ - value to append to JAVA_PKG_CLASSPATH
414# ------------------------------------------------------------------------------
415java-pkg_addcp() { 401java-pkg_addcp() {
416 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 402 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
417 java-pkg_do_write_ 403 java-pkg_do_write_
418} 404}
419 405
420# ------------------------------------------------------------------------------ 406# @FUNCTION: java-pkg_doso
421# @ebuild-function java-pkg_doso 407# @USAGE: <path/to/file1.so> [...]
422# 408# @DESCRIPTION:
423# Installs any number of JNI libraries 409# Installs any number of JNI libraries
424# They will be installed into /usr/lib by default, but java-pkg_sointo 410# They will be installed into /usr/lib by default, but java-pkg_sointo
425# can be used change this path 411# can be used change this path
426# 412#
413# @CODE
427# Example: 414# Example:
428# java-pkg_doso *.so 415# java-pkg_doso *.so
429# 416# @CODE
430# @param $@ - JNI libraries to install
431# ------------------------------------------------------------------------------
432java-pkg_doso() { 417java-pkg_doso() {
433 debug-print-function ${FUNCNAME} $* 418 debug-print-function ${FUNCNAME} $*
434 419
435 java-pkg_check-phase install 420 java-pkg_check-phase install
436 421
444 # if the lib exists... 429 # if the lib exists...
445 if [[ -e "${lib}" ]] ; then 430 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 431 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 432 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 433 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 434 INSOPTIONS="-m0755" \
450 doins "${lib}" || die "failed to install ${lib}" 435 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 436 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 437 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 438 # otherwise make a symlink to the symlink's origin
454 else 439 else
462 done 447 done
463 448
464 java-pkg_do_write_ 449 java-pkg_do_write_
465} 450}
466 451
467# ------------------------------------------------------------------------------ 452# @FUNCTION: java-pkg_regso
468# @ebuild-function java-pkg_regso 453# @USAGE: <file1.so> [...]
469# 454# @DESCRIPTION:
470# Registers an already JNI library in package.env. 455# Registers an already installed JNI library in package.env.
456#
457# @CODE
458# Parameters:
459# $@ - JNI libraries to register
471# 460#
472# Example: 461# Example:
473# java-pkg_regso *.so /path/*.so 462# java-pkg_regso *.so /path/*.so
474# 463# @CODE
475# @param $@ - JNI libraries to register
476# ------------------------------------------------------------------------------
477java-pkg_regso() { 464java-pkg_regso() {
478 debug-print-function ${FUNCNAME} $* 465 debug-print-function ${FUNCNAME} $*
479 466
480 java-pkg_check-phase install 467 java-pkg_check-phase install
481 468
499 done 486 done
500 487
501 java-pkg_do_write_ 488 java-pkg_do_write_
502} 489}
503 490
504# ------------------------------------------------------------------------------ 491# @FUNCTION: java-pkg_jarinto
505# @ebuild-function java-pkg_jarinto 492# @USAGE: </path/to/install/jars/into>
506# 493# @DESCRIPTION:
507# Changes the path jars are installed into 494# Changes the path jars are installed into via subsequent java-pkg_dojar calls.
508#
509# @param $1 - new location to install jars into.
510# -----------------------------------------------------------------------------
511java-pkg_jarinto() { 495java-pkg_jarinto() {
512 debug-print-function ${FUNCNAME} $* 496 debug-print-function ${FUNCNAME} $*
513 497
514 JAVA_PKG_JARDEST="${1}" 498 JAVA_PKG_JARDEST="${1}"
515} 499}
516 500
517# ------------------------------------------------------------------------------ 501# @FUNCTION: java-pkg_sointo
518# @ebuild-function java-pkg_sointo 502# @USAGE: </path/to/install/sofiles/into>
519# 503# @DESCRIPTION:
520# Changes the path that JNI libraries are installed into. 504# Changes the path that JNI libraries are installed into via subsequent
521# 505# java-pkg_doso calls.
522# @param $1 - new location to install JNI libraries into.
523# ------------------------------------------------------------------------------
524java-pkg_sointo() { 506java-pkg_sointo() {
525 debug-print-function ${FUNCNAME} $* 507 debug-print-function ${FUNCNAME} $*
526 508
527 JAVA_PKG_LIBDEST="${1}" 509 JAVA_PKG_LIBDEST="${1}"
528} 510}
529 511
530# ------------------------------------------------------------------------------ 512# @FUNCTION: java-pkg_dohtml
531# @ebuild-function java-pkg_dohtml 513# @USAGE: <path/to/javadoc/documentation> [...]
514# @DESCRIPTION:
515# Install Javadoc HTML documentation. Usage of java-pkg_dojavadoc is preferred.
532# 516#
533# Install Javadoc HTML documentation 517# @CODE
534#
535# @example
536# java-pkg_dohtml dist/docs/ 518# java-pkg_dohtml dist/docs/
537# 519# @CODE
538# ------------------------------------------------------------------------------
539java-pkg_dohtml() { 520java-pkg_dohtml() {
540 debug-print-function ${FUNCNAME} $* 521 debug-print-function ${FUNCNAME} $*
541 522
542 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 523 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
543 524
549 # a reasonable way to catch # docs for all of the 530 # a reasonable way to catch # docs for all of the
550 # old ebuilds. 531 # old ebuilds.
551 java-pkg_recordjavadoc 532 java-pkg_recordjavadoc
552} 533}
553 534
554# ------------------------------------------------------------------------------ 535# @FUNCTION: java-pkg_dojavadoc
555# @ebuild-function java-pkg_dojavadoc 536# @USAGE: [--symlink destination] <path/to/javadocs/root>
556# 537# @DESCRIPTION:
557# Installs javadoc documentation. This should be controlled by the doc use flag. 538# Installs javadoc documentation. This should be controlled by the doc use flag.
558# 539#
540# @CODE
541# Parameters:
559# @param $1: optional --symlink creates to symlink like this for html 542# $1: optional --symlink creates to symlink like this for html
560# documentation bundles. 543# documentation bundles.
561# @param $2: - The javadoc root directory. 544# $2: - The javadoc root directory.
562# 545#
563# @example: 546# Examples:
564# java-pkg_dojavadoc docs/api 547# java-pkg_dojavadoc docs/api
565# java-pkg_dojavadoc --symlink apidocs docs/api 548# java-pkg_dojavadoc --symlink apidocs docs/api
566# 549# @CODE
567# ------------------------------------------------------------------------------
568java-pkg_dojavadoc() { 550java-pkg_dojavadoc() {
569 debug-print-function ${FUNCNAME} $* 551 debug-print-function ${FUNCNAME} $*
570 552
571 # For html documentation bundles that link to Javadoc 553 # For html documentation bundles that link to Javadoc
572 local symlink 554 local symlink
579 local dest=/usr/share/doc/${PF}/html 561 local dest=/usr/share/doc/${PF}/html
580 562
581 # QA checks 563 # QA checks
582 564
583 java-pkg_check-phase install 565 java-pkg_check-phase install
566 java-pkg_init_paths_
584 567
585 [[ -z "${dir}" ]] && die "Must specify a directory!" 568 [[ -z "${dir}" ]] && die "Must specify a directory!"
586 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 569 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
587 if [[ ! -e "${dir}/index.html" ]]; then 570 if [[ ! -e "${dir}/index.html" ]]; then
588 local msg="No index.html in javadoc directory" 571 local msg="No index.html in javadoc directory"
615 debug-print "symlinking ${dest}/{api,${symlink}}" 598 debug-print "symlinking ${dest}/{api,${symlink}}"
616 dosym ${dest}/{api,${symlink}} || die 599 dosym ${dest}/{api,${symlink}} || die
617 fi 600 fi
618} 601}
619 602
620# ------------------------------------------------------------------------------ 603# @FUNCTION: java-pkg_dosrc
621# @ebuild-function java-pkg_dosrc 604# @USAGE: <path/to/sources> [...]
622# 605# @DESCRIPTION:
623# Installs a zip containing the source for a package, so it can used in 606# Installs a zip containing the source for a package, so it can used in
624# from IDEs like eclipse and netbeans. 607# from IDEs like eclipse and netbeans.
608# Ebuild needs to DEPEND on app-arch/zip to use this. It also should be controlled by USE=source.
625# 609#
626# Ebuild needs to DEPEND on app-arch/zip to use this. 610# @CODE
627#
628# It also should be controlled by USE=source.
629#
630# @example: 611# Example:
631# java-pkg_dosrc src/* 612# java-pkg_dosrc src/*
632# 613# @CODE
633# ------------------------------------------------------------------------------ 614
634# TODO change so it the arguments it takes are the base directories containing 615# TODO change so it the arguments it takes are the base directories containing
635# source -nichoj 616# source -nichoj
617#
636# TODO should we be able to handle multiple calls to dosrc? -nichoj 618# TODO should we be able to handle multiple calls to dosrc? -nichoj
619#
637# TODO maybe we can take an existing zip/jar? -nichoj 620# TODO maybe we can take an existing zip/jar? -nichoj
621#
638# FIXME apparently this fails if you give it an empty directories 622# FIXME apparently this fails if you give it an empty directories
639java-pkg_dosrc() { 623java-pkg_dosrc() {
640 debug-print-function ${FUNCNAME} $* 624 debug-print-function ${FUNCNAME} $*
641 625
642 [ ${#} -lt 1 ] && die "At least one argument needed" 626 [ ${#} -lt 1 ] && die "At least one argument needed"
674 658
675 JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}" 659 JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
676 java-pkg_do_write_ 660 java-pkg_do_write_
677} 661}
678 662
679# ------------------------------------------------------------------------------ 663# @FUNCTION: java-pkg_dolauncher
680# @ebuild-function java-pkg_dolauncher 664# @USAGE: <filename> [options]
681# 665# @DESCRIPTION:
682# Make a wrapper script to lauch/start this package 666# Make a wrapper script to lauch/start this package
683# If necessary, the wrapper will switch to the appropriate VM. 667# If necessary, the wrapper will switch to the appropriate VM.
684# 668#
685# Can be called without parameters if the package installs only one jar 669# Can be called without parameters if the package installs only one jar
686# that has the Main-class attribute set. The wrapper will be named ${PN}. 670# that has the Main-class attribute set. The wrapper will be named ${PN}.
687# 671#
672# @CODE
673# Parameters:
688# @param $1 - filename of launcher to create 674# $1 - filename of launcher to create
689# @param $2 - options, as follows: 675# $2 - options, as follows:
690# --main the.main.class.too.start 676# --main the.main.class.to.start
691# --jar /the/jar/too/launch.jar or just <name>.jar 677# --jar /the/jar/too/launch.jar or just <name>.jar
692# --java_args 'Extra arguments to pass to java' 678# --java_args 'Extra arguments to pass to java'
693# --pkg_args 'Extra arguments to pass to the package' 679# --pkg_args 'Extra arguments to pass to the package'
694# --pwd Directory the launcher changes to before executing java 680# --pwd Directory the launcher changes to before executing java
695# -into Directory to install the launcher to, instead of /usr/bin 681# -into Directory to install the launcher to, instead of /usr/bin
696# -pre Prepend contents of this file to the launcher 682# -pre Prepend contents of this file to the launcher
697# ------------------------------------------------------------------------------ 683# @CODE
698java-pkg_dolauncher() { 684java-pkg_dolauncher() {
699 debug-print-function ${FUNCNAME} $* 685 debug-print-function ${FUNCNAME} $*
700 686
701 java-pkg_check-phase install 687 java-pkg_check-phase install
702 java-pkg_init_paths_ 688 java-pkg_init_paths_
763 else 749 else
764 dobin "${target}" 750 dobin "${target}"
765 fi 751 fi
766} 752}
767 753
768# ------------------------------------------------------------------------------ 754# @FUNCTION: java-pkg_dowar
755# @DESCRIPTION:
769# Install war files. 756# Install war files.
770# TODO document 757# TODO document
771# ------------------------------------------------------------------------------
772java-pkg_dowar() { 758java-pkg_dowar() {
773 debug-print-function ${FUNCNAME} $* 759 debug-print-function ${FUNCNAME} $*
774 760
775 # Check for arguments 761 # Check for arguments
776 [[ ${#} -lt 1 ]] && die "At least one argument needed" 762 [[ ${#} -lt 1 ]] && die "At least one argument needed"
800 INSDESTTREE=${JAVA_PKG_WARDEST} \ 786 INSDESTTREE=${JAVA_PKG_WARDEST} \
801 doins ${warpath} 787 doins ${warpath}
802 done 788 done
803} 789}
804 790
805# ------------------------------------------------------------------------------ 791# @FUNCTION: java-pkg_recordjavadoc
806# @internal-function java-pkg_recordjavadoc 792# @INTERNAL
793# @DESCRIPTION:
807# Scan for JavaDocs, and record their existence in the package.env file 794# Scan for JavaDocs, and record their existence in the package.env file
808# 795
809# TODO make sure this in the proper section 796# TODO make sure this in the proper section
810# ------------------------------------------------------------------------------
811java-pkg_recordjavadoc() 797java-pkg_recordjavadoc()
812{ 798{
813 debug-print-function ${FUNCNAME} $* 799 debug-print-function ${FUNCNAME} $*
814 # the find statement is important 800 # the find statement is important
815 # as some packages include multiple trees of javadoc 801 # as some packages include multiple trees of javadoc
822 else 808 else
823 debug-print "No javadocs found" 809 debug-print "No javadocs found"
824 fi 810 fi
825} 811}
826 812
827# ------------------------------------------------------------------------------
828# @section-end install
829# ------------------------------------------------------------------------------
830 813
831# ------------------------------------------------------------------------------ 814# @FUNCTION: java-pkg_jar-from
832# @begin-section query 815# @USAGE: [--build-only] [--with-dependencies] [--virtual] [--into dir] <package> [<package.jar>] [<destination.jar>]
833# Use these to build the classpath for building a package. 816# @DESCRIPTION:
834# ------------------------------------------------------------------------------
835
836# ------------------------------------------------------------------------------
837# @ebuild-function java-pkg_jar-from
838#
839# Makes a symlink to a jar from a certain package 817# Makes a symlink to a jar from a certain package
840# A lot of java packages include dependencies in a lib/ directory 818# A lot of java packages include dependencies in a lib/ directory
841# You can use this function to replace these bundled dependencies. 819# You can use this function to replace these bundled dependencies.
842# The dependency is recorded into package.env DEPEND line, unless "--build-only" 820# The dependency is recorded into package.env DEPEND line, unless "--build-only"
843# is passed as the very first argument, for jars that have to be present only 821# is passed as the very first argument, for jars that have to be present only
844# at build time and are not needed on runtime (junit testing etc). 822# at build time and are not needed on runtime (junit testing etc).
845# 823#
824# @CODE
846# Example: get all jars from xerces slot 2 825# Example: get all jars from xerces slot 2
847# java-pkg_jar-from xerces-2 826# java-pkg_jar-from xerces-2
827#
848# Example: get a specific jar from xerces slot 2 828# Example: get a specific jar from xerces slot 2
849# java-pkg_jar-from xerces-2 xml-apis.jar 829# java-pkg_jar-from xerces-2 xml-apis.jar
830#
850# Example: get a specific jar from xerces slot 2, and name it diffrently 831# Example: get a specific jar from xerces slot 2, and name it diffrently
851# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 832# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
833#
852# Example: get junit.jar which is needed only for building 834# Example: get junit.jar which is needed only for building
853# java-pkg_jar-from --build-only junit junit.jar 835# java-pkg_jar-from --build-only junit junit.jar
836# @CODE
854# 837#
855# @param $opt 838# @CODE
839# Parameters
856# --build-only - makes the jar(s) not added into package.env DEPEND line. 840# --build-only - makes the jar(s) not added into package.env DEPEND line.
857# (assumed automatically when called inside src_test) 841# (assumed automatically when called inside src_test)
858# --with-dependencies - get jars also from requested package's dependencies 842# --with-dependencies - get jars also from requested package's dependencies
859# transitively. 843# transitively.
860# --virtual - Packages passed to this function are to be handled as virtuals 844# --virtual - Packages passed to this function are to be handled as virtuals
861# and will not have individual jar dependencies recorded. 845# and will not have individual jar dependencies recorded.
862# --into $dir - symlink jar(s) into $dir (must exist) instead of . 846# --into $dir - symlink jar(s) into $dir (must exist) instead of .
863# @param $1 - Package to get jars from, or comma-separated list of packages in 847# $1 - Package to get jars from, or comma-separated list of packages in
864# case other parameters are not used. 848# case other parameters are not used.
865# @param $2 - jar from package. If not specified, all jars will be used. 849# $2 - jar from package. If not specified, all jars will be used.
866# @param $3 - When a single jar is specified, destination filename of the 850# $3 - When a single jar is specified, destination filename of the
867# symlink. Defaults to the name of the jar. 851# symlink. Defaults to the name of the jar.
868# ------------------------------------------------------------------------------ 852# @CODE
853
869# TODO could probably be cleaned up a little 854# TODO could probably be cleaned up a little
870java-pkg_jar-from() { 855java-pkg_jar-from() {
871 debug-print-function ${FUNCNAME} $* 856 debug-print-function ${FUNCNAME} $*
872 857
873 local build_only="" 858 local build_only=""
874 local destdir="." 859 local destdir="."
875 local deep="" 860 local deep=""
876 local virtual="" 861 local virtual=""
862 local record_jar=""
877 863
878 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 864 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
879 865
880 while [[ "${1}" == --* ]]; do 866 while [[ "${1}" == --* ]]; do
881 if [[ "${1}" = "--build-only" ]]; then 867 if [[ "${1}" = "--build-only" ]]; then
916 for pkg in ${target_pkg//,/ }; do 902 for pkg in ${target_pkg//,/ }; do
917 java-pkg_ensure-dep "${build_only}" "${pkg}" 903 java-pkg_ensure-dep "${build_only}" "${pkg}"
918 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 904 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
919 done 905 done
920 # setting this disables further record-jar_ calls later 906 # setting this disables further record-jar_ calls later
921 build_only="build" 907 record_jar="true"
922 else 908 else
923 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 909 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
924 fi 910 fi
925 911
926 # Record the entire virtual as a dependency so that 912 # Record the entire virtual as a dependency so that
927 # no jars are missed. 913 # no jars are missed.
928 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 914 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
929 java-pkg_record-jar_ "${target_pkg}" 915 java-pkg_record-jar_ "${target_pkg}"
930 # setting this disables further record-jars_ calls later 916 # setting this disables further record-jars_ calls later
931 build_only="build" 917 record_jar="true"
932 fi 918 fi
933 919
934 pushd ${destdir} > /dev/null \ 920 pushd ${destdir} > /dev/null \
935 || die "failed to change directory to ${destdir}" 921 || die "failed to change directory to ${destdir}"
936 922
944 # If no specific target jar was indicated, link it 930 # If no specific target jar was indicated, link it
945 if [[ -z "${target_jar}" ]] ; then 931 if [[ -z "${target_jar}" ]] ; then
946 [[ -f "${target_jar}" ]] && rm "${target_jar}" 932 [[ -f "${target_jar}" ]] && rm "${target_jar}"
947 ln -snf "${jar}" \ 933 ln -snf "${jar}" \
948 || die "Failed to make symlink from ${jar} to ${jar_name}" 934 || die "Failed to make symlink from ${jar} to ${jar_name}"
935 if [[ -z "${record_jar}" ]]; then
936 if [[ -z "${build_only}" ]]; then
949 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 937 java-pkg_record-jar_ "${target_pkg}" "${jar}"
938 else
939 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
940 fi
941 fi
950 # otherwise, if the current jar is the target jar, link it 942 # otherwise, if the current jar is the target jar, link it
951 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 943 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
952 [[ -f "${destjar}" ]] && rm "${destjar}" 944 [[ -f "${destjar}" ]] && rm "${destjar}"
953 ln -snf "${jar}" "${destjar}" \ 945 ln -snf "${jar}" "${destjar}" \
954 || die "Failed to make symlink from ${jar} to ${destjar}" 946 || die "Failed to make symlink from ${jar} to ${destjar}"
947 if [[ -z "${record_jar}" ]]; then
948 if [[ -z "${build_only}" ]]; then
955 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 949 java-pkg_record-jar_ "${target_pkg}" "${jar}"
950 else
951 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
952 fi
953 fi
956 popd > /dev/null 954 popd > /dev/null
957 return 0 955 return 0
958 fi 956 fi
959 done 957 done
960 popd > /dev/null 958 popd > /dev/null
965 else 963 else
966 die "Failed to find ${target_jar:-jar} in ${target_pkg}" 964 die "Failed to find ${target_jar:-jar} in ${target_pkg}"
967 fi 965 fi
968} 966}
969 967
970# ------------------------------------------------------------------------------ 968# @FUNCTION: java-pkg_jarfrom
971# @ebuild-function java-pkg_jarfrom 969# @DESCRIPTION:
972#
973# See java-pkg_jar-from 970# See java-pkg_jar-from
974# ------------------------------------------------------------------------------
975java-pkg_jarfrom() { 971java-pkg_jarfrom() {
976 java-pkg_jar-from "$@" 972 java-pkg_jar-from "$@"
977} 973}
978 974
979# ------------------------------------------------------------------------------ 975# @FUNCTION: java-pkg_getjars
980# @ebuild-function java-pkg_getjars 976# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
981# 977# @DESCRIPTION:
982# Get the classpath provided by any number of packages 978# Get the classpath provided by any number of packages
983# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 979# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
984# The providing packages are recorded as dependencies into package.env DEPEND 980# The providing packages are recorded as dependencies into package.env DEPEND
985# line, unless "--build-only" is passed as the very first argument, for jars 981# line, unless "--build-only" is passed as the very first argument, for jars
986# that have to be present only at build time and are not needed on runtime 982# that have to be present only at build time and are not needed on runtime
987# (junit testing etc). 983# (junit testing etc).
988# 984#
985# @CODE
989# Example: Get the classpath for xerces-2 and xalan, 986# Example: Get the classpath for xerces-2 and xalan,
990# java-pkg_getjars xerces-2,xalan 987# java-pkg_getjars xerces-2,xalan
988#
991# Example Return: 989# Example Return:
992# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 990# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
993# 991#
994# @param $opt 992#
993# Parameters:
995# --build-only - makes the jar(s) not added into package.env DEPEND line. 994# --build-only - makes the jar(s) not added into package.env DEPEND line.
996# (assumed automatically when called inside src_test) 995# (assumed automatically when called inside src_test)
997# --with-dependencies - get jars also from requested package's dependencies 996# --with-dependencies - get jars also from requested package's dependencies
998# transitively. 997# transitively.
999# @param $1 - list of packages to get jars from 998# $1 - list of packages to get jars from
1000# (passed to java-config --classpath) 999# (passed to java-config --classpath)
1001# ------------------------------------------------------------------------------ 1000# @CODE
1002java-pkg_getjars() { 1001java-pkg_getjars() {
1003 debug-print-function ${FUNCNAME} $* 1002 debug-print-function ${FUNCNAME} $*
1004 1003
1005 local build_only="" 1004 local build_only=""
1006 local deep="" 1005 local deep=""
1033 1032
1034 for pkg in ${pkgs//,/ }; do 1033 for pkg in ${pkgs//,/ }; do
1035 java-pkg_ensure-dep "${build_only}" "${pkg}" 1034 java-pkg_ensure-dep "${build_only}" "${pkg}"
1036 done 1035 done
1037 1036
1038 # Only record jars that aren't build-only 1037 for pkg in ${pkgs//,/ }; do
1039 if [[ -z "${build_only}" ]]; then 1038 if [[ -z "${build_only}" ]]; then
1040 for pkg in ${pkgs//,/ }; do
1041 java-pkg_record-jar_ "${pkg}" 1039 java-pkg_record-jar_ "${pkg}"
1040 else
1041 java-pkg_record-jar_ --build-only "${pkg}"
1042 fi
1042 done 1043 done
1043 fi
1044 1044
1045 echo "${jars}" 1045 echo "${jars}"
1046} 1046}
1047 1047
1048# ------------------------------------------------------------------------------ 1048# @FUNCTION: java-pkg_getjar
1049# @ebuild-function java-pkg_getjar 1049# @USAGE: [--build-only] [--virtual] <package> <jarfile>
1050# 1050# @DESCRIPTION:
1051# Get the filename of a single jar from a package 1051# Get the complete path of a single jar from a package
1052# The providing package is recorded as runtime dependency into package.env 1052# The providing package is recorded as runtime dependency into package.env
1053# DEPEND line, unless "--build-only" is passed as the very first argument, for 1053# DEPEND line, unless "--build-only" is passed as the very first argument, for
1054# jars that have to be present only at build time and are not needed on runtime 1054# jars that have to be present only at build time and are not needed on runtime
1055# (junit testing etc). 1055# (junit testing etc).
1056# 1056#
1057# @CODE
1057# @example 1058# Example:
1058# java-pkg_getjar xerces-2 xml-apis.jar 1059# java-pkg_getjar xerces-2 xml-apis.jar
1059# @example-return 1060# returns
1060# /usr/share/xerces-2/lib/xml-apis.jar 1061# /usr/share/xerces-2/lib/xml-apis.jar
1061# 1062#
1062# @param $opt 1063# Parameters:
1063# --build-only - makes the jar not added into package.env DEPEND line. 1064# --build-only - makes the jar not added into package.env DEPEND line.
1064# --virtual - Packages passed to this function are to be handled as virtuals 1065# --virtual - Packages passed to this function are to be handled as virtuals
1065# and will not have individual jar dependencies recorded. 1066# and will not have individual jar dependencies recorded.
1066# @param $1 - package to use 1067# $1 - package to use
1067# @param $2 - jar to get 1068# $2 - jar to get
1068# ------------------------------------------------------------------------------ 1069# @CODE
1069java-pkg_getjar() { 1070java-pkg_getjar() {
1070 debug-print-function ${FUNCNAME} $* 1071 debug-print-function ${FUNCNAME} $*
1071 1072
1072 local build_only="" 1073 local build_only=""
1073 local virtual="" 1074 local virtual=""
1075 local record_jar=""
1074 1076
1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1076 1078
1077 while [[ "${1}" == --* ]]; do 1079 while [[ "${1}" == --* ]]; do
1078 if [[ "${1}" = "--build-only" ]]; then 1080 if [[ "${1}" = "--build-only" ]]; then
1104 java-pkg_ensure-dep "${build_only}" "${pkg}" 1106 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105 1107
1106 # Record the package(Virtual) as a dependency and then set build_only 1108 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded. 1109 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then 1110 if [[ -n "${virtual}" ]]; then
1111 if [[ -z "${build_only}" ]]; then
1109 java-pkg_record-jar_ "${pkg}" 1112 java-pkg_record-jar_ "${pkg}"
1110 build_only="true" 1113 else
1114 java-pkg_record-jar_ --build-only "${pkg}"
1115 fi
1116 record_jar="true"
1111 fi 1117 fi
1112 1118
1113 for jar in ${classpath//:/ }; do 1119 for jar in ${classpath//:/ }; do
1114 if [[ ! -f "${jar}" ]] ; then 1120 if [[ ! -f "${jar}" ]] ; then
1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1121 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1116 fi 1122 fi
1117 1123
1118 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1124 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1119 # Only record jars that aren't build-only 1125 # Only record jars that aren't build-only
1120 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1126 if [[ -z "${record_jar}" ]]; then
1127 if [[ -z "${build_only}" ]]; then
1128 java-pkg_record-jar_ "${pkg}" "${jar}"
1129 else
1130 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1131 fi
1132 fi
1121 echo "${jar}" 1133 echo "${jar}"
1122 return 0 1134 return 0
1123 fi 1135 fi
1124 done 1136 done
1125 1137
1126 die "Could not find ${target_jar} in ${pkg}" 1138 die "Could not find ${target_jar} in ${pkg}"
1127 return 1 1139 return 1
1128} 1140}
1129 1141
1130# ------------------------------------------------------------------------------ 1142# @FUNCTION: java-pkg_register-dependency
1131# @ebuild-function java-pkg_register-dependency 1143# @USAGE: <package>[,<package2>...] [<jarfile>]
1132# 1144# @DESCRIPTION:
1133# Registers runtime dependency on a package, list of packages, or a single jar 1145# Registers runtime dependency on a package, list of packages, or a single jar
1134# from a package, into package.env DEPEND line. Can only be called in 1146# from a package, into package.env DEPEND line. Can only be called in
1135# src_install phase. 1147# src_install phase.
1136# Intended for binary packages where you don't need to symlink the jars or get 1148# Intended for binary packages where you don't need to symlink the jars or get
1137# their classpath during build. As such, the dependencies only need to be 1149# their classpath during build. As such, the dependencies only need to be
1138# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1150# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1139# 1151#
1152# @CODE
1153# Parameters:
1140# @param $1 - comma-separated list of packages, or a single package 1154# $1 - comma-separated list of packages, or a single package
1141# @param $2 - if param $1 is a single package, optionally specify the jar 1155# $2 - if param $1 is a single package, optionally specify the jar
1142# to depend on 1156# to depend on
1143# 1157#
1158# Examples:
1144# Example: Record the dependency on whole xerces-2 and xalan, 1159# Record the dependency on whole xerces-2 and xalan,
1145# java-pkg_register-dependency xerces-2,xalan 1160# java-pkg_register-dependency xerces-2,xalan
1161#
1146# Example: Record the dependency on ant.jar from ant-core 1162# Record the dependency on ant.jar from ant-core
1147# java-pkg_register-dependency ant-core ant.jar 1163# java-pkg_register-dependency ant-core ant.jar
1164# @CODE
1148# 1165#
1149# Note: Passing both list of packages as the first parameter AND specifying the 1166# Note: Passing both list of packages as the first parameter AND specifying the
1150# jar as the second is not allowed and will cause the function to die. We assume 1167# jar as the second is not allowed and will cause the function to die. We assume
1151# that there's more chance one passes such combination as a mistake, than that 1168# that there's more chance one passes such combination as a mistake, than that
1152# there are more packages providing identically named jar without class 1169# there are more packages providing identically named jar without class
1153# collisions. 1170# collisions.
1154# ------------------------------------------------------------------------------
1155java-pkg_register-dependency() { 1171java-pkg_register-dependency() {
1156 debug-print-function ${FUNCNAME} $* 1172 debug-print-function ${FUNCNAME} $*
1157 1173
1158 java-pkg_check-phase install 1174 java-pkg_check-phase install
1159 1175
1181 fi 1197 fi
1182 1198
1183 java-pkg_do_write_ 1199 java-pkg_do_write_
1184} 1200}
1185 1201
1186# ------------------------------------------------------------------------------
1187# @ebuild-function java-pkg_register-optional-dependency 1202# @FUNCTION: java-pkg_register-optional-dependency
1188# 1203# @USAGE: <package>[,<package2>...] [<jarfile>]
1204# @DESCRIPTION:
1189# Registers optional runtime dependency on a package, list of packages, or a 1205# Registers optional runtime dependency on a package, list of packages, or a
1190# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be 1206# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1191# called in src_install phase. 1207# called in src_install phase.
1192# Intended for packages that can use other packages when those are in classpath. 1208# Intended for packages that can use other packages when those are in classpath.
1193# Will be put on classpath by launcher if they are installed. Typical case is 1209# Will be put on classpath by launcher if they are installed. Typical case is
1194# JDBC implementations for various databases. It's better than having USE flag 1210# JDBC implementations for various databases. It's better than having USE flag
1195# for each implementation triggering hard dependency. 1211# for each implementation triggering hard dependency.
1196# 1212#
1213# @CODE
1214# Parameters:
1197# @param $1 - comma-separated list of packages, or a single package 1215# $1 - comma-separated list of packages, or a single package
1198# @param $2 - if param $1 is a single package, optionally specify the jar 1216# $2 - if param $1 is a single package, optionally specify the jar to depend on
1199# to depend on
1200# 1217#
1218# Example:
1201# Example: Record the optional dependency on some jdbc providers 1219# Record the optional dependency on some jdbc providers
1202# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql 1220# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1221# @CODE
1203# 1222#
1204# Note: Passing both list of packages as the first parameter AND specifying the 1223# Note: Passing both list of packages as the first parameter AND specifying the
1205# jar as the second is not allowed and will cause the function to die. We assume 1224# jar as the second is not allowed and will cause the function to die. We assume
1206# that there's more chance one passes such combination as a mistake, than that 1225# that there's more chance one passes such combination as a mistake, than that
1207# there are more packages providing identically named jar without class 1226# there are more packages providing identically named jar without class
1208# collisions. 1227# collisions.
1209# ------------------------------------------------------------------------------
1210java-pkg_register-optional-dependency() { 1228java-pkg_register-optional-dependency() {
1211 debug-print-function ${FUNCNAME} $* 1229 debug-print-function ${FUNCNAME} $*
1212 1230
1213 java-pkg_check-phase install 1231 java-pkg_check-phase install
1214 1232
1234 fi 1252 fi
1235 1253
1236 java-pkg_do_write_ 1254 java-pkg_do_write_
1237} 1255}
1238 1256
1239# ------------------------------------------------------------------------------
1240# @ebuild-function java-pkg_register-environment-variable 1257# @FUNCTION: java-pkg_register-environment-variable
1241# 1258# @USAGE: <name> <value>
1259# @DESCRIPTION:
1242# Register an arbitrary environment variable into package.env. The gjl launcher 1260# Register an arbitrary environment variable into package.env. The gjl launcher
1243# for this package or any package depending on this will export it into 1261# for this package or any package depending on this will export it into
1244# environement before executing java command. 1262# environement before executing java command.
1245# Must only be called in src_install phase. 1263# Must only be called in src_install phase.
1246#
1247# @param $1 - variable name
1248# @param $2 - variable value
1249# ------------------------------------------------------------------------------
1250JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env" 1264JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1251JAVA_PKG_EXTRA_ENV_VARS="" 1265JAVA_PKG_EXTRA_ENV_VARS=""
1252java-pkg_register-environment-variable() { 1266java-pkg_register-environment-variable() {
1253 debug-print-function ${FUNCNAME} $* 1267 debug-print-function ${FUNCNAME} $*
1254 1268
1259 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1273 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1260 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1274 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1261 1275
1262 java-pkg_do_write_ 1276 java-pkg_do_write_
1263} 1277}
1278
1279# @FUNCTION: java-pkg_get-bootclasspath
1280# @USAGE: <version>
1281# @DESCRIPTION:
1282# Returns classpath of a given bootclasspath-providing package version.
1283#
1284# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1285# of the current JDK
1286java-pkg_get-bootclasspath() {
1287 local version="${1}"
1288
1289 local bcp
1290 case "${version}" in
1291 auto)
1292 bcp="$(java-config -g BOOTCLASSPATH)"
1293 ;;
1294 1.5)
1295 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1296 ;;
1297 *)
1298 eerror "unknown parameter of java-pkg_get-bootclasspath"
1299 die "unknown parameter of java-pkg_get-bootclasspath"
1300 ;;
1301 esac
1302
1303 echo "${bcp}"
1304}
1305
1264 1306
1265# This function reads stdin, and based on that input, figures out how to 1307# This function reads stdin, and based on that input, figures out how to
1266# populate jars from the filesystem. 1308# populate jars from the filesystem.
1267# Need to figure out a good way of making use of this, ie be able to use a 1309# Need to figure out a good way of making use of this, ie be able to use a
1268# string that was built instead of stdin 1310# string that was built instead of stdin
1296# 1338#
1297# read line 1339# read line
1298# done 1340# done
1299#} 1341#}
1300 1342
1301# ------------------------------------------------------------------------------ 1343# @FUNCTION: java-pkg_find-normal-jars
1302# @section-end query 1344# @USAGE: [<path/to/directory>]
1303# ------------------------------------------------------------------------------ 1345# @DESCRIPTION:
1304
1305# ------------------------------------------------------------------------------
1306# @section-begin helper
1307# @section-summary Helper functions
1308#
1309# Various other functions to use from an ebuild
1310# ------------------------------------------------------------------------------
1311
1312# ------------------------------------------------------------------------------
1313# @ebuild-function java-pkg_need
1314#
1315# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1316# Currently supported virtuals are:
1317# javamail
1318# jdbc-stdext
1319# jaf
1320# jdbc-rowset
1321# jms
1322#
1323# @param $1 - Optionally indicate that the dependencies are controlled by
1324# a use flag by specifying '--use' Requires $2.
1325# @param $2 - USE flag which will enable the dependencies.
1326# @param $@ - virtual packages to add depenedencies for
1327# ------------------------------------------------------------------------------
1328# TODO rewrite to parse a line based declaration file instead -- karltk
1329#java-pkg_need() {
1330# debug-print-function ${FUNCNAME} $*
1331# local useflag
1332# if [[ ${1} == "--use" ]]; then
1333# useflag="${2}"
1334# shift 2
1335# fi
1336#
1337# if [[ -z ${1} ]]; then
1338# die "Must specify at least one virtual package."
1339# fi
1340#
1341# local depstr newdepstr
1342#
1343# for virtual in ${@}; do
1344# if has ${virtual} ${JAVA_PKG_VNEED}; then
1345# debug-print "Already registered virtual ${virtual}"
1346# continue
1347# fi
1348# case ${virtual} in
1349# javamail)
1350# debug-print "java-pkg_need: adding javamail dependencies"
1351# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1352# ;;
1353# jdbc-stdext)
1354# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1355# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1356# ;;
1357# jaf)
1358# debug-print "java-pkg_need: adding jaf dependencies"
1359# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1360# ;;
1361# jdbc-rowset)
1362# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1363# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1364# ;;
1365# jms)
1366# debug-print "java-pkg_need: adding jms dependencies"
1367# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1368# ;;
1369# *)
1370# die "Invalid virtual: ${virtual}"
1371# esac
1372#
1373# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1374#
1375# if [[ -n ${useflag} ]]; then
1376# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1377# else
1378# depstr="${depstr} ${newdepstr}"
1379# fi
1380# done
1381#
1382# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1383# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1384#
1385# export DEPEND="${DEPEND} ${depstr}"
1386# export RDEPEND="${RDEPEND} ${depstr}"
1387#}
1388
1389# ------------------------------------------------------------------------------
1390# @ebuild-function java-pkg_find-normal-jars
1391#
1392# Find the files with suffix .jar file in the given directory or $WORKDIR 1346# Find the files with suffix .jar file in the given directory (default: $WORKDIR)
1393#
1394# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1395# ------------------------------------------------------------------------------
1396java-pkg_find-normal-jars() { 1347java-pkg_find-normal-jars() {
1397 local dir=$1 1348 local dir=$1
1398 [[ "${dir}" ]] || dir="${WORKDIR}" 1349 [[ "${dir}" ]] || dir="${WORKDIR}"
1399 local found 1350 local found
1400 for jar in $(find "${dir}" -name "*.jar" -type f); do 1351 for jar in $(find "${dir}" -name "*.jar" -type f); do
1403 done 1354 done
1404 [[ "${found}" ]] 1355 [[ "${found}" ]]
1405 return $? 1356 return $?
1406} 1357}
1407 1358
1408# ------------------------------------------------------------------------------ 1359# @FUNCTION: java-pkg_ensure-no-bundled-jars
1409# @ebuild-function java-pkg_ensure-no-bundled-jars 1360# @DESCRIPTION:
1410#
1411# Try to locate bundled jar files in ${WORKDIR} and die if found. 1361# Try to locate bundled jar files in ${WORKDIR} and die if found.
1412# This function should be called after WORKDIR has been populated with symlink 1362# This function should be called after WORKDIR has been populated with symlink
1413# to system jar files or bundled jars removed. 1363# to system jar files or bundled jars removed.
1414# ------------------------------------------------------------------------------
1415java-pkg_ensure-no-bundled-jars() { 1364java-pkg_ensure-no-bundled-jars() {
1416 debug-print-function ${FUNCNAME} $* 1365 debug-print-function ${FUNCNAME} $*
1417 1366
1418 local bundled_jars=$(java-pkg_find-normal-jars) 1367 local bundled_jars=$(java-pkg_find-normal-jars)
1419 if [[ -n ${bundled_jars} ]]; then 1368 if [[ -n ${bundled_jars} ]]; then
1424 done 1373 done
1425 die "Bundled jars found!" 1374 die "Bundled jars found!"
1426 fi 1375 fi
1427} 1376}
1428 1377
1429# ------------------------------------------------------------------------------
1430# @internal-function java-pkg_ensure-vm-version-sufficient 1378# @FUNCTION: java-pkg_ensure-vm-version-sufficient
1431# 1379# @INTERNAL
1380# @DESCRIPTION:
1432# Checks if we have a sufficient VM and dies if we don't. 1381# Checks if we have a sufficient VM and dies if we don't.
1433#
1434# ------------------------------------------------------------------------------
1435java-pkg_ensure-vm-version-sufficient() { 1382java-pkg_ensure-vm-version-sufficient() {
1436 debug-print-function ${FUNCNAME} $* 1383 debug-print-function ${FUNCNAME} $*
1437 1384
1438 if ! java-pkg_is-vm-version-sufficient; then 1385 if ! java-pkg_is-vm-version-sufficient; then
1439 debug-print "VM is not suffient" 1386 debug-print "VM is not suffient"
1441 einfo "Please use java-config -S to set the correct one" 1388 einfo "Please use java-config -S to set the correct one"
1442 die "Active Java VM cannot build this package" 1389 die "Active Java VM cannot build this package"
1443 fi 1390 fi
1444} 1391}
1445 1392
1446# ------------------------------------------------------------------------------ 1393# @FUNCTION: java-pkg_is-vm-version-sufficient
1447# @internal-function java-pkg_is-vm-version-sufficient 1394# @INTERNAL
1448# 1395# @DESCRIPTION:
1449# @return zero - VM is sufficient 1396# @RETURN: zero - VM is sufficient; non-zero - VM is not sufficient
1450# @return non-zero - VM is not sufficient
1451# ------------------------------------------------------------------------------
1452java-pkg_is-vm-version-sufficient() { 1397java-pkg_is-vm-version-sufficient() {
1453 debug-print-function ${FUNCNAME} $* 1398 debug-print-function ${FUNCNAME} $*
1454 1399
1455 depend-java-query --is-sufficient "${DEPEND}" > /dev/null 1400 depend-java-query --is-sufficient "${DEPEND}" > /dev/null
1456 return $? 1401 return $?
1457} 1402}
1458 1403
1459# ------------------------------------------------------------------------------ 1404# @FUNCTION: java-pkg_ensure-vm-version-eq
1460# @internal-function java-pkg_ensure-vm-version-eq 1405# @INTERNAL
1461# 1406# @DESCRIPTION:
1462# Die if the current VM is not equal to the argument passed. 1407# Die if the current VM is not equal to the argument passed.
1463# 1408#
1464# @param $@ - Desired VM version to ensure 1409# @param $@ - Desired VM version to ensure
1465# ------------------------------------------------------------------------------
1466java-pkg_ensure-vm-version-eq() { 1410java-pkg_ensure-vm-version-eq() {
1467 debug-print-function ${FUNCNAME} $* 1411 debug-print-function ${FUNCNAME} $*
1468 1412
1469 if ! java-pkg_is-vm-version-eq $@ ; then 1413 if ! java-pkg_is-vm-version-eq $@ ; then
1470 debug-print "VM is not suffient" 1414 debug-print "VM is not suffient"
1472 einfo "Please use java-config -S to set the correct one" 1416 einfo "Please use java-config -S to set the correct one"
1473 die "Active Java VM too old" 1417 die "Active Java VM too old"
1474 fi 1418 fi
1475} 1419}
1476 1420
1477# ------------------------------------------------------------------------------ 1421# @FUNCTION: java-pkg_is-vm-version-eq
1478# @internal-function java-pkg_is-vm-version-eq 1422# @USAGE: <version>
1479# 1423# @INTERNAL
1480# @param $@ - VM version to compare current VM to 1424# @RETURN: zero - VM versions are equal; non-zero - VM version are not equal
1481# @return zero - VM versions are equal
1482# @return non-zero - VM version are not equal
1483# ------------------------------------------------------------------------------
1484java-pkg_is-vm-version-eq() { 1425java-pkg_is-vm-version-eq() {
1485 debug-print-function ${FUNCNAME} $* 1426 debug-print-function ${FUNCNAME} $*
1486 1427
1487 local needed_version="$@" 1428 local needed_version="$@"
1488 1429
1505 return 1 1446 return 1
1506 fi 1447 fi
1507 fi 1448 fi
1508} 1449}
1509 1450
1510# ------------------------------------------------------------------------------ 1451# @FUNCTION: java-pkg_ensure-vm-version-ge
1511# @internal-function java-pkg_ensure-vm-version-ge 1452# @INTERNAL
1512# 1453# @DESCRIPTION:
1513# Die if the current VM is not greater than the desired version 1454# Die if the current VM is not greater than the desired version
1514# 1455#
1515# @param $@ - VM version to compare current to 1456# @param $@ - VM version to compare current to
1516# ------------------------------------------------------------------------------
1517java-pkg_ensure-vm-version-ge() { 1457java-pkg_ensure-vm-version-ge() {
1518 debug-print-function ${FUNCNAME} $* 1458 debug-print-function ${FUNCNAME} $*
1519 1459
1520 if ! java-pkg_is-vm-version-ge "$@" ; then 1460 if ! java-pkg_is-vm-version-ge "$@" ; then
1521 debug-print "vm is not suffient" 1461 debug-print "vm is not suffient"
1523 einfo "Please use java-config -S to set the correct one" 1463 einfo "Please use java-config -S to set the correct one"
1524 die "Active Java VM too old" 1464 die "Active Java VM too old"
1525 fi 1465 fi
1526} 1466}
1527 1467
1528# ------------------------------------------------------------------------------ 1468# @FUNCTION: java-pkg_is-vm-version-ge
1529# @internal-function java-pkg_is-vm-version-ge 1469# @INTERNAL
1530# 1470# @DESCRIPTION:
1471# @CODE
1472# Parameters:
1531# @param $@ - VM version to compare current VM to 1473# $@ - VM version to compare current VM to
1474# @CODE
1532# @return zero - current VM version is greater than checked version 1475# @RETURN: zero - current VM version is greater than checked version;
1533# @return non-zero - current VM version is not greater than checked version 1476# non-zero - current VM version is not greater than checked version
1534# ------------------------------------------------------------------------------
1535java-pkg_is-vm-version-ge() { 1477java-pkg_is-vm-version-ge() {
1536 debug-print-function ${FUNCNAME} $* 1478 debug-print-function ${FUNCNAME} $*
1537 1479
1538 local needed_version=$@ 1480 local needed_version=$@
1539 local vm_version=$(java-pkg_get-vm-version) 1481 local vm_version=$(java-pkg_get-vm-version)
1558java-pkg_get-current-vm() { 1500java-pkg_get-current-vm() {
1559 echo ${GENTOO_VM} 1501 echo ${GENTOO_VM}
1560} 1502}
1561 1503
1562java-pkg_current-vm-matches() { 1504java-pkg_current-vm-matches() {
1563 hasq $(java-pkg_get-current-vm) ${@} 1505 has $(java-pkg_get-current-vm) ${@}
1564 return $? 1506 return $?
1565} 1507}
1566 1508
1567# ------------------------------------------------------------------------------ 1509# @FUNCTION: java-pkg_get-source
1568# @ebuild-function java-pkg_get-source 1510# @DESCRIPTION:
1569#
1570# Determines what source version should be used, for passing to -source. 1511# Determines what source version should be used, for passing to -source.
1571# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1512# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1572# 1513#
1573# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1514# @RETURN: string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1574# ------------------------------------------------------------------------------
1575java-pkg_get-source() { 1515java-pkg_get-source() {
1576 echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")} 1516 echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1577} 1517}
1578 1518
1579# ------------------------------------------------------------------------------ 1519# @FUNCTION: java-pkg_get-target
1580# @ebuild-function java-pkg_get-target 1520# @DESCRIPTION:
1581#
1582# Determines what target version should be used, for passing to -target. 1521# Determines what target version should be used, for passing to -target.
1583# If you don't care about lower versions, you can set _WANT_TARGET to the 1522# If you don't care about lower versions, you can set _WANT_TARGET to the
1584# version of your JDK. 1523# version of your JDK.
1585# 1524#
1586# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1525# @RETURN: string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1587# ------------------------------------------------------------------------------
1588java-pkg_get-target() { 1526java-pkg_get-target() {
1589 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")} 1527 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1590} 1528}
1591 1529
1530# @FUNCTION: java-pkg_get-javac
1531# @DESCRIPTION:
1532# Returns the compiler executable
1592java-pkg_get-javac() { 1533java-pkg_get-javac() {
1593 debug-print-function ${FUNCNAME} $* 1534 debug-print-function ${FUNCNAME} $*
1594 1535
1595 1536
1596 local compiler="${GENTOO_COMPILER}" 1537 local compiler="${GENTOO_COMPILER}"
1626 fi 1567 fi
1627 fi 1568 fi
1628 echo ${compiler_executable} 1569 echo ${compiler_executable}
1629} 1570}
1630 1571
1631# ------------------------------------------------------------------------------ 1572# @FUNCTION: java-pkg_javac-args
1632# @ebuild-function java-pkg_javac-args 1573# @DESCRIPTION:
1633#
1634# If an ebuild uses javac directly, instead of using ejavac, it should call this 1574# If an ebuild uses javac directly, instead of using ejavac, it should call this
1635# to know what -source/-target to use. 1575# to know what -source/-target to use.
1636# 1576#
1637# @return string - arguments to pass to javac, complete with -target and -source 1577# @RETURN: string - arguments to pass to javac, complete with -target and -source
1638# ------------------------------------------------------------------------------
1639java-pkg_javac-args() { 1578java-pkg_javac-args() {
1640 debug-print-function ${FUNCNAME} $* 1579 debug-print-function ${FUNCNAME} $*
1641 1580
1642 local want_source="$(java-pkg_get-source)" 1581 local want_source="$(java-pkg_get-source)"
1643 local want_target="$(java-pkg_get-target)" 1582 local want_target="$(java-pkg_get-target)"
1651 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1590 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1652 debug-print "could not find valid -source/-target values for javac" 1591 debug-print "could not find valid -source/-target values for javac"
1653 echo "Could not find valid -source/-target values for javac" 1592 echo "Could not find valid -source/-target values for javac"
1654 return 1 1593 return 1
1655 else 1594 else
1656 if java-pkg_is-vm-version-ge "1.4"; then
1657 echo "${source_str} ${target_str}" 1595 echo "${source_str} ${target_str}"
1658 else
1659 echo "${target_str}"
1660 fi 1596 fi
1661 fi
1662} 1597}
1663 1598
1664# TODO document 1599# @FUNCTION: java-pkg_get-jni-cflags
1600# @DESCRIPTION:
1601# Echos the CFLAGS for JNI compilations
1665java-pkg_get-jni-cflags() { 1602java-pkg_get-jni-cflags() {
1666 local flags="-I${JAVA_HOME}/include" 1603 local flags="-I${JAVA_HOME}/include"
1667 1604
1668 local platform="linux" 1605 local platform="linux"
1669 use elibc_FreeBSD && platform="freebsd" 1606 use elibc_FreeBSD && platform="freebsd"
1673 1610
1674 echo ${flags} 1611 echo ${flags}
1675} 1612}
1676 1613
1677java-pkg_ensure-gcj() { 1614java-pkg_ensure-gcj() {
1678 if ! built_with_use sys-devel/gcc gcj ; then 1615 # was enforcing sys-devel/gcc[gcj]
1679 ewarn 1616 die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
1680 ewarn "You must build gcc with the gcj support to build with gcj"
1681 ewarn
1682 ebeep 5
1683 die "No GCJ support found!"
1684 fi
1685} 1617}
1686 1618
1687java-pkg_ensure-test() { 1619java-pkg_ensure-test() {
1688 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1620 # was enforcing USE=test if FEATURES=test
1689 && hasq test ${IUSE} && ! use test; 1621 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1690 then
1691 eerror "You specified FEATURES=test, but USE=test is needed"
1692 eerror "to pull in the additional dependencies for testing"
1693 die "Need USE=test enabled"
1694 fi
1695} 1622}
1696 1623
1697# ------------------------------------------------------------------------------ 1624# @FUNCTION: java-pkg_register-ant-task
1698# @ebuild-function java-pkg_register-ant-task 1625# @USAGE: [--version x.y] [<name>]
1699# 1626# @DESCRIPTION:
1700# Register this package as ant task, so that ant will load it when no specific 1627# Register this package as ant task, so that ant will load it when no specific
1701# ANT_TASKS are specified. Note that even without this registering, all packages 1628# ANT_TASKS are specified. Note that even without this registering, all packages
1702# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks 1629# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1703# packages, but can be also used by other ebuilds that used to symlink their 1630# packages, but can be also used by other ebuilds that used to symlink their
1704# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards 1631# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1705# compatibility. 1632# compatibility.
1706# 1633#
1634# @CODE
1635# Parameters
1707# @param --version x.y Register only for ant version x.y (otherwise for any ant 1636# --version x.y Register only for ant version x.y (otherwise for any ant
1708# version). Used by the ant-* packages to prevent loading of mismatched 1637# version). Used by the ant-* packages to prevent loading of mismatched
1709# ant-core ant tasks after core was updated, before the tasks are updated, 1638# ant-core ant tasks after core was updated, before the tasks are updated,
1710# without a need for blockers. 1639# without a need for blockers.
1711# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT]) 1640# $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1712# ------------------------------------------------------------------------------ 1641# @CODE
1713java-pkg_register-ant-task() { 1642java-pkg_register-ant-task() {
1714 local TASKS_DIR="tasks" 1643 local TASKS_DIR="tasks"
1715 1644
1716 # check for --version x.y parameters 1645 # check for --version x.y parameters
1717 while [[ -n "${1}" && -n "${2}" ]]; do 1646 while [[ -n "${1}" && -n "${2}" ]]; do
1729 1658
1730 dodir /usr/share/ant/${TASKS_DIR} 1659 dodir /usr/share/ant/${TASKS_DIR}
1731 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}" 1660 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1732} 1661}
1733 1662
1734# ------------------------------------------------------------------------------ 1663# @FUNCTION: java-pkg_ant-tasks-depend
1735# @internal-function java-pkg_ant-tasks-depend 1664# @INTERNAL
1736# 1665# @DESCRIPTION:
1737# Translates the WANT_ANT_TASKS variable into valid dependencies. 1666# Translates the WANT_ANT_TASKS variable into valid dependencies.
1738# ------------------------------------------------------------------------------
1739java-pkg_ant-tasks-depend() { 1667java-pkg_ant-tasks-depend() {
1740 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS} 1668 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1741 1669
1742 if [[ -n "${WANT_ANT_TASKS}" ]]; then 1670 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1743 local DEP="" 1671 local DEP=""
1757 else 1685 else
1758 return 0 1686 return 0
1759 fi 1687 fi
1760} 1688}
1761 1689
1762# ------------------------------------------------------------------------------ 1690
1763# @ebuild-function ejunit 1691# @FUNCTION: ejunit_
1764# 1692# @INTERNAL
1693# @DESCRIPTION:
1765# Junit wrapper function. Makes it easier to run the tests and checks for 1694# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1766# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1695# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1767# 1696# @CODE
1768# Examples: 1697# Parameters:
1769# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests 1698# $1 - junit package (junit or junit-4)
1770# ejunit org.blinkenlights.jid3.test.AllTests
1771#
1772# @param $1 - -cp or -classpath 1699# $2 - -cp or -classpath
1773# @param $2 - classpath; junit and recorded dependencies get appended 1700# $3 - classpath; junit and recorded dependencies get appended
1774# @param $@ - the rest of the parameters are passed to java 1701# $@ - the rest of the parameters are passed to java
1775# ------------------------------------------------------------------------------ 1702# @CODE
1776ejunit() { 1703ejunit_() {
1777 debug-print-function ${FUNCNAME} $* 1704 debug-print-function ${FUNCNAME} $*
1778 1705
1779 local pkgs 1706 local pkgs
1780 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1707 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1781 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1708 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1782 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1709 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1783 done 1710 done
1784 fi 1711 fi
1785 1712
1713 local junit=${1}
1714 shift 1
1715
1786 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1716 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1787 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1717 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1788 cp="${2}:${cp}" 1718 cp="${2}:${cp}"
1789 shift 2 1719 shift 2
1790 else 1720 else
1791 cp=".:${cp}" 1721 cp=".:${cp}"
1792 fi 1722 fi
1793 1723
1794 local runner=junit.textui.TestRunner 1724 local runner=junit.textui.TestRunner
1725 if [[ "${junit}" == "junit-4" ]] ; then
1726 runner=org.junit.runner.JUnitCore
1727 fi
1795 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1728 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1796 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1729 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1797} 1730}
1798 1731
1799# ------------------------------------------------------------------------------ 1732# @FUNCTION: ejunit
1800# @section-end helper 1733# @DESCRIPTION:
1801# ------------------------------------------------------------------------------ 1734# Junit wrapper function. Makes it easier to run the tests and checks for
1802 1735# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1803# ------------------------------------------------------------------------------
1804# @eclass-src_prepare
1805# 1736#
1737# @CODE
1738# Parameters:
1739# $1 - -cp or -classpath
1740# $2 - classpath; junit and recorded dependencies get appended
1741# $@ - the rest of the parameters are passed to java
1742#
1743# Examples:
1744# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1745# ejunit org.blinkenlights.jid3.test.AllTests
1746# ejunit org.blinkenlights.jid3.test.FirstTest org.blinkenlights.jid3.test.SecondTest
1747# @CODE
1748ejunit() {
1749 debug-print-function ${FUNCNAME} $*
1750
1751 ejunit_ "junit" "${@}"
1752}
1753
1754# @FUNCTION: ejunit4
1755# @DESCRIPTION:
1756# Junit4 wrapper function. Makes it easier to run the tests and checks for
1757# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1758#
1759# @CODE
1760# Parameters:
1761# $1 - -cp or -classpath
1762# $2 - classpath; junit and recorded dependencies get appended
1763# $@ - the rest of the parameters are passed to java
1764#
1765# Examples:
1766# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1767# ejunit4 org.blinkenlights.jid3.test.AllTests
1768# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1769# org.blinkenlights.jid3.test.SecondTest
1770# @CODE
1771ejunit4() {
1772 debug-print-function ${FUNCNAME} $*
1773
1774 ejunit_ "junit-4" "${@}"
1775}
1776
1777# @FUNCTION: java-utils-2_src_prepare
1778# @DESCRIPTION:
1806# src_prepare Searches for bundled jars 1779# src_prepare Searches for bundled jars
1807# Don't call directly, but via java-pkg-2_src_prepare! 1780# Don't call directly, but via java-pkg-2_src_prepare!
1808# ------------------------------------------------------------------------------
1809
1810java-utils-2_src_prepare() { 1781java-utils-2_src_prepare() {
1811 [[ ${EBUILD_PHASE} == prepare ]] && 1782 [[ ${EBUILD_PHASE} == prepare ]] &&
1812 java-pkg_func-exists java_prepare && java_prepare 1783 java-pkg_func-exists java_prepare && java_prepare
1813 1784
1814 # Remember that eant will call this unless called via Portage 1785 # Remember that eant will call this unless called via Portage
1820 echo "Search done." 1791 echo "Search done."
1821 fi 1792 fi
1822 touch "${T}/java-utils-2_src_prepare-run" 1793 touch "${T}/java-utils-2_src_prepare-run"
1823} 1794}
1824 1795
1825# ------------------------------------------------------------------------------ 1796# @FUNCTION: java-utils-2_pkg_preinst
1826# @eclass-pkg_preinst 1797# @DESCRIPTION:
1827#
1828# pkg_preinst Searches for missing and unneeded dependencies 1798# pkg_preinst Searches for missing and unneeded dependencies
1829# Don't call directly, but via java-pkg-2_pkg_preinst! 1799# Don't call directly, but via java-pkg-2_pkg_preinst!
1830# ------------------------------------------------------------------------------
1831
1832java-utils-2_pkg_preinst() { 1800java-utils-2_pkg_preinst() {
1833 if is-java-strict; then 1801 if is-java-strict; then
1802 if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
1803 return
1804 fi
1805
1834 if has_version dev-java/java-dep-check; then 1806 if has_version dev-java/java-dep-check; then
1835 [[ -e "${JAVA_PKG_ENV}" ]] || return
1836 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}") 1807 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1837 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then 1808 [[ ${output} ]] && ewarn "${output}"
1838 ewarn "Possibly unneeded dependencies found in package.env:"
1839 for dep in ${output}; do
1840 ewarn "\t${dep}"
1841 done
1842 fi
1843 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1844 ewarn "${output}"
1845 fi
1846 else 1809 else
1847 eerror "Install dev-java/java-dep-check for dependency checking" 1810 eerror "Install dev-java/java-dep-check for dependency checking"
1848 fi 1811 fi
1849 fi 1812 fi
1850} 1813}
1851 1814
1852# ------------------------------------------------------------------------------ 1815# @FUNCTION: eant
1853# @section-begin build 1816# @USAGE: <ant_build_target(s)>
1854# @section-summary Build functions 1817# @DESCRIPTION:
1855#
1856# These are some functions for building a package. In particular, it consists of
1857# wrappers for javac and ant.
1858# ------------------------------------------------------------------------------
1859
1860# ------------------------------------------------------------------------------
1861# @ebuild-function eant
1862#
1863# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1818# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1864# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1819# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1865# variables: 1820# variables:
1821#
1822# @CODE
1823# Variables:
1866# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1824# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1867# gentoo.classpath property. Be sure to call 1825# gentoo.classpath property. Be sure to call java-ant_rewrite-classpath in src_unpack.
1868# java-ant_rewrite-classpath in src_unpack.
1869# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used 1826# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1870# for build-time purposes, the dependency is not recorded to 1827# for build-time purposes, the dependency is not recorded to
1871# package.env! 1828# package.env!
1872# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1873# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1829# ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1874# ------------------------------------------------------------------------------ 1830# @CODE
1875eant() { 1831eant() {
1876 debug-print-function ${FUNCNAME} $* 1832 debug-print-function ${FUNCNAME} $*
1877 1833
1878 if [[ ${EBUILD_PHASE} = compile ]]; then 1834 if [[ ${EBUILD_PHASE} = compile ]]; then
1879 java-ant-2_src_configure 1835 java-ant-2_src_configure
1880 java-utils-2_src_prepare 1836 java-utils-2_src_prepare
1881 fi 1837 fi
1882 1838
1883 if ! hasq java-ant-2 ${INHERITED}; then 1839 if ! has java-ant-2 ${INHERITED}; then
1884 local msg="You should inherit java-ant-2 when using eant" 1840 local msg="You should inherit java-ant-2 when using eant"
1885 java-pkg_announce-qa-violation "${msg}" 1841 java-pkg_announce-qa-violation "${msg}"
1886 fi 1842 fi
1887 1843
1888 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1844 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1961 local gcp="${EANT_GENTOO_CLASSPATH}" 1917 local gcp="${EANT_GENTOO_CLASSPATH}"
1962 local getjarsarg="" 1918 local getjarsarg=""
1963 1919
1964 if [[ ${EBUILD_PHASE} = "test" ]]; then 1920 if [[ ${EBUILD_PHASE} = "test" ]]; then
1965 antflags="${antflags} -DJunit.present=true" 1921 antflags="${antflags} -DJunit.present=true"
1966 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1967 getjarsarg="--with-dependencies" 1922 getjarsarg="--with-dependencies"
1923
1924 local re="\bant-junit4?([-:]\S+)?\b"
1925 [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}"
1926 else
1927 antflags="${antflags} -Dmaven.test.skip=true"
1968 fi 1928 fi
1969 1929
1970 local cp 1930 local cp
1971 1931
1972 for atom in ${gcp}; do 1932 for atom in ${gcp}; do
1973 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1933 cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})"
1974 done 1934 done
1975 1935
1976 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)" 1936 [[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)"
1937 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}"
1977 1938
1978 if [[ ${cp} ]]; then 1939 if [[ ${cp#:} ]]; then
1979 # It seems ant does not like single quotes around ${cp} 1940 # It seems ant does not like single quotes around ${cp}
1980 cp=${cp#:}
1981 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1982 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1983 antflags="${antflags} -Dgentoo.classpath=\"${cp}\"" 1941 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1984 fi 1942 fi
1985 1943
1986 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1944 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1987 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1945 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1988 ant ${antflags} "${@}" || die "eant failed" 1946 ant ${antflags} "${@}" || die "eant failed"
1989} 1947}
1990 1948
1991# ------------------------------------------------------------------------------ 1949# @FUNCTION: ejavac
1992# @ebuild-function ejavac 1950# @USAGE: <javac_arguments>
1993# 1951# @DESCRIPTION:
1994# Javac wrapper function. Will use the appropriate compiler, based on 1952# Javac wrapper function. Will use the appropriate compiler, based on
1995# /etc/java-config/compilers.conf 1953# /etc/java-config/compilers.conf
1996#
1997# @param $@ - Arguments to be passed to the compiler
1998# ------------------------------------------------------------------------------
1999ejavac() { 1954ejavac() {
2000 debug-print-function ${FUNCNAME} $* 1955 debug-print-function ${FUNCNAME} $*
2001 1956
2002 java-pkg_init-compiler_ 1957 java-pkg_init-compiler_
2003 1958
2017 1972
2018 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}" 1973 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
2019 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed" 1974 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
2020} 1975}
2021 1976
2022# ------------------------------------------------------------------------------ 1977# @FUNCTION: ejavadoc
2023# @ebuild-function java-pkg_filter-compiler 1978# @USAGE: <javadoc_arguments>
2024# 1979# @DESCRIPTION:
1980# javadoc wrapper function. Will set some flags based on the VM version
1981# due to strict javadoc rules in 1.8.
1982ejavadoc() {
1983 debug-print-function ${FUNCNAME} $*
1984
1985 local javadoc_args=""
1986
1987 if java-pkg_is-vm-version-ge "1.8" ; then
1988 javadoc_args="-Xdoclint:none"
1989 fi
1990
1991 javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
1992}
1993
1994# @FUNCTION: java-pkg_filter-compiler
1995# @USAGE: <compiler(s)_to_filter>
1996# @DESCRIPTION:
2025# Used to prevent the use of some compilers. Should be used in src_compile. 1997# Used to prevent the use of some compilers. Should be used in src_compile.
2026# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1998# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
2027#
2028# @param $@ - compilers to filter
2029# ------------------------------------------------------------------------------
2030java-pkg_filter-compiler() { 1999java-pkg_filter-compiler() {
2031 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 2000 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
2032} 2001}
2033 2002
2034# ------------------------------------------------------------------------------ 2003# @FUNCTION: java-pkg_force-compiler
2035# @ebuild-function java-pkg_force-compiler 2004# @USAGE: <compiler(s)_to_force>
2036# 2005# @DESCRIPTION:
2037# Used to force the use of particular compilers. Should be used in src_compile. 2006# Used to force the use of particular compilers. Should be used in src_compile.
2038# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid 2007# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
2039# OutOfMemoryErrors that may come up. 2008# OutOfMemoryErrors that may come up.
2040#
2041# @param $@ - compilers to force
2042# ------------------------------------------------------------------------------
2043java-pkg_force-compiler() { 2009java-pkg_force-compiler() {
2044 JAVA_PKG_FORCE_COMPILER="$@" 2010 JAVA_PKG_FORCE_COMPILER="$@"
2045} 2011}
2046 2012
2047# ------------------------------------------------------------------------------ 2013# @FUNCTION: use_doc
2048# @ebuild-function use_doc 2014# @DESCRIPTION:
2049# 2015#
2050# Helper function for getting ant to build javadocs. If the user has USE=doc, 2016# Helper function for getting ant to build javadocs. If the user has USE=doc,
2051# then 'javadoc' or the argument are returned. Otherwise, there is no return. 2017# then 'javadoc' or the argument are returned. Otherwise, there is no return.
2052# 2018#
2053# The output of this should be passed to ant. 2019# The output of this should be passed to ant.
2020# @CODE
2021# Parameters:
2022# $@ - Option value to return. Defaults to 'javadoc'
2054# 2023#
2024# Examples:
2055# Example: build javadocs by calling 'javadoc' target 2025# build javadocs by calling 'javadoc' target
2056# eant $(use_doc) 2026# eant $(use_doc)
2027#
2057# Example: build javadocs by calling 'apidoc' target 2028# build javadocs by calling 'apidoc' target
2058# eant $(use_doc apidoc) 2029# eant $(use_doc apidoc)
2059# 2030# @CODE
2060# @param $@ - Option value to return. Defaults to 'javadoc'
2061# @return string - Name of the target to create javadocs 2031# @RETURN string - Name of the target to create javadocs
2062# ------------------------------------------------------------------------------
2063use_doc() { 2032use_doc() {
2064 use doc && echo ${@:-javadoc} 2033 use doc && echo ${@:-javadoc}
2065} 2034}
2066 2035
2067 2036
2068# ------------------------------------------------------------------------------ 2037# @FUNCTION: java-pkg_init
2069# @section-end build 2038# @INTERNAL
2070# ------------------------------------------------------------------------------ 2039# @DESCRIPTION:
2071
2072# ------------------------------------------------------------------------------
2073# @section-begin internal
2074# @section-summary Internal functions
2075#
2076# Do __NOT__ use any of these from an ebuild! These are only to be used from
2077# within the java eclasses.
2078# ------------------------------------------------------------------------------
2079
2080# -----------------------------------------------------------------------------
2081# @function-internal java-pkg_init
2082#
2083# The purpose of this function, as the name might imply, is to initialize the 2040# The purpose of this function, as the name might imply, is to initialize the
2084# Java environment. It ensures that that there aren't any environment variables 2041# Java environment. It ensures that that there aren't any environment variables
2085# that'll muss things up. It initializes some variables, which are used 2042# that'll muss things up. It initializes some variables, which are used
2086# internally. And most importantly, it'll switch the VM if necessary. 2043# internally. And most importantly, it'll switch the VM if necessary.
2087# 2044#
2088# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2045# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2089# call it during each of the phases of the merge process. 2046# call it during each of the phases of the merge process.
2090#
2091# -----------------------------------------------------------------------------
2092java-pkg_init() { 2047java-pkg_init() {
2093 debug-print-function ${FUNCNAME} $* 2048 debug-print-function ${FUNCNAME} $*
2049
2050 # Don't set up build environment if installing from binary. #206024 #258423
2051 [[ "${MERGE_TYPE}" == "binary" ]] && return
2052 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2053 # work nothing is lost.
2054 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2055
2094 unset JAVAC 2056 unset JAVAC
2095 unset JAVA_HOME 2057 unset JAVA_HOME
2096 2058
2097 java-config --help >/dev/null || { 2059 java-config --help >/dev/null || {
2098 eerror "" 2060 eerror ""
2125 2087
2126 if java-pkg_func-exists ant_src_unpack; then 2088 if java-pkg_func-exists ant_src_unpack; then
2127 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack" 2089 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2128 fi 2090 fi
2129 2091
2130 java-pkg_init_paths_
2131 java-pkg_switch-vm 2092 java-pkg_switch-vm
2132 PATH=${JAVA_HOME}/bin:${PATH} 2093 PATH=${JAVA_HOME}/bin:${PATH}
2133 2094
2134 # TODO we will probably want to set JAVAC and JAVACFLAGS 2095 # TODO we will probably want to set JAVAC and JAVACFLAGS
2135 2096
2149 export ANT_TASKS= 2110 export ANT_TASKS=
2150 export ANT_OPTS= 2111 export ANT_OPTS=
2151 export ANT_RESPECT_JAVA_HOME= 2112 export ANT_RESPECT_JAVA_HOME=
2152} 2113}
2153 2114
2154# ------------------------------------------------------------------------------ 2115# @FUNCTION: java-pkg-init-compiler_
2155# @function-internal java-pkg-init-compiler_ 2116# @INTERNAL
2156# 2117# @DESCRIPTION:
2157# This function attempts to figure out what compiler should be used. It does 2118# This function attempts to figure out what compiler should be used. It does
2158# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 2119# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
2159# COMPILERS variable defined there. 2120# COMPILERS variable defined there.
2160# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 2121# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
2161# 2122#
2172# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no 2133# If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
2173# suitable compiler was found there, then the default is to use javac provided 2134# suitable compiler was found there, then the default is to use javac provided
2174# by the current VM. 2135# by the current VM.
2175# 2136#
2176# 2137#
2177# @return name of the compiler to use 2138# @RETURN name of the compiler to use
2178# ------------------------------------------------------------------------------
2179java-pkg_init-compiler_() { 2139java-pkg_init-compiler_() {
2180 debug-print-function ${FUNCNAME} $* 2140 debug-print-function ${FUNCNAME} $*
2181 2141
2182 if [[ -n ${GENTOO_COMPILER} ]]; then 2142 if [[ -n ${GENTOO_COMPILER} ]]; then
2183 debug-print "GENTOO_COMPILER already set" 2143 debug-print "GENTOO_COMPILER already set"
2224 if ! has ${desired_target} ${supported_target}; then 2184 if ! has ${desired_target} ${supported_target}; then
2225 ewarn "${compiler} does not support -target ${desired_target}, skipping" 2185 ewarn "${compiler} does not support -target ${desired_target}, skipping"
2226 continue 2186 continue
2227 fi 2187 fi
2228 2188
2229 # -source was introduced in 1.3, so only check 1.3 and on
2230 if version_is_at_least "${desired_soure}" "1.3"; then
2231 # Verify that the compiler supports source 2189 # Verify that the compiler supports source
2232 local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE}) 2190 local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
2233 if ! has ${desired_source} ${supported_source}; then 2191 if ! has ${desired_source} ${supported_source}; then
2234 ewarn "${compiler} does not support -source ${desired_source}, skipping" 2192 ewarn "${compiler} does not support -source ${desired_source}, skipping"
2235 continue 2193 continue
2236 fi
2237 fi 2194 fi
2238 2195
2239 # if you get here, then the compiler should be good to go 2196 # if you get here, then the compiler should be good to go
2240 export GENTOO_COMPILER="${compiler}" 2197 export GENTOO_COMPILER="${compiler}"
2241 break 2198 break
2263 einfo "Using ${GENTOO_COMPILER} for compilation" 2220 einfo "Using ${GENTOO_COMPILER} for compilation"
2264 fi 2221 fi
2265 2222
2266} 2223}
2267 2224
2268# ------------------------------------------------------------------------------ 2225# @FUNCTION: init_paths_
2269# @internal-function init_paths_ 2226# @INTERNAL
2270# 2227# @DESCRIPTION:
2271# Initializes some variables that will be used. These variables are mostly used 2228# Initializes some variables that will be used. These variables are mostly used
2272# to determine where things will eventually get installed. 2229# to determine where things will eventually get installed.
2273# ------------------------------------------------------------------------------
2274java-pkg_init_paths_() { 2230java-pkg_init_paths_() {
2275 debug-print-function ${FUNCNAME} $* 2231 debug-print-function ${FUNCNAME} $*
2276 2232
2277 local pkg_name 2233 local pkg_name
2278 if [[ "$SLOT" == "0" ]] ; then 2234 if [[ "${SLOT%/*}" == "0" ]] ; then
2279 JAVA_PKG_NAME="${PN}" 2235 JAVA_PKG_NAME="${PN}"
2280 else 2236 else
2281 JAVA_PKG_NAME="${PN}-${SLOT}" 2237 JAVA_PKG_NAME="${PN}-${SLOT%/*}"
2282 fi 2238 fi
2283 2239
2284 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2240 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2285 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2241 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2286 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2242 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2288 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}" 2244 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2289 2245
2290 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2246 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2291 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2247 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2292 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2248 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2293
2294 2249
2295 # TODO maybe only print once? 2250 # TODO maybe only print once?
2296 debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}" 2251 debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}"
2297 debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}" 2252 debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}"
2298 debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}" 2253 debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
2299 debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}" 2254 debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
2300 debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}" 2255 debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
2301} 2256}
2302 2257
2303# ------------------------------------------------------------------------------ 2258# @FUNCTION: java-pkg_do_write_
2304# @internal-function java-pkg_do_write_ 2259# @INTERNAL
2305# 2260# @DESCRIPTION:
2306# Writes the package.env out to disk. 2261# Writes the package.env out to disk.
2307# 2262#
2308# ------------------------------------------------------------------------------
2309# TODO change to do-write, to match everything else 2263# TODO change to do-write, to match everything else
2310java-pkg_do_write_() { 2264java-pkg_do_write_() {
2311 debug-print-function ${FUNCNAME} $* 2265 debug-print-function ${FUNCNAME} $*
2312 java-pkg_init_paths_ 2266 java-pkg_init_paths_
2313 # Create directory for package.env 2267 # Create directory for package.env
2318 # Create package.env 2272 # Create package.env
2319 ( 2273 (
2320 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2274 echo "DESCRIPTION=\"${DESCRIPTION}\""
2321 echo "GENERATION=\"2\"" 2275 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\"" 2276 echo "SLOT=\"${SLOT}\""
2277 echo "CATEGORY=\"${CATEGORY}\""
2278 echo "PVR=\"${PVR}\""
2323 2279
2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2280 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2281 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2282 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2283 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2328 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2284 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2329 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2285 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2330 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2286 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2331 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2287 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2288 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2289 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2332 ) > "${JAVA_PKG_ENV}" 2290 ) > "${JAVA_PKG_ENV}"
2333 2291
2334 # register target/source 2292 # register target/source
2335 local target="$(java-pkg_get-target)" 2293 local target="$(java-pkg_get-target)"
2336 local source="$(java-pkg_get-source)" 2294 local source="$(java-pkg_get-source)"
2364 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't" 2322 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2365 debug-print "write package.env." 2323 debug-print "write package.env."
2366 fi 2324 fi
2367} 2325}
2368 2326
2369# ------------------------------------------------------------------------------ 2327# @FUNCTION: java-pkg_record-jar_
2370# @internal-function java-pkg_record-jar_ 2328# @INTERNAL
2371# 2329# @DESCRIPTION:
2372# Record an (optional) dependency to the package.env 2330# Record an (optional) dependency to the package.env
2331# @CODE
2332# Parameters:
2373# @param --optional - record dependency as optional 2333# --optional - record dependency as optional
2334# --build - record dependency as build_only
2374# @param $1 - package to record 2335# $1 - package to record
2375# @param $2 - (optional) jar of package to record 2336# $2 - (optional) jar of package to record
2376# ------------------------------------------------------------------------------ 2337# @CODE
2377JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2338JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2378JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2339JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2340JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2379 2341
2380java-pkg_record-jar_() { 2342java-pkg_record-jar_() {
2381 debug-print-function ${FUNCNAME} $* 2343 debug-print-function ${FUNCNAME} $*
2382 2344
2383 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2345 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2384 if [[ "${1}" == "--optional" ]]; then 2346 case "${1}" in
2385 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2347 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2386 shift 2348 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2387 fi 2349 esac
2388 2350
2389 local pkg=${1} jar=${2} append 2351 local pkg=${1} jar=${2} append
2390 if [[ -z "${jar}" ]]; then 2352 if [[ -z "${jar}" ]]; then
2391 append="${pkg}" 2353 append="${pkg}"
2392 else 2354 else
2394 fi 2356 fi
2395 2357
2396 echo "${append}" >> "${depend_file}" 2358 echo "${append}" >> "${depend_file}"
2397} 2359}
2398 2360
2399# ------------------------------------------------------------------------------ 2361# @FUNCTION: java-pkg_append_
2400# @internal-function java-pkg_append_ 2362# @INTERNAL
2401# 2363# @DESCRIPTION:
2402# Appends a value to a variable 2364# Appends a value to a variable
2403# 2365#
2404# Example: java-pkg_append_ CLASSPATH foo.jar 2366# @CODE
2367# Parameters:
2405# @param $1 variable name to modify 2368# $1 variable name to modify
2406# @param $2 value to append 2369# $2 value to append
2407# ------------------------------------------------------------------------------ 2370#
2371# Examples:
2372# java-pkg_append_ CLASSPATH foo.jar
2373# @CODE
2408java-pkg_append_() { 2374java-pkg_append_() {
2409 debug-print-function ${FUNCNAME} $* 2375 debug-print-function ${FUNCNAME} $*
2410 2376
2411 local var="${1}" value="${2}" 2377 local var="${1}" value="${2}"
2412 if [[ -z "${!var}" ]] ; then 2378 if [[ -z "${!var}" ]] ; then
2423 [[ -z ${haveit} ]] && export ${var}="${!var}:${value}" 2389 [[ -z ${haveit} ]] && export ${var}="${!var}:${value}"
2424 IFS=${oldIFS} 2390 IFS=${oldIFS}
2425 fi 2391 fi
2426} 2392}
2427 2393
2428# ------------------------------------------------------------------------------ 2394# @FUNCTION: java-pkg_expand_dir_
2429# @internal-function java-pkg_expand_dir_ 2395# @INTERNAL
2430# 2396# @DESCRIPTION:
2431# Gets the full path of the file/directory's parent. 2397# Gets the full path of the file/directory's parent.
2398# @CODE
2399# Parameters:
2432# @param $1 - file/directory to find parent directory for 2400# $1 - file/directory to find parent directory for
2401# @CODE
2433# @return - path to $1's parent directory 2402# @RETURN: path to $1's parent directory
2434# ------------------------------------------------------------------------------
2435java-pkg_expand_dir_() { 2403java-pkg_expand_dir_() {
2436 pushd "$(dirname "${1}")" >/dev/null 2>&1 2404 pushd "$(dirname "${1}")" >/dev/null 2>&1
2437 pwd 2405 pwd
2438 popd >/dev/null 2>&1 2406 popd >/dev/null 2>&1
2439} 2407}
2440 2408
2441# ------------------------------------------------------------------------------ 2409# @FUNCTION: java-pkg_func-exists
2442# @internal-function java-pkg_func-exists 2410# @INTERNAL
2443# 2411# @DESCRIPTION:
2444# Does the indicated function exist? 2412# Does the indicated function exist?
2445# 2413# @RETURN: 0 - function is declared, 1 - function is undeclared
2446# @return 0 - function is declared
2447# @return 1 - function is undeclared
2448# ------------------------------------------------------------------------------
2449java-pkg_func-exists() { 2414java-pkg_func-exists() {
2450 declare -F ${1} > /dev/null 2415 declare -F ${1} > /dev/null
2451} 2416}
2452 2417
2453# ------------------------------------------------------------------------------ 2418# @FUNCTION: java-pkg_setup-vm
2454# @internal-function java-pkg_setup-vm 2419# @INTERNAL
2455# 2420# @DESCRIPTION:
2456# Sets up the environment for a specific VM 2421# Sets up the environment for a specific VM
2457#
2458# ------------------------------------------------------------------------------
2459java-pkg_setup-vm() { 2422java-pkg_setup-vm() {
2460 debug-print-function ${FUNCNAME} $* 2423 debug-print-function ${FUNCNAME} $*
2461
2462 export LANG="C" LC_ALL="C"
2463 2424
2464 local vendor="$(java-pkg_get-vm-vendor)" 2425 local vendor="$(java-pkg_get-vm-vendor)"
2465 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2426 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2466 addpredict "/dev/random" 2427 addpredict "/dev/random"
2467 elif [[ "${vendor}" == "ibm" ]]; then 2428 elif [[ "${vendor}" == "ibm" ]]; then
2468 addpredict "/proc/self/maps" 2429 addpredict "/proc/self/maps"
2469 addpredict "/proc/cpuinfo" 2430 addpredict "/proc/cpuinfo"
2431 addpredict "/proc/self/coredump_filter"
2432 elif [[ "${vendor}" == "oracle" ]]; then
2433 addpredict "/dev/random"
2434 addpredict "/proc/self/coredump_filter"
2435 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2436 addpredict "/dev/random"
2437 addpredict "/proc/self/coredump_filter"
2470 elif [[ "${vendor}" == "jrockit" ]]; then 2438 elif [[ "${vendor}" == "jrockit" ]]; then
2471 addpredict "/proc/cpuinfo" 2439 addpredict "/proc/cpuinfo"
2472 fi 2440 fi
2473} 2441}
2474 2442
2475# ------------------------------------------------------------------------------ 2443# @FUNCTION: java-pkg_needs-vm
2476# @internal-function java-pkg_needs-vm 2444# @INTERNAL
2477# 2445# @DESCRIPTION:
2478# Does the current package depend on virtual/jdk? 2446# Does the current package depend on virtual/jdk or does it set
2447# JAVA_PKG_WANT_BUILD_VM?
2479# 2448#
2480# @return 0 - Package depends on virtual/jdk 2449# @RETURN: 0 - Package depends on virtual/jdk; 1 - Package does not depend on virtual/jdk
2481# @return 1 - Package does not depend on virtual/jdk
2482# ------------------------------------------------------------------------------
2483java-pkg_needs-vm() { 2450java-pkg_needs-vm() {
2484 debug-print-function ${FUNCNAME} $* 2451 debug-print-function ${FUNCNAME} $*
2485 2452
2486 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2453 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2487 return 0 2454 return 0
2488 fi 2455 fi
2489 2456
2457 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2458
2490 return 1 2459 return 1
2491} 2460}
2492 2461
2493# ------------------------------------------------------------------------------ 2462# @FUNCTION: java-pkg_get-current-vm
2494# @internal-function java-pkg_get-current-vm 2463# @INTERNAL
2495#
2496# @return - The current VM being used 2464# @RETURN - The current VM being used
2497# ------------------------------------------------------------------------------
2498java-pkg_get-current-vm() { 2465java-pkg_get-current-vm() {
2499 java-config -f 2466 java-config -f
2500} 2467}
2501 2468
2502# ------------------------------------------------------------------------------ 2469# @FUNCTION: java-pkg_get-vm-vendor
2503# @internal-function java-pkg_get-vm-vendor 2470# @INTERNAL
2504#
2505# @return - The vendor of the current VM 2471# @RETURN - The vendor of the current VM
2506# ------------------------------------------------------------------------------
2507java-pkg_get-vm-vendor() { 2472java-pkg_get-vm-vendor() {
2508 debug-print-function ${FUNCNAME} $* 2473 debug-print-function ${FUNCNAME} $*
2509 2474
2510 local vm="$(java-pkg_get-current-vm)" 2475 local vm="$(java-pkg_get-current-vm)"
2511 vm="${vm/-*/}" 2476 vm="${vm/-*/}"
2512 echo "${vm}" 2477 echo "${vm}"
2513} 2478}
2514 2479
2515# ------------------------------------------------------------------------------ 2480# @FUNCTION: java-pkg_get-vm-version
2516# @internal-function java-pkg_get-vm-version 2481# @INTERNAL
2517#
2518# @return - The version of the current VM 2482# @RETURN - The version of the current VM
2519# ------------------------------------------------------------------------------
2520java-pkg_get-vm-version() { 2483java-pkg_get-vm-version() {
2521 debug-print-function ${FUNCNAME} $* 2484 debug-print-function ${FUNCNAME} $*
2522 2485
2523 java-config -g PROVIDES_VERSION 2486 java-config -g PROVIDES_VERSION
2524} 2487}
2525 2488
2526# ------------------------------------------------------------------------------ 2489# @FUNCTION: java-pkg_build-vm-from-handle
2527# @internal-function java-pkg_switch-vm 2490# @INTERNAL
2491# @DESCRIPTION:
2492# Selects a build vm from a list of vm handles. First checks for the system-vm
2493# beeing usable, then steps through the listed handles till a suitable vm is
2494# found.
2528# 2495#
2496# @RETURN - VM handle of an available JDK
2497java-pkg_build-vm-from-handle() {
2498 debug-print-function ${FUNCNAME} "$*"
2499
2500 local vm
2501 vm=$(java-pkg_get-current-vm 2>/dev/null)
2502 if [[ $? -eq 0 ]]; then
2503 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2504 echo ${vm}
2505 return 0
2506 fi
2507 fi
2508
2509 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2510 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2511 echo ${vm}
2512 return 0
2513 fi
2514 done
2515
2516 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2517 return 1
2518}
2519
2520# @FUNCTION: java-pkg_switch-vm
2521# @INTERNAL
2522# @DESCRIPTION:
2529# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2523# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
2530# verify that the current VM is sufficient. 2524# verify that the current VM is sufficient.
2531# Setup the environment for the VM being used. 2525# Setup the environment for the VM being used.
2532# ------------------------------------------------------------------------------
2533java-pkg_switch-vm() { 2526java-pkg_switch-vm() {
2534 debug-print-function ${FUNCNAME} $* 2527 debug-print-function ${FUNCNAME} $*
2535 2528
2536 if java-pkg_needs-vm; then 2529 if java-pkg_needs-vm; then
2537 # Use the VM specified by JAVA_PKG_FORCE_VM 2530 # Use the VM specified by JAVA_PKG_FORCE_VM
2539 # If you're forcing the VM, I hope you know what your doing... 2532 # If you're forcing the VM, I hope you know what your doing...
2540 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2533 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2541 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2534 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2542 # if we're allowed to switch the vm... 2535 # if we're allowed to switch the vm...
2543 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2536 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2544 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2537 # if there is an explicit list of handles to choose from
2545 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2538 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2546 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2539 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2540 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2541 if [[ $? != 0 ]]; then
2542 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2543 die "${FUNCNAME}: Failed to determine VM for building"
2544 fi
2545 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2546 # they can't be deduced from handles.
2547 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2548 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2549 die "Specify JAVA_PKG_WANT_SOURCE"
2550 fi
2551 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2552 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2553 die "Specify JAVA_PKG_WANT_TARGET"
2554 fi
2555 # otherwise determine a vm from dep string
2547 else 2556 else
2557 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2548 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2558 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2559 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2560 eerror "Unable to determine VM for building from dependencies:"
2561 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2562 die "Failed to determine VM for building."
2563 fi
2549 fi 2564 fi
2550 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2551 eerror "Unable to determine VM for building from dependencies:"
2552 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2553 echo "VNEED: ${JAVA_PKG_VNEED}"
2554 die "Failed to determine VM for building."
2555 else
2556 export GENTOO_VM 2565 export GENTOO_VM
2557 fi
2558 # otherwise just make sure the current VM is sufficient 2566 # otherwise just make sure the current VM is sufficient
2559 else 2567 else
2560 java-pkg_ensure-vm-version-sufficient 2568 java-pkg_ensure-vm-version-sufficient
2561 fi 2569 fi
2562 debug-print "Using: $(java-config -f)" 2570 debug-print "Using: $(java-config -f)"
2590 else 2598 else
2591 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2599 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2592 fi 2600 fi
2593} 2601}
2594 2602
2595# ------------------------------------------------------------------------------ 2603# @FUNCTION: java-pkg_die
2596# @internal-function java-pkg_die 2604# @INTERNAL
2597# 2605# @DESCRIPTION:
2598# Enhanced die for Java packages, which displays some information that may be 2606# Enhanced die for Java packages, which displays some information that may be
2599# useful for debugging bugs on bugzilla. 2607# useful for debugging bugs on bugzilla.
2600# ------------------------------------------------------------------------------
2601#register_die_hook java-pkg_die 2608#register_die_hook java-pkg_die
2602if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2609if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2603 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2610 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2604fi 2611fi
2605 2612
2606java-pkg_die() { 2613java-pkg_die() {
2607 echo "!!! When you file a bug report, please include the following information:" >&2 2614 echo "!!! When you file a bug report, please include the following information:" >&2
2608 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 2615 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
2609 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 2616 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
2610 echo "and of course, the output of emerge --info" >&2 2617 echo "and of course, the output of emerge --info =${P}" >&2
2611} 2618}
2612 2619
2613 2620
2614# TODO document 2621# TODO document
2615# List jars in the source directory, ${S} 2622# List jars in the source directory, ${S}
2622 einfo "Classes" 2629 einfo "Classes"
2623 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2630 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2624 fi 2631 fi
2625} 2632}
2626 2633
2627# ------------------------------------------------------------------------------ 2634# @FUNCTION: java-pkg_verify-classes
2628# @internal-function java-pkg_verify-classes 2635# @INTERNAL
2629# 2636# @DESCRIPTION:
2630# Verify that the classes were compiled for the right source / target. Dies if 2637# Verify that the classes were compiled for the right source / target. Dies if
2631# not. 2638# not.
2639# @CODE
2632# @param $1 (optional) - the file to check, otherwise checks whole ${D} 2640# $1 (optional) - the file to check, otherwise checks whole ${D}
2633# ------------------------------------------------------------------------------ 2641# @CODE
2634java-pkg_verify-classes() { 2642java-pkg_verify-classes() {
2635 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2643 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2636 2644
2637 local version_verify="/usr/bin/class-version-verify.py" 2645 local version_verify="/usr/bin/class-version-verify.py"
2638 2646
2666 eerror "See ${log} for more details." 2674 eerror "See ${log} for more details."
2667 die "Incorrect bytecode found" 2675 die "Incorrect bytecode found"
2668 fi 2676 fi
2669} 2677}
2670 2678
2671# ---------------------------------------------------------------------------- 2679# @FUNCTION: java-pkg_ensure-dep
2672# @internal-function java-pkg_ensure-dep 2680# @INTERNAL
2681# @DESCRIPTION:
2673# Check that a package being used in jarfrom, getjars and getjar is contained 2682# Check that a package being used in jarfrom, getjars and getjar is contained
2674# within DEPEND or RDEPEND. 2683# within DEPEND or RDEPEND with the correct SLOT. See this mail for details:
2684# https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e
2685# @CODE
2686# Parameters:
2675# @param $1 - empty - check both vars; "runtime" or "build" - check only 2687# $1 - empty - check both vars; "runtime" or "build" - check only
2676# RDEPEND, resp. DEPEND 2688# RDEPEND, resp. DEPEND
2677# @param $2 - Package name and slot. 2689# $2 - Package name and slot.
2678 2690# @CODE
2679java-pkg_ensure-dep() { 2691java-pkg_ensure-dep() {
2680 debug-print-function ${FUNCNAME} $* 2692 debug-print-function ${FUNCNAME} $*
2681 2693
2682 local limit_to="${1}" 2694 local limit_to="${1}"
2683 local target_pkg="${2}" 2695 local target_pkg="${2}"
2684 local dev_error="" 2696 local dev_error=""
2685 2697
2686 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2698 # Transform into a regular expression to look for a matching package
2687 's/-[0-9]*\(\.[0-9]\)*$//') 2699 # and SLOT. SLOTs don't have to be numeric so foo-bar could either
2700 # mean foo-bar:0 or foo:bar. So you want to get your head around the
2701 # line below?
2702 #
2703 # * The target package first has any dots escaped, e.g. foo-1.2
2704 # becomes foo-1\.2.
2705 #
2706 # * sed then looks at the component following the last - or :
2707 # character, or the whole string if there is no - or :
2708 # character. It uses this to build a new regexp with two
2709 # significant branches.
2710 #
2711 # * The first checks for the whole target package string, optionally
2712 # followed by a version number, and then :0.
2713 #
2714 # * The second checks for the first part of the target package
2715 # string, optionally followed by a version number, followed by the
2716 # aforementioned component, treating that as a SLOT.
2717 #
2718 local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b
2688 2719
2689 debug-print "Matching against: ${stripped_pkg}" 2720 debug-print "Matching against: ${stripped_pkg}"
2690 2721
2722 # Uncomment the lines below once we've dealt with more of these
2723 # otherwise we'll be tempted to turn JAVA_PKG_STRICT off while
2724 # getting hit with a wave of bug reports. :(
2725
2691 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2726 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
2692 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2727 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2693 dev_error="${dev_error} declared in DEPEND." 2728 dev_error+="declared with a SLOT in DEPEND."
2694 if is-java-strict; then 2729# if is-java-strict; then
2695 eerror "${dev_error}"
2696 die "${dev_error}" 2730# die "${dev_error}"
2697 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2731# else
2698 eerror "${dev_error}" 2732 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2699 elog "Because you have this package installed the package will" 2733# eerror "Because you have ${target_pkg} installed,"
2700 elog "build without problems, but please report this to" 2734# eerror "the package will build without problems, but please"
2701 elog "http://bugs.gentoo.org" 2735# eerror "report this to http://bugs.gentoo.org."
2702 fi 2736# fi
2703 fi 2737 elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
2704
2705 if [[ ${limit_to} != build ]]; then
2706 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2707 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2708 dev_error="The ebuild is attempting to use ${target_pkg}," 2738 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2709 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND" 2739 dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given."
2710 dev_error="${dev_error} or PDEPEND."
2711 if is-java-strict; then 2740# if is-java-strict; then
2712 eerror "${dev_error}"
2713 die "${dev_error}" 2741# die "${dev_error}"
2714 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2742# else
2715 eerror "${dev_error}" 2743 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2716 elog "The package will build without problems, but may fail to run" 2744# eerror "The package will build without problems, but may fail to run"
2717 elog "if you don't have ${target_pkg} installed, so please report" 2745# eerror "if you don't have ${target_pkg} installed,"
2718 elog "this to http://bugs.gentoo.org" 2746# eerror "so please report this to http://bugs.gentoo.org."
2719 fi
2720 fi
2721 fi 2747# fi
2722 fi 2748 fi
2723} 2749}
2724
2725# ------------------------------------------------------------------------------
2726# @section-end internal
2727# ------------------------------------------------------------------------------
2728 2750
2729java-pkg_check-phase() { 2751java-pkg_check-phase() {
2730 local phase=${1} 2752 local phase=${1}
2731 local funcname=${FUNCNAME[1]} 2753 local funcname=${FUNCNAME[1]}
2732 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 2754 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2742 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2764 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2743 fi 2765 fi
2744} 2766}
2745 2767
2746java-pkg_check-jikes() { 2768java-pkg_check-jikes() {
2747 if hasq jikes ${IUSE}; then 2769 if has jikes ${IUSE}; then
2748 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2770 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2749 fi 2771 fi
2750} 2772}
2751 2773
2752java-pkg_announce-qa-violation() { 2774java-pkg_announce-qa-violation() {
2767 2789
2768is-java-strict() { 2790is-java-strict() {
2769 [[ -n ${JAVA_PKG_STRICT} ]] 2791 [[ -n ${JAVA_PKG_STRICT} ]]
2770 return $? 2792 return $?
2771} 2793}
2772
2773
2774# ------------------------------------------------------------------------------
2775# @eclass-end
2776# ------------------------------------------------------------------------------

Legend:
Removed from v.1.127  
changed lines
  Added in v.1.165

  ViewVC Help
Powered by ViewVC 1.1.20