/[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.10 Revision 1.154
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-2011, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.154 2013/08/27 05:32:28 radhermit Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
15# 15#
16# This eclass provides functionality which is used by 16# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 18#
19# @warning 19# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 20# You probably don't want to inherit this directly from an ebuild. Instead,
21# you should inherit java-ant for Ant-based Java packages, java-pkg for other 21# you should inherit java-ant for Ant-based Java packages, java-pkg for other
22# Java packages, or java-pkg-opt for packages that have optional Java support. 22# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 23#
24# ----------------------------------------------------------------------------- 24# -----------------------------------------------------------------------------
25 25
26inherit eutils versionator multilib 26inherit eutils versionator multilib
27
28IUSE="elibc_FreeBSD"
27 29
28# ----------------------------------------------------------------------------- 30# -----------------------------------------------------------------------------
29# @section-begin variables 31# @section-begin variables
30# @section-title Variables 32# @section-title Variables
31# 33#
33# ----------------------------------------------------------------------------- 35# -----------------------------------------------------------------------------
34 36
35# Make sure we use java-config-2 37# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 38export WANT_JAVA_CONFIG="2"
37 39
38# TODO document 40# -----------------------------------------------------------------------------
41# @variable-external WANT_ANT_TASKS
42# @variable-default ""
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
63# 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.
65# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
40 67
41# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
43# 70#
44# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
45# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
46# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
47# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
49 94
50# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
52# @variable-default yes 97# @variable-default yes
53# 98#
69# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
70# 115#
71# ----------------------------------------------------------------------------- 116# -----------------------------------------------------------------------------
72 117
73# ----------------------------------------------------------------------------- 118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
129# -----------------------------------------------------------------------------
130
131# -----------------------------------------------------------------------------
74# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
75# 133#
76# Specify a specific VM version to compile for to use for -source. 134# Specify a specific VM version to compile for to use for -source.
77# Normally this is determined from DEPEND. 135# Normally this is determined from DEPEND.
78# See java-pkg_get-source function below. 136# See java-pkg_get-source function below.
100# ----------------------------------------------------------------------------- 158# -----------------------------------------------------------------------------
101 159
102# ----------------------------------------------------------------------------- 160# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 161# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 162# @default /usr/share/java-config-2/compiler
105# 163#
106# Directory where compiler settings are saved, without trailing slash. 164# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 165# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 166# -----------------------------------------------------------------------------
109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 167JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
110 168
120 178
121# ----------------------------------------------------------------------------- 179# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 180# @variable-external JAVA_PKG_FORCE_COMPILER
123# 181#
124# Explicitly set a list of compilers to use. This is normally read from 182# Explicitly set a list of compilers to use. This is normally read from
125# JAVA_PKG_COMPILERS_CONF. 183# JAVA_PKG_COMPILERS_CONF.
126# 184#
127# @note This should only be used internally or for testing. 185# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 186# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 187# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 188# -----------------------------------------------------------------------------
131 189
190# -----------------------------------------------------------------------------
191# @variable-external JAVA_PKG_FORCE_ANT_TASKS
192#
193# An $IFS separated list of ant tasks. Can be set in environment before calling
194# emerge/ebuild to override variables set in ebuild, mainly for testing before
195# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
196# eant() call, not the dependencies specified in WANT_ANT_TASKS.
197#
198# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
199# ebuild foo.ebuild compile
200#
201# @seealso WANT_ANT_TASKS
202# -----------------------------------------------------------------------------
203
132# TODO document me 204# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 205JAVA_PKG_QA_VIOLATIONS=0
134 206
135# ----------------------------------------------------------------------------- 207# -----------------------------------------------------------------------------
136# @section-end variables 208# @section-end variables
143# 215#
144# These are used to install Java-related things, such as jars, Javadocs, JNI 216# These are used to install Java-related things, such as jars, Javadocs, JNI
145# libraries, etc. 217# libraries, etc.
146# ----------------------------------------------------------------------------- 218# -----------------------------------------------------------------------------
147 219
220# -----------------------------------------------------------------------------
221# @ebuild-function java-pkg_doexamples
222#
223# Installs given arguments to /usr/share/doc/${PF}/examples
224# If you give it only one parameter and it is a directory it will install
225# everything in that directory to the examples directory.
226#
227# @example
228# java-pkg_doexamples demo
229# java-pkg_doexamples demo/* examples/*
230#
231# @param --subdir - If the examples need a certain directory structure
232# @param $* - list of files to install
233# ------------------------------------------------------------------------------
234java-pkg_doexamples() {
235 debug-print-function ${FUNCNAME} $*
236
237 [[ ${#} -lt 1 ]] && die "At least one argument needed"
238
239 java-pkg_check-phase install
240
241 local dest=/usr/share/doc/${PF}/examples
242 if [[ ${1} == --subdir ]]; then
243 local dest=${dest}/${2}
244 dodir ${dest}
245 shift 2
246 fi
247
248 if [[ ${#} = 1 && -d ${1} ]]; then
249 ( # dont want to pollute calling env
250 insinto "${dest}"
251 doins -r ${1}/*
252 ) || die "Installing examples failed"
253 else
254 ( # dont want to pollute calling env
255 insinto "${dest}"
256 doins -r "$@"
257 ) || die "Installing examples failed"
258 fi
259
260 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
262}
148 263
149# ----------------------------------------------------------------------------- 264# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 265# @ebuild-function java-pkg_dojar
151# 266#
152# Installs any number of jars. 267# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 268# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 269# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 270# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 271# Instead, use java-pkg_newjar defined below.
157# 272#
158# @example 273# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 274# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 275#
171 # Create JARDEST if it doesn't exist 286 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 287 dodir ${JAVA_PKG_JARDEST}
173 288
174 local jar 289 local jar
175 # for each jar 290 # for each jar
176 for jar in "$@"; do 291 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 292 local jar_basename=$(basename "${jar}")
178 293
179 java-pkg_check-versioned-jar ${jar_basename} 294 java-pkg_check-versioned-jar ${jar_basename}
180 295
181 # check if it exists 296 # check if it exists
182 if [[ -e "${jar}" ]] ; then 297 if [[ -e "${jar}" ]] ; then
298 # Don't overwrite if jar has already been installed with the same
299 # name
300 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
301 if [[ -e "${dest}" ]]; then
302 ewarn "Overwriting ${dest}"
303 fi
304
183 # install it into JARDEST if it's a non-symlink 305 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 306 if [[ ! -L "${jar}" ]] ; then
307 #but first check class version when in strict mode.
308 is-java-strict && java-pkg_verify-classes "${jar}"
309
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 310 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 311 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 312 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
188 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 313 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
189 # make a symlink to the original jar if it's symlink 314 # make a symlink to the original jar if it's symlink
199 done 324 done
200 325
201 java-pkg_do_write_ 326 java-pkg_do_write_
202} 327}
203 328
329# ------------------------------------------------------------------------------
330# @internal-function depend-java-query
331#
332# Wrapper for the depend-java-query binary to enable passing USE in env.
333# Using env variables keeps this eclass working with java-config versions that
334# do not handle use flags.
335# ------------------------------------------------------------------------------
204 336
337depend-java-query() {
338 # Used to have a which call here but it caused endless loops for some people
339 # that had some weird bashrc voodoo for which.
340 USE="${USE}" /usr/bin/depend-java-query "${@}"
341}
205 342
206# ------------------------------------------------------------------------------ 343# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 344# @ebuild-function java-pkg_regjar
208# 345#
209# Records an already installed jar in the package.env 346# Records an already installed jar in the package.env
222# will not work, because: 359# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 360# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 361# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 362# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 363# doesn't exist
227# 364#
228# you have to use it as: 365# you have to use it as:
229# 366#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 367# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 368#
232# @param $@ - jars to record 369# @param $@ - jars to record
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 377 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 378
242 java-pkg_init_paths_ 379 java-pkg_init_paths_
243 380
244 local jar jar_dir jar_file 381 local jar jar_dir jar_file
245 for jar in "$@"; do 382 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 383 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 384 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
385 [[ -d "${jar}" || -d "${D}${jar}" ]] \
386 && die "Called ${FUNCNAME} on a directory $*"
387
388 #check that class version correct when in strict mode
389 is-java-strict && java-pkg_verify-classes "${jar}"
390
248 # nelchael: we should strip ${D} in this case too, here's why: 391 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 392 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 393 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 394 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 395 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 396 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 397 else
398 if [[ ${jar} = *\** ]]; then
399 eerror "The argument ${jar} to ${FUNCNAME}"
400 eerror "has * in it. If you want it to glob in"
401 eerror '${D} add ${D} to the argument.'
402 fi
403 debug-print "${jar} or ${D}${jar} not found"
257 die "${jar} does not exist" 404 die "${jar} does not exist"
258 fi 405 fi
259 done 406 done
260 407
261 java-pkg_do_write_ 408 java-pkg_do_write_
262} 409}
263
264 410
265# ------------------------------------------------------------------------------ 411# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 412# @ebuild-function java-pkg_newjar
267# 413#
268# Installs a jar with a new name 414# Installs a jar with a new name
279 local original_jar="${1}" 425 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 426 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 427 local new_jar_dest="${T}/${new_jar}"
282 428
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 429 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 430 [[ ! -f ${original_jar} ]] \
431 && die "${original_jar} does not exist or is not a file!"
285 432
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 433 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 434 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 435 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 436 java-pkg_dojar "${new_jar_dest}"
290} 437}
291 438
292
293# ------------------------------------------------------------------------------ 439# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 440# @ebuild-function java-pkg_addcp
295# 441#
296# Add something to the package's classpath. For jars, you should use dojar, 442# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 443# newjar, or regjar. This is typically used to add directories to the classpath.
302java-pkg_addcp() { 448java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 449 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 450 java-pkg_do_write_
305} 451}
306 452
307
308# ------------------------------------------------------------------------------ 453# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 454# @ebuild-function java-pkg_doso
310# 455#
311# Installs any number of JNI libraries 456# Installs any number of JNI libraries
312# They will be installed into /usr/lib by default, but java-pkg_sointo 457# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 458# can be used change this path
314# 459#
315# Example: 460# Example:
318# @param $@ - JNI libraries to install 463# @param $@ - JNI libraries to install
319# ------------------------------------------------------------------------------ 464# ------------------------------------------------------------------------------
320java-pkg_doso() { 465java-pkg_doso() {
321 debug-print-function ${FUNCNAME} $* 466 debug-print-function ${FUNCNAME} $*
322 467
323 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
324 java-pkg_check-phase install 468 java-pkg_check-phase install
325 469
326 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 470 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
327 471
328 java-pkg_init_paths_ 472 java-pkg_init_paths_
329 473
330 local lib 474 local lib
331 # for each lib 475 # for each lib
334 if [[ -e "${lib}" ]] ; then 478 if [[ -e "${lib}" ]] ; then
335 # install if it isn't a symlink 479 # install if it isn't a symlink
336 if [[ ! -L "${lib}" ]] ; then 480 if [[ ! -L "${lib}" ]] ; then
337 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 481 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
338 INSOPTIONS="${LIBOPTIONS}" \ 482 INSOPTIONS="${LIBOPTIONS}" \
339 doins "${lib}" || "failed to install ${lib}" 483 doins "${lib}" || die "failed to install ${lib}"
340 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 484 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
341 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 485 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
342 # otherwise make a symlink to the symlink's origin 486 # otherwise make a symlink to the symlink's origin
343 else 487 else
344 # TODO use dosym
345 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 488 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
346 debug-print "${lib} is a symlink, linking accordanly" 489 debug-print "${lib} is a symlink, linking accordantly"
347 fi 490 fi
348 # otherwise die 491 # otherwise die
349 else 492 else
350 die "${lib} does not exist" 493 die "${lib} does not exist"
351 fi 494 fi
367java-pkg_regso() { 510java-pkg_regso() {
368 debug-print-function ${FUNCNAME} $* 511 debug-print-function ${FUNCNAME} $*
369 512
370 java-pkg_check-phase install 513 java-pkg_check-phase install
371 514
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 515 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
373 516
374 java-pkg_init_paths_ 517 java-pkg_init_paths_
375 518
376 local lib target_dir 519 local lib target_dir
377 for lib in "$@" ; do 520 for lib in "$@" ; do
378 # Check the absolute path of the lib 521 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 522 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 523 target_dir="$(java-pkg_expand_dir_ ${lib})"
428# ------------------------------------------------------------------------------ 571# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 572java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 573 debug-print-function ${FUNCNAME} $*
431 574
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 575 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 576
577 # from /usr/lib/portage/bin/dohtml -h
578 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 579 dohtml -f package-list "$@"
580
435 # this probably shouldn't be here but it provides 581 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 582 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 583 # old ebuilds.
438 java-pkg_recordjavadoc 584 java-pkg_recordjavadoc
439} 585}
440 586
441# TODO document 587# ------------------------------------------------------------------------------
588# @ebuild-function java-pkg_dojavadoc
589#
590# Installs javadoc documentation. This should be controlled by the doc use flag.
591#
592# @param $1: optional --symlink creates to symlink like this for html
593# documentation bundles.
594# @param $2: - The javadoc root directory.
595#
596# @example:
597# java-pkg_dojavadoc docs/api
598# java-pkg_dojavadoc --symlink apidocs docs/api
599#
600# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 601java-pkg_dojavadoc() {
602 debug-print-function ${FUNCNAME} $*
603
604 # For html documentation bundles that link to Javadoc
605 local symlink
606 if [[ ${1} = --symlink ]]; then
607 symlink=${2}
608 shift 2
609 fi
610
443 local dir="$1" 611 local dir="$1"
612 local dest=/usr/share/doc/${PF}/html
613
614 # QA checks
444 615
445 java-pkg_check-phase install 616 java-pkg_check-phase install
446 617
447 [[ -z "${dir}" ]] && die "Must specify a directory!" 618 [[ -z "${dir}" ]] && die "Must specify a directory!"
448 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 619 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
620 if [[ ! -e "${dir}/index.html" ]]; then
621 local msg="No index.html in javadoc directory"
622 ewarn "${msg}"
623 is-java-strict && die "${msg}"
624 fi
625
626 if [[ -e ${D}/${dest}/api ]]; then
627 eerror "${dest} already exists. Will not overwrite."
628 die "${dest}"
629 fi
630
631 # Renaming to match our directory layout
449 632
450 local dir_to_install="${dir}" 633 local dir_to_install="${dir}"
451 if [[ "$(basename "${dir}")" != "api" ]]; then 634 if [[ "$(basename "${dir}")" != "api" ]]; then
452 dir_to_install="${T}/api" 635 dir_to_install="${T}/api"
453 # TODO use doins 636 # TODO use doins
454 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 637 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
455 fi 638 fi
456 639
640 # Actual installation
641
457 java-pkg_dohtml -r ${dir_to_install} 642 java-pkg_dohtml -r "${dir_to_install}"
643
644 # Let's make a symlink to the directory we have everything else under
645 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
646
647 if [[ ${symlink} ]]; then
648 debug-print "symlinking ${dest}/{api,${symlink}}"
649 dosym ${dest}/{api,${symlink}} || die
650 fi
458} 651}
459 652
460# ------------------------------------------------------------------------------ 653# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 654# @ebuild-function java-pkg_dosrc
462# 655#
463# Installs a zip containing the source for a package, so it can used in 656# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 657# from IDEs like eclipse and netbeans.
465# 658#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 659# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 660#
468# It also should be controlled by USE=source. 661# It also should be controlled by USE=source.
469# 662#
470# @example: 663# @example:
471# java-pkg_dosrc src/* 664# java-pkg_dosrc src/*
472# 665#
473# ------------------------------------------------------------------------------ 666# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 667# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 668# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 669# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 670# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 671# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 672java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 673 debug-print-function ${FUNCNAME} $*
481 674
482 [ ${#} -lt 1 ] && die "At least one argument needed" 675 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi
486 676
487 java-pkg_check-phase install 677 java-pkg_check-phase install
488 678
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 679 [[ ${#} -lt 1 ]] && die "At least one argument needed"
680
681 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
682 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
683 java-pkg_announce-qa-violation ${msg}
684 fi
490 685
491 java-pkg_init_paths_ 686 java-pkg_init_paths_
492 687
493 local zip_name="${PN}-src.zip" 688 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 689 local zip_path="${T}/${zip_name}"
495 local dir 690 local dir
496 for dir in ${@}; do 691 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 692 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 693 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 694 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 695 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 696 local result=$?
518# @ebuild-function java-pkg_dolauncher 713# @ebuild-function java-pkg_dolauncher
519# 714#
520# Make a wrapper script to lauch/start this package 715# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 716# If necessary, the wrapper will switch to the appropriate VM.
522# 717#
718# Can be called without parameters if the package installs only one jar
719# that has the Main-class attribute set. The wrapper will be named ${PN}.
720#
523# @param $1 - filename of launcher to create 721# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 722# @param $2 - options, as follows:
525# --main the.main.class.too.start 723# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 724# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass too jave' 725# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 726# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 727# --pwd Directory the launcher changes to before executing java
530# -into 728# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 729# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 730# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 731java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 732 debug-print-function ${FUNCNAME} $*
535 733
536 java-pkg_check-phase install 734 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 735 java-pkg_init_paths_
541 736
737 if [[ ${#} = 0 ]]; then
738 local name="${PN}"
739 else
542 local name="${1}" 740 local name="${1}"
741 shift
742 fi
743
543 # TODO rename to launcher 744 # TODO rename to launcher
544 local target="${T}/${name}" 745 local target="${T}/${name}"
746 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 747 local target_dir pre
546 shift
547 748
548 echo "#!/bin/bash" > "${target}" 749 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 750 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 751 local var="${1}" value="${2}"
551 if [[ "${var:0:2}" == "--" ]]; then 752 if [[ "${var:0:2}" == "--" ]]; then
753 local var=${var:2}
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 754 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
755 local gjl_${var}="${value}"
553 elif [[ "${var}" == "-into" ]]; then 756 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 757 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 758 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 759 pre="${value}"
557 fi 760 fi
558 shift 2 761 shift 2
559 done 762 done
763
764 # Test if no --jar and --main arguments were given and
765 # in that case check if the package only installs one jar
766 # and use that jar.
767 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
768 local cp="${JAVA_PKG_CLASSPATH}"
769 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
770 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
771 else
772 local msg="Not enough information to create a launcher given."
773 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
774 die "${msg}"
775 fi
776 fi
777
778 # Write the actual script
779 echo "#!/bin/bash" > "${target}"
780 if [[ -n "${pre}" ]]; then
781 if [[ -f "${pre}" ]]; then
782 cat "${pre}" >> "${target}"
783 else
784 die "-pre specified file '${pre}' does not exist"
785 fi
786 fi
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 787 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 788 cat "${var_tmp}" >> "${target}"
789 rm -f "${var_tmp}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 790 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 791
564 if [[ -n "${into}" ]]; then 792 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 793 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 794 local ret=$?
567 return ${ret} 795 return ${ret}
568 else 796 else
569 dobin "${target}" 797 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 825 echo "dowar: warning, skipping directory ${war}"
598 continue 826 continue
599 else 827 else
600 warpath="${war}" 828 warpath="${war}"
601 fi 829 fi
602 830
603 # Install those files like you mean it 831 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 832 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 833 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 834 doins ${warpath}
607 done 835 done
642# @ebuild-function java-pkg_jar-from 870# @ebuild-function java-pkg_jar-from
643# 871#
644# Makes a symlink to a jar from a certain package 872# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 873# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 874# You can use this function to replace these bundled dependencies.
875# The dependency is recorded into package.env DEPEND line, unless "--build-only"
876# is passed as the very first argument, for jars that have to be present only
877# at build time and are not needed on runtime (junit testing etc).
647# 878#
648# Example: get all jars from xerces slot 2 879# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 880# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 881# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 882# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 883# Example: get a specific jar from xerces slot 2, and name it diffrently
653# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 884# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
885# Example: get junit.jar which is needed only for building
886# java-pkg_jar-from --build-only junit junit.jar
654# 887#
655# @param $1 - Package to get jars from. 888# @param $opt
889# --build-only - makes the jar(s) not added into package.env DEPEND line.
890# (assumed automatically when called inside src_test)
891# --with-dependencies - get jars also from requested package's dependencies
892# transitively.
893# --virtual - Packages passed to this function are to be handled as virtuals
894# and will not have individual jar dependencies recorded.
895# --into $dir - symlink jar(s) into $dir (must exist) instead of .
896# @param $1 - Package to get jars from, or comma-separated list of packages in
897# case other parameters are not used.
656# @param $2 - jar from package. If not specified, all jars will be used. 898# @param $2 - jar from package. If not specified, all jars will be used.
657# @param $3 - When a single jar is specified, destination filename of the 899# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 900# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 901# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 902# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 903java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 904 debug-print-function ${FUNCNAME} $*
663 905
906 local build_only=""
907 local destdir="."
908 local deep=""
909 local virtual=""
910 local record_jar=""
911
912 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
913
914 while [[ "${1}" == --* ]]; do
915 if [[ "${1}" = "--build-only" ]]; then
916 build_only="build"
917 elif [[ "${1}" = "--with-dependencies" ]]; then
918 deep="--with-dependencies"
919 elif [[ "${1}" = "--virtual" ]]; then
920 virtual="true"
921 elif [[ "${1}" = "--into" ]]; then
922 destdir="${2}"
923 shift
924 else
925 die "java-pkg_jar-from called with unknown parameter: ${1}"
926 fi
927 shift
928 done
929
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 930 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 931
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 932 [[ -z ${target_pkg} ]] && die "Must specify a package"
933
934 if [[ "${EAPI}" == "1" ]]; then
935 target_pkg="${target_pkg//:/-}"
936 fi
667 937
668 # default destjar to the target jar 938 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 939 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 940
941 local error_msg="There was a problem getting the classpath for ${target_pkg}."
942 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 943 classpath="$(java-config ${deep} --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 944 [[ $? != 0 ]] && die ${error_msg}
945
946 # When we have commas this functions is called to bring jars from multiple
947 # packages. This affects recording of dependencencies performed later
948 # which expects one package only, so we do it here.
949 if [[ ${target_pkg} = *,* ]]; then
950 for pkg in ${target_pkg//,/ }; do
951 java-pkg_ensure-dep "${build_only}" "${pkg}"
952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
953 done
954 # setting this disables further record-jar_ calls later
955 record_jar="true"
956 else
957 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
958 fi
959
960 # Record the entire virtual as a dependency so that
961 # no jars are missed.
962 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
963 java-pkg_record-jar_ "${target_pkg}"
964 # setting this disables further record-jars_ calls later
965 record_jar="true"
966 fi
967
968 pushd ${destdir} > /dev/null \
969 || die "failed to change directory to ${destdir}"
673 970
674 local jar 971 local jar
675 for jar in ${classpath//:/ }; do 972 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 973 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 974 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 978 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 979 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 980 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 981 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 982 || die "Failed to make symlink from ${jar} to ${jar_name}"
983 if [[ -z "${record_jar}" ]]; then
984 if [[ -z "${build_only}" ]]; then
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 985 java-pkg_record-jar_ "${target_pkg}" "${jar}"
986 else
987 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
988 fi
989 fi
687 # otherwise, if the current jar is the target jar, link it 990 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 991 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 992 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 993 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 994 || die "Failed to make symlink from ${jar} to ${destjar}"
995 if [[ -z "${record_jar}" ]]; then
996 if [[ -z "${build_only}" ]]; then
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 997 java-pkg_record-jar_ "${target_pkg}" "${jar}"
998 else
999 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
1000 fi
1001 fi
1002 popd > /dev/null
693 return 0 1003 return 0
694 fi 1004 fi
695 done 1005 done
1006 popd > /dev/null
696 # if no target was specified, we're ok 1007 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 1008 if [[ -z "${target_jar}" ]] ; then
698 return 0 1009 return 0
699 # otherwise, die bitterly 1010 # otherwise, die bitterly
700 else 1011 else
714# ------------------------------------------------------------------------------ 1025# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 1026# @ebuild-function java-pkg_getjars
716# 1027#
717# Get the classpath provided by any number of packages 1028# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 1029# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
1030# The providing packages are recorded as dependencies into package.env DEPEND
1031# line, unless "--build-only" is passed as the very first argument, for jars
1032# that have to be present only at build time and are not needed on runtime
1033# (junit testing etc).
719# 1034#
720# Example: Get the classpath for xerces-2, 1035# Example: Get the classpath for xerces-2 and xalan,
721# java-pkg_getjars xerces-2 xalan 1036# java-pkg_getjars xerces-2,xalan
722# Example Return: 1037# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 1038# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 1039#
1040# @param $opt
1041# --build-only - makes the jar(s) not added into package.env DEPEND line.
1042# (assumed automatically when called inside src_test)
1043# --with-dependencies - get jars also from requested package's dependencies
1044# transitively.
725# @param $@ - list of packages to get jars from 1045# @param $1 - list of packages to get jars from
1046# (passed to java-config --classpath)
726# ------------------------------------------------------------------------------ 1047# ------------------------------------------------------------------------------
727java-pkg_getjars() { 1048java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 1049 debug-print-function ${FUNCNAME} $*
729 1050
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 1051 local build_only=""
1052 local deep=""
731 1053
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 1054 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
733 local classpath pkg 1055
734 for pkg in ${@//,/ }; do 1056 while [[ "${1}" == --* ]]; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do 1057 if [[ "${1}" = "--build-only" ]]; then
736 jars="$(java-config --classpath=${pkg})" 1058 build_only="build"
737 debug-print "${pkg}:${jars}" 1059 elif [[ "${1}" = "--with-dependencies" ]]; then
738 # TODO should we ensure jars exist? 1060 deep="--with-dependencies"
739 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}"
741 else 1061 else
742 classpath="${classpath}:${jars}" 1062 die "java-pkg_jar-from called with unknown parameter: ${1}"
743 fi 1063 fi
744 java-pkg_record-jar_ "${pkg}" 1064 shift
745 done 1065 done
746 echo "${classpath}" 1066
1067 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1068
1069
1070 local pkgs="${1}"
1071
1072 if [[ "${EAPI}" == "1" ]]; then
1073 pkgs="${pkgs//:/-}"
1074 fi
1075
1076 jars="$(java-config ${deep} --classpath=${pkgs})"
1077 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1078 debug-print "${pkgs}:${jars}"
1079
1080 for pkg in ${pkgs//,/ }; do
1081 java-pkg_ensure-dep "${build_only}" "${pkg}"
1082 done
1083
1084 for pkg in ${pkgs//,/ }; do
1085 if [[ -z "${build_only}" ]]; then
1086 java-pkg_record-jar_ "${pkg}"
1087 else
1088 java-pkg_record-jar_ --build-only "${pkg}"
1089 fi
1090 done
1091
1092 echo "${jars}"
747} 1093}
748 1094
749# ------------------------------------------------------------------------------ 1095# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 1096# @ebuild-function java-pkg_getjar
751# 1097#
752# Get the filename of a single jar from a package 1098# Get the filename of a single jar from a package
1099# The providing package is recorded as runtime dependency into package.env
1100# DEPEND line, unless "--build-only" is passed as the very first argument, for
1101# jars that have to be present only at build time and are not needed on runtime
1102# (junit testing etc).
753# 1103#
754# @example 1104# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 1105# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 1106# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 1107# /usr/share/xerces-2/lib/xml-apis.jar
758# 1108#
1109# @param $opt
1110# --build-only - makes the jar not added into package.env DEPEND line.
1111# --virtual - Packages passed to this function are to be handled as virtuals
1112# and will not have individual jar dependencies recorded.
759# @param $1 - package to use 1113# @param $1 - package to use
760# @param $2 - jar to get 1114# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 1115# ------------------------------------------------------------------------------
762java-pkg_getjar() { 1116java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 1117 debug-print-function ${FUNCNAME} $*
764 1118
1119 local build_only=""
1120 local virtual=""
1121 local record_jar=""
1122
1123 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1124
1125 while [[ "${1}" == --* ]]; do
1126 if [[ "${1}" = "--build-only" ]]; then
1127 build_only="build"
1128 elif [[ "${1}" == "--virtual" ]]; then
1129 virtual="true"
1130 else
1131 die "java-pkg_getjar called with unknown parameter: ${1}"
1132 fi
1133 shift
1134 done
1135
1136 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1137
765 local pkg="${1}" target_jar="${2}" jar 1138 local pkg="${1}" target_jar="${2}" jar
1139
1140 if [[ "${EAPI}" == "1" ]]; then
1141 pkg="${pkg//:/-}"
1142 fi
1143
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1144 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1145 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 1146
769 # TODO check that package is actually installed 1147 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1148 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 1149 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 1150 [[ $? != 0 ]] && die ${error_msg}
1151
1152 java-pkg_ensure-dep "${build_only}" "${pkg}"
1153
1154 # Record the package(Virtual) as a dependency and then set build_only
1155 # So that individual jars are not recorded.
1156 if [[ -n "${virtual}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}"
1161 fi
1162 record_jar="true"
1163 fi
1164
772 for jar in ${classpath//:/ }; do 1165 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 1166 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 1167 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 1168 fi
776 1169
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1170 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1171 # Only record jars that aren't build-only
1172 if [[ -z "${record_jar}" ]]; then
1173 if [[ -z "${build_only}" ]]; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 1174 java-pkg_record-jar_ "${pkg}" "${jar}"
1175 else
1176 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1177 fi
1178 fi
779 echo "${jar}" 1179 echo "${jar}"
780 return 0 1180 return 0
781 fi 1181 fi
782 done 1182 done
783 1183
784 die "Could not find ${target_jar} in ${pkg}" 1184 die "Could not find ${target_jar} in ${pkg}"
785 return 1 1185 return 1
786} 1186}
1187
1188# ------------------------------------------------------------------------------
1189# @ebuild-function java-pkg_register-dependency
1190#
1191# Registers runtime dependency on a package, list of packages, or a single jar
1192# from a package, into package.env DEPEND line. Can only be called in
1193# src_install phase.
1194# Intended for binary packages where you don't need to symlink the jars or get
1195# their classpath during build. As such, the dependencies only need to be
1196# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1197#
1198# @param $1 - comma-separated list of packages, or a single package
1199# @param $2 - if param $1 is a single package, optionally specify the jar
1200# to depend on
1201#
1202# Example: Record the dependency on whole xerces-2 and xalan,
1203# java-pkg_register-dependency xerces-2,xalan
1204# Example: Record the dependency on ant.jar from ant-core
1205# java-pkg_register-dependency ant-core ant.jar
1206#
1207# Note: Passing both list of packages as the first parameter AND specifying the
1208# jar as the second is not allowed and will cause the function to die. We assume
1209# that there's more chance one passes such combination as a mistake, than that
1210# there are more packages providing identically named jar without class
1211# collisions.
1212# ------------------------------------------------------------------------------
1213java-pkg_register-dependency() {
1214 debug-print-function ${FUNCNAME} $*
1215
1216 java-pkg_check-phase install
1217
1218 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1219
1220 local pkgs="${1}"
1221 local jar="${2}"
1222
1223 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1224
1225 if [[ "${EAPI}" == "1" ]]; then
1226 pkgs="${pkgs//:/-}"
1227 fi
1228
1229 if [[ -z "${jar}" ]]; then
1230 for pkg in ${pkgs//,/ }; do
1231 java-pkg_ensure-dep runtime "${pkg}"
1232 java-pkg_record-jar_ "${pkg}"
1233 done
1234 else
1235 [[ ${pkgs} == *,* ]] && \
1236 die "${FUNCNAME} called with both package list and jar name"
1237 java-pkg_ensure-dep runtime "${pkgs}"
1238 java-pkg_record-jar_ "${pkgs}" "${jar}"
1239 fi
1240
1241 java-pkg_do_write_
1242}
1243
1244# ------------------------------------------------------------------------------
1245# @ebuild-function java-pkg_register-optional-dependency
1246#
1247# Registers optional runtime dependency on a package, list of packages, or a
1248# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1249# called in src_install phase.
1250# Intended for packages that can use other packages when those are in classpath.
1251# Will be put on classpath by launcher if they are installed. Typical case is
1252# JDBC implementations for various databases. It's better than having USE flag
1253# for each implementation triggering hard dependency.
1254#
1255# @param $1 - comma-separated list of packages, or a single package
1256# @param $2 - if param $1 is a single package, optionally specify the jar
1257# to depend on
1258#
1259# Example: Record the optional dependency on some jdbc providers
1260# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1261#
1262# Note: Passing both list of packages as the first parameter AND specifying the
1263# jar as the second is not allowed and will cause the function to die. We assume
1264# that there's more chance one passes such combination as a mistake, than that
1265# there are more packages providing identically named jar without class
1266# collisions.
1267# ------------------------------------------------------------------------------
1268java-pkg_register-optional-dependency() {
1269 debug-print-function ${FUNCNAME} $*
1270
1271 java-pkg_check-phase install
1272
1273 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1274
1275 local pkgs="${1}"
1276 local jar="${2}"
1277
1278 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1279
1280 if [[ "${EAPI}" == "1" ]]; then
1281 pkgs="${pkgs//:/-}"
1282 fi
1283
1284 if [[ -z "${jar}" ]]; then
1285 for pkg in ${pkgs//,/ }; do
1286 java-pkg_record-jar_ --optional "${pkg}"
1287 done
1288 else
1289 [[ ${pkgs} == *,* ]] && \
1290 die "${FUNCNAME} called with both package list and jar name"
1291 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1292 fi
1293
1294 java-pkg_do_write_
1295}
1296
1297# ------------------------------------------------------------------------------
1298# @ebuild-function java-pkg_register-environment-variable
1299#
1300# Register an arbitrary environment variable into package.env. The gjl launcher
1301# for this package or any package depending on this will export it into
1302# environement before executing java command.
1303# Must only be called in src_install phase.
1304#
1305# @param $1 - variable name
1306# @param $2 - variable value
1307# ------------------------------------------------------------------------------
1308JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1309JAVA_PKG_EXTRA_ENV_VARS=""
1310java-pkg_register-environment-variable() {
1311 debug-print-function ${FUNCNAME} $*
1312
1313 java-pkg_check-phase install
1314
1315 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1316
1317 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1319
1320 java-pkg_do_write_
1321}
1322
1323# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_get-bootclasspath
1325#
1326# Returns classpath of a given bootclasspath-providing package version.
1327#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() {
1333 local version="${1}"
1334
1335 local bcp
1336 case "${version}" in
1337 auto)
1338 bcp="$(java-config -g BOOTCLASSPATH)"
1339 ;;
1340 1.5)
1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1342 ;;
1343 *)
1344 eerror "unknown parameter of java-pkg_get-bootclasspath"
1345 die "unknown parameter of java-pkg_get-bootclasspath"
1346 ;;
1347 esac
1348
1349 echo "${bcp}"
1350}
1351
787 1352
788# This function reads stdin, and based on that input, figures out how to 1353# This function reads stdin, and based on that input, figures out how to
789# populate jars from the filesystem. 1354# populate jars from the filesystem.
790# Need to figure out a good way of making use of this, ie be able to use a 1355# Need to figure out a good way of making use of this, ie be able to use a
791# string that was built instead of stdin 1356# string that was built instead of stdin
802# line="${line// /}" 1367# line="${line// /}"
803# 1368#
804# # format: path=jarinfo 1369# # format: path=jarinfo
805# local path=${line%%=*} 1370# local path=${line%%=*}
806# local jarinfo=${line##*=} 1371# local jarinfo=${line##*=}
807# 1372#
808# # format: jar@package 1373# # format: jar@package
809# local jar=${jarinfo%%@*}.jar 1374# local jar=${jarinfo%%@*}.jar
810# local package=${jarinfo##*@} 1375# local package=${jarinfo##*@}
811# if [[ -n ${replace_only} ]]; then 1376# if [[ -n ${replace_only} ]]; then
812# [[ ! -f $path ]] && die "No jar exists at ${path}" 1377# [[ ! -f $path ]] && die "No jar exists at ${path}"
825# @section-end query 1390# @section-end query
826# ------------------------------------------------------------------------------ 1391# ------------------------------------------------------------------------------
827 1392
828# ------------------------------------------------------------------------------ 1393# ------------------------------------------------------------------------------
829# @section-begin helper 1394# @section-begin helper
830# @section-summary Helper functions 1395# @section-summary Helper functions
831# 1396#
832# Various other functions to use from an ebuild 1397# Various other functions to use from an ebuild
833# ------------------------------------------------------------------------------ 1398# ------------------------------------------------------------------------------
834 1399
835# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
836# @ebuild-function java-pkg_need 1401# @ebuild-function java-pkg_find-normal-jars
837# 1402#
838# Adds virtual dependencies, which can optionally be controlled by a USE flag. 1403# Find the files with suffix .jar file in the given directory or $WORKDIR
839# Currently supported virtuals are:
840# javamail
841# jdbc-stdext
842# jaf
843# jdbc-rowset
844# jms
845# 1404#
846# @param $1 - Optionally indicate that the dependencies are controlled by 1405# @param $1 - The directory to search for jar files (default: ${WORKDIR})
847# a use flag by specifying '--use' Requires $2.
848# @param $2 - USE flag which will enable the dependencies.
849# @param $@ - virtual packages to add depenedencies for
850# ------------------------------------------------------------------------------ 1406# ------------------------------------------------------------------------------
851# TODO rewrite to parse a line based declaration file instead -- karltk 1407java-pkg_find-normal-jars() {
852#java-pkg_need() { 1408 local dir=$1
853# debug-print-function ${FUNCNAME} $* 1409 [[ "${dir}" ]] || dir="${WORKDIR}"
854# local useflag 1410 local found
855# if [[ ${1} == "--use" ]]; then 1411 for jar in $(find "${dir}" -name "*.jar" -type f); do
856# useflag="${2}" 1412 echo "${jar}"
857# shift 2 1413 found="true"
858# fi
859#
860# if [[ -z ${1} ]]; then
861# die "Must specify at least one virtual package."
862# fi
863#
864# local depstr newdepstr
865#
866# for virtual in ${@}; do
867# if has ${virtual} ${JAVA_PKG_VNEED}; then
868# debug-print "Already registered virtual ${virtual}"
869# continue
870# fi
871# case ${virtual} in
872# javamail)
873# debug-print "java-pkg_need: adding javamail dependencies"
874# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
875# ;;
876# jdbc-stdext)
877# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
878# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
879# ;;
880# jaf)
881# debug-print "java-pkg_need: adding jaf dependencies"
882# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
883# ;;
884# jdbc-rowset)
885# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
886# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
887# ;;
888# jms)
889# debug-print "java-pkg_need: adding jms dependencies"
890# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
891# ;;
892# *)
893# die "Invalid virtual: ${virtual}"
894# esac
895#
896# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
897#
898# if [[ -n ${useflag} ]]; then
899# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
900# else
901# depstr="${depstr} ${newdepstr}"
902# fi
903# done 1414 done
904# 1415 [[ "${found}" ]]
905# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}" 1416 return $?
906# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}" 1417}
907#
908# export DEPEND="${DEPEND} ${depstr}"
909# export RDEPEND="${RDEPEND} ${depstr}"
910#}
911 1418
1419# ------------------------------------------------------------------------------
1420# @ebuild-function java-pkg_ensure-no-bundled-jars
1421#
1422# Try to locate bundled jar files in ${WORKDIR} and die if found.
912# This should be used after S has been populated with symlinks to jars 1423# This function should be called after WORKDIR has been populated with symlink
913# TODO document 1424# to system jar files or bundled jars removed.
1425# ------------------------------------------------------------------------------
914java-pkg_ensure-no-bundled-jars() { 1426java-pkg_ensure-no-bundled-jars() {
915 debug-print-function ${FUNCNAME} $* 1427 debug-print-function ${FUNCNAME} $*
916 pushd ${WORKDIR} >/dev/null 2>/dev/null
917 1428
918 local bundled_jars=$(find . -name "*.jar" -type f) 1429 local bundled_jars=$(java-pkg_find-normal-jars)
919 if [[ -n ${bundled_jars} ]]; then 1430 if [[ -n ${bundled_jars} ]]; then
920 echo "Bundled jars found:" 1431 echo "Bundled jars found:"
921 local jar 1432 local jar
922 for jar in ${bundled_jars}; do 1433 for jar in ${bundled_jars}; do
923 echo $(pwd)${jar/./} 1434 echo $(pwd)${jar/./}
924 done 1435 done
925 die "Bundled jars found!" 1436 die "Bundled jars found!"
926
927 fi 1437 fi
928 popd >/dev/null 2>/dev/null
929} 1438}
930 1439
931# ------------------------------------------------------------------------------ 1440# ------------------------------------------------------------------------------
932# @internal-function java-pkg_ensure-vm-version-sufficient 1441# @internal-function java-pkg_ensure-vm-version-sufficient
933# 1442#
945 fi 1454 fi
946} 1455}
947 1456
948# ------------------------------------------------------------------------------ 1457# ------------------------------------------------------------------------------
949# @internal-function java-pkg_is-vm-version-sufficient 1458# @internal-function java-pkg_is-vm-version-sufficient
950# 1459#
951# @return zero - VM is sufficient 1460# @return zero - VM is sufficient
952# @return non-zero - VM is not sufficient 1461# @return non-zero - VM is not sufficient
953# ------------------------------------------------------------------------------ 1462# ------------------------------------------------------------------------------
954java-pkg_is-vm-version-sufficient() { 1463java-pkg_is-vm-version-sufficient() {
955 debug-print-function ${FUNCNAME} $* 1464 debug-print-function ${FUNCNAME} $*
975 die "Active Java VM too old" 1484 die "Active Java VM too old"
976 fi 1485 fi
977} 1486}
978 1487
979# ------------------------------------------------------------------------------ 1488# ------------------------------------------------------------------------------
980# @internal-function java-pkg_is-vm-version-eq 1489# @internal-function java-pkg_is-vm-version-eq
981# 1490#
982# @param $@ - VM version to compare current VM to 1491# @param $@ - VM version to compare current VM to
983# @return zero - VM versions are equal 1492# @return zero - VM versions are equal
984# @return non-zero - VM version are not equal 1493# @return non-zero - VM version are not equal
985# ------------------------------------------------------------------------------ 1494# ------------------------------------------------------------------------------
986java-pkg_is-vm-version-eq() { 1495java-pkg_is-vm-version-eq() {
1016# 1525#
1017# @param $@ - VM version to compare current to 1526# @param $@ - VM version to compare current to
1018# ------------------------------------------------------------------------------ 1527# ------------------------------------------------------------------------------
1019java-pkg_ensure-vm-version-ge() { 1528java-pkg_ensure-vm-version-ge() {
1020 debug-print-function ${FUNCNAME} $* 1529 debug-print-function ${FUNCNAME} $*
1021 1530
1022 if ! java-pkg_is-vm-version-ge "$@" ; then 1531 if ! java-pkg_is-vm-version-ge "$@" ; then
1023 debug-print "vm is not suffient" 1532 debug-print "vm is not suffient"
1024 eerror "This package requires a Java VM version >= $@" 1533 eerror "This package requires a Java VM version >= $@"
1025 einfo "Please use java-config -S to set the correct one" 1534 einfo "Please use java-config -S to set the correct one"
1026 die "Active Java VM too old" 1535 die "Active Java VM too old"
1027 fi 1536 fi
1028} 1537}
1029 1538
1030# ------------------------------------------------------------------------------ 1539# ------------------------------------------------------------------------------
1031# @internal-function java-pkg_is-vm-version-ge 1540# @internal-function java-pkg_is-vm-version-ge
1032# 1541#
1033# @param $@ - VM version to compare current VM to 1542# @param $@ - VM version to compare current VM to
1034# @return zero - current VM version is greater than checked version 1543# @return zero - current VM version is greater than checked version
1035# @return non-zero - current VM version is not greater than checked version 1544# @return non-zero - current VM version is not greater than checked version
1036# ------------------------------------------------------------------------------ 1545# ------------------------------------------------------------------------------
1037java-pkg_is-vm-version-ge() { 1546java-pkg_is-vm-version-ge() {
1051 return 1 1560 return 1
1052 fi 1561 fi
1053 fi 1562 fi
1054} 1563}
1055 1564
1565java-pkg_set-current-vm() {
1566 export GENTOO_VM=${1}
1567}
1568
1569java-pkg_get-current-vm() {
1570 echo ${GENTOO_VM}
1571}
1572
1573java-pkg_current-vm-matches() {
1574 has $(java-pkg_get-current-vm) ${@}
1575 return $?
1576}
1577
1056# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1057# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1058# 1580#
1059# Determines what source version should be used, for passing to -source. 1581# Determines what source version should be used, for passing to -source.
1060# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1582# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1061# 1583#
1062# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1584# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1063# ------------------------------------------------------------------------------ 1585# ------------------------------------------------------------------------------
1068# ------------------------------------------------------------------------------ 1590# ------------------------------------------------------------------------------
1069# @ebuild-function java-pkg_get-target 1591# @ebuild-function java-pkg_get-target
1070# 1592#
1071# Determines what target version should be used, for passing to -target. 1593# Determines what target version should be used, for passing to -target.
1072# If you don't care about lower versions, you can set _WANT_TARGET to the 1594# If you don't care about lower versions, you can set _WANT_TARGET to the
1073# version of your JDK. 1595# version of your JDK.
1074# Remember doing this will mostly like cause things to break.
1075# Doesn't allow it to be lower then the one in depend.
1076# Doesn't allow it to be higher then the active vm.
1077# 1596#
1078# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1597# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1079# ------------------------------------------------------------------------------ 1598# ------------------------------------------------------------------------------
1080java-pkg_get-target() { 1599java-pkg_get-target() {
1081 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1082 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1083 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1084 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1085 echo ${JAVA_PKG_WANT_TARGET}
1086 else
1087 echo ${min}
1088 fi
1089 else
1090 echo ${min}
1091 fi
1092
1093 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1600 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1094} 1601}
1095 1602
1096java-pkg_get-javac() { 1603java-pkg_get-javac() {
1097 debug-print-function ${FUNCNAME} $* 1604 debug-print-function ${FUNCNAME} $*
1098 1605
1099 java-pkg_init-compiler_ 1606
1100 local compiler="${GENTOO_COMPILER}" 1607 local compiler="${GENTOO_COMPILER}"
1101 1608
1102 local compiler_executable 1609 local compiler_executable
1103 if [[ "${compiler}" = "javac" ]]; then 1610 if [[ "${compiler}" = "javac" ]]; then
1104 # nothing fancy needs to be done for javac 1611 # nothing fancy needs to be done for javac
1112 unset JAVAC 1619 unset JAVAC
1113 # try to get value of JAVAC 1620 # try to get value of JAVAC
1114 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1621 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1115 export JAVAC=${old_javac} 1622 export JAVAC=${old_javac}
1116 1623
1117 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1624 if [[ -z ${compiler_executable} ]]; then
1118 1625 echo "JAVAC is empty or undefined in ${compiler_env}"
1626 return 1
1627 fi
1628
1119 # check that it's executable 1629 # check that it's executable
1120 if [[ ! -x ${compiler_executable} ]]; then 1630 if [[ ! -x ${compiler_executable} ]]; then
1121 eerror "Could not find ${compiler_executable}!"
1122 die "${compiler_executable} doesn't exist, or isn't executable" 1631 echo "${compiler_executable} doesn't exist, or isn't executable"
1632 return 1
1123 fi 1633 fi
1124 else 1634 else
1125 eerror "Could not find environment file for ${compiler}" 1635 echo "Could not find environment file for ${compiler}"
1126 die "Could not find ${compiler_env}" 1636 return 1
1127 fi 1637 fi
1128 fi 1638 fi
1129 echo ${compiler_executable} 1639 echo ${compiler_executable}
1130} 1640}
1131 1641
1132# ------------------------------------------------------------------------------ 1642# ------------------------------------------------------------------------------
1133# @ebuild-function java-pkg_javac-args 1643# @ebuild-function java-pkg_javac-args
1134# 1644#
1135# If an ebuild uses javac directly, instead of using ejavac, it should call this 1645# If an ebuild uses javac directly, instead of using ejavac, it should call this
1136# to know what -source/-target to use. 1646# to know what -source/-target to use.
1137# 1647#
1138# @return string - arguments to pass to javac, complete with -target and -source 1648# @return string - arguments to pass to javac, complete with -target and -source
1141 debug-print-function ${FUNCNAME} $* 1651 debug-print-function ${FUNCNAME} $*
1142 1652
1143 local want_source="$(java-pkg_get-source)" 1653 local want_source="$(java-pkg_get-source)"
1144 local want_target="$(java-pkg_get-target)" 1654 local want_target="$(java-pkg_get-target)"
1145 1655
1146 local source_str="-source ${want_source}" 1656 local source_str="-source ${want_source}"
1147 local target_str="-target ${want_target}" 1657 local target_str="-target ${want_target}"
1148 1658
1149 debug-print "want source: ${want_source}" 1659 debug-print "want source: ${want_source}"
1150 debug-print "want target: ${want_target}" 1660 debug-print "want target: ${want_target}"
1151 1661
1152 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1662 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1153 debug-print "could not find valid -source/-target values" 1663 debug-print "could not find valid -source/-target values for javac"
1154 die "Could not find valid -source/-target values" 1664 echo "Could not find valid -source/-target values for javac"
1665 return 1
1155 else 1666 else
1156 if java-pkg_is-vm-version-ge "1.4"; then 1667 if java-pkg_is-vm-version-ge "1.4"; then
1157 echo "${source_str} ${target_str}" 1668 echo "${source_str} ${target_str}"
1158 else 1669 else
1159 echo "${target_str}" 1670 echo "${target_str}"
1163 1674
1164# TODO document 1675# TODO document
1165java-pkg_get-jni-cflags() { 1676java-pkg_get-jni-cflags() {
1166 local flags="-I${JAVA_HOME}/include" 1677 local flags="-I${JAVA_HOME}/include"
1167 1678
1679 local platform="linux"
1680 use elibc_FreeBSD && platform="freebsd"
1681
1168 # TODO do a check that the directories are valid 1682 # TODO do a check that the directories are valid
1169 # TODO figure out how to cope with other things than linux...
1170 flags="${flags} -I${JAVA_HOME}/include/linux" 1683 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1171 1684
1172 echo ${flags} 1685 echo ${flags}
1173} 1686}
1174 1687
1175java-pkg_ensure-gcj() { 1688java-pkg_ensure-gcj() {
1176 if ! built_with_use sys-devel/gcc gcj ; then 1689 # was enforcing sys-devel/gcc[gcj]
1177 ewarn 1690 die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
1178 ewarn "You must build gcc with the gcj support to build with gcj" 1691}
1179 ewarn 1692
1180 ebeep 5 1693java-pkg_ensure-test() {
1181 die "No GCJ support found!" 1694 # was enforcing USE=test if FEATURES=test
1695 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1696}
1697
1698# ------------------------------------------------------------------------------
1699# @ebuild-function java-pkg_register-ant-task
1700#
1701# Register this package as ant task, so that ant will load it when no specific
1702# ANT_TASKS are specified. Note that even without this registering, all packages
1703# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1704# packages, but can be also used by other ebuilds that used to symlink their
1705# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1706# compatibility.
1707#
1708# @param --version x.y Register only for ant version x.y (otherwise for any ant
1709# version). Used by the ant-* packages to prevent loading of mismatched
1710# ant-core ant tasks after core was updated, before the tasks are updated,
1711# without a need for blockers.
1712# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1713# ------------------------------------------------------------------------------
1714java-pkg_register-ant-task() {
1715 local TASKS_DIR="tasks"
1716
1717 # check for --version x.y parameters
1718 while [[ -n "${1}" && -n "${2}" ]]; do
1719 local var="${1#--}"
1720 local val="${2}"
1721 if [[ "${var}" == "version" ]]; then
1722 TASKS_DIR="tasks-${val}"
1723 else
1724 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1182 fi 1725 fi
1726 shift 2
1727 done
1728
1729 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1730
1731 dodir /usr/share/ant/${TASKS_DIR}
1732 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1733}
1734
1735# ------------------------------------------------------------------------------
1736# @internal-function java-pkg_ant-tasks-depend
1737#
1738# Translates the WANT_ANT_TASKS variable into valid dependencies.
1739# ------------------------------------------------------------------------------
1740java-pkg_ant-tasks-depend() {
1741 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1742
1743 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1744 local DEP=""
1745 for i in ${WANT_ANT_TASKS}
1746 do
1747 if [[ ${i} = ant-* ]]; then
1748 DEP="${DEP}dev-java/${i} "
1749 elif [[ ${i} = */*:* ]]; then
1750 DEP="${DEP}${i} "
1751 else
1752 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1753 return 1
1754 fi
1755 done
1756 echo ${DEP}
1757 return 0
1758 else
1759 return 0
1760 fi
1761}
1762
1763
1764# ------------------------------------------------------------------------------
1765# @internal-function ejunit_
1766#
1767# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1768# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1769#
1770# @param $1 - junit package (junit or junit-4)
1771# @param $2 - -cp or -classpath
1772# @param $3 - classpath; junit and recorded dependencies get appended
1773# @param $@ - the rest of the parameters are passed to java
1774ejunit_() {
1775 debug-print-function ${FUNCNAME} $*
1776
1777 local pkgs
1778 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1779 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1780 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1781 done
1782 fi
1783
1784 local junit=${1}
1785 shift 1
1786
1787 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1788 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1789 cp="${2}:${cp}"
1790 shift 2
1791 else
1792 cp=".:${cp}"
1793 fi
1794
1795 local runner=junit.textui.TestRunner
1796 if [[ "${junit}" == "junit-4" ]] ; then
1797 runner=org.junit.runner.JUnitCore
1798 fi
1799 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1800 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1801}
1802
1803# ------------------------------------------------------------------------------
1804# @ebuild-function ejunit
1805#
1806# Junit wrapper function. Makes it easier to run the tests and checks for
1807# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1808#
1809# Examples:
1810# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1811# ejunit org.blinkenlights.jid3.test.AllTests
1812# ejunit org.blinkenlights.jid3.test.FirstTest \
1813# org.blinkenlights.jid3.test.SecondTest
1814#
1815# @param $1 - -cp or -classpath
1816# @param $2 - classpath; junit and recorded dependencies get appended
1817# @param $@ - the rest of the parameters are passed to java
1818# ------------------------------------------------------------------------------
1819ejunit() {
1820 debug-print-function ${FUNCNAME} $*
1821
1822 ejunit_ "junit" "${@}"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @ebuild-function ejunit4
1827#
1828# Junit4 wrapper function. Makes it easier to run the tests and checks for
1829# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1830#
1831# Examples:
1832# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1833# ejunit4 org.blinkenlights.jid3.test.AllTests
1834# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1835# org.blinkenlights.jid3.test.SecondTest
1836#
1837# @param $1 - -cp or -classpath
1838# @param $2 - classpath; junit and recorded dependencies get appended
1839# @param $@ - the rest of the parameters are passed to java
1840# ------------------------------------------------------------------------------
1841ejunit4() {
1842 debug-print-function ${FUNCNAME} $*
1843
1844 ejunit_ "junit-4" "${@}"
1183} 1845}
1184 1846
1185# ------------------------------------------------------------------------------ 1847# ------------------------------------------------------------------------------
1186# @section-end helper 1848# @section-end helper
1187# ------------------------------------------------------------------------------ 1849# ------------------------------------------------------------------------------
1850
1851# ------------------------------------------------------------------------------
1852# @eclass-src_prepare
1853#
1854# src_prepare Searches for bundled jars
1855# Don't call directly, but via java-pkg-2_src_prepare!
1856# ------------------------------------------------------------------------------
1857
1858java-utils-2_src_prepare() {
1859 [[ ${EBUILD_PHASE} == prepare ]] &&
1860 java-pkg_func-exists java_prepare && java_prepare
1861
1862 # Remember that eant will call this unless called via Portage
1863 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1864 echo "Searching for bundled jars:"
1865 java-pkg_find-normal-jars || echo "None found."
1866 echo "Searching for bundled classes (no output if none found):"
1867 find "${WORKDIR}" -name "*.class"
1868 echo "Search done."
1869 fi
1870 touch "${T}/java-utils-2_src_prepare-run"
1871}
1872
1873# ------------------------------------------------------------------------------
1874# @eclass-pkg_preinst
1875#
1876# pkg_preinst Searches for missing and unneeded dependencies
1877# Don't call directly, but via java-pkg-2_pkg_preinst!
1878# ------------------------------------------------------------------------------
1879
1880java-utils-2_pkg_preinst() {
1881 if is-java-strict; then
1882 if has_version dev-java/java-dep-check; then
1883 [[ -e "${JAVA_PKG_ENV}" ]] || return
1884 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1885 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1886 ewarn "Possibly unneeded dependencies found in package.env:"
1887 for dep in ${output}; do
1888 ewarn "\t${dep}"
1889 done
1890 fi
1891 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1892 ewarn "${output}"
1893 fi
1894 else
1895 eerror "Install dev-java/java-dep-check for dependency checking"
1896 fi
1897 fi
1898}
1188 1899
1189# ------------------------------------------------------------------------------ 1900# ------------------------------------------------------------------------------
1190# @section-begin build 1901# @section-begin build
1191# @section-summary Build functions 1902# @section-summary Build functions
1192# 1903#
1196 1907
1197# ------------------------------------------------------------------------------ 1908# ------------------------------------------------------------------------------
1198# @ebuild-function eant 1909# @ebuild-function eant
1199# 1910#
1200# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1911# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1201# compiler. 1912# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1202# 1913# variables:
1914# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1915# gentoo.classpath property. Be sure to call
1916# java-ant_rewrite-classpath in src_unpack.
1917# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1918# for build-time purposes, the dependency is not recorded to
1919# package.env!
1920# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1203# ------------------------------------------------------------------------------ 1921# ------------------------------------------------------------------------------
1204eant() { 1922eant() {
1205 debug-print-function ${FUNCNAME} $* 1923 debug-print-function ${FUNCNAME} $*
1206 1924
1207 local antflags 1925 if [[ ${EBUILD_PHASE} = compile ]]; then
1926 java-ant-2_src_configure
1927 java-utils-2_src_prepare
1928 fi
1929
1930 if ! has java-ant-2 ${INHERITED}; then
1931 local msg="You should inherit java-ant-2 when using eant"
1932 java-pkg_announce-qa-violation "${msg}"
1933 fi
1934
1935 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1936
1208 java-pkg_init-compiler_ 1937 java-pkg_init-compiler_
1209 local compiler="${GENTOO_COMPILER}" 1938 local compiler="${GENTOO_COMPILER}"
1210 1939
1211 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1940 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1212
1213 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1941 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1214 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1942 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1215 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1943 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1216 fi 1944 fi
1217 1945
1218 if [[ ${compiler} != "javac" ]]; then 1946 if [[ ${compiler} != "javac" ]]; then
1219 antflags="-Dbuild.compiler=${build_compiler}" 1947 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1220 # Figure out any extra stuff to put on the classpath for compilers aside 1948 # Figure out any extra stuff to put on the classpath for compilers aside
1221 # from javac 1949 # from javac
1222 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1950 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1223 # java-config -p 1951 # java-config -p
1224 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1952 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1225 if [[ -n ${build_compiler_deps} ]]; then 1953 if [[ -n ${build_compiler_deps} ]]; then
1226 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1954 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1227 fi 1955 fi
1228 fi 1956 fi
1229 1957
1958 for arg in "${@}"; do
1959 if [[ ${arg} = -lib ]]; then
1230 if is-java-strict; then 1960 if is-java-strict; then
1231 einfo "Disabling system classpath for ant" 1961 eerror "You should not use the -lib argument to eant because it will fail"
1232 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1962 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1963 eerror "or ant properties to make dependencies available."
1964 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1965 eerror "split ant (>=dev-java/ant-core-1.7)."
1966 die "eant -lib is deprecated/forbidden"
1967 else
1968 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1969 echo "more info."
1970 fi
1233 fi 1971 fi
1234 1972 done
1235 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1973
1236 antflags="${antflags} -debug" 1974 # parse WANT_ANT_TASKS for atoms
1975 local want_ant_tasks
1976 for i in ${WANT_ANT_TASKS}; do
1977 if [[ ${i} = */*:* ]]; then
1978 i=${i#*/}
1979 i=${i%:0}
1980 want_ant_tasks+="${i/:/-} "
1981 else
1982 want_ant_tasks+="${i} "
1237 fi 1983 fi
1238 1984 done
1985 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1986 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1987
1988 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1989 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1990
1991 # if ant-tasks is not set by ebuild or forced, use none
1992 ANT_TASKS="${ANT_TASKS:-none}"
1993
1994 # at this point, ANT_TASKS should be "all", "none" or explicit list
1995 if [[ "${ANT_TASKS}" == "all" ]]; then
1996 einfo "Using all available ANT_TASKS"
1997 elif [[ "${ANT_TASKS}" == "none" ]]; then
1998 einfo "Disabling all optional ANT_TASKS"
1999 else
2000 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
2001 fi
2002
2003 export ANT_TASKS
2004
2005 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
2006 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
2007
2008 local gcp="${EANT_GENTOO_CLASSPATH}"
2009 local getjarsarg=""
2010
2011 if [[ ${EBUILD_PHASE} = "test" ]]; then
2012 antflags="${antflags} -DJunit.present=true"
2013 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
2014 getjarsarg="--with-dependencies"
2015 else
2016 antflags="${antflags} -Dmaven.test.skip=true"
2017 fi
2018
2019 local cp
2020
2021 for atom in ${gcp}; do
2022 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
2023 done
2024
2025 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2026
2027 if [[ ${cp} ]]; then
2028 # It seems ant does not like single quotes around ${cp}
2029 cp=${cp#:}
2030 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2031 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
2032 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
2033 fi
2034
1239 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2035 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
2036 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1240 ant ${antflags} "${@}" || die "eant failed" 2037 ant ${antflags} "${@}" || die "eant failed"
1241
1242} 2038}
1243 2039
1244# ------------------------------------------------------------------------------ 2040# ------------------------------------------------------------------------------
1245# @ebuild-function ejavac 2041# @ebuild-function ejavac
1246# 2042#
1247# Javac wrapper function. Will use the appropriate compiler, based on 2043# Javac wrapper function. Will use the appropriate compiler, based on
1248# /etc/java-config/compilers.conf 2044# /etc/java-config/compilers.conf
1249# 2045#
1250# @param $@ - Arguments to be passed to the compiler 2046# @param $@ - Arguments to be passed to the compiler
1251# ------------------------------------------------------------------------------ 2047# ------------------------------------------------------------------------------
1252ejavac() { 2048ejavac() {
1253 debug-print-function ${FUNCNAME} $* 2049 debug-print-function ${FUNCNAME} $*
1254 2050
1255 # FIXME using get-javac ends up printing stuff with einfo 2051 java-pkg_init-compiler_
2052
2053 local compiler_executable
1256# local compiler_executable=$(java-pkg_get-javac) 2054 compiler_executable=$(java-pkg_get-javac)
1257 local compiler_executable="javac" 2055 if [[ ${?} != 0 ]]; then
2056 eerror "There was a problem determining compiler: ${compiler_executable}"
2057 die "get-javac failed"
2058 fi
1258 2059
2060 local javac_args
2061 javac_args="$(java-pkg_javac-args)"
2062 if [[ ${?} != 0 ]]; then
2063 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
2064 die "java-pkg_javac-args failed"
2065 fi
2066
1259 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 2067 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1260 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 2068 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1261} 2069}
1262 2070
1263# ------------------------------------------------------------------------------ 2071# ------------------------------------------------------------------------------
1264# @ebuild-function java-pkg_filter-compiler 2072# @ebuild-function java-pkg_filter-compiler
1265# 2073#
1266# Used to prevent the use of some compilers. Should be used in src_compile. 2074# Used to prevent the use of some compilers. Should be used in src_compile.
1267# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 2075# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1268# 2076#
1269# @param $@ - compilers to filter 2077# @param $@ - compilers to filter
1270# ------------------------------------------------------------------------------ 2078# ------------------------------------------------------------------------------
1288# ------------------------------------------------------------------------------ 2096# ------------------------------------------------------------------------------
1289# @ebuild-function use_doc 2097# @ebuild-function use_doc
1290# 2098#
1291# Helper function for getting ant to build javadocs. If the user has USE=doc, 2099# Helper function for getting ant to build javadocs. If the user has USE=doc,
1292# then 'javadoc' or the argument are returned. Otherwise, there is no return. 2100# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1293# 2101#
1294# The output of this should be passed to ant. 2102# The output of this should be passed to ant.
1295# 2103#
1296# Example: build javadocs by calling 'javadoc' target 2104# Example: build javadocs by calling 'javadoc' target
1297# eant $(use_doc) 2105# eant $(use_doc)
1298# Example: build javadocs by calling 'apidoc' target 2106# Example: build javadocs by calling 'apidoc' target
1303# ------------------------------------------------------------------------------ 2111# ------------------------------------------------------------------------------
1304use_doc() { 2112use_doc() {
1305 use doc && echo ${@:-javadoc} 2113 use doc && echo ${@:-javadoc}
1306} 2114}
1307 2115
2116
1308# ------------------------------------------------------------------------------ 2117# ------------------------------------------------------------------------------
1309# @section-end build 2118# @section-end build
1310# ------------------------------------------------------------------------------ 2119# ------------------------------------------------------------------------------
1311 2120
1312# ------------------------------------------------------------------------------ 2121# ------------------------------------------------------------------------------
1313# @section-begin internal 2122# @section-begin internal
1314# @section-summary Internal functions 2123# @section-summary Internal functions
1315# 2124#
1316# Do __NOT__ use any of these from an ebuild! These are only to be used from 2125# Do __NOT__ use any of these from an ebuild! These are only to be used from
1317# within the java eclasses. 2126# within the java eclasses.
1318# ------------------------------------------------------------------------------ 2127# ------------------------------------------------------------------------------
1319 2128
1320# ----------------------------------------------------------------------------- 2129# -----------------------------------------------------------------------------
1321# @function-internal java-pkg_init 2130# @function-internal java-pkg_init
1322# 2131#
1323# The purpose of this function, as the name might imply, is to initialize the 2132# The purpose of this function, as the name might imply, is to initialize the
1324# Java environment. It ensures that that there aren't any environment variables 2133# Java environment. It ensures that that there aren't any environment variables
1325# that'll muss things up. It initializes some variables, which are used 2134# that'll muss things up. It initializes some variables, which are used
1326# internally. And most importantly, it'll switch the VM if necessary. 2135# internally. And most importantly, it'll switch the VM if necessary.
1327# 2136#
1328# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2137# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1329# call it during each of the phases of the merge process. 2138# call it during each of the phases of the merge process.
1330# 2139#
1331# ----------------------------------------------------------------------------- 2140# -----------------------------------------------------------------------------
1332java-pkg_init() { 2141java-pkg_init() {
2142 debug-print-function ${FUNCNAME} $*
2143
2144 # Don't set up build environment if installing from binary. #206024 #258423
2145 [[ "${MERGE_TYPE}" == "binary" ]] && return
2146 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2147 # work nothing is lost.
2148 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2149
1333 unset JAVAC 2150 unset JAVAC
1334 unset JAVA_HOME 2151 unset JAVA_HOME
2152
2153 java-config --help >/dev/null || {
2154 eerror ""
2155 eerror "Can't run java-config --help"
2156 eerror "Have you upgraded python recently but haven't"
2157 eerror "run python-updater yet?"
2158 die "Can't run java-config --help"
2159 }
2160
2161 # People do all kinds of weird things.
2162 # http://forums.gentoo.org/viewtopic-p-3943166.html
2163 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2164 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2165 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2166 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2167 ewarn "sun-jdk vms and and as such break configure scripts that"
2168 ewarn "use it (for example app-office/openoffice) so we filter it out."
2169 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2170 ewarn "make.conf for example) to silence this warning or"
2171 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2172 fi
2173
2174 if [[ -z ${accept} ]]; then
2175 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2176 # -version output
2177 unset _JAVA_OPTIONS
2178 # phase hooks make this run many times without this
2179 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2180 fi
2181
2182 if java-pkg_func-exists ant_src_unpack; then
2183 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2184 fi
2185
1335 java-pkg_init_paths_ 2186 java-pkg_init_paths_
1336 java-pkg_switch-vm 2187 java-pkg_switch-vm
1337 PATH=${JAVA_HOME}/bin:${PATH} 2188 PATH=${JAVA_HOME}/bin:${PATH}
1338 2189
1339 # TODO we will probably want to set JAVAC and JAVACFLAGS 2190 # TODO we will probably want to set JAVAC and JAVACFLAGS
1340 2191
1341 # Do some QA checks 2192 # Do some QA checks
1342 java-pkg_check-jikes 2193 java-pkg_check-jikes
1343 2194
2195 # Can't use unset here because Portage does not save the unset
2196 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2197
1344 # When users have crazy classpaths some packages can fail to compile. 2198 # When users have crazy classpaths some packages can fail to compile.
1345 # and everything should work with empty CLASSPATH. 2199 # and everything should work with empty CLASSPATH.
1346 # This also helps prevent unexpected dependencies on random things 2200 # This also helps prevent unexpected dependencies on random things
1347 # from the CLASSPATH. 2201 # from the CLASSPATH.
1348 unset CLASSPATH 2202 export CLASSPATH=
2203
2204 # Unset external ANT_ stuff
2205 export ANT_TASKS=
2206 export ANT_OPTS=
2207 export ANT_RESPECT_JAVA_HOME=
1349} 2208}
1350 2209
1351# ------------------------------------------------------------------------------ 2210# ------------------------------------------------------------------------------
1352# @function-internal java-pkg-init-compiler_ 2211# @function-internal java-pkg-init-compiler_
1353# 2212#
1354# This function attempts to figure out what compiler should be used. It does 2213# This function attempts to figure out what compiler should be used. It does
1355# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 2214# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1356# COMPILERS variable defined there. 2215# COMPILERS variable defined there.
1357# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 2216# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1358# 2217#
1359# It will go through the list of compilers, and verify that it supports the 2218# It will go through the list of compilers, and verify that it supports the
1360# target and source that are needed. If it is not suitable, then the next 2219# target and source that are needed. If it is not suitable, then the next
1361# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 2220# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1362# isn't done. 2221# isn't done.
1363# 2222#
1385 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2244 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1386 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 2245 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1387 else 2246 else
1388 compilers=${JAVA_PKG_FORCE_COMPILER} 2247 compilers=${JAVA_PKG_FORCE_COMPILER}
1389 fi 2248 fi
1390 2249
1391 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 2250 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1392 2251
1393 # Figure out if we should announce what compiler we're using 2252 # Figure out if we should announce what compiler we're using
1394 local compiler 2253 local compiler
1395 for compiler in ${compilers}; do 2254 for compiler in ${compilers}; do
1398 if [[ ${compiler} = "javac" ]]; then 2257 if [[ ${compiler} = "javac" ]]; then
1399 debug-print "Found javac... breaking" 2258 debug-print "Found javac... breaking"
1400 export GENTOO_COMPILER="javac" 2259 export GENTOO_COMPILER="javac"
1401 break 2260 break
1402 fi 2261 fi
1403 2262
1404 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 2263 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1405 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2264 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1406 einfo "Filtering ${compiler}" 2265 einfo "Filtering ${compiler}"
1407 continue 2266 continue
1408 fi 2267 fi
1409 fi 2268 fi
1410 2269
1411 # for non-javac, we need to make sure it supports the right target and 2270 # for non-javac, we need to make sure it supports the right target and
1412 # source 2271 # source
1413 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 2272 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1414 if [[ -f ${compiler_env} ]]; then 2273 if [[ -f ${compiler_env} ]]; then
1415 local desired_target="$(java-pkg_get-target)" 2274 local desired_target="$(java-pkg_get-target)"
1444 done 2303 done
1445 2304
1446 # If it hasn't been defined already, default to javac 2305 # If it hasn't been defined already, default to javac
1447 if [[ -z ${GENTOO_COMPILER} ]]; then 2306 if [[ -z ${GENTOO_COMPILER} ]]; then
1448 if [[ -n ${compilers} ]]; then 2307 if [[ -n ${compilers} ]]; then
1449 einfo "No suitable compiler found: defaulting javac for compilation" 2308 einfo "No suitable compiler found: defaulting to JDK default for compilation"
1450 else 2309 else
1451 # probably don't need to notify users about the default. 2310 # probably don't need to notify users about the default.
1452 :;#einfo "Defaulting to javac for compilation" 2311 :;#einfo "Defaulting to javac for compilation"
1453 fi 2312 fi
2313 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2314 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2315 else
1454 export GENTOO_COMPILER=javac 2316 export GENTOO_COMPILER=javac
2317 fi
1455 else 2318 else
1456 einfo "Using ${GENTOO_COMPILER} for compilation" 2319 einfo "Using ${GENTOO_COMPILER} for compilation"
1457 fi 2320 fi
1458 2321
1459} 2322}
1466# ------------------------------------------------------------------------------ 2329# ------------------------------------------------------------------------------
1467java-pkg_init_paths_() { 2330java-pkg_init_paths_() {
1468 debug-print-function ${FUNCNAME} $* 2331 debug-print-function ${FUNCNAME} $*
1469 2332
1470 local pkg_name 2333 local pkg_name
1471 if [[ "$SLOT" == "0" ]] ; then 2334 if [[ "${SLOT%/*}" == "0" ]] ; then
1472 JAVA_PKG_NAME="${PN}" 2335 JAVA_PKG_NAME="${PN}"
1473 else 2336 else
1474 JAVA_PKG_NAME="${PN}-${SLOT}" 2337 JAVA_PKG_NAME="${PN}-${SLOT%/*}"
1475 fi 2338 fi
1476 2339
1477 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2340 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1478 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2341 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1479 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2342 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2343 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2344 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
1480 2345
1481 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2346 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
1482 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2347 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
1483 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2348 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
1484 2349
1497# Writes the package.env out to disk. 2362# Writes the package.env out to disk.
1498# 2363#
1499# ------------------------------------------------------------------------------ 2364# ------------------------------------------------------------------------------
1500# TODO change to do-write, to match everything else 2365# TODO change to do-write, to match everything else
1501java-pkg_do_write_() { 2366java-pkg_do_write_() {
2367 debug-print-function ${FUNCNAME} $*
2368 java-pkg_init_paths_
1502 # Create directory for package.env 2369 # Create directory for package.env
1503 dodir "${JAVA_PKG_SHAREPATH}" 2370 dodir "${JAVA_PKG_SHAREPATH}"
1504 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2371 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2372 "${JAVA_PKG_DEPEND_FILE}" || -f \
2373 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1505 # Create package.env 2374 # Create package.env
1506 ( 2375 (
1507 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2376 echo "DESCRIPTION=\"${DESCRIPTION}\""
1508 echo "GENERATION=\"2\"" 2377 echo "GENERATION=\"2\""
2378 echo "SLOT=\"${SLOT}\""
2379 echo "CATEGORY=\"${CATEGORY}\""
2380 echo "PVR=\"${PVR}\""
1509 2381
1510 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2382 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1511 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2383 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1512 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2384 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1513 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2385 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2386 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2387 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2388 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
1514 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2389 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2390 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2391 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
1515 ) > "${JAVA_PKG_ENV}" 2392 ) > "${JAVA_PKG_ENV}"
1516 2393
1517 # register target/source 2394 # register target/source
1518 local target="$(java-pkg_get-target)" 2395 local target="$(java-pkg_get-target)"
1519 local source="$(java-pkg_get-source)" 2396 local source="$(java-pkg_get-source)"
1520 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 2397 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1521 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 2398 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1529 2406
1530 2407
1531 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2408 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1532 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2409 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1533 2410
2411 # extra env variables
2412 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2413 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2414 # nested echo to remove leading/trailing spaces
2415 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2416 >> "${JAVA_PKG_ENV}" || die
2417 fi
2418
1534 # Strip unnecessary leading and trailing colons 2419 # Strip unnecessary leading and trailing colons
1535 # TODO try to cleanup if possible 2420 # TODO try to cleanup if possible
1536 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2421 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2422 else
2423 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2424 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2425 debug-print "write package.env."
1537 fi 2426 fi
1538} 2427}
1539
1540 2428
1541# ------------------------------------------------------------------------------ 2429# ------------------------------------------------------------------------------
1542# @internal-function java-pkg_record-jar_ 2430# @internal-function java-pkg_record-jar_
1543# 2431#
1544# Record a dependency to the package.env 2432# Record an (optional) dependency to the package.env
1545# 2433# @param --optional - record dependency as optional
2434# @param --build - record dependency as build_only
2435# @param $1 - package to record
2436# @param $2 - (optional) jar of package to record
1546# ------------------------------------------------------------------------------ 2437# ------------------------------------------------------------------------------
1547JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2438JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2439JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2440JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
1548 2441
1549java-pkg_record-jar_() { 2442java-pkg_record-jar_() {
1550 debug-print-function ${FUNCNAME} $* 2443 debug-print-function ${FUNCNAME} $*
2444
2445 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2446 case "${1}" in
2447 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2448 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2449 esac
1551 2450
1552 local pkg=${1} jar=${2} append 2451 local pkg=${1} jar=${2} append
1553 if [[ -z "${jar}" ]]; then 2452 if [[ -z "${jar}" ]]; then
1554 append="${pkg}" 2453 append="${pkg}"
1555 else 2454 else
1556 append="$(basename ${jar})@${pkg}" 2455 append="$(basename ${jar})@${pkg}"
1557 fi 2456 fi
1558 2457
1559 echo ${append} >> ${JAVA_PKG_DEPEND} 2458 echo "${append}" >> "${depend_file}"
1560} 2459}
1561 2460
1562# ------------------------------------------------------------------------------ 2461# ------------------------------------------------------------------------------
1563# @internal-function java-pkg_append_ 2462# @internal-function java-pkg_append_
1564# 2463#
1588 fi 2487 fi
1589} 2488}
1590 2489
1591# ------------------------------------------------------------------------------ 2490# ------------------------------------------------------------------------------
1592# @internal-function java-pkg_expand_dir_ 2491# @internal-function java-pkg_expand_dir_
1593# 2492#
1594# Gets the full path of the file/directory's parent. 2493# Gets the full path of the file/directory's parent.
1595# @param $1 - file/directory to find parent directory for 2494# @param $1 - file/directory to find parent directory for
1596# @return - path to $1's parent directory 2495# @return - path to $1's parent directory
1597# ------------------------------------------------------------------------------ 2496# ------------------------------------------------------------------------------
1598java-pkg_expand_dir_() { 2497java-pkg_expand_dir_() {
1608# 2507#
1609# @return 0 - function is declared 2508# @return 0 - function is declared
1610# @return 1 - function is undeclared 2509# @return 1 - function is undeclared
1611# ------------------------------------------------------------------------------ 2510# ------------------------------------------------------------------------------
1612java-pkg_func-exists() { 2511java-pkg_func-exists() {
1613 if [[ -n "$(declare -f ${1})" ]]; then 2512 declare -F ${1} > /dev/null
1614 return 0
1615 else
1616 return 1
1617 fi
1618} 2513}
1619 2514
1620# ------------------------------------------------------------------------------ 2515# ------------------------------------------------------------------------------
1621# @internal-function java-pkg_setup-vm 2516# @internal-function java-pkg_setup-vm
1622# 2517#
1625# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
1626java-pkg_setup-vm() { 2521java-pkg_setup-vm() {
1627 debug-print-function ${FUNCNAME} $* 2522 debug-print-function ${FUNCNAME} $*
1628 2523
1629 local vendor="$(java-pkg_get-vm-vendor)" 2524 local vendor="$(java-pkg_get-vm-vendor)"
1630 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2525 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1631 addpredict "/dev/random" 2526 addpredict "/dev/random"
1632 elif [[ "${vendor}" == "ibm" ]]; then 2527 elif [[ "${vendor}" == "ibm" ]]; then
1633 addpredict "/proc/self/maps" 2528 addpredict "/proc/self/maps"
1634 addpredict "/proc/cpuinfo" 2529 addpredict "/proc/cpuinfo"
1635 export LANG="C" LC_ALL="C" 2530 addpredict "/proc/self/coredump_filter"
2531 elif [[ "${vendor}" == "oracle" ]]; then
2532 addpredict "/dev/random"
2533 addpredict "/proc/self/coredump_filter"
2534 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2535 addpredict "/dev/random"
2536 addpredict "/proc/self/coredump_filter"
1636 elif [[ "${vendor}" == "jrockit" ]]; then 2537 elif [[ "${vendor}" == "jrockit" ]]; then
1637 addpredict "/proc/cpuinfo" 2538 addpredict "/proc/cpuinfo"
1638 fi 2539 fi
1639} 2540}
1640 2541
1641# ------------------------------------------------------------------------------ 2542# ------------------------------------------------------------------------------
1642# @internal-function java-pkg_needs-vm 2543# @internal-function java-pkg_needs-vm
1643# 2544#
1644# Does the current package depend on virtual/jdk? 2545# Does the current package depend on virtual/jdk or does it set
2546# JAVA_PKG_WANT_BUILD_VM?
1645# 2547#
1646# @return 0 - Package depends on virtual/jdk 2548# @return 0 - Package depends on virtual/jdk
1647# @return 1 - Package does not depend on virtual/jdk 2549# @return 1 - Package does not depend on virtual/jdk
1648# ------------------------------------------------------------------------------ 2550# ------------------------------------------------------------------------------
1649java-pkg_needs-vm() { 2551java-pkg_needs-vm() {
1650 debug-print-function ${FUNCNAME} $* 2552 debug-print-function ${FUNCNAME} $*
1651 2553
1652 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2554 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
1653 return 0 2555 return 0
1654 fi 2556 fi
2557
2558 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
1655 2559
1656 return 1 2560 return 1
1657} 2561}
1658 2562
1659# ------------------------------------------------------------------------------ 2563# ------------------------------------------------------------------------------
1684# @return - The version of the current VM 2588# @return - The version of the current VM
1685# ------------------------------------------------------------------------------ 2589# ------------------------------------------------------------------------------
1686java-pkg_get-vm-version() { 2590java-pkg_get-vm-version() {
1687 debug-print-function ${FUNCNAME} $* 2591 debug-print-function ${FUNCNAME} $*
1688 2592
1689 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 2593 java-config -g PROVIDES_VERSION
2594}
2595
2596# ------------------------------------------------------------------------------
2597# @internal-function java-pkg_build-vm-from-handle
2598#
2599# Selects a build vm from a list of vm handles. First checks for the system-vm
2600# beeing usable, then steps through the listed handles till a suitable vm is
2601# found.
2602#
2603# @return - VM handle of an available JDK
2604# ------------------------------------------------------------------------------
2605java-pkg_build-vm-from-handle() {
2606 debug-print-function ${FUNCNAME} "$*"
2607
2608 local vm
2609 vm=$(java-pkg_get-current-vm 2>/dev/null)
2610 if [[ $? -eq 0 ]]; then
2611 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2612 echo ${vm}
2613 return 0
2614 fi
2615 fi
2616
2617 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2618 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2619 echo ${vm}
2620 return 0
2621 fi
2622 done
2623
2624 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2625 return 1
1690} 2626}
1691 2627
1692# ------------------------------------------------------------------------------ 2628# ------------------------------------------------------------------------------
1693# @internal-function java-pkg_switch-vm 2629# @internal-function java-pkg_switch-vm
1694# 2630#
1695# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2631# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1696# verify that the current VM is sufficient. 2632# verify that the current VM is sufficient.
1697# Setup the environment for the VM being used. 2633# Setup the environment for the VM being used.
1698# ------------------------------------------------------------------------------ 2634# ------------------------------------------------------------------------------
1699java-pkg_switch-vm() { 2635java-pkg_switch-vm() {
2636 debug-print-function ${FUNCNAME} $*
2637
1700 if java-pkg_needs-vm; then 2638 if java-pkg_needs-vm; then
1701 # Use the VM specified by JAVA_PKG_FORCE_VM 2639 # Use the VM specified by JAVA_PKG_FORCE_VM
1702 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2640 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1703 # If you're forcing the VM, I hope you know what your doing... 2641 # If you're forcing the VM, I hope you know what your doing...
2642 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1704 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2643 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1705 # if we're allowed to switch the vm... 2644 # if we're allowed to switch the vm...
1706 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2645 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1707 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2646 # if there is an explicit list of handles to choose from
1708 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2647 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
1709 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2648 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2649 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2650 if [[ $? != 0 ]]; then
2651 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2652 die "${FUNCNAME}: Failed to determine VM for building"
2653 fi
2654 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2655 # they can't be deduced from handles.
2656 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2657 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2658 die "Specify JAVA_PKG_WANT_SOURCE"
2659 fi
2660 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2661 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2662 die "Specify JAVA_PKG_WANT_TARGET"
2663 fi
2664 # otherwise determine a vm from dep string
1710 else 2665 else
2666 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1711 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2667 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2668 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2669 eerror "Unable to determine VM for building from dependencies:"
2670 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2671 die "Failed to determine VM for building."
2672 fi
1712 fi 2673 fi
2674 export GENTOO_VM
1713 # otherwise just make sure the current VM is sufficient 2675 # otherwise just make sure the current VM is sufficient
1714 else 2676 else
1715 java-pkg_ensure-vm-version-sufficient 2677 java-pkg_ensure-vm-version-sufficient
1716 fi 2678 fi
1717 debug-print "Using: $(java-config -f)" 2679 debug-print "Using: $(java-config -f)"
1718 2680
1719 java-pkg_setup-vm 2681 java-pkg_setup-vm
1720 2682
1721 export JAVA=$(java-config --java) 2683 export JAVA=$(java-config --java)
1722 export JAVAC=$(java-config --javac) 2684 export JAVAC=$(java-config --javac)
1723 export JAVACFLAGS="$(java-pkg_javac-args)" 2685 JAVACFLAGS="$(java-pkg_javac-args)"
2686 if [[ ${?} != 0 ]]; then
2687 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2688 die "java-pkg_javac-args failed"
2689 fi
1724 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2690 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2691 export JAVACFLAGS
1725 2692
1726 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2693 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1727 export JDK_HOME=${JAVA_HOME} 2694 export JDK_HOME=${JAVA_HOME}
1728 2695
1729 #TODO If you know a better solution let us know. 2696 #TODO If you know a better solution let us know.
1730 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2697 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1731 2698
1732 local tann="${T}/announced-vm" 2699 local tann="${T}/announced-vm"
2700 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2701 # if people have for example modified eclasses some where
1733 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2702 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1734 # Add a check for setup/preinst phase... to avoid duplicate outputs
1735 # for when FEATURES=buildpkg
1736 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1737 then
1738 einfo "Using: $(java-config -f)" 2703 einfo "Using: $(java-config -f)"
1739 [[ ! -f "${tann}" ]] && touch "${tann}" 2704 [[ ! -f "${tann}" ]] && touch "${tann}"
1740 fi
1741 fi 2705 fi
1742 2706
1743 else 2707 else
1744 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2708 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
1745 fi 2709 fi
1750# 2714#
1751# Enhanced die for Java packages, which displays some information that may be 2715# Enhanced die for Java packages, which displays some information that may be
1752# useful for debugging bugs on bugzilla. 2716# useful for debugging bugs on bugzilla.
1753# ------------------------------------------------------------------------------ 2717# ------------------------------------------------------------------------------
1754#register_die_hook java-pkg_die 2718#register_die_hook java-pkg_die
1755if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2719if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
1756 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2720 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
1757fi 2721fi
1758 2722
1759java-pkg_die() { 2723java-pkg_die() {
1760 echo "!!! When you file a bug report, please include the following information:" >&2 2724 echo "!!! When you file a bug report, please include the following information:" >&2
1761 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 2725 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1762 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 2726 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1763 echo "and of course, the output of emerge --info" >&2 2727 echo "and of course, the output of emerge --info =${P}" >&2
1764} 2728}
1765 2729
1766 2730
1767# TODO document 2731# TODO document
1768# List jars in the source directory, ${S} 2732# List jars in the source directory, ${S}
1775 einfo "Classes" 2739 einfo "Classes"
1776 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2740 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1777 fi 2741 fi
1778} 2742}
1779 2743
1780# TODO document 2744# ------------------------------------------------------------------------------
2745# @internal-function java-pkg_verify-classes
2746#
1781# Verify that the classes were compiled for the right source / target 2747# Verify that the classes were compiled for the right source / target. Dies if
2748# not.
2749# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2750# ------------------------------------------------------------------------------
1782java-pkg_verify-classes() { 2751java-pkg_verify-classes() {
1783 ebegin "Verifying java class versions"
1784 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2752 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1785 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2753
2754 local version_verify="/usr/bin/class-version-verify.py"
2755
2756 if [[ ! -x "${version_verify}" ]]; then
2757 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2758 fi
2759
2760 if [[ ! -x "${version_verify}" ]]; then
2761 ewarn "Unable to perform class version checks as"
2762 ewarn "class-version-verify.py is unavailable"
2763 ewarn "Please install dev-java/javatoolkit."
2764 return
2765 fi
2766
2767 local target=$(java-pkg_get-target)
2768 local result
2769 local log="${T}/class-version-verify.log"
2770 if [[ -n "${1}" ]]; then
2771 ${version_verify} -v -t ${target} "${1}" > "${log}"
1786 result=$? 2772 result=$?
1787 eend ${result}
1788 if [[ ${result} == 0 ]]; then
1789 einfo "All good"
1790 else 2773 else
1791 ewarn "Possible problem" 2774 ebegin "Verifying java class versions (target: ${target})"
1792 die "Bad class files found" 2775 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2776 result=$?
2777 eend ${result}
2778 fi
2779 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2780 if [[ ${result} != 0 ]]; then
2781 eerror "Incorrect bytecode version found"
2782 [[ -n "${1}" ]] && eerror "in file: ${1}"
2783 eerror "See ${log} for more details."
2784 die "Incorrect bytecode found"
2785 fi
2786}
2787
2788# ----------------------------------------------------------------------------
2789# @internal-function java-pkg_ensure-dep
2790# Check that a package being used in jarfrom, getjars and getjar is contained
2791# within DEPEND or RDEPEND.
2792# @param $1 - empty - check both vars; "runtime" or "build" - check only
2793# RDEPEND, resp. DEPEND
2794# @param $2 - Package name and slot.
2795
2796java-pkg_ensure-dep() {
2797 debug-print-function ${FUNCNAME} $*
2798
2799 local limit_to="${1}"
2800 local target_pkg="${2}"
2801 local dev_error=""
2802
2803 # remove the version specification, which may include globbing (* and [123])
2804 local stripped_pkg=$(echo "${target_pkg}" | sed \
2805 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2806
2807 debug-print "Matching against: ${stripped_pkg}"
2808
2809 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2810 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2811 dev_error="${dev_error} declared in DEPEND."
2812 if is-java-strict; then
2813 eerror "${dev_error}"
2814 die "${dev_error}"
2815 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2816 eerror "${dev_error}"
2817 elog "Because you have this package installed the package will"
2818 elog "build without problems, but please report this to"
2819 elog "http://bugs.gentoo.org"
1793 fi 2820 fi
1794} 2821 fi
1795 2822
2823 if [[ ${limit_to} != build ]]; then
2824 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2825 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2826 dev_error="The ebuild is attempting to use ${target_pkg},"
2827 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2828 dev_error="${dev_error} or PDEPEND."
2829 if is-java-strict; then
2830 eerror "${dev_error}"
2831 die "${dev_error}"
2832 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2833 eerror "${dev_error}"
2834 elog "The package will build without problems, but may fail to run"
2835 elog "if you don't have ${target_pkg} installed, so please report"
2836 elog "this to http://bugs.gentoo.org"
2837 fi
2838 fi
2839 fi
2840 fi
2841}
1796 2842
1797# ------------------------------------------------------------------------------ 2843# ------------------------------------------------------------------------------
1798# @section-end internal 2844# @section-end internal
1799# ------------------------------------------------------------------------------ 2845# ------------------------------------------------------------------------------
1800 2846
1801java-pkg_check-phase() { 2847java-pkg_check-phase() {
1802 local phase=${1} 2848 local phase=${1}
1803 local funcname=${2} 2849 local funcname=${FUNCNAME[1]}
1804 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2850 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
1805 java-pkg_announce-qa-violation \
1806 "${funcname} used outside of src_${phase}" 2851 local msg="${funcname} used outside of src_${phase}"
2852 java-pkg_announce-qa-violation "${msg}"
1807 fi 2853 fi
1808} 2854}
1809 2855
1810java-pkg_check-versioned-jar() { 2856java-pkg_check-versioned-jar() {
1811 local jar=${1} 2857 local jar=${1}
1814 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2860 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
1815 fi 2861 fi
1816} 2862}
1817 2863
1818java-pkg_check-jikes() { 2864java-pkg_check-jikes() {
1819 if hasq jikes ${IUSE}; then 2865 if has jikes ${IUSE}; then
1820 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2866 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1821 fi 2867 fi
1822} 2868}
1823 2869
1824java-pkg_announce-qa-violation() { 2870java-pkg_announce-qa-violation() {
1825 if is-java-strict; then 2871 local nodie
2872 if [[ ${1} == "--nodie" ]]; then
2873 nodie="true"
2874 shift
2875 fi
1826 echo "Java QA Notice: $@" >&2 2876 echo "Java QA Notice: $@" >&2
1827 increment-qa-violations 2877 increment-qa-violations
1828 fi 2878 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
1829} 2879}
1830 2880
1831increment-qa-violations() { 2881increment-qa-violations() {
1832 let "JAVA_PKG_QA_VIOLATIONS+=1" 2882 let "JAVA_PKG_QA_VIOLATIONS+=1"
1833 export JAVA_PKG_QA_VIOLATIONS 2883 export JAVA_PKG_QA_VIOLATIONS
1834} 2884}
1835 2885
1836is-java-strict() { 2886is-java-strict() {
1837 hasq java-strict ${FEATURES}; 2887 [[ -n ${JAVA_PKG_STRICT} ]]
1838 return $? 2888 return $?
1839} 2889}
1840 2890
2891
1841# ------------------------------------------------------------------------------ 2892# ------------------------------------------------------------------------------
1842# @eclass-end 2893# @eclass-end
1843# ------------------------------------------------------------------------------ 2894# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20