/[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.103
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-2005, 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.103 2008/01/12 15:08:47 caster 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.
65# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_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.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
49 77
50# ----------------------------------------------------------------------------- 78# -----------------------------------------------------------------------------
51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
52# @variable-default yes 80# @variable-default yes
53# 81#
100# ----------------------------------------------------------------------------- 128# -----------------------------------------------------------------------------
101 129
102# ----------------------------------------------------------------------------- 130# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 131# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 132# @default /usr/share/java-config-2/compiler
105# 133#
106# Directory where compiler settings are saved, without trailing slash. 134# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 135# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 136# -----------------------------------------------------------------------------
109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 137JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
110 138
120 148
121# ----------------------------------------------------------------------------- 149# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 150# @variable-external JAVA_PKG_FORCE_COMPILER
123# 151#
124# Explicitly set a list of compilers to use. This is normally read from 152# Explicitly set a list of compilers to use. This is normally read from
125# JAVA_PKG_COMPILERS_CONF. 153# JAVA_PKG_COMPILERS_CONF.
126# 154#
127# @note This should only be used internally or for testing. 155# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 156# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 157# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 158# -----------------------------------------------------------------------------
131 159
160# -----------------------------------------------------------------------------
161# @variable-external JAVA_PKG_FORCE_ANT_TASKS
162#
163# An $IFS separated list of ant tasks. Can be set in environment before calling
164# emerge/ebuild to override variables set in ebuild, mainly for testing before
165# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
166# eant() call, not the dependencies specified in WANT_ANT_TASKS.
167#
168# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
169# ebuild foo.ebuild compile
170#
171# @seealso WANT_ANT_TASKS
172# -----------------------------------------------------------------------------
173
132# TODO document me 174# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 175JAVA_PKG_QA_VIOLATIONS=0
134 176
135# ----------------------------------------------------------------------------- 177# -----------------------------------------------------------------------------
136# @section-end variables 178# @section-end variables
143# 185#
144# These are used to install Java-related things, such as jars, Javadocs, JNI 186# These are used to install Java-related things, such as jars, Javadocs, JNI
145# libraries, etc. 187# libraries, etc.
146# ----------------------------------------------------------------------------- 188# -----------------------------------------------------------------------------
147 189
190# -----------------------------------------------------------------------------
191# @ebuild-function java-pkg_doexamples
192#
193# Installs given arguments to /usr/share/doc/${PF}/examples
194# If you give it only one parameter and it is a directory it will install
195# everything in that directory to the examples directory.
196#
197# @example
198# java-pkg_doexamples demo
199# java-pkg_doexamples demo/* examples/*
200#
201# @param --subdir - If the examples need a certain directory structure
202# @param $* - list of files to install
203# ------------------------------------------------------------------------------
204java-pkg_doexamples() {
205 debug-print-function ${FUNCNAME} $*
206
207 [[ ${#} -lt 1 ]] && die "At least one argument needed"
208
209 java-pkg_check-phase install
210
211 local dest=/usr/share/doc/${PF}/examples
212 if [[ ${1} == --subdir ]]; then
213 local dest=${dest}/${2}
214 dodir ${dest}
215 shift 2
216 fi
217
218 if [[ ${#} = 1 && -d ${1} ]]; then
219 ( # dont want to pollute calling env
220 insinto "${dest}"
221 doins -r ${1}/*
222 ) || die "Installing examples failed"
223 else
224 ( # dont want to pollute calling env
225 insinto "${dest}"
226 doins -r "$@"
227 ) || die "Installing examples failed"
228 fi
229}
148 230
149# ----------------------------------------------------------------------------- 231# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 232# @ebuild-function java-pkg_dojar
151# 233#
152# Installs any number of jars. 234# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 235# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 236# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 237# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 238# Instead, use java-pkg_newjar defined below.
157# 239#
158# @example 240# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 241# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 242#
171 # Create JARDEST if it doesn't exist 253 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 254 dodir ${JAVA_PKG_JARDEST}
173 255
174 local jar 256 local jar
175 # for each jar 257 # for each jar
176 for jar in "$@"; do 258 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 259 local jar_basename=$(basename "${jar}")
178 260
179 java-pkg_check-versioned-jar ${jar_basename} 261 java-pkg_check-versioned-jar ${jar_basename}
180 262
181 # check if it exists 263 # check if it exists
182 if [[ -e "${jar}" ]] ; then 264 if [[ -e "${jar}" ]] ; then
265 # Don't overwrite if jar has already been installed with the same
266 # name
267 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
268 if [[ -e "${dest}" ]]; then
269 ewarn "Overwriting ${dest}"
270 fi
271
183 # install it into JARDEST if it's a non-symlink 272 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 273 if [[ ! -L "${jar}" ]] ; then
274 #but first check class version when in strict mode.
275 is-java-strict && java-pkg_verify-classes "${jar}"
276
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 277 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 278 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 279 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
188 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 280 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
189 # make a symlink to the original jar if it's symlink 281 # make a symlink to the original jar if it's symlink
200 292
201 java-pkg_do_write_ 293 java-pkg_do_write_
202} 294}
203 295
204 296
297# ------------------------------------------------------------------------------
298# @internal-function depend-java-query
299#
300# Wrapper for the depend-java-query binary to enable passing USE in env.
301# Using env variables keeps this eclass working with java-config versions that
302# do not handle use flags.
303# ------------------------------------------------------------------------------
304
305depend-java-query() {
306 # Used to have a which call here but it caused endless loops for some people
307 # that had some weird bashrc voodoo for which.
308 USE="${USE}" /usr/bin/depend-java-query "${@}"
309}
205 310
206# ------------------------------------------------------------------------------ 311# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 312# @ebuild-function java-pkg_regjar
208# 313#
209# Records an already installed jar in the package.env 314# Records an already installed jar in the package.env
222# will not work, because: 327# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 328# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 329# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 330# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 331# doesn't exist
227# 332#
228# you have to use it as: 333# you have to use it as:
229# 334#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 335# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 336#
232# @param $@ - jars to record 337# @param $@ - jars to record
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 345 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 346
242 java-pkg_init_paths_ 347 java-pkg_init_paths_
243 348
244 local jar jar_dir jar_file 349 local jar jar_dir jar_file
245 for jar in "$@"; do 350 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 351 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 352 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
353 [[ -d "${jar}" || -d "${D}${jar}" ]] \
354 && die "Called ${FUNCNAME} on a directory $*"
355
356 #check that class version correct when in strict mode
357 is-java-strict && java-pkg_verify-classes "${jar}"
358
248 # nelchael: we should strip ${D} in this case too, here's why: 359 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 360 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 361 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 362 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 363 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 364 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 365 else
366 if [[ ${jar} = *\** ]]; then
367 eerror "The argument ${jar} to ${FUNCNAME}"
368 eerror "has * in it. If you want it to glob in"
369 eerror '${D} add ${D} to the argument.'
370 fi
257 die "${jar} does not exist" 371 die "${jar} does not exist"
258 fi 372 fi
259 done 373 done
260 374
261 java-pkg_do_write_ 375 java-pkg_do_write_
262} 376}
263
264 377
265# ------------------------------------------------------------------------------ 378# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 379# @ebuild-function java-pkg_newjar
267# 380#
268# Installs a jar with a new name 381# Installs a jar with a new name
279 local original_jar="${1}" 392 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 393 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 394 local new_jar_dest="${T}/${new_jar}"
282 395
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 396 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 397 [[ ! -f ${original_jar} ]] \
398 && die "${original_jar} does not exist or is not a file!"
285 399
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 400 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 401 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 402 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 403 java-pkg_dojar "${new_jar_dest}"
290} 404}
291 405
292
293# ------------------------------------------------------------------------------ 406# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 407# @ebuild-function java-pkg_addcp
295# 408#
296# Add something to the package's classpath. For jars, you should use dojar, 409# 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. 410# newjar, or regjar. This is typically used to add directories to the classpath.
302java-pkg_addcp() { 415java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 416 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 417 java-pkg_do_write_
305} 418}
306 419
307
308# ------------------------------------------------------------------------------ 420# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 421# @ebuild-function java-pkg_doso
310# 422#
311# Installs any number of JNI libraries 423# Installs any number of JNI libraries
312# They will be installed into /usr/lib by default, but java-pkg_sointo 424# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 425# can be used change this path
314# 426#
315# Example: 427# Example:
340 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 452 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
341 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 453 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
342 # otherwise make a symlink to the symlink's origin 454 # otherwise make a symlink to the symlink's origin
343 else 455 else
344 # TODO use dosym 456 # TODO use dosym
457 ln -s "$(readlink "${lib}")" \
345 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 458 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
346 debug-print "${lib} is a symlink, linking accordanly" 459 debug-print "${lib} is a symlink, linking accordanly"
347 fi 460 fi
348 # otherwise die 461 # otherwise die
349 else 462 else
350 die "${lib} does not exist" 463 die "${lib} does not exist"
370 java-pkg_check-phase install 483 java-pkg_check-phase install
371 484
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 485 [[ ${#} -lt 1 ]] && "at least one argument needed"
373 486
374 java-pkg_init_paths_ 487 java-pkg_init_paths_
375 488
376 local lib target_dir 489 local lib target_dir
377 for lib in "$@" ; do 490 for lib in "$@" ; do
378 # Check the absolute path of the lib 491 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 492 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 493 target_dir="$(java-pkg_expand_dir_ ${lib})"
428# ------------------------------------------------------------------------------ 541# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 542java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 543 debug-print-function ${FUNCNAME} $*
431 544
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 545 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 546
547 # from /usr/lib/portage/bin/dohtml -h
548 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 549 dohtml -f package-list "$@"
550
435 # this probably shouldn't be here but it provides 551 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 552 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 553 # old ebuilds.
438 java-pkg_recordjavadoc 554 java-pkg_recordjavadoc
439} 555}
440 556
441# TODO document 557# ------------------------------------------------------------------------------
558# @ebuild-function java-pkg_dojavadoc
559#
560# Installs javadoc documentation. This should be controlled by the doc use flag.
561#
562# @param $1: optional --symlink creates to symlink like this for html
563# documentation bundles.
564# @param $2: - The javadoc root directory.
565#
566# @example:
567# java-pkg_dojavadoc docs/api
568# java-pkg_dojavadoc --symlink apidocs docs/api
569#
570# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 571java-pkg_dojavadoc() {
572 debug-print-function ${FUNCNAME} $*
573
574 # For html documentation bundles that link to Javadoc
575 local symlink
576 if [[ ${1} = --symlink ]]; then
577 symlink=${2}
578 shift 2
579 fi
580
443 local dir="$1" 581 local dir="$1"
582 local dest=/usr/share/doc/${PF}/html
583
584 # QA checks
444 585
445 java-pkg_check-phase install 586 java-pkg_check-phase install
446 587
447 [[ -z "${dir}" ]] && die "Must specify a directory!" 588 [[ -z "${dir}" ]] && die "Must specify a directory!"
448 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 589 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
590 if [[ ! -e "${dir}/index.html" ]]; then
591 local msg="No index.html in javadoc directory"
592 ewarn "${msg}"
593 is-java-strict && die "${msg}"
594 fi
595
596 if [[ -e ${D}/${dest}/api ]]; then
597 eerror "${dest} already exists. Will not overwrite."
598 die "${dest}"
599 fi
600
601 # Renaming to match our directory layout
449 602
450 local dir_to_install="${dir}" 603 local dir_to_install="${dir}"
451 if [[ "$(basename "${dir}")" != "api" ]]; then 604 if [[ "$(basename "${dir}")" != "api" ]]; then
452 dir_to_install="${T}/api" 605 dir_to_install="${T}/api"
453 # TODO use doins 606 # TODO use doins
454 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 607 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
455 fi 608 fi
456 609
610 # Actual installation
611
457 java-pkg_dohtml -r ${dir_to_install} 612 java-pkg_dohtml -r "${dir_to_install}"
613
614 # Let's make a symlink to the directory we have everything else under
615 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
616
617 if [[ ${symlink} ]]; then
618 dosym ${dest}/{api,${symlink}} || die
619 fi
458} 620}
459 621
460# ------------------------------------------------------------------------------ 622# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 623# @ebuild-function java-pkg_dosrc
462# 624#
463# Installs a zip containing the source for a package, so it can used in 625# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 626# from IDEs like eclipse and netbeans.
465# 627#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 628# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 629#
468# It also should be controlled by USE=source. 630# It also should be controlled by USE=source.
469# 631#
470# @example: 632# @example:
471# java-pkg_dosrc src/* 633# java-pkg_dosrc src/*
472# 634#
473# ------------------------------------------------------------------------------ 635# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 636# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 637# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 638# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 639# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 640# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 641java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 642 debug-print-function ${FUNCNAME} $*
481 643
482 [ ${#} -lt 1 ] && die "At least one argument needed" 644 [ ${#} -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 645
487 java-pkg_check-phase install 646 java-pkg_check-phase install
488 647
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 648 [[ ${#} -lt 1 ]] && die "At least one argument needed"
649
650 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
651 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
652 if is-java-strict; then
653 eerror "${msg}"
654 die "${msg}"
655 else
656 echo "${msg}"
657 echo "Please report this to http://bugs.gentoo.org."
658 fi
659 fi
490 660
491 java-pkg_init_paths_ 661 java-pkg_init_paths_
492 662
493 local zip_name="${PN}-src.zip" 663 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 664 local zip_path="${T}/${zip_name}"
495 local dir 665 local dir
496 for dir in ${@}; do 666 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 667 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 668 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 669 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 670 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 671 local result=$?
518# @ebuild-function java-pkg_dolauncher 688# @ebuild-function java-pkg_dolauncher
519# 689#
520# Make a wrapper script to lauch/start this package 690# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 691# If necessary, the wrapper will switch to the appropriate VM.
522# 692#
693# Can be called without parameters if the package installs only one jar
694# that has the Main-class attribute set. The wrapper will be named ${PN}.
695#
523# @param $1 - filename of launcher to create 696# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 697# @param $2 - options, as follows:
525# --main the.main.class.too.start 698# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 699# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass too jave' 700# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 701# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 702# --pwd Directory the launcher changes to before executing java
530# -into 703# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 704# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 705# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 706java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 707 debug-print-function ${FUNCNAME} $*
535 708
536 java-pkg_check-phase install 709 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 710 java-pkg_init_paths_
541 711
712 if [[ ${#} = 0 ]]; then
713 local name="${PN}"
714 else
542 local name="${1}" 715 local name="${1}"
716 shift
717 fi
718
543 # TODO rename to launcher 719 # TODO rename to launcher
544 local target="${T}/${name}" 720 local target="${T}/${name}"
721 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 722 local target_dir pre
546 shift
547 723
548 echo "#!/bin/bash" > "${target}" 724 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 725 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 726 local var="${1}" value="${2}"
551 if [[ "${var:0:2}" == "--" ]]; then 727 if [[ "${var:0:2}" == "--" ]]; then
728 local var=${var:2}
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 729 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
730 local gjl_${var}="${value}"
553 elif [[ "${var}" == "-into" ]]; then 731 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 732 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 733 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 734 pre="${value}"
557 fi 735 fi
558 shift 2 736 shift 2
559 done 737 done
738
739 # Test if no --jar and --main arguments were given and
740 # in that case check if the package only installs one jar
741 # and use that jar.
742 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
743 local cp="${JAVA_PKG_CLASSPATH}"
744 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
745 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
746 else
747 local msg="Not enough information to create a launcher given."
748 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
749 die "${msg}"
750 fi
751 fi
752
753 # Write the actual script
754 echo "#!/bin/bash" > "${target}"
755 if [[ -n "${pre}" ]]; then
756 if [[ -f "${pre}" ]]; then
757 cat "${pre}" >> "${target}"
758 else
759 die "-pre specified file '${pre}' does not exist"
760 fi
761 fi
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 762 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 763 cat "${var_tmp}" >> "${target}"
764 rm -f "${var_tmp}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 765 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 766
564 if [[ -n "${into}" ]]; then 767 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 768 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 769 local ret=$?
567 return ${ret} 770 return ${ret}
568 else 771 else
569 dobin "${target}" 772 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 800 echo "dowar: warning, skipping directory ${war}"
598 continue 801 continue
599 else 802 else
600 warpath="${war}" 803 warpath="${war}"
601 fi 804 fi
602 805
603 # Install those files like you mean it 806 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 807 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 808 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 809 doins ${warpath}
607 done 810 done
642# @ebuild-function java-pkg_jar-from 845# @ebuild-function java-pkg_jar-from
643# 846#
644# Makes a symlink to a jar from a certain package 847# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 848# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 849# You can use this function to replace these bundled dependencies.
850# The dependency is recorded into package.env DEPEND line, unless "--build-only"
851# is passed as the very first argument, for jars that have to be present only
852# at build time and are not needed on runtime (junit testing etc).
647# 853#
648# Example: get all jars from xerces slot 2 854# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 855# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 856# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 857# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 858# 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 859# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
860# Example: get junit.jar which is needed only for building
861# java-pkg_jar-from --build-only junit junit.jar
654# 862#
655# @param $1 - Package to get jars from. 863# @param $opt
864# --build-only - makes the jar(s) not added into package.env DEPEND line.
865# (assumed automatically when called inside src_test)
866# --with-dependencies - get jars also from requested package's dependencies
867# transitively.
868# --virtual - Packages passed to this function are to be handled as virtuals
869# and will not have individual jar dependencies recorded.
870# --into $dir - symlink jar(s) into $dir (must exist) instead of .
871# @param $1 - Package to get jars from, or comma-separated list of packages in
872# case other parameters are not used.
656# @param $2 - jar from package. If not specified, all jars will be used. 873# @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 874# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 875# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 876# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 877# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 878java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 879 debug-print-function ${FUNCNAME} $*
663 880
881 local build_only=""
882 local destdir="."
883 local deep=""
884 local virtual=""
885
886 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
887
888 while [[ "${1}" == --* ]]; do
889 if [[ "${1}" = "--build-only" ]]; then
890 build_only="build"
891 elif [[ "${1}" = "--with-dependencies" ]]; then
892 deep="--with-dependencies"
893 elif [[ "${1}" = "--virtual" ]]; then
894 virtual="true"
895 elif [[ "${1}" = "--into" ]]; then
896 destdir="${2}"
897 shift
898 else
899 die "java-pkg_jar-from called with unknown parameter: ${1}"
900 fi
901 shift
902 done
903
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 904 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 905
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 906 [[ -z ${target_pkg} ]] && die "Must specify a package"
667 907
668 # default destjar to the target jar 908 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 909 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 910
911 local error_msg="There was a problem getting the classpath for ${target_pkg}."
912 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 913 classpath="$(java-config ${deep} --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 914 [[ $? != 0 ]] && die ${error_msg}
915
916 # When we have commas this functions is called to bring jars from multiple
917 # packages. This affects recording of dependencencies performed later
918 # which expects one package only, so we do it here.
919 if [[ ${target_pkg} = *,* ]]; then
920 for pkg in ${target_pkg//,/ }; do
921 java-pkg_ensure-dep "${build_only}" "${pkg}"
922 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
923 done
924 # setting this disables further record-jar_ calls later
925 build_only="build"
926 else
927 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
928 fi
929
930 # Record the entire virtual as a dependency so that
931 # no jars are missed.
932 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
933 java-pkg_record-jar_ "${target_pkg}"
934 # setting this disables further record-jars_ calls later
935 build_only="build"
936 fi
937
938 pushd ${destdir} > /dev/null \
939 || die "failed to change directory to ${destdir}"
673 940
674 local jar 941 local jar
675 for jar in ${classpath//:/ }; do 942 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 943 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 944 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 948 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 949 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 950 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 951 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 952 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 953 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 954 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 955 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 956 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 957 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 958 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 959 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
960 popd > /dev/null
693 return 0 961 return 0
694 fi 962 fi
695 done 963 done
964 popd > /dev/null
696 # if no target was specified, we're ok 965 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 966 if [[ -z "${target_jar}" ]] ; then
698 return 0 967 return 0
699 # otherwise, die bitterly 968 # otherwise, die bitterly
700 else 969 else
714# ------------------------------------------------------------------------------ 983# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 984# @ebuild-function java-pkg_getjars
716# 985#
717# Get the classpath provided by any number of packages 986# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 987# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
988# The providing packages are recorded as dependencies into package.env DEPEND
989# line, unless "--build-only" is passed as the very first argument, for jars
990# that have to be present only at build time and are not needed on runtime
991# (junit testing etc).
719# 992#
720# Example: Get the classpath for xerces-2, 993# Example: Get the classpath for xerces-2 and xalan,
721# java-pkg_getjars xerces-2 xalan 994# java-pkg_getjars xerces-2,xalan
722# Example Return: 995# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 996# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 997#
998# @param $opt
999# --build-only - makes the jar(s) not added into package.env DEPEND line.
1000# (assumed automatically when called inside src_test)
1001# --with-dependencies - get jars also from requested package's dependencies
1002# transitively.
725# @param $@ - list of packages to get jars from 1003# @param $1 - list of packages to get jars from
1004# (passed to java-config --classpath)
726# ------------------------------------------------------------------------------ 1005# ------------------------------------------------------------------------------
727java-pkg_getjars() { 1006java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 1007 debug-print-function ${FUNCNAME} $*
729 1008
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 1009 local build_only=""
1010 local deep=""
731 1011
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 1012 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
733 local classpath pkg 1013
734 for pkg in ${@//,/ }; do 1014 while [[ "${1}" == --* ]]; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do 1015 if [[ "${1}" = "--build-only" ]]; then
736 jars="$(java-config --classpath=${pkg})" 1016 build_only="build"
737 debug-print "${pkg}:${jars}" 1017 elif [[ "${1}" = "--with-dependencies" ]]; then
738 # TODO should we ensure jars exist? 1018 deep="--with-dependencies"
739 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}"
741 else 1019 else
742 classpath="${classpath}:${jars}" 1020 die "java-pkg_jar-from called with unknown parameter: ${1}"
743 fi 1021 fi
744 java-pkg_record-jar_ "${pkg}" 1022 shift
745 done 1023 done
1024
1025 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1026
1027
1028 local classpath pkgs="${1}"
1029 jars="$(java-config ${deep} --classpath=${pkgs})"
1030 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
1031 debug-print "${pkgs}:${jars}"
1032
1033 for pkg in ${pkgs//,/ }; do
1034 java-pkg_ensure-dep "${build_only}" "${pkg}"
1035 done
1036
1037 if [[ -z "${classpath}" ]]; then
1038 classpath="${jars}"
1039 else
1040 classpath="${classpath}:${jars}"
1041 fi
1042
1043 # Only record jars that aren't build-only
1044 if [[ -z "${build_only}" ]]; then
1045 for pkg in ${pkgs//,/ }; do
1046 java-pkg_record-jar_ "${pkg}"
1047 done
1048 fi
1049
746 echo "${classpath}" 1050 echo "${classpath}"
747} 1051}
748 1052
749# ------------------------------------------------------------------------------ 1053# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 1054# @ebuild-function java-pkg_getjar
751# 1055#
752# Get the filename of a single jar from a package 1056# Get the filename of a single jar from a package
1057# The providing package is recorded as runtime dependency into package.env
1058# DEPEND line, unless "--build-only" is passed as the very first argument, for
1059# jars that have to be present only at build time and are not needed on runtime
1060# (junit testing etc).
753# 1061#
754# @example 1062# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 1063# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 1064# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 1065# /usr/share/xerces-2/lib/xml-apis.jar
758# 1066#
1067# @param $opt
1068# --build-only - makes the jar not added into package.env DEPEND line.
1069# --virtual - Packages passed to this function are to be handled as virtuals
1070# and will not have individual jar dependencies recorded.
759# @param $1 - package to use 1071# @param $1 - package to use
760# @param $2 - jar to get 1072# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 1073# ------------------------------------------------------------------------------
762java-pkg_getjar() { 1074java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 1075 debug-print-function ${FUNCNAME} $*
1076
1077 local build_only=""
1078 local virtual=""
1079
1080 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1081
1082 while [[ "${1}" == --* ]]; do
1083 if [[ "${1}" = "--build-only" ]]; then
1084 build_only="build"
1085 elif [[ "${1}" == "--virtual" ]]; then
1086 virtual="true"
1087 else
1088 die "java-pkg_getjar called with unknown parameter: ${1}"
1089 fi
1090 shift
1091 done
1092
1093 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
764 1094
765 local pkg="${1}" target_jar="${2}" jar 1095 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1096 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1097 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 1098
769 # TODO check that package is actually installed 1099 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1100 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 1101 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 1102 [[ $? != 0 ]] && die ${error_msg}
1103
1104 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105
1106 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then
1109 java-pkg_record-jar_ "${pkg}"
1110 build_only="true"
1111 fi
1112
772 for jar in ${classpath//:/ }; do 1113 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 1114 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 1116 fi
776 1117
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1118 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 1119 # Only record jars that aren't build-only
1120 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 1121 echo "${jar}"
780 return 0 1122 return 0
781 fi 1123 fi
782 done 1124 done
783 1125
784 die "Could not find ${target_jar} in ${pkg}" 1126 die "Could not find ${target_jar} in ${pkg}"
785 return 1 1127 return 1
1128}
1129
1130# ------------------------------------------------------------------------------
1131# @ebuild-function java-pkg_register-dependency
1132#
1133# Registers runtime dependency on a package, list of packages, or a single jar
1134# from a package, into package.env DEPEND line. Can only be called in
1135# src_install phase.
1136# Intended for binary packages where you don't need to symlink the jars or get
1137# their classpath during build. As such, the dependencies only need to be
1138# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1139#
1140# @param $1 - comma-separated list of packages, or a single package
1141# @param $2 - if param $1 is a single package, optionally specify the jar
1142# to depend on
1143#
1144# Example: Record the dependency on whole xerces-2 and xalan,
1145# java-pkg_register-dependency xerces-2,xalan
1146# Example: Record the dependency on ant.jar from ant-core
1147# java-pkg_register-dependency ant-core ant.jar
1148#
1149# Note: Passing both list of packages as the first parameter AND specifying the
1150# jar as the second is not allowed and will cause the function to die. We assume
1151# that there's more chance one passes such combination as a mistake, than that
1152# there are more packages providing identically named jar without class
1153# collisions.
1154# ------------------------------------------------------------------------------
1155java-pkg_register-dependency() {
1156 debug-print-function ${FUNCNAME} $*
1157
1158 java-pkg_check-phase install
1159
1160 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1161
1162 local pkgs="${1}"
1163 local jar="${2}"
1164
1165 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1166
1167 if [[ -z "${jar}" ]]; then
1168 for pkg in ${pkgs//,/ }; do
1169 java-pkg_ensure-dep runtime "${pkg}"
1170 java-pkg_record-jar_ "${pkg}"
1171 done
1172 else
1173 [[ ${pkgs} == *,* ]] && \
1174 die "${FUNCNAME} called with both package list and jar name"
1175 java-pkg_ensure-dep runtime "${pkgs}"
1176 java-pkg_record-jar_ "${pkgs}" "${jar}"
1177 fi
1178
1179 java-pkg_do_write_
1180}
1181
1182# ------------------------------------------------------------------------------
1183# @ebuild-function java-pkg_register-optional-dependency
1184#
1185# Registers optional runtime dependency on a package, list of packages, or a
1186# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1187# called in src_install phase.
1188# Intended for packages that can use other packages when those are in classpath.
1189# Will be put on classpath by launcher if they are installed. Typical case is
1190# JDBC implementations for various databases. It's better than having USE flag
1191# for each implementation triggering hard dependency.
1192#
1193# @param $1 - comma-separated list of packages, or a single package
1194# @param $2 - if param $1 is a single package, optionally specify the jar
1195# to depend on
1196#
1197# Example: Record the optional dependency on some jdbc providers
1198# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1199#
1200# Note: Passing both list of packages as the first parameter AND specifying the
1201# jar as the second is not allowed and will cause the function to die. We assume
1202# that there's more chance one passes such combination as a mistake, than that
1203# there are more packages providing identically named jar without class
1204# collisions.
1205# ------------------------------------------------------------------------------
1206java-pkg_register-optional-dependency() {
1207 debug-print-function ${FUNCNAME} $*
1208
1209 java-pkg_check-phase install
1210
1211 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1212
1213 local pkgs="${1}"
1214 local jar="${2}"
1215
1216 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1217
1218 if [[ -z "${jar}" ]]; then
1219 for pkg in ${pkgs//,/ }; do
1220 java-pkg_record-jar_ --optional "${pkg}"
1221 done
1222 else
1223 [[ ${pkgs} == *,* ]] && \
1224 die "${FUNCNAME} called with both package list and jar name"
1225 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1226 fi
1227
1228 java-pkg_do_write_
1229}
1230
1231# ------------------------------------------------------------------------------
1232# @ebuild-function java-pkg_register-environment-variable
1233#
1234# Register an arbitrary environment variable into package.env. The gjl launcher
1235# for this package or any package depending on this will export it into
1236# environement before executing java command.
1237# Must only be called in src_install phase.
1238#
1239# @param $1 - variable name
1240# @param $2 - variable value
1241# ------------------------------------------------------------------------------
1242JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1243JAVA_PKG_EXTRA_ENV_VARS=""
1244java-pkg_register-environment-variable() {
1245 debug-print-function ${FUNCNAME} $*
1246
1247 java-pkg_check-phase install
1248
1249 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1250
1251 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1252 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1253
1254 java-pkg_do_write_
786} 1255}
787 1256
788# This function reads stdin, and based on that input, figures out how to 1257# This function reads stdin, and based on that input, figures out how to
789# populate jars from the filesystem. 1258# populate jars from the filesystem.
790# Need to figure out a good way of making use of this, ie be able to use a 1259# Need to figure out a good way of making use of this, ie be able to use a
802# line="${line// /}" 1271# line="${line// /}"
803# 1272#
804# # format: path=jarinfo 1273# # format: path=jarinfo
805# local path=${line%%=*} 1274# local path=${line%%=*}
806# local jarinfo=${line##*=} 1275# local jarinfo=${line##*=}
807# 1276#
808# # format: jar@package 1277# # format: jar@package
809# local jar=${jarinfo%%@*}.jar 1278# local jar=${jarinfo%%@*}.jar
810# local package=${jarinfo##*@} 1279# local package=${jarinfo##*@}
811# if [[ -n ${replace_only} ]]; then 1280# if [[ -n ${replace_only} ]]; then
812# [[ ! -f $path ]] && die "No jar exists at ${path}" 1281# [[ ! -f $path ]] && die "No jar exists at ${path}"
825# @section-end query 1294# @section-end query
826# ------------------------------------------------------------------------------ 1295# ------------------------------------------------------------------------------
827 1296
828# ------------------------------------------------------------------------------ 1297# ------------------------------------------------------------------------------
829# @section-begin helper 1298# @section-begin helper
830# @section-summary Helper functions 1299# @section-summary Helper functions
831# 1300#
832# Various other functions to use from an ebuild 1301# Various other functions to use from an ebuild
833# ------------------------------------------------------------------------------ 1302# ------------------------------------------------------------------------------
834 1303
835# ------------------------------------------------------------------------------ 1304# ------------------------------------------------------------------------------
841# jdbc-stdext 1310# jdbc-stdext
842# jaf 1311# jaf
843# jdbc-rowset 1312# jdbc-rowset
844# jms 1313# jms
845# 1314#
846# @param $1 - Optionally indicate that the dependencies are controlled by 1315# @param $1 - Optionally indicate that the dependencies are controlled by
847# a use flag by specifying '--use' Requires $2. 1316# a use flag by specifying '--use' Requires $2.
848# @param $2 - USE flag which will enable the dependencies. 1317# @param $2 - USE flag which will enable the dependencies.
849# @param $@ - virtual packages to add depenedencies for 1318# @param $@ - virtual packages to add depenedencies for
850# ------------------------------------------------------------------------------ 1319# ------------------------------------------------------------------------------
851# TODO rewrite to parse a line based declaration file instead -- karltk 1320# TODO rewrite to parse a line based declaration file instead -- karltk
907# 1376#
908# export DEPEND="${DEPEND} ${depstr}" 1377# export DEPEND="${DEPEND} ${depstr}"
909# export RDEPEND="${RDEPEND} ${depstr}" 1378# export RDEPEND="${RDEPEND} ${depstr}"
910#} 1379#}
911 1380
1381# ------------------------------------------------------------------------------
1382# @ebuild-function java-pkg_find-normal-jars
1383#
1384# Find the files with suffix .jar file in the given directory or $WORKDIR
1385#
1386# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1387# ------------------------------------------------------------------------------
1388java-pkg_find-normal-jars() {
1389 local dir=$1
1390 [[ "${dir}" ]] || dir="${WORKDIR}"
1391 local found
1392 for jar in $(find "${dir}" -name "*.jar" -type f); do
1393 echo "${jar}"
1394 found="true"
1395 done
1396 [[ "${found}" ]]
1397 return $?
1398}
1399
1400# ------------------------------------------------------------------------------
1401# @ebuild-function java-pkg_ensure-no-bundled-jars
1402#
1403# 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 1404# This function should be called after WORKDIR has been populated with symlink
913# TODO document 1405# to system jar files or bundled jars removed.
1406# ------------------------------------------------------------------------------
914java-pkg_ensure-no-bundled-jars() { 1407java-pkg_ensure-no-bundled-jars() {
915 debug-print-function ${FUNCNAME} $* 1408 debug-print-function ${FUNCNAME} $*
916 pushd ${WORKDIR} >/dev/null 2>/dev/null
917 1409
918 local bundled_jars=$(find . -name "*.jar" -type f) 1410 local bundled_jars=$(java-pkg_find-normal-jars)
919 if [[ -n ${bundled_jars} ]]; then 1411 if [[ -n ${bundled_jars} ]]; then
920 echo "Bundled jars found:" 1412 echo "Bundled jars found:"
921 local jar 1413 local jar
922 for jar in ${bundled_jars}; do 1414 for jar in ${bundled_jars}; do
923 echo $(pwd)${jar/./} 1415 echo $(pwd)${jar/./}
924 done 1416 done
925 die "Bundled jars found!" 1417 die "Bundled jars found!"
926
927 fi 1418 fi
928 popd >/dev/null 2>/dev/null
929} 1419}
930 1420
931# ------------------------------------------------------------------------------ 1421# ------------------------------------------------------------------------------
932# @internal-function java-pkg_ensure-vm-version-sufficient 1422# @internal-function java-pkg_ensure-vm-version-sufficient
933# 1423#
945 fi 1435 fi
946} 1436}
947 1437
948# ------------------------------------------------------------------------------ 1438# ------------------------------------------------------------------------------
949# @internal-function java-pkg_is-vm-version-sufficient 1439# @internal-function java-pkg_is-vm-version-sufficient
950# 1440#
951# @return zero - VM is sufficient 1441# @return zero - VM is sufficient
952# @return non-zero - VM is not sufficient 1442# @return non-zero - VM is not sufficient
953# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
954java-pkg_is-vm-version-sufficient() { 1444java-pkg_is-vm-version-sufficient() {
955 debug-print-function ${FUNCNAME} $* 1445 debug-print-function ${FUNCNAME} $*
975 die "Active Java VM too old" 1465 die "Active Java VM too old"
976 fi 1466 fi
977} 1467}
978 1468
979# ------------------------------------------------------------------------------ 1469# ------------------------------------------------------------------------------
980# @internal-function java-pkg_is-vm-version-eq 1470# @internal-function java-pkg_is-vm-version-eq
981# 1471#
982# @param $@ - VM version to compare current VM to 1472# @param $@ - VM version to compare current VM to
983# @return zero - VM versions are equal 1473# @return zero - VM versions are equal
984# @return non-zero - VM version are not equal 1474# @return non-zero - VM version are not equal
985# ------------------------------------------------------------------------------ 1475# ------------------------------------------------------------------------------
986java-pkg_is-vm-version-eq() { 1476java-pkg_is-vm-version-eq() {
1016# 1506#
1017# @param $@ - VM version to compare current to 1507# @param $@ - VM version to compare current to
1018# ------------------------------------------------------------------------------ 1508# ------------------------------------------------------------------------------
1019java-pkg_ensure-vm-version-ge() { 1509java-pkg_ensure-vm-version-ge() {
1020 debug-print-function ${FUNCNAME} $* 1510 debug-print-function ${FUNCNAME} $*
1021 1511
1022 if ! java-pkg_is-vm-version-ge "$@" ; then 1512 if ! java-pkg_is-vm-version-ge "$@" ; then
1023 debug-print "vm is not suffient" 1513 debug-print "vm is not suffient"
1024 eerror "This package requires a Java VM version >= $@" 1514 eerror "This package requires a Java VM version >= $@"
1025 einfo "Please use java-config -S to set the correct one" 1515 einfo "Please use java-config -S to set the correct one"
1026 die "Active Java VM too old" 1516 die "Active Java VM too old"
1027 fi 1517 fi
1028} 1518}
1029 1519
1030# ------------------------------------------------------------------------------ 1520# ------------------------------------------------------------------------------
1031# @internal-function java-pkg_is-vm-version-ge 1521# @internal-function java-pkg_is-vm-version-ge
1032# 1522#
1033# @param $@ - VM version to compare current VM to 1523# @param $@ - VM version to compare current VM to
1034# @return zero - current VM version is greater than checked version 1524# @return zero - current VM version is greater than checked version
1035# @return non-zero - current VM version is not greater than checked version 1525# @return non-zero - current VM version is not greater than checked version
1036# ------------------------------------------------------------------------------ 1526# ------------------------------------------------------------------------------
1037java-pkg_is-vm-version-ge() { 1527java-pkg_is-vm-version-ge() {
1051 return 1 1541 return 1
1052 fi 1542 fi
1053 fi 1543 fi
1054} 1544}
1055 1545
1546java-pkg_set-current-vm() {
1547 export GENTOO_VM=${1}
1548}
1549
1550java-pkg_get-current-vm() {
1551 echo ${GENTOO_VM}
1552}
1553
1554java-pkg_current-vm-matches() {
1555 hasq $(java-pkg_get-current-vm) ${@}
1556 return $?
1557}
1558
1056# ------------------------------------------------------------------------------ 1559# ------------------------------------------------------------------------------
1057# @ebuild-function java-pkg_get-source 1560# @ebuild-function java-pkg_get-source
1058# 1561#
1059# Determines what source version should be used, for passing to -source. 1562# 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 1563# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1061# 1564#
1062# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1565# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1063# ------------------------------------------------------------------------------ 1566# ------------------------------------------------------------------------------
1068# ------------------------------------------------------------------------------ 1571# ------------------------------------------------------------------------------
1069# @ebuild-function java-pkg_get-target 1572# @ebuild-function java-pkg_get-target
1070# 1573#
1071# Determines what target version should be used, for passing to -target. 1574# 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 1575# If you don't care about lower versions, you can set _WANT_TARGET to the
1073# version of your JDK. 1576# 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# 1577#
1078# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1578# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1079# ------------------------------------------------------------------------------ 1579# ------------------------------------------------------------------------------
1080java-pkg_get-target() { 1580java-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}")} 1581 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1094} 1582}
1095 1583
1096java-pkg_get-javac() { 1584java-pkg_get-javac() {
1097 debug-print-function ${FUNCNAME} $* 1585 debug-print-function ${FUNCNAME} $*
1098 1586
1099 java-pkg_init-compiler_ 1587
1100 local compiler="${GENTOO_COMPILER}" 1588 local compiler="${GENTOO_COMPILER}"
1101 1589
1102 local compiler_executable 1590 local compiler_executable
1103 if [[ "${compiler}" = "javac" ]]; then 1591 if [[ "${compiler}" = "javac" ]]; then
1104 # nothing fancy needs to be done for javac 1592 # nothing fancy needs to be done for javac
1112 unset JAVAC 1600 unset JAVAC
1113 # try to get value of JAVAC 1601 # try to get value of JAVAC
1114 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1602 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1115 export JAVAC=${old_javac} 1603 export JAVAC=${old_javac}
1116 1604
1117 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1605 if [[ -z ${compiler_executable} ]]; then
1118 1606 echo "JAVAC is empty or undefined in ${compiler_env}"
1607 return 1
1608 fi
1609
1119 # check that it's executable 1610 # check that it's executable
1120 if [[ ! -x ${compiler_executable} ]]; then 1611 if [[ ! -x ${compiler_executable} ]]; then
1121 eerror "Could not find ${compiler_executable}!"
1122 die "${compiler_executable} doesn't exist, or isn't executable" 1612 echo "${compiler_executable} doesn't exist, or isn't executable"
1613 return 1
1123 fi 1614 fi
1124 else 1615 else
1125 eerror "Could not find environment file for ${compiler}" 1616 echo "Could not find environment file for ${compiler}"
1126 die "Could not find ${compiler_env}" 1617 return 1
1127 fi 1618 fi
1128 fi 1619 fi
1129 echo ${compiler_executable} 1620 echo ${compiler_executable}
1130} 1621}
1131 1622
1132# ------------------------------------------------------------------------------ 1623# ------------------------------------------------------------------------------
1133# @ebuild-function java-pkg_javac-args 1624# @ebuild-function java-pkg_javac-args
1134# 1625#
1135# If an ebuild uses javac directly, instead of using ejavac, it should call this 1626# If an ebuild uses javac directly, instead of using ejavac, it should call this
1136# to know what -source/-target to use. 1627# to know what -source/-target to use.
1137# 1628#
1138# @return string - arguments to pass to javac, complete with -target and -source 1629# @return string - arguments to pass to javac, complete with -target and -source
1141 debug-print-function ${FUNCNAME} $* 1632 debug-print-function ${FUNCNAME} $*
1142 1633
1143 local want_source="$(java-pkg_get-source)" 1634 local want_source="$(java-pkg_get-source)"
1144 local want_target="$(java-pkg_get-target)" 1635 local want_target="$(java-pkg_get-target)"
1145 1636
1146 local source_str="-source ${want_source}" 1637 local source_str="-source ${want_source}"
1147 local target_str="-target ${want_target}" 1638 local target_str="-target ${want_target}"
1148 1639
1149 debug-print "want source: ${want_source}" 1640 debug-print "want source: ${want_source}"
1150 debug-print "want target: ${want_target}" 1641 debug-print "want target: ${want_target}"
1151 1642
1152 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1643 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1153 debug-print "could not find valid -source/-target values" 1644 debug-print "could not find valid -source/-target values for javac"
1154 die "Could not find valid -source/-target values" 1645 echo "Could not find valid -source/-target values for javac"
1646 return 1
1155 else 1647 else
1156 if java-pkg_is-vm-version-ge "1.4"; then 1648 if java-pkg_is-vm-version-ge "1.4"; then
1157 echo "${source_str} ${target_str}" 1649 echo "${source_str} ${target_str}"
1158 else 1650 else
1159 echo "${target_str}" 1651 echo "${target_str}"
1163 1655
1164# TODO document 1656# TODO document
1165java-pkg_get-jni-cflags() { 1657java-pkg_get-jni-cflags() {
1166 local flags="-I${JAVA_HOME}/include" 1658 local flags="-I${JAVA_HOME}/include"
1167 1659
1660 local platform="linux"
1661 use elibc_FreeBSD && platform="freebsd"
1662
1168 # TODO do a check that the directories are valid 1663 # 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" 1664 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1171 1665
1172 echo ${flags} 1666 echo ${flags}
1173} 1667}
1174 1668
1175java-pkg_ensure-gcj() { 1669java-pkg_ensure-gcj() {
1180 ebeep 5 1674 ebeep 5
1181 die "No GCJ support found!" 1675 die "No GCJ support found!"
1182 fi 1676 fi
1183} 1677}
1184 1678
1679java-pkg_ensure-test() {
1680 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1681 && hasq test ${IUSE} && ! use test;
1682 then
1683 eerror "You specified FEATURES=test, but USE=test is needed"
1684 eerror "to pull in the additional dependencies for testing"
1685 die "Need USE=test enabled"
1686 fi
1687}
1688
1689# ------------------------------------------------------------------------------
1690# @ebuild-function java-pkg_register-ant-task
1691#
1692# Register this package as ant task, so that ant will load it when no specific
1693# ANT_TASKS are specified. Note that even without this registering, all packages
1694# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1695# packages, but can be also used by other ebuilds that used to symlink their
1696# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1697# compatibility.
1698#
1699# @param --version x.y Register only for ant version x.y (otherwise for any ant
1700# version). Used by the ant-* packages to prevent loading of mismatched
1701# ant-core ant tasks after core was updated, before the tasks are updated,
1702# without a need for blockers.
1703# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1704# ------------------------------------------------------------------------------
1705java-pkg_register-ant-task() {
1706 local TASKS_DIR="tasks"
1707
1708 # check for --version x.y parameters
1709 while [[ -n "${1}" && -n "${2}" ]]; do
1710 local var="${1#--}"
1711 local val="${2}"
1712 if [[ "${var}" == "version" ]]; then
1713 TASKS_DIR="tasks-${val}"
1714 else
1715 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1716 fi
1717 shift 2
1718 done
1719
1720 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1721
1722 dodir /usr/share/ant/${TASKS_DIR}
1723 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1724}
1725
1726# ------------------------------------------------------------------------------
1727# @internal-function java-pkg_ant-tasks-depend
1728#
1729# Translates the WANT_ANT_TASKS variable into valid dependencies.
1730# ------------------------------------------------------------------------------
1731java-pkg_ant-tasks-depend() {
1732 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1733
1734 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1735 local DEP=""
1736 for i in ${WANT_ANT_TASKS}
1737 do
1738 if [[ ${i} != ant-* ]]; then
1739 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1740 return 1
1741 fi
1742 DEP="${DEP}dev-java/${i} "
1743 done
1744 echo ${DEP}
1745 return 0
1746 else
1747 return 0
1748 fi
1749}
1750
1751# ------------------------------------------------------------------------------
1752# @ebuild-function ejunit
1753#
1754# Junit wrapper function. Makes it easier to run the tests and checks for
1755# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1756#
1757# Examples:
1758# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1759# ejunit org.blinkenlights.jid3.test.AllTests
1760#
1761# @param $1 - -cp or -classpath
1762# @param $2 - classpath; junit and recorded dependencies get appended
1763# @param $@ - the rest of the parameters are passed to java
1764# ------------------------------------------------------------------------------
1765ejunit() {
1766 debug-print-function ${FUNCNAME} $*
1767
1768 local pkgs
1769 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1770 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1771 done
1772
1773 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1774 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1775 cp="${2}:${cp}"
1776 shift 2
1777 else
1778 cp=".:${cp}"
1779 fi
1780
1781 local runner=junit.textui.TestRunner
1782 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1783 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1784}
1785
1185# ------------------------------------------------------------------------------ 1786# ------------------------------------------------------------------------------
1186# @section-end helper 1787# @section-end helper
1187# ------------------------------------------------------------------------------ 1788# ------------------------------------------------------------------------------
1188 1789
1189# ------------------------------------------------------------------------------ 1790# ------------------------------------------------------------------------------
1196 1797
1197# ------------------------------------------------------------------------------ 1798# ------------------------------------------------------------------------------
1198# @ebuild-function eant 1799# @ebuild-function eant
1199# 1800#
1200# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1801# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1201# compiler. 1802# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1202# 1803# variables:
1804# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1805# gentoo.classpath property. Be sure to call
1806# java-ant_rewrite-classpath in src_unpack.
1807# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1808# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1203# ------------------------------------------------------------------------------ 1809# ------------------------------------------------------------------------------
1204eant() { 1810eant() {
1205 debug-print-function ${FUNCNAME} $* 1811 debug-print-function ${FUNCNAME} $*
1206 1812
1207 local antflags 1813 if [[ ${EBUILD_PHASE} = compile ]]; then
1814 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1815 # finally get rid of the hooks without breaking stuff
1816
1817 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1818 && java-ant_ignore-system-classes "${S}/build.xml"
1819
1820 if hasq java-ant-2 ${INHERITED}; then
1821 java-ant_bsfix
1822 fi
1823
1824 # eant can be called multiple times
1825 JAVA_PKG_BSFIX="off"
1826
1827 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1828 echo "Searching for bundled jars:"
1829 java-pkg_find-normal-jars || echo "None found."
1830 echo "Searching for bundled classes (no output if none found):"
1831 find "${WORKDIR}" -name "*.class"
1832 echo "Search done."
1833 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1834 fi
1835 fi
1836
1837 if ! hasq java-ant-2 ${INHERITED}; then
1838 local msg="You should inherit java-ant-2 when using eant"
1839 java-pkg_announce-qa-violation "${msg}"
1840 fi
1841
1842 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1843
1208 java-pkg_init-compiler_ 1844 java-pkg_init-compiler_
1209 local compiler="${GENTOO_COMPILER}" 1845 local compiler="${GENTOO_COMPILER}"
1210 1846
1211 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1847 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})" 1848 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1214 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1849 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1215 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1850 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1216 fi 1851 fi
1217 1852
1218 if [[ ${compiler} != "javac" ]]; then 1853 if [[ ${compiler} != "javac" ]]; then
1219 antflags="-Dbuild.compiler=${build_compiler}" 1854 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1220 # Figure out any extra stuff to put on the classpath for compilers aside 1855 # Figure out any extra stuff to put on the classpath for compilers aside
1221 # from javac 1856 # from javac
1222 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1857 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1223 # java-config -p 1858 # java-config -p
1224 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1859 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 1860 if [[ -n ${build_compiler_deps} ]]; then
1226 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1861 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1227 fi 1862 fi
1228 fi 1863 fi
1229 1864
1865 for arg in "${@}"; do
1866 if [[ ${arg} = -lib ]]; then
1230 if is-java-strict; then 1867 if is-java-strict; then
1231 einfo "Disabling system classpath for ant" 1868 eerror "You should not use the -lib argument to eant because it will fail"
1232 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1869 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1870 eerror "or ant properties to make dependencies available."
1871 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1872 eerror "split ant (>=dev-java/ant-core-1.7)."
1873 die "eant -lib is deprecated/forbidden"
1874 else
1875 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1876 echo "more info."
1877 fi
1233 fi 1878 fi
1234 1879 done
1235 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1880
1236 antflags="${antflags} -debug" 1881 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1882 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1883
1884 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1885 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1886
1887 # if ant-tasks is not set by ebuild or forced, use none
1888 ANT_TASKS="${ANT_TASKS:-none}"
1889
1890 # at this point, ANT_TASKS should be "all", "none" or explicit list
1891 if [[ "${ANT_TASKS}" == "all" ]]; then
1892 einfo "Using all available ANT_TASKS"
1893 elif [[ "${ANT_TASKS}" == "none" ]]; then
1894 einfo "Disabling all optional ANT_TASKS"
1895 else
1896 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1237 fi 1897 fi
1238 1898
1899 export ANT_TASKS
1900
1901 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1902 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1903
1904 local gcp="${EANT_GENTOO_CLASSPATH}"
1905 local getjarsarg=""
1906
1907 if [[ ${EBUILD_PHASE} = "test" ]]; then
1908 antflags="${antflags} -DJunit.present=true"
1909 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1910 getjarsarg="--with-dependencies"
1911 fi
1912
1913 local cp
1914
1915 for atom in ${gcp}; do
1916 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1917 done
1918
1919 if [[ ${cp} ]]; then
1920 # It seems ant does not like single quotes around ${cp}
1921 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1922 fi
1923
1239 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1924 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1925 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1240 ant ${antflags} "${@}" || die "eant failed" 1926 ant ${antflags} "${@}" || die "eant failed"
1241
1242} 1927}
1243 1928
1244# ------------------------------------------------------------------------------ 1929# ------------------------------------------------------------------------------
1245# @ebuild-function ejavac 1930# @ebuild-function ejavac
1246# 1931#
1247# Javac wrapper function. Will use the appropriate compiler, based on 1932# Javac wrapper function. Will use the appropriate compiler, based on
1248# /etc/java-config/compilers.conf 1933# /etc/java-config/compilers.conf
1249# 1934#
1250# @param $@ - Arguments to be passed to the compiler 1935# @param $@ - Arguments to be passed to the compiler
1251# ------------------------------------------------------------------------------ 1936# ------------------------------------------------------------------------------
1252ejavac() { 1937ejavac() {
1253 debug-print-function ${FUNCNAME} $* 1938 debug-print-function ${FUNCNAME} $*
1254 1939
1255 # FIXME using get-javac ends up printing stuff with einfo 1940 java-pkg_init-compiler_
1941
1942 local compiler_executable
1256# local compiler_executable=$(java-pkg_get-javac) 1943 compiler_executable=$(java-pkg_get-javac)
1257 local compiler_executable="javac" 1944 if [[ ${?} != 0 ]]; then
1945 eerror "There was a problem determining compiler: ${compiler_executable}"
1946 die "get-javac failed"
1947 fi
1258 1948
1949 local javac_args
1950 javac_args="$(java-pkg_javac-args)"
1951 if [[ ${?} != 0 ]]; then
1952 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1953 die "java-pkg_javac-args failed"
1954 fi
1955
1259 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1956 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1260 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1957 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1261} 1958}
1262 1959
1263# ------------------------------------------------------------------------------ 1960# ------------------------------------------------------------------------------
1264# @ebuild-function java-pkg_filter-compiler 1961# @ebuild-function java-pkg_filter-compiler
1265# 1962#
1266# Used to prevent the use of some compilers. Should be used in src_compile. 1963# Used to prevent the use of some compilers. Should be used in src_compile.
1267# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1964# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1268# 1965#
1269# @param $@ - compilers to filter 1966# @param $@ - compilers to filter
1270# ------------------------------------------------------------------------------ 1967# ------------------------------------------------------------------------------
1288# ------------------------------------------------------------------------------ 1985# ------------------------------------------------------------------------------
1289# @ebuild-function use_doc 1986# @ebuild-function use_doc
1290# 1987#
1291# Helper function for getting ant to build javadocs. If the user has USE=doc, 1988# 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. 1989# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1293# 1990#
1294# The output of this should be passed to ant. 1991# The output of this should be passed to ant.
1295# 1992#
1296# Example: build javadocs by calling 'javadoc' target 1993# Example: build javadocs by calling 'javadoc' target
1297# eant $(use_doc) 1994# eant $(use_doc)
1298# Example: build javadocs by calling 'apidoc' target 1995# Example: build javadocs by calling 'apidoc' target
1303# ------------------------------------------------------------------------------ 2000# ------------------------------------------------------------------------------
1304use_doc() { 2001use_doc() {
1305 use doc && echo ${@:-javadoc} 2002 use doc && echo ${@:-javadoc}
1306} 2003}
1307 2004
2005
1308# ------------------------------------------------------------------------------ 2006# ------------------------------------------------------------------------------
1309# @section-end build 2007# @section-end build
1310# ------------------------------------------------------------------------------ 2008# ------------------------------------------------------------------------------
1311 2009
1312# ------------------------------------------------------------------------------ 2010# ------------------------------------------------------------------------------
1313# @section-begin internal 2011# @section-begin internal
1314# @section-summary Internal functions 2012# @section-summary Internal functions
1315# 2013#
1316# Do __NOT__ use any of these from an ebuild! These are only to be used from 2014# Do __NOT__ use any of these from an ebuild! These are only to be used from
1317# within the java eclasses. 2015# within the java eclasses.
1318# ------------------------------------------------------------------------------ 2016# ------------------------------------------------------------------------------
1319 2017
1320# ----------------------------------------------------------------------------- 2018# -----------------------------------------------------------------------------
1321# @function-internal java-pkg_init 2019# @function-internal java-pkg_init
1322# 2020#
1323# The purpose of this function, as the name might imply, is to initialize the 2021# 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 2022# 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 2023# that'll muss things up. It initializes some variables, which are used
1326# internally. And most importantly, it'll switch the VM if necessary. 2024# internally. And most importantly, it'll switch the VM if necessary.
1327# 2025#
1328# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2026# 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. 2027# call it during each of the phases of the merge process.
1330# 2028#
1331# ----------------------------------------------------------------------------- 2029# -----------------------------------------------------------------------------
1332java-pkg_init() { 2030java-pkg_init() {
2031 debug-print-function ${FUNCNAME} $*
1333 unset JAVAC 2032 unset JAVAC
1334 unset JAVA_HOME 2033 unset JAVA_HOME
2034
2035 # People do all kinds of weird things.
2036 # http://forums.gentoo.org/viewtopic-p-3943166.html
2037 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2038 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2039 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2040 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2041 ewarn "sun-jdk vms and and as such break configure scripts that"
2042 ewarn "use it (for example app-office/openoffice) so we filter it out."
2043 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2044 ewarn "make.conf for example) to silence this warning or"
2045 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2046 fi
2047
2048 if [[ -z ${accept} ]]; then
2049 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2050 # -version output
2051 unset _JAVA_OPTIONS
2052 # phase hooks make this run many times without this
2053 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2054 fi
2055
2056 if java-pkg_func-exists ant_src_unpack; then
2057 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2058 fi
2059
1335 java-pkg_init_paths_ 2060 java-pkg_init_paths_
1336 java-pkg_switch-vm 2061 java-pkg_switch-vm
1337 PATH=${JAVA_HOME}/bin:${PATH} 2062 PATH=${JAVA_HOME}/bin:${PATH}
1338 2063
1339 # TODO we will probably want to set JAVAC and JAVACFLAGS 2064 # TODO we will probably want to set JAVAC and JAVACFLAGS
1340 2065
1341 # Do some QA checks 2066 # Do some QA checks
1342 java-pkg_check-jikes 2067 java-pkg_check-jikes
1343 2068
2069 # Can't use unset here because Portage does not save the unset
2070 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2071
1344 # When users have crazy classpaths some packages can fail to compile. 2072 # When users have crazy classpaths some packages can fail to compile.
1345 # and everything should work with empty CLASSPATH. 2073 # and everything should work with empty CLASSPATH.
1346 # This also helps prevent unexpected dependencies on random things 2074 # This also helps prevent unexpected dependencies on random things
1347 # from the CLASSPATH. 2075 # from the CLASSPATH.
1348 unset CLASSPATH 2076 export CLASSPATH=
2077
2078 # Unset external ANT_ stuff
2079 export ANT_TASKS=
2080 export ANT_OPTS=
1349} 2081}
1350 2082
1351# ------------------------------------------------------------------------------ 2083# ------------------------------------------------------------------------------
1352# @function-internal java-pkg-init-compiler_ 2084# @function-internal java-pkg-init-compiler_
1353# 2085#
1354# This function attempts to figure out what compiler should be used. It does 2086# 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 2087# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1356# COMPILERS variable defined there. 2088# COMPILERS variable defined there.
1357# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 2089# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1358# 2090#
1359# It will go through the list of compilers, and verify that it supports the 2091# 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 2092# 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 2093# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1362# isn't done. 2094# isn't done.
1363# 2095#
1385 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2117 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1386 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 2118 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1387 else 2119 else
1388 compilers=${JAVA_PKG_FORCE_COMPILER} 2120 compilers=${JAVA_PKG_FORCE_COMPILER}
1389 fi 2121 fi
1390 2122
1391 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 2123 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1392 2124
1393 # Figure out if we should announce what compiler we're using 2125 # Figure out if we should announce what compiler we're using
1394 local compiler 2126 local compiler
1395 for compiler in ${compilers}; do 2127 for compiler in ${compilers}; do
1398 if [[ ${compiler} = "javac" ]]; then 2130 if [[ ${compiler} = "javac" ]]; then
1399 debug-print "Found javac... breaking" 2131 debug-print "Found javac... breaking"
1400 export GENTOO_COMPILER="javac" 2132 export GENTOO_COMPILER="javac"
1401 break 2133 break
1402 fi 2134 fi
1403 2135
1404 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 2136 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1405 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2137 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1406 einfo "Filtering ${compiler}" 2138 einfo "Filtering ${compiler}"
1407 continue 2139 continue
1408 fi 2140 fi
1409 fi 2141 fi
1410 2142
1411 # for non-javac, we need to make sure it supports the right target and 2143 # for non-javac, we need to make sure it supports the right target and
1412 # source 2144 # source
1413 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 2145 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1414 if [[ -f ${compiler_env} ]]; then 2146 if [[ -f ${compiler_env} ]]; then
1415 local desired_target="$(java-pkg_get-target)" 2147 local desired_target="$(java-pkg_get-target)"
1475 fi 2207 fi
1476 2208
1477 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2209 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1478 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2210 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1479 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2211 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2212 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2213 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
1480 2214
1481 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2215 [[ -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}" 2216 [[ -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" 2217 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
1484 2218
1497# Writes the package.env out to disk. 2231# Writes the package.env out to disk.
1498# 2232#
1499# ------------------------------------------------------------------------------ 2233# ------------------------------------------------------------------------------
1500# TODO change to do-write, to match everything else 2234# TODO change to do-write, to match everything else
1501java-pkg_do_write_() { 2235java-pkg_do_write_() {
2236 debug-print-function ${FUNCNAME} $*
2237 java-pkg_init_paths_
1502 # Create directory for package.env 2238 # Create directory for package.env
1503 dodir "${JAVA_PKG_SHAREPATH}" 2239 dodir "${JAVA_PKG_SHAREPATH}"
1504 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2240 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2241 "${JAVA_PKG_DEPEND_FILE}" || -f \
2242 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1505 # Create package.env 2243 # Create package.env
1506 ( 2244 (
1507 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2245 echo "DESCRIPTION=\"${DESCRIPTION}\""
1508 echo "GENERATION=\"2\"" 2246 echo "GENERATION=\"2\""
1509 2247
1510 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2248 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1511 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2249 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1512 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2250 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1513 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2251 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2252 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2253 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2254 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
1514 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2255 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1515 ) > "${JAVA_PKG_ENV}" 2256 ) > "${JAVA_PKG_ENV}"
1516 2257
1517 # register target/source 2258 # register target/source
1518 local target="$(java-pkg_get-target)" 2259 local target="$(java-pkg_get-target)"
1519 local source="$(java-pkg_get-source)" 2260 local source="$(java-pkg_get-source)"
1520 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 2261 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1521 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 2262 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1529 2270
1530 2271
1531 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2272 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1532 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2273 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1533 2274
2275 # extra env variables
2276 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2277 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2278 # nested echo to remove leading/trailing spaces
2279 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2280 >> "${JAVA_PKG_ENV}" || die
2281 fi
2282
1534 # Strip unnecessary leading and trailing colons 2283 # Strip unnecessary leading and trailing colons
1535 # TODO try to cleanup if possible 2284 # TODO try to cleanup if possible
1536 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2285 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2286 else
2287 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2288 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2289 debug-print "write package.env."
1537 fi 2290 fi
1538} 2291}
1539
1540 2292
1541# ------------------------------------------------------------------------------ 2293# ------------------------------------------------------------------------------
1542# @internal-function java-pkg_record-jar_ 2294# @internal-function java-pkg_record-jar_
1543# 2295#
1544# Record a dependency to the package.env 2296# Record an (optional) dependency to the package.env
1545# 2297# @param --optional - record dependency as optional
2298# @param $1 - package to record
2299# @param $2 - (optional) jar of package to record
1546# ------------------------------------------------------------------------------ 2300# ------------------------------------------------------------------------------
1547JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2301JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2302JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
1548 2303
1549java-pkg_record-jar_() { 2304java-pkg_record-jar_() {
1550 debug-print-function ${FUNCNAME} $* 2305 debug-print-function ${FUNCNAME} $*
2306
2307 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2308 if [[ "${1}" == "--optional" ]]; then
2309 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2310 shift
2311 fi
1551 2312
1552 local pkg=${1} jar=${2} append 2313 local pkg=${1} jar=${2} append
1553 if [[ -z "${jar}" ]]; then 2314 if [[ -z "${jar}" ]]; then
1554 append="${pkg}" 2315 append="${pkg}"
1555 else 2316 else
1556 append="$(basename ${jar})@${pkg}" 2317 append="$(basename ${jar})@${pkg}"
1557 fi 2318 fi
1558 2319
1559 echo ${append} >> ${JAVA_PKG_DEPEND} 2320 echo "${append}" >> "${depend_file}"
1560} 2321}
1561 2322
1562# ------------------------------------------------------------------------------ 2323# ------------------------------------------------------------------------------
1563# @internal-function java-pkg_append_ 2324# @internal-function java-pkg_append_
1564# 2325#
1588 fi 2349 fi
1589} 2350}
1590 2351
1591# ------------------------------------------------------------------------------ 2352# ------------------------------------------------------------------------------
1592# @internal-function java-pkg_expand_dir_ 2353# @internal-function java-pkg_expand_dir_
1593# 2354#
1594# Gets the full path of the file/directory's parent. 2355# Gets the full path of the file/directory's parent.
1595# @param $1 - file/directory to find parent directory for 2356# @param $1 - file/directory to find parent directory for
1596# @return - path to $1's parent directory 2357# @return - path to $1's parent directory
1597# ------------------------------------------------------------------------------ 2358# ------------------------------------------------------------------------------
1598java-pkg_expand_dir_() { 2359java-pkg_expand_dir_() {
1624# 2385#
1625# ------------------------------------------------------------------------------ 2386# ------------------------------------------------------------------------------
1626java-pkg_setup-vm() { 2387java-pkg_setup-vm() {
1627 debug-print-function ${FUNCNAME} $* 2388 debug-print-function ${FUNCNAME} $*
1628 2389
2390 export LANG="C" LC_ALL="C"
2391
1629 local vendor="$(java-pkg_get-vm-vendor)" 2392 local vendor="$(java-pkg_get-vm-vendor)"
1630 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2393 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1631 addpredict "/dev/random" 2394 addpredict "/dev/random"
1632 elif [[ "${vendor}" == "ibm" ]]; then 2395 elif [[ "${vendor}" == "ibm" ]]; then
1633 addpredict "/proc/self/maps" 2396 addpredict "/proc/self/maps"
1634 addpredict "/proc/cpuinfo" 2397 addpredict "/proc/cpuinfo"
1635 export LANG="C" LC_ALL="C"
1636 elif [[ "${vendor}" == "jrockit" ]]; then 2398 elif [[ "${vendor}" == "jrockit" ]]; then
1637 addpredict "/proc/cpuinfo" 2399 addpredict "/proc/cpuinfo"
1638 fi 2400 fi
1639} 2401}
1640 2402
1684# @return - The version of the current VM 2446# @return - The version of the current VM
1685# ------------------------------------------------------------------------------ 2447# ------------------------------------------------------------------------------
1686java-pkg_get-vm-version() { 2448java-pkg_get-vm-version() {
1687 debug-print-function ${FUNCNAME} $* 2449 debug-print-function ${FUNCNAME} $*
1688 2450
1689 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 2451 java-config -g PROVIDES_VERSION
1690} 2452}
1691 2453
1692# ------------------------------------------------------------------------------ 2454# ------------------------------------------------------------------------------
1693# @internal-function java-pkg_switch-vm 2455# @internal-function java-pkg_switch-vm
1694# 2456#
1695# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2457# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1696# verify that the current VM is sufficient. 2458# verify that the current VM is sufficient.
1697# Setup the environment for the VM being used. 2459# Setup the environment for the VM being used.
1698# ------------------------------------------------------------------------------ 2460# ------------------------------------------------------------------------------
1699java-pkg_switch-vm() { 2461java-pkg_switch-vm() {
2462 debug-print-function ${FUNCNAME} $*
2463
1700 if java-pkg_needs-vm; then 2464 if java-pkg_needs-vm; then
1701 # Use the VM specified by JAVA_PKG_FORCE_VM 2465 # Use the VM specified by JAVA_PKG_FORCE_VM
1702 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2466 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1703 # If you're forcing the VM, I hope you know what your doing... 2467 # If you're forcing the VM, I hope you know what your doing...
2468 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1704 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2469 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1705 # if we're allowed to switch the vm... 2470 # if we're allowed to switch the vm...
1706 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2471 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}" 2472 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1708 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2473 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1709 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2474 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1710 else 2475 else
1711 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2476 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2477 fi
2478 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2479 eerror "Unable to determine VM for building from dependencies:"
2480 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2481 echo "VNEED: ${JAVA_PKG_VNEED}"
2482 die "Failed to determine VM for building."
2483 else
2484 export GENTOO_VM
1712 fi 2485 fi
1713 # otherwise just make sure the current VM is sufficient 2486 # otherwise just make sure the current VM is sufficient
1714 else 2487 else
1715 java-pkg_ensure-vm-version-sufficient 2488 java-pkg_ensure-vm-version-sufficient
1716 fi 2489 fi
1717 debug-print "Using: $(java-config -f)" 2490 debug-print "Using: $(java-config -f)"
1718 2491
1719 java-pkg_setup-vm 2492 java-pkg_setup-vm
1720 2493
1721 export JAVA=$(java-config --java) 2494 export JAVA=$(java-config --java)
1722 export JAVAC=$(java-config --javac) 2495 export JAVAC=$(java-config --javac)
1723 export JAVACFLAGS="$(java-pkg_javac-args)" 2496 JAVACFLAGS="$(java-pkg_javac-args)"
2497 if [[ ${?} != 0 ]]; then
2498 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2499 die "java-pkg_javac-args failed"
2500 fi
1724 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2501 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2502 export JAVACFLAGS
1725 2503
1726 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2504 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1727 export JDK_HOME=${JAVA_HOME} 2505 export JDK_HOME=${JAVA_HOME}
1728 2506
1729 #TODO If you know a better solution let us know. 2507 #TODO If you know a better solution let us know.
1730 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2508 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1731 2509
1732 local tann="${T}/announced-vm" 2510 local tann="${T}/announced-vm"
2511 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2512 # if people have for example modified eclasses some where
1733 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2513 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)" 2514 einfo "Using: $(java-config -f)"
1739 [[ ! -f "${tann}" ]] && touch "${tann}" 2515 [[ ! -f "${tann}" ]] && touch "${tann}"
1740 fi
1741 fi 2516 fi
1742 2517
1743 else 2518 else
1744 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2519 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
1745 fi 2520 fi
1775 einfo "Classes" 2550 einfo "Classes"
1776 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2551 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1777 fi 2552 fi
1778} 2553}
1779 2554
1780# TODO document 2555# ------------------------------------------------------------------------------
2556# @internal-function java-pkg_verify-classes
2557#
1781# Verify that the classes were compiled for the right source / target 2558# Verify that the classes were compiled for the right source / target. Dies if
2559# not.
2560# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2561# ------------------------------------------------------------------------------
1782java-pkg_verify-classes() { 2562java-pkg_verify-classes() {
1783 ebegin "Verifying java class versions"
1784 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2563 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1785 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2564 local target=$(java-pkg_get-target)
2565 local result
2566 local log="${T}/class-version-verify.log"
2567 if [[ -n "${1}" ]]; then
2568 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1786 result=$? 2569 result=$?
1787 eend ${result}
1788 if [[ ${result} == 0 ]]; then
1789 einfo "All good"
1790 else 2570 else
1791 ewarn "Possible problem" 2571 ebegin "Verifying java class versions (target: ${target})"
1792 die "Bad class files found" 2572 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2573 result=$?
2574 eend ${result}
2575 fi
2576 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2577 if [[ ${result} != 0 ]]; then
2578 eerror "Incorrect bytecode version found"
2579 [[ -n "${1}" ]] && eerror "in file: ${1}"
2580 eerror "See ${log} for more details."
2581 die "Incorrect bytecode found"
2582 fi
2583}
2584
2585# ----------------------------------------------------------------------------
2586# @internal-function java-pkg_ensure-dep
2587# Check that a package being used in jarfrom, getjars and getjar is contained
2588# within DEPEND or RDEPEND.
2589# @param $1 - empty - check both vars; "runtime" or "build" - check only
2590# RDEPEND, resp. DEPEND
2591# @param $2 - Package name and slot.
2592
2593java-pkg_ensure-dep() {
2594 debug-print-function ${FUNCNAME} $*
2595
2596 local limit_to="${1}"
2597 local target_pkg="${2}"
2598 local dev_error=""
2599
2600 local stripped_pkg=$(echo "${target_pkg}" | sed \
2601 's/-[0-9]*\(\.[0-9]\)*$//')
2602
2603 debug-print "Matching against: ${stripped_pkg}"
2604
2605 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2606 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2607 dev_error="${dev_error} declared in DEPEND."
2608 if is-java-strict; then
2609 eerror "${dev_error}"
2610 die "${dev_error}"
2611 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2612 eerror "${dev_error}"
2613 elog "Because you have this package installed the package will"
2614 elog "build without problems, but please report this to"
2615 elog "http://bugs.gentoo.org"
1793 fi 2616 fi
1794} 2617 fi
1795 2618
2619 if [[ ${limit_to} != build ]]; then
2620 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2621 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2622 dev_error="The ebuild is attempting to use ${target_pkg},"
2623 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2624 dev_error="${dev_error} or PDEPEND."
2625 if is-java-strict; then
2626 eerror "${dev_error}"
2627 die "${dev_error}"
2628 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2629 eerror "${dev_error}"
2630 elog "The package will build without problems, but may fail to run"
2631 elog "if you don't have ${target_pkg} installed, so please report"
2632 elog "this to http://bugs.gentoo.org"
2633 fi
2634 fi
2635 fi
2636 fi
2637}
1796 2638
1797# ------------------------------------------------------------------------------ 2639# ------------------------------------------------------------------------------
1798# @section-end internal 2640# @section-end internal
1799# ------------------------------------------------------------------------------ 2641# ------------------------------------------------------------------------------
1800 2642
1801java-pkg_check-phase() { 2643java-pkg_check-phase() {
1802 local phase=${1} 2644 local phase=${1}
1803 local funcname=${2} 2645 local funcname=${FUNCNAME[1]}
1804 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2646 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
1805 java-pkg_announce-qa-violation \
1806 "${funcname} used outside of src_${phase}" 2647 local msg="${funcname} used outside of src_${phase}"
2648 java-pkg_announce-qa-violation "${msg}"
1807 fi 2649 fi
1808} 2650}
1809 2651
1810java-pkg_check-versioned-jar() { 2652java-pkg_check-versioned-jar() {
1811 local jar=${1} 2653 local jar=${1}
1820 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2662 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1821 fi 2663 fi
1822} 2664}
1823 2665
1824java-pkg_announce-qa-violation() { 2666java-pkg_announce-qa-violation() {
1825 if is-java-strict; then 2667 local nodie
2668 if [[ ${1} == "--nodie" ]]; then
2669 nodie="true"
2670 shift
2671 fi
1826 echo "Java QA Notice: $@" >&2 2672 echo "Java QA Notice: $@" >&2
1827 increment-qa-violations 2673 increment-qa-violations
1828 fi 2674 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
1829} 2675}
1830 2676
1831increment-qa-violations() { 2677increment-qa-violations() {
1832 let "JAVA_PKG_QA_VIOLATIONS+=1" 2678 let "JAVA_PKG_QA_VIOLATIONS+=1"
1833 export JAVA_PKG_QA_VIOLATIONS 2679 export JAVA_PKG_QA_VIOLATIONS
1834} 2680}
1835 2681
1836is-java-strict() { 2682is-java-strict() {
1837 hasq java-strict ${FEATURES}; 2683 [[ -n ${JAVA_PKG_STRICT} ]]
1838 return $? 2684 return $?
1839} 2685}
1840 2686
1841# ------------------------------------------------------------------------------ 2687# ------------------------------------------------------------------------------
1842# @eclass-end 2688# @eclass-end

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

  ViewVC Help
Powered by ViewVC 1.1.20