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

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

  ViewVC Help
Powered by ViewVC 1.1.20