/[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.3 Revision 1.56
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# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.56 2007/01/30 14:12:34 caster Exp $
9 10
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 15# @eclass-maintainer java@gentoo.org
15# 16#
16# This eclass provides functionality which is used by 17# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 18# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 19#
19# @warning 20# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 21# 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 22# 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. 23# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
28
29IUSE="elibc_FreeBSD"
27 30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
34 37
35# Make sure we use java-config-2 38# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 39export WANT_JAVA_CONFIG="2"
37 40
38# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
42# @variable-external WANT_ANT_TASKS
43# @variable-default ""
44#
45# An $IFS separated list of ant tasks.
46# Ebuild can specify this variable before inheriting java-ant-2 eclass to
47# determine ANT_TASKS it needs. They will be automatically translated to
48# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
49# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
50# Ebuilds that need to depend conditionally on certain tasks and specify them
51# differently for different eant calls can't use this simplified approach.
52# You also cannot specify version or anything else than ant-*.
53#
54# @example WANT_ANT_TASKS="ant-junit ant-trax"
55#
56# @seealso JAVA_PKG_FORCE_ANT_TASKS
57# -----------------------------------------------------------------------------
58#WANT_ANT_TASKS
59
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. At this moment it's
63# portage with phase hooks support.
64# -----------------------------------------------------------------------------
65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
66
67# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 68# @variable-internal JAVA_PKG_E_DEPEND
40# 69#
41# This is a convience variable to be used from the other java eclasses. This is 70# This is a convience variable to be used from the other java eclasses. This is
42# the version of java-config we want to use. We also need a recent version 71# the version of java-config we want to use. We also need a recent version
43# portage, that includes phase hooks. 72# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 73# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 75
47# ----------------------------------------------------------------------------- 76# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 78# @variable-default yes
50# 79#
97# ----------------------------------------------------------------------------- 126# -----------------------------------------------------------------------------
98 127
99# ----------------------------------------------------------------------------- 128# -----------------------------------------------------------------------------
100# @variable-internal JAVA_PKG_COMPILER_DIR 129# @variable-internal JAVA_PKG_COMPILER_DIR
101# @default /usr/share/java-config-2/compiler 130# @default /usr/share/java-config-2/compiler
102# 131#
103# Directory where compiler settings are saved, without trailing slash. 132# Directory where compiler settings are saved, without trailing slash.
104# Probably shouldn't touch this variable. 133# Probably shouldn't touch this variable.
105# ----------------------------------------------------------------------------- 134# -----------------------------------------------------------------------------
106JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 135JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
107 136
117 146
118# ----------------------------------------------------------------------------- 147# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_FORCE_COMPILER 148# @variable-external JAVA_PKG_FORCE_COMPILER
120# 149#
121# Explicitly set a list of compilers to use. This is normally read from 150# Explicitly set a list of compilers to use. This is normally read from
122# JAVA_PKG_COMPILERS_CONF. 151# JAVA_PKG_COMPILERS_CONF.
123# 152#
124# @note This should only be used internally or for testing. 153# @note This should only be used internally or for testing.
125# @example Use jikes and javac, in that order 154# @example Use jikes and javac, in that order
126# JAVA_PKG_FORCE_COMPILER="jikes javac" 155# JAVA_PKG_FORCE_COMPILER="jikes javac"
127# ----------------------------------------------------------------------------- 156# -----------------------------------------------------------------------------
128 157
158# -----------------------------------------------------------------------------
159# @variable-external JAVA_PKG_FORCE_ANT_TASKS
160#
161# An $IFS separated list of ant tasks. Can be set in environment before calling
162# emerge/ebuild to override variables set in ebuild, mainly for testing before
163# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
164# eant() call, not the dependencies specified in WANT_ANT_TASKS.
165#
166# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
167# ebuild foo.ebuild compile
168#
169# @seealso WANT_ANT_TASKS
170# -----------------------------------------------------------------------------
171
129# TODO document me 172# TODO document me
130JAVA_PKG_QA_VIOLATIONS=0 173JAVA_PKG_QA_VIOLATIONS=0
131 174
132# ----------------------------------------------------------------------------- 175# -----------------------------------------------------------------------------
133# @section-end variables 176# @section-end variables
147# @ebuild-function java-pkg_dojar 190# @ebuild-function java-pkg_dojar
148# 191#
149# Installs any number of jars. 192# Installs any number of jars.
150# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 193# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
151# You can use java-pkg_jarinto to change this path. 194# You can use java-pkg_jarinto to change this path.
152# You should never install a jar with a package version in the filename. 195# You should never install a jar with a package version in the filename.
153# Instead, use java-pkg_newjar defined below. 196# Instead, use java-pkg_newjar defined below.
154# 197#
155# @example 198# @example
156# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 199# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
157# 200#
168 # Create JARDEST if it doesn't exist 211 # Create JARDEST if it doesn't exist
169 dodir ${JAVA_PKG_JARDEST} 212 dodir ${JAVA_PKG_JARDEST}
170 213
171 local jar 214 local jar
172 # for each jar 215 # for each jar
173 for jar in "$@"; do 216 for jar in "${@}"; do
174 local jar_basename=$(basename "${jar}") 217 local jar_basename=$(basename "${jar}")
175 218
176 java-pkg_check-versioned-jar ${jar_basename} 219 java-pkg_check-versioned-jar ${jar_basename}
177 220
178 # check if it exists 221 # check if it exists
179 if [[ -e "${jar}" ]] ; then 222 if [[ -e "${jar}" ]] ; then
223 # Don't overwrite if jar has already been installed with the same
224 # name
225 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
226 if [[ -e "${dest}" ]]; then
227 ewarn "Overwriting ${dest}"
228 fi
229
180 # install it into JARDEST if it's a non-symlink 230 # install it into JARDEST if it's a non-symlink
181 if [[ ! -L "${jar}" ]] ; then 231 if [[ ! -L "${jar}" ]] ; then
232 #but first check class version when in strict mode.
233 is-java-strict && java-pkg_verify-classes "${jar}"
234
182 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 235 INSDESTTREE="${JAVA_PKG_JARDEST}" \
183 doins "${jar}" || die "failed to install ${jar}" 236 doins "${jar}" || die "failed to install ${jar}"
184 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 237 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
185 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 238 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
186 # make a symlink to the original jar if it's symlink 239 # make a symlink to the original jar if it's symlink
197 250
198 java-pkg_do_write_ 251 java-pkg_do_write_
199} 252}
200 253
201 254
255# ------------------------------------------------------------------------------
256# @internal-function depend-java-query
257#
258# Wrapper for the depend-java-query binary to enable passing USE in env.
259# Using env variables keeps this eclass working with java-config versions that
260# do not handle use flags.
261# ------------------------------------------------------------------------------
262
263depend-java-query() {
264 USE="${USE}" $(which depend-java-query) "${@}"
265}
202 266
203# ------------------------------------------------------------------------------ 267# ------------------------------------------------------------------------------
204# @ebuild-function java-pkg_regjar 268# @ebuild-function java-pkg_regjar
205# 269#
206# Records an already installed jar in the package.env 270# Records an already installed jar in the package.env
207# This would mostly be used if the package has make or a custom script to 271# This would mostly be used if the package has make or a custom script to
208# install things. 272# install things.
209# 273#
210# Example: 274# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 275# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
276#
277# WARNING:
278# if you want to use shell expansion, you have to use ${D}/... as the for in
279# this function will not be able to expand the path, here's an example:
280#
281# java-pkg_regjar /opt/my-java/lib/*.jar
282#
283# will not work, because:
284# * the `for jar in "$@"` can't expand the path to jar file names, as they
285# don't exist yet
286# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
287# doesn't exist
288#
289# you have to use it as:
290#
291# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 292#
213# @param $@ - jars to record 293# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 294# ------------------------------------------------------------------------------
215# TODO fix me! 295# TODO should we be making sure the jar is present on ${D} or wherever?
216java-pkg_regjar() { 296java-pkg_regjar() {
217 debug-print-function ${FUNCNAME} $* 297 debug-print-function ${FUNCNAME} $*
218 298
219 java-pkg_check-phase install 299 java-pkg_check-phase install
220 300
221 [[ ${#} -lt 1 ]] && die "at least one argument needed" 301 [[ ${#} -lt 1 ]] && die "at least one argument needed"
222 302
223 java-pkg_init_paths_ 303 java-pkg_init_paths_
224 304
225 local jar jar_dir jar_file 305 local jar jar_dir jar_file
226 for jar in "$@"; do 306 for jar in "${@}"; do
227 # TODO use java-pkg_check-versioned-jar 307 # TODO use java-pkg_check-versioned-jar
228 if [[ -e "${jar}" ]]; then
229 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}"
230 elif [[ -e "${D}${jar}" ]]; then 308 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
309 [[ -d "${jar}" || -d "${D}${jar}" ]] \
310 && die "Called ${FUNCNAME} on a directory $*"
311
312 #check that class version correct when in strict mode
313 is-java-strict && java-pkg_verify-classes "${jar}"
314
315 # nelchael: we should strip ${D} in this case too, here's why:
316 # imagine such call:
317 # java-pkg_regjar ${D}/opt/java/*.jar
318 # such call will fall into this case (-e ${jar}) and will
319 # record paths with ${D} in package.env
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 320 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 321 else
233 die "${jar} does not exist" 322 die "${jar} does not exist"
234 fi 323 fi
235 done 324 done
236 325
237 java-pkg_do_write_ 326 java-pkg_do_write_
238} 327}
239 328
240
241# ------------------------------------------------------------------------------ 329# ------------------------------------------------------------------------------
242# @ebuild-function java-pkg_newjar 330# @ebuild-function java-pkg_newjar
243# 331#
244# Installs a jar with a new name 332# Installs a jar with a new name
245# 333#
255 local original_jar="${1}" 343 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 344 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 345 local new_jar_dest="${T}/${new_jar}"
258 346
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 347 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 348 [[ ! -f ${original_jar} ]] \
349 && die "${original_jar} does not exist or is not a file!"
261 350
262 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 351 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
263 cp "${original_jar}" "${new_jar_dest}" \ 352 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 353 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 354 java-pkg_dojar "${new_jar_dest}"
266} 355}
267 356
268
269# ------------------------------------------------------------------------------ 357# ------------------------------------------------------------------------------
270# @ebuild-function java-pkg_addcp 358# @ebuild-function java-pkg_addcp
271# 359#
272# Add something to the package's classpath. For jars, you should use dojar, 360# Add something to the package's classpath. For jars, you should use dojar,
273# newjar, or regjar. This is typically used to add directories to the classpath. 361# newjar, or regjar. This is typically used to add directories to the classpath.
278java-pkg_addcp() { 366java-pkg_addcp() {
279 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 367 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
280 java-pkg_do_write_ 368 java-pkg_do_write_
281} 369}
282 370
283
284# ------------------------------------------------------------------------------ 371# ------------------------------------------------------------------------------
285# @ebuild-function java-pkg_doso 372# @ebuild-function java-pkg_doso
286# 373#
287# Installs any number of JNI libraries 374# Installs any number of JNI libraries
288# They will be installed into /usr/lib by default, but java-pkg_sointo 375# They will be installed into /usr/lib by default, but java-pkg_sointo
289# can be used change this path 376# can be used change this path
290# 377#
291# Example: 378# Example:
346 java-pkg_check-phase install 433 java-pkg_check-phase install
347 434
348 [[ ${#} -lt 1 ]] && "at least one argument needed" 435 [[ ${#} -lt 1 ]] && "at least one argument needed"
349 436
350 java-pkg_init_paths_ 437 java-pkg_init_paths_
351 438
352 local lib target_dir 439 local lib target_dir
353 for lib in "$@" ; do 440 for lib in "$@" ; do
354 # Check the absolute path of the lib 441 # Check the absolute path of the lib
355 if [[ -e "${lib}" ]] ; then 442 if [[ -e "${lib}" ]] ; then
356 target_dir="$(java-pkg_expand_dir_ ${lib})" 443 target_dir="$(java-pkg_expand_dir_ ${lib})"
404# ------------------------------------------------------------------------------ 491# ------------------------------------------------------------------------------
405java-pkg_dohtml() { 492java-pkg_dohtml() {
406 debug-print-function ${FUNCNAME} $* 493 debug-print-function ${FUNCNAME} $*
407 494
408 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 495 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
409 # TODO-nichoj find out what exactly -f package-list does 496
497 # from /usr/lib/portage/bin/dohtml -h
498 # -f Set list of allowed extensionless file names.
410 dohtml -f package-list "$@" 499 dohtml -f package-list "$@"
500
411 # this probably shouldn't be here but it provides 501 # this probably shouldn't be here but it provides
412 # a reasonable way to catch # docs for all of the 502 # a reasonable way to catch # docs for all of the
413 # old ebuilds. 503 # old ebuilds.
414 java-pkg_recordjavadoc 504 java-pkg_recordjavadoc
415} 505}
416 506
417# TODO document 507# ------------------------------------------------------------------------------
508# @ebuild-function java-pkg_dojavadoc
509#
510# Installs javadoc documentation. This should be controlled by the doc use flag.
511#
512# @param $1: - The javadoc root directory.
513#
514# @example:
515# java-pkg_dojavadoc docs/api
516#
517# ------------------------------------------------------------------------------
418java-pkg_dojavadoc() { 518java-pkg_dojavadoc() {
419 local dir="$1" 519 local dir="$1"
420 520
421 java-pkg_check-phase install 521 java-pkg_check-phase install
422 522
434} 534}
435 535
436# ------------------------------------------------------------------------------ 536# ------------------------------------------------------------------------------
437# @ebuild-function java-pkg_dosrc 537# @ebuild-function java-pkg_dosrc
438# 538#
439# Installs a zip containing the source for a package, so it can used in 539# Installs a zip containing the source for a package, so it can used in
440# from IDEs like eclipse and netbeans. 540# from IDEs like eclipse and netbeans.
441# 541#
442# Ebuild needs to DEPEND on app-arch/zip to use this. 542# Ebuild needs to DEPEND on app-arch/zip to use this.
443# 543#
444# It also should be controlled by USE=source. 544# It also should be controlled by USE=source.
445# 545#
446# @example: 546# @example:
447# java-pkg_dosrc src/* 547# java-pkg_dosrc src/*
448# 548#
449# ------------------------------------------------------------------------------ 549# ------------------------------------------------------------------------------
450# TODO change so it the arguments it takes are the base directories containing 550# TODO change so it the arguments it takes are the base directories containing
451# source -nichoj 551# source -nichoj
452# TODO should we be able to handle multiple calls to dosrc? -nichoj 552# TODO should we be able to handle multiple calls to dosrc? -nichoj
453# TODO maybe we can take an existing zip/jar? -nichoj 553# TODO maybe we can take an existing zip/jar? -nichoj
454# FIXME apparently this fails if you give it an empty directories 554# FIXME apparently this fails if you give it an empty directories
455java-pkg_dosrc() { 555java-pkg_dosrc() {
456 debug-print-function ${FUNCNAME} $* 556 debug-print-function ${FUNCNAME} $*
457 557
458 [ ${#} -lt 1 ] && die "At least one argument needed" 558 [ ${#} -lt 1 ] && die "At least one argument needed"
459 if ! hasq source ${IUSE}; then 559 if ! hasq source ${IUSE}; then
460 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 560 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
461 fi 561 fi
462 562
463 java-pkg_check-phase install 563 java-pkg_check-phase install
464 564
465 [[ ${#} -lt 1 ]] && die "At least one argument needed" 565 [[ ${#} -lt 1 ]] && die "At least one argument needed"
466 566
467 java-pkg_init_paths_ 567 java-pkg_init_paths_
468 568
469 local zip_name="${PN}-src.zip" 569 local zip_name="${PN}-src.zip"
470 local zip_path="${T}/${zip_name}" 570 local zip_path="${T}/${zip_name}"
471 local dir 571 local dir
472 for dir in ${@}; do 572 for dir in "${@}"; do
473 local dir_parent=$(dirname "${dir}") 573 local dir_parent=$(dirname "${dir}")
474 local dir_name=$(basename "${dir}") 574 local dir_name=$(basename "${dir}")
475 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 575 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
476 zip -q -r ${zip_path} ${dir_name} -i '*.java' 576 zip -q -r ${zip_path} ${dir_name} -i '*.java'
477 local result=$? 577 local result=$?
494# @ebuild-function java-pkg_dolauncher 594# @ebuild-function java-pkg_dolauncher
495# 595#
496# Make a wrapper script to lauch/start this package 596# Make a wrapper script to lauch/start this package
497# If necessary, the wrapper will switch to the appropriate VM. 597# If necessary, the wrapper will switch to the appropriate VM.
498# 598#
599# Can be called without parameters if the package installs only one jar
600# that has the Main-class attribute set. The wrapper will be named ${PN}.
601#
499# @param $1 - filename of launcher to create 602# @param $1 - filename of launcher to create
500# @param $2 - options, as follows: 603# @param $2 - options, as follows:
501# --main the.main.class.too.start 604# --main the.main.class.too.start
502# --jar /the/jar/too/launch.jar 605# --jar /the/jar/too/launch.jar or just <name>.jar
503# --java_args 'Extra arguments to pass too jave' 606# --java_args 'Extra arguments to pass to java'
504# --pkg_args 'extra arguments too pass too the package' 607# --pkg_args 'Extra arguments to pass to the package'
505# --pwd 608# --pwd Directory the launcher changes to before executing java
506# -into 609# -into Directory to install the launcher to, instead of /usr/bin
507# -pre 610# -pre Prepend contents of this file to the launcher
508# ------------------------------------------------------------------------------ 611# ------------------------------------------------------------------------------
509java-pkg_dolauncher() { 612java-pkg_dolauncher() {
510 debug-print-function ${FUNCNAME} $* 613 debug-print-function ${FUNCNAME} $*
511 614
512 java-pkg_check-phase install 615 java-pkg_check-phase install
513
514 [[ ${#} -lt 1 ]] && die "Need at least one argument"
515
516 java-pkg_init_paths_ 616 java-pkg_init_paths_
517 617
618 if [[ ${#} = 0 ]]; then
619 local name="${PN}"
620 else
518 local name="${1}" 621 local name="${1}"
622 shift
623 fi
624
519 # TODO rename to launcher 625 # TODO rename to launcher
520 local target="${T}/${name}" 626 local target="${T}/${name}"
627 local var_tmp="${T}/launcher_variables_tmp"
521 local target_dir pre 628 local target_dir pre
522 shift
523 629
524 echo "#!/bin/bash" > "${target}" 630 # Process the other the rest of the arguments
525 while [[ -n "${1}" && -n "${2}" ]]; do 631 while [[ -n "${1}" && -n "${2}" ]]; do
526 local var=${1} value=${2} 632 local var="${1}" value="${2}"
527 if [[ "${var:0:2}" == "--" ]]; then 633 if [[ "${var:0:2}" == "--" ]]; then
634 local var=${var:2}
528 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 635 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
636 local gjl_${var}="${value}"
529 elif [[ "${var}" == "-into" ]]; then 637 elif [[ "${var}" == "-into" ]]; then
530 target_dir="${value}" 638 target_dir="${value}"
531 elif [[ "${var}" == "-pre" ]]; then 639 elif [[ "${var}" == "-pre" ]]; then
532 pre="${value}" 640 pre="${value}"
533 fi 641 fi
534 shift 2 642 shift 2
535 done 643 done
644
645 # Test if no --jar and --main arguments were given and
646 # in that case check if the package only installs one jar
647 # and use that jar.
648 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
649 local cp="${JAVA_PKG_CLASSPATH}"
650 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
651 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
652 else
653 local msg="Not enough information to create a launcher given."
654 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
655 die "${msg}"
656 fi
657 fi
658
659 # Write the actual script
660 echo "#!/bin/bash" > "${target}"
661 if [[ -n "${pre}" ]]; then
662 if [[ -f "${pre}" ]]; then
663 cat "${pre}" >> "${target}"
664 else
665 die "-pre specified file '${pre}' does not exist"
666 fi
667 fi
536 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 668 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
537 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 669 cat "${var_tmp}" >> "${target}"
670 rm -f "${var_tmp}"
538 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 671 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
539 672
540 if [[ -n "${into}" ]]; then 673 if [[ -n "${target_dir}" ]]; then
541 DESTTREE="${target_dir}" dobin "${target}" 674 DESTTREE="${target_dir}" dobin "${target}"
542 local ret=$? 675 local ret=$?
543 return ${ret} 676 return ${ret}
544 else 677 else
545 dobin "${target}" 678 dobin "${target}"
573 echo "dowar: warning, skipping directory ${war}" 706 echo "dowar: warning, skipping directory ${war}"
574 continue 707 continue
575 else 708 else
576 warpath="${war}" 709 warpath="${war}"
577 fi 710 fi
578 711
579 # Install those files like you mean it 712 # Install those files like you mean it
580 INSOPTIONS="-m 0644" \ 713 INSOPTIONS="-m 0644" \
581 INSDESTTREE=${JAVA_PKG_WARDEST} \ 714 INSDESTTREE=${JAVA_PKG_WARDEST} \
582 doins ${warpath} 715 doins ${warpath}
583 done 716 done
618# @ebuild-function java-pkg_jar-from 751# @ebuild-function java-pkg_jar-from
619# 752#
620# Makes a symlink to a jar from a certain package 753# Makes a symlink to a jar from a certain package
621# A lot of java packages include dependencies in a lib/ directory 754# A lot of java packages include dependencies in a lib/ directory
622# You can use this function to replace these bundled dependencies. 755# You can use this function to replace these bundled dependencies.
756# The dependency is recorded into package.env DEPEND line, unless "--build-only"
757# is passed as the very first argument, for jars that have to be present only
758# at build time and are not needed on runtime (junit testing etc).
623# 759#
624# Example: get all jars from xerces slot 2 760# Example: get all jars from xerces slot 2
625# java-pkg_jar-from xerces-2 761# java-pkg_jar-from xerces-2
626# Example: get a specific jar from xerces slot 2 762# Example: get a specific jar from xerces slot 2
627# java-pkg_jar-from xerces-2 xml-apis.jar 763# java-pkg_jar-from xerces-2 xml-apis.jar
628# Example get a specific jar from xerces slot 2, and name it diffrently 764# Example: get a specific jar from xerces slot 2, and name it diffrently
629# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 765# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
766# Example: get junit.jar which is needed only for building
767# java-pkg_jar-from --build-only junit junit.jar
630# 768#
769# @param $opt
770# --build-only - makes the jar(s) not added into package.env DEPEND line.
771# (assumed automatically when called inside src_test)
772# --with-dependencies - get jars also from requested package's dependencies
773# transitively.
774# --into $dir - symlink jar(s) into $dir (must exist) instead of .
631# @param $1 - Package to get jars from. 775# @param $1 - Package to get jars from.
632# @param $2 - jar from package. If not specified, all jars will be used. 776# @param $2 - jar from package. If not specified, all jars will be used.
633# @param $3 - When a single jar is specified, destination filename of the 777# @param $3 - When a single jar is specified, destination filename of the
634# symlink. Defaults to the name of the jar. 778# symlink. Defaults to the name of the jar.
635# ------------------------------------------------------------------------------ 779# ------------------------------------------------------------------------------
636# TODO could probably be cleaned up a little 780# TODO could probably be cleaned up a little
637java-pkg_jar-from() { 781java-pkg_jar-from() {
638 debug-print-function ${FUNCNAME} $* 782 debug-print-function ${FUNCNAME} $*
639 783
640 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 784 local build_only=""
785 local destdir="."
786 local deep=""
641 787
788 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
789
790 while [[ "${1}" == --* ]]; do
791 if [[ "${1}" = "--build-only" ]]; then
792 build_only="true"
793 elif [[ "${1}" = "--with-dependencies" ]]; then
794 deep="--with-dependencies"
795 elif [[ "${1}" = "--into" ]]; then
796 destdir="${2}"
797 shift
798 else
799 die "java-pkg_jar-from called with unknown parameter: ${1}"
800 fi
801 shift
802 done
803
804 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
805
642 [[ -z ${target_pkg} ]] && die "Must specify a package" 806 [[ -z ${target_pkg} ]] && die "Must specify a package"
643 807
644 # default destjar to the target jar 808 # default destjar to the target jar
645 [[ -z "${destjar}" ]] && destjar="${target_jar}" 809 [[ -z "${destjar}" ]] && destjar="${target_jar}"
646 810
811 local error_msg="There was a problem getting the classpath for ${target_pkg}."
812 local classpath
647 local classpath="$(java-config --classpath=${target_pkg})" 813 classpath="$(java-config ${deep} --classpath=${target_pkg})"
648 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 814 [[ $? != 0 ]] && die ${error_msg}
649 815
816 pushd ${destdir} > /dev/null \
817 || die "failed to change directory to ${destdir}"
650 local jar 818 local jar
651 for jar in ${classpath//:/ }; do 819 for jar in ${classpath//:/ }; do
652 local jar_name=$(basename "${jar}") 820 local jar_name=$(basename "${jar}")
653 if [[ ! -f "${jar}" ]] ; then 821 if [[ ! -f "${jar}" ]] ; then
654 debug-print "${jar} from ${target_pkg} does not exist" 822 debug-print "${jar} from ${target_pkg} does not exist"
657 # If no specific target jar was indicated, link it 825 # If no specific target jar was indicated, link it
658 if [[ -z "${target_jar}" ]] ; then 826 if [[ -z "${target_jar}" ]] ; then
659 [[ -f "${target_jar}" ]] && rm "${target_jar}" 827 [[ -f "${target_jar}" ]] && rm "${target_jar}"
660 ln -snf "${jar}" \ 828 ln -snf "${jar}" \
661 || die "Failed to make symlink from ${jar} to ${jar_name}" 829 || die "Failed to make symlink from ${jar} to ${jar_name}"
662 java-pkg_record-jar_ "${target_pkg}" "${jar}" 830 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
663 # otherwise, if the current jar is the target jar, link it 831 # otherwise, if the current jar is the target jar, link it
664 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 832 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
665 [[ -f "${destjar}" ]] && rm "${destjar}" 833 [[ -f "${destjar}" ]] && rm "${destjar}"
666 ln -snf "${jar}" "${destjar}" \ 834 ln -snf "${jar}" "${destjar}" \
667 || die "Failed to make symlink from ${jar} to ${destjar}" 835 || die "Failed to make symlink from ${jar} to ${destjar}"
668 java-pkg_record-jar_ "${target_pkg}" "${jar}" 836 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
837 popd > /dev/null
669 return 0 838 return 0
670 fi 839 fi
671 done 840 done
841 popd > /dev/null
672 # if no target was specified, we're ok 842 # if no target was specified, we're ok
673 if [[ -z "${target_jar}" ]] ; then 843 if [[ -z "${target_jar}" ]] ; then
674 return 0 844 return 0
675 # otherwise, die bitterly 845 # otherwise, die bitterly
676 else 846 else
690# ------------------------------------------------------------------------------ 860# ------------------------------------------------------------------------------
691# @ebuild-function java-pkg_getjars 861# @ebuild-function java-pkg_getjars
692# 862#
693# Get the classpath provided by any number of packages 863# Get the classpath provided by any number of packages
694# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 864# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
865# The providing packages are recorded as dependencies into package.env DEPEND
866# line, unless "--build-only" is passed as the very first argument, for jars
867# that have to be present only at build time and are not needed on runtime
868# (junit testing etc).
695# 869#
696# Example: Get the classpath for xerces-2, 870# Example: Get the classpath for xerces-2 and xalan,
697# java-pkg_getjars xerces-2 xalan 871# java-pkg_getjars xerces-2,xalan
698# Example Return: 872# Example Return:
699# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 873# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
700# 874#
875# @param $opt
876# --build-only - makes the jar(s) not added into package.env DEPEND line.
877# (assumed automatically when called inside src_test)
878# --with-dependencies - get jars also from requested package's dependencies
879# transitively.
701# @param $@ - list of packages to get jars from 880# @param $1 - list of packages to get jars from
881# (passed to java-config --classpath)
702# ------------------------------------------------------------------------------ 882# ------------------------------------------------------------------------------
703java-pkg_getjars() { 883java-pkg_getjars() {
704 debug-print-function ${FUNCNAME} $* 884 debug-print-function ${FUNCNAME} $*
705 885
706 [[ ${#} -lt 1 ]] && die "At least one argument needed" 886 local build_only=""
887 local deep=""
888
889 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
707 890
708 # NOTE could probably just pass $@ to java-config --classpath. and return it 891 while [[ "${1}" == --* ]]; do
709 local classpath pkg 892 if [[ "${1}" = "--build-only" ]]; then
710 for pkg in ${@//,/ }; do 893 build_only="true"
711 #for pkg in $(echo "$@" | tr ',' ' '); do 894 elif [[ "${1}" = "--with-dependencies" ]]; then
712 jars="$(java-config --classpath=${pkg})" 895 deep="--with-dependencies"
713 debug-print "${pkg}:${jars}"
714 # TODO should we ensure jars exist?
715 if [[ -z "${classpath}" ]]; then
716 classpath="${jars}"
717 else 896 else
718 classpath="${classpath}:${jars}" 897 die "java-pkg_jar-from called with unknown parameter: ${1}"
719 fi 898 fi
720 java-pkg_record-jar_ "${pkg}" 899 shift
721 done 900 done
901
902 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
903
904 local classpath pkgs="${1}"
905 jars="$(java-config ${deep} --classpath=${pkgs})"
906 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
907 debug-print "${pkgs}:${jars}"
908
909 if [[ -z "${classpath}" ]]; then
910 classpath="${jars}"
911 else
912 classpath="${classpath}:${jars}"
913 fi
914
915 # Only record jars that aren't build-only
916 if [[ -z "${build_only}" ]]; then
917 oldifs="${IFS}"
918 IFS=","
919 for pkg in ${pkgs}; do
920 java-pkg_record-jar_ "${pkg}"
921 done
922 IFS="${oldifs}"
923 fi
924
722 echo "${classpath}" 925 echo "${classpath}"
723} 926}
724 927
725# ------------------------------------------------------------------------------ 928# ------------------------------------------------------------------------------
726# @ebuild-function java-pkg_getjar 929# @ebuild-function java-pkg_getjar
727# 930#
728# Get the filename of a single jar from a package 931# Get the filename of a single jar from a package
932# The providing package is recorded as runtime dependency into package.env
933# DEPEND line, unless "--build-only" is passed as the very first argument, for
934# jars that have to be present only at build time and are not needed on runtime
935# (junit testing etc).
729# 936#
730# @example 937# @example
731# java-pkg_getjar xerces-2 xml-apis.jar 938# java-pkg_getjar xerces-2 xml-apis.jar
732# @example-return 939# @example-return
733# /usr/share/xerces-2/lib/xml-apis.jar 940# /usr/share/xerces-2/lib/xml-apis.jar
734# 941#
942# @param $opt
943# --build-only - makes the jar not added into package.env DEPEND line.
735# @param $1 - package to use 944# @param $1 - package to use
736# @param $2 - jar to get 945# @param $2 - jar to get
737# ------------------------------------------------------------------------------ 946# ------------------------------------------------------------------------------
738java-pkg_getjar() { 947java-pkg_getjar() {
739 debug-print-function ${FUNCNAME} $* 948 debug-print-function ${FUNCNAME} $*
949
950 local build_only=""
951
952 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
953
954 while [[ "${1}" == --* ]]; do
955 if [[ "${1}" = "--build-only" ]]; then
956 build_only="true"
957 else
958 die "java-pkg_jar-from called with unknown parameter: ${1}"
959 fi
960 shift
961 done
962
963 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
740 964
741 local pkg="${1}" target_jar="${2}" jar 965 local pkg="${1}" target_jar="${2}" jar
742 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 966 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
743 [[ -z ${target_jar} ]] && die "Must specify jar to get" 967 [[ -z ${target_jar} ]] && die "Must specify jar to get"
744 968
745 # TODO check that package is actually installed 969 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
970 local classpath
746 local classpath=$(java-config --classpath=${pkg}) 971 classpath=$(java-config --classpath=${pkg})
747 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 972 [[ $? != 0 ]] && die ${error_msg}
973
748 for jar in ${classpath//:/ }; do 974 for jar in ${classpath//:/ }; do
749 if [[ ! -f "${jar}" ]] ; then 975 if [[ ! -f "${jar}" ]] ; then
750 die "Installation problems with jars in ${pkg} - is it installed?" 976 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
751 fi 977 fi
752 978
753 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 979 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
754 java-pkg_record-jar_ "${pkg}" "${jar}" 980 # Only record jars that aren't build-only
981 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
755 echo "${jar}" 982 echo "${jar}"
756 return 0 983 return 0
757 fi 984 fi
758 done 985 done
759 986
760 die "Could not find ${target_jar} in ${pkg}" 987 die "Could not find ${target_jar} in ${pkg}"
761 return 1 988 return 1
762} 989}
763 990
764# This function reads stdin, and based on that input, figures out how to 991# This function reads stdin, and based on that input, figures out how to
778# line="${line// /}" 1005# line="${line// /}"
779# 1006#
780# # format: path=jarinfo 1007# # format: path=jarinfo
781# local path=${line%%=*} 1008# local path=${line%%=*}
782# local jarinfo=${line##*=} 1009# local jarinfo=${line##*=}
783# 1010#
784# # format: jar@package 1011# # format: jar@package
785# local jar=${jarinfo%%@*}.jar 1012# local jar=${jarinfo%%@*}.jar
786# local package=${jarinfo##*@} 1013# local package=${jarinfo##*@}
787# if [[ -n ${replace_only} ]]; then 1014# if [[ -n ${replace_only} ]]; then
788# [[ ! -f $path ]] && die "No jar exists at ${path}" 1015# [[ ! -f $path ]] && die "No jar exists at ${path}"
801# @section-end query 1028# @section-end query
802# ------------------------------------------------------------------------------ 1029# ------------------------------------------------------------------------------
803 1030
804# ------------------------------------------------------------------------------ 1031# ------------------------------------------------------------------------------
805# @section-begin helper 1032# @section-begin helper
806# @section-summary Helper functions 1033# @section-summary Helper functions
807# 1034#
808# Various other functions to use from an ebuild 1035# Various other functions to use from an ebuild
809# ------------------------------------------------------------------------------ 1036# ------------------------------------------------------------------------------
810 1037
811# ------------------------------------------------------------------------------ 1038# ------------------------------------------------------------------------------
817# jdbc-stdext 1044# jdbc-stdext
818# jaf 1045# jaf
819# jdbc-rowset 1046# jdbc-rowset
820# jms 1047# jms
821# 1048#
822# @param $1 - Optionally indicate that the dependencies are controlled by 1049# @param $1 - Optionally indicate that the dependencies are controlled by
823# a use flag by specifying '--use' Requires $2. 1050# a use flag by specifying '--use' Requires $2.
824# @param $2 - USE flag which will enable the dependencies. 1051# @param $2 - USE flag which will enable the dependencies.
825# @param $@ - virtual packages to add depenedencies for 1052# @param $@ - virtual packages to add depenedencies for
826# ------------------------------------------------------------------------------ 1053# ------------------------------------------------------------------------------
827# TODO rewrite to parse a line based declaration file instead -- karltk 1054# TODO rewrite to parse a line based declaration file instead -- karltk
883# 1110#
884# export DEPEND="${DEPEND} ${depstr}" 1111# export DEPEND="${DEPEND} ${depstr}"
885# export RDEPEND="${RDEPEND} ${depstr}" 1112# export RDEPEND="${RDEPEND} ${depstr}"
886#} 1113#}
887 1114
1115# ------------------------------------------------------------------------------
1116# @ebuild-function java-pkg_find-normal-jars
1117#
1118# Find the files with suffix .jar file in the given directory or $WORKDIR
1119#
1120# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1121# ------------------------------------------------------------------------------
1122java-pkg_find-normal-jars() {
1123 local dir=$1
1124 [[ "${dir}" ]] || dir="${WORKDIR}"
1125 local found
1126 for jar in $(find "${dir}" -name "*.jar" -type f); do
1127 echo "${jar}"
1128 found="true"
1129 done
1130 [[ "${found}" ]]
1131 return $?
1132}
1133
1134# ------------------------------------------------------------------------------
1135# @ebuild-function java-pkg_ensure-no-bundled-jars
1136#
1137# Try to locate bundled jar files in ${WORKDIR} and die if found.
888# This should be used after S has been populated with symlinks to jars 1138# This function should be called after WORKDIR has been populated with symlink
889# TODO document 1139# to system jar files or bundled jars removed.
1140# ------------------------------------------------------------------------------
890java-pkg_ensure-no-bundled-jars() { 1141java-pkg_ensure-no-bundled-jars() {
891 debug-print-function ${FUNCNAME} $* 1142 debug-print-function ${FUNCNAME} $*
892 pushd ${WORKDIR} >/dev/null 2>/dev/null
893 1143
894 local bundled_jars=$(find . -name "*.jar" -type f) 1144 local bundled_jars=$(java-pkg_find-normal-jars)
895 if [[ -n ${bundled_jars} ]]; then 1145 if [[ -n ${bundled_jars} ]]; then
896 echo "Bundled jars found:" 1146 echo "Bundled jars found:"
897 local jar 1147 local jar
898 for jar in ${bundled_jars}; do 1148 for jar in ${bundled_jars}; do
899 echo $(pwd)${jar/./} 1149 echo $(pwd)${jar/./}
900 done 1150 done
901 die "Bundled jars found!" 1151 die "Bundled jars found!"
902
903 fi 1152 fi
904 popd >/dev/null 2>/dev/null
905} 1153}
906 1154
907# ------------------------------------------------------------------------------ 1155# ------------------------------------------------------------------------------
908# @internal-function java-pkg_ensure-vm-version-sufficient 1156# @internal-function java-pkg_ensure-vm-version-sufficient
909# 1157#
921 fi 1169 fi
922} 1170}
923 1171
924# ------------------------------------------------------------------------------ 1172# ------------------------------------------------------------------------------
925# @internal-function java-pkg_is-vm-version-sufficient 1173# @internal-function java-pkg_is-vm-version-sufficient
926# 1174#
927# @return zero - VM is sufficient 1175# @return zero - VM is sufficient
928# @return non-zero - VM is not sufficient 1176# @return non-zero - VM is not sufficient
929# ------------------------------------------------------------------------------ 1177# ------------------------------------------------------------------------------
930java-pkg_is-vm-version-sufficient() { 1178java-pkg_is-vm-version-sufficient() {
931 debug-print-function ${FUNCNAME} $* 1179 debug-print-function ${FUNCNAME} $*
951 die "Active Java VM too old" 1199 die "Active Java VM too old"
952 fi 1200 fi
953} 1201}
954 1202
955# ------------------------------------------------------------------------------ 1203# ------------------------------------------------------------------------------
956# @internal-function java-pkg_is-vm-version-eq 1204# @internal-function java-pkg_is-vm-version-eq
957# 1205#
958# @param $@ - VM version to compare current VM to 1206# @param $@ - VM version to compare current VM to
959# @return zero - VM versions are equal 1207# @return zero - VM versions are equal
960# @return non-zero - VM version are not equal 1208# @return non-zero - VM version are not equal
961# ------------------------------------------------------------------------------ 1209# ------------------------------------------------------------------------------
962java-pkg_is-vm-version-eq() { 1210java-pkg_is-vm-version-eq() {
992# 1240#
993# @param $@ - VM version to compare current to 1241# @param $@ - VM version to compare current to
994# ------------------------------------------------------------------------------ 1242# ------------------------------------------------------------------------------
995java-pkg_ensure-vm-version-ge() { 1243java-pkg_ensure-vm-version-ge() {
996 debug-print-function ${FUNCNAME} $* 1244 debug-print-function ${FUNCNAME} $*
997 1245
998 if ! java-pkg_is-vm-version-ge "$@" ; then 1246 if ! java-pkg_is-vm-version-ge "$@" ; then
999 debug-print "vm is not suffient" 1247 debug-print "vm is not suffient"
1000 eerror "This package requires a Java VM version >= $@" 1248 eerror "This package requires a Java VM version >= $@"
1001 einfo "Please use java-config -S to set the correct one" 1249 einfo "Please use java-config -S to set the correct one"
1002 die "Active Java VM too old" 1250 die "Active Java VM too old"
1003 fi 1251 fi
1004} 1252}
1005 1253
1006# ------------------------------------------------------------------------------ 1254# ------------------------------------------------------------------------------
1007# @internal-function java-pkg_is-vm-version-ge 1255# @internal-function java-pkg_is-vm-version-ge
1008# 1256#
1009# @param $@ - VM version to compare current VM to 1257# @param $@ - VM version to compare current VM to
1010# @return zero - current VM version is greater than checked version 1258# @return zero - current VM version is greater than checked version
1011# @return non-zero - current VM version is not greater than checked version 1259# @return non-zero - current VM version is not greater than checked version
1012# ------------------------------------------------------------------------------ 1260# ------------------------------------------------------------------------------
1013java-pkg_is-vm-version-ge() { 1261java-pkg_is-vm-version-ge() {
1027 return 1 1275 return 1
1028 fi 1276 fi
1029 fi 1277 fi
1030} 1278}
1031 1279
1280java-pkg_set-current-vm() {
1281 export GENTOO_VM=${1}
1282}
1283
1284java-pkg_get-current-vm() {
1285 echo ${GENTOO_VM}
1286}
1287
1288java-pkg_current-vm-matches() {
1289 hasq $(java-pkg_get-current-vm) ${@}
1290 return $?
1291}
1292
1032# ------------------------------------------------------------------------------ 1293# ------------------------------------------------------------------------------
1033# @ebuild-function java-pkg_get-source 1294# @ebuild-function java-pkg_get-source
1034# 1295#
1035# Determines what source version should be used, for passing to -source. 1296# Determines what source version should be used, for passing to -source.
1036# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1297# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1037# 1298#
1038# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1299# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1039# ------------------------------------------------------------------------------ 1300# ------------------------------------------------------------------------------
1044# ------------------------------------------------------------------------------ 1305# ------------------------------------------------------------------------------
1045# @ebuild-function java-pkg_get-target 1306# @ebuild-function java-pkg_get-target
1046# 1307#
1047# Determines what target version should be used, for passing to -target. 1308# Determines what target version should be used, for passing to -target.
1048# If you don't care about lower versions, you can set _WANT_TARGET to the 1309# If you don't care about lower versions, you can set _WANT_TARGET to the
1049# version of your JDK. 1310# version of your JDK.
1050# Remember doing this will mostly like cause things to break.
1051# Doesn't allow it to be lower then the one in depend.
1052# Doesn't allow it to be higher then the active vm.
1053# 1311#
1054# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1312# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1055# ------------------------------------------------------------------------------ 1313# ------------------------------------------------------------------------------
1056java-pkg_get-target() { 1314java-pkg_get-target() {
1057 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1058 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1059 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1060 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1061 echo ${JAVA_PKG_WANT_TARGET}
1062 else
1063 echo ${min}
1064 fi
1065 else
1066 echo ${min}
1067 fi
1068
1069 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1315 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1070} 1316}
1071 1317
1072java-pkg_get-javac() { 1318java-pkg_get-javac() {
1073 debug-print-function ${FUNCNAME} $* 1319 debug-print-function ${FUNCNAME} $*
1074 1320
1075 java-pkg_init-compiler_ 1321
1076 local compiler="${GENTOO_COMPILER}" 1322 local compiler="${GENTOO_COMPILER}"
1077 1323
1078 local compiler_executable 1324 local compiler_executable
1079 if [[ "${compiler}" = "javac" ]]; then 1325 if [[ "${compiler}" = "javac" ]]; then
1080 # nothing fancy needs to be done for javac 1326 # nothing fancy needs to be done for javac
1088 unset JAVAC 1334 unset JAVAC
1089 # try to get value of JAVAC 1335 # try to get value of JAVAC
1090 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1336 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1091 export JAVAC=${old_javac} 1337 export JAVAC=${old_javac}
1092 1338
1093 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1339 if [[ -z ${compiler_executable} ]]; then
1094 1340 echo "JAVAC is empty or undefined in ${compiler_env}"
1341 return 1
1342 fi
1343
1095 # check that it's executable 1344 # check that it's executable
1096 if [[ ! -x ${compiler_executable} ]]; then 1345 if [[ ! -x ${compiler_executable} ]]; then
1097 eerror "Could not find ${compiler_executable}!"
1098 die "${compiler_executable} doesn't exist, or isn't executable" 1346 echo "${compiler_executable} doesn't exist, or isn't executable"
1347 return 1
1099 fi 1348 fi
1100 else 1349 else
1101 eerror "Could not find environment file for ${compiler}" 1350 echo "Could not find environment file for ${compiler}"
1102 die "Could not find ${compiler_env}" 1351 return 1
1103 fi 1352 fi
1104 fi 1353 fi
1105 echo ${compiler_executable} 1354 echo ${compiler_executable}
1106} 1355}
1107 1356
1108# ------------------------------------------------------------------------------ 1357# ------------------------------------------------------------------------------
1109# @ebuild-function java-pkg_javac-args 1358# @ebuild-function java-pkg_javac-args
1110# 1359#
1111# If an ebuild uses javac directly, instead of using ejavac, it should call this 1360# If an ebuild uses javac directly, instead of using ejavac, it should call this
1112# to know what -source/-target to use. 1361# to know what -source/-target to use.
1113# 1362#
1114# @return string - arguments to pass to javac, complete with -target and -source 1363# @return string - arguments to pass to javac, complete with -target and -source
1117 debug-print-function ${FUNCNAME} $* 1366 debug-print-function ${FUNCNAME} $*
1118 1367
1119 local want_source="$(java-pkg_get-source)" 1368 local want_source="$(java-pkg_get-source)"
1120 local want_target="$(java-pkg_get-target)" 1369 local want_target="$(java-pkg_get-target)"
1121 1370
1122 local source_str="-source ${want_source}" 1371 local source_str="-source ${want_source}"
1123 local target_str="-target ${want_target}" 1372 local target_str="-target ${want_target}"
1124 1373
1125 debug-print "want source: ${want_source}" 1374 debug-print "want source: ${want_source}"
1126 debug-print "want target: ${want_target}" 1375 debug-print "want target: ${want_target}"
1127 1376
1128 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1377 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1129 debug-print "could not find valid -source/-target values" 1378 debug-print "could not find valid -source/-target values for javac"
1130 die "Could not find valid -source/-target values" 1379 echo "Could not find valid -source/-target values for javac"
1380 return 1
1131 else 1381 else
1132 if java-pkg_is-vm-version-ge "1.4"; then 1382 if java-pkg_is-vm-version-ge "1.4"; then
1133 echo "${source_str} ${target_str}" 1383 echo "${source_str} ${target_str}"
1134 else 1384 else
1135 echo "${target_str}" 1385 echo "${target_str}"
1139 1389
1140# TODO document 1390# TODO document
1141java-pkg_get-jni-cflags() { 1391java-pkg_get-jni-cflags() {
1142 local flags="-I${JAVA_HOME}/include" 1392 local flags="-I${JAVA_HOME}/include"
1143 1393
1144 # TODO figure out how to cope with other things than linux... 1394 local platform="linux"
1395 use elibc_FreeBSD && platform="freebsd"
1396
1397 # TODO do a check that the directories are valid
1145 flags="${flags} -I${JAVA_HOME}/include/linux" 1398 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1146 1399
1147 echo ${flags} 1400 echo ${flags}
1401}
1402
1403java-pkg_ensure-gcj() {
1404 if ! built_with_use sys-devel/gcc gcj ; then
1405 ewarn
1406 ewarn "You must build gcc with the gcj support to build with gcj"
1407 ewarn
1408 ebeep 5
1409 die "No GCJ support found!"
1410 fi
1411}
1412
1413java-pkg_ensure-test() {
1414 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1415 && hasq test ${IUSE} && ! use test;
1416 then
1417 eerror "You specified FEATURES=test, but USE=test is needed"
1418 eerror "to pull in the additional dependencies for testing"
1419 die "Need USE=test enabled"
1420 fi
1421}
1422
1423# ------------------------------------------------------------------------------
1424# @ebuild-function java-pkg_register-ant-task
1425#
1426# Register this package as ant task, so that ant will load it when no specific
1427# ANT_TASKS are specified. Note that even without this registering, all packages
1428# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1429# packages, but can be also used by other ebuilds that used to symlink their
1430# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1431# compatibility.
1432#
1433# @param --version x.y Register only for ant version x.y (otherwise for any ant
1434# version). Used by the ant-* packages to prevent loading of mismatched
1435# ant-core ant tasks after core was updated, before the tasks are updated,
1436# without a need for blockers.
1437# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1438# ------------------------------------------------------------------------------
1439java-pkg_register-ant-task() {
1440 local TASKS_DIR="tasks"
1441
1442 # check for --version x.y parameters
1443 while [[ -n "${1}" && -n "${2}" ]]; do
1444 local var="${1#--}"
1445 local val="${2}"
1446 if [[ "${var}" == "version" ]]; then
1447 TASKS_DIR="tasks-${val}"
1448 else
1449 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1450 fi
1451 shift 2
1452 done
1453
1454 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1455
1456 dodir /usr/share/ant/${TASKS_DIR}
1457 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1458}
1459
1460# ------------------------------------------------------------------------------
1461# @internal-function java-pkg_ant-tasks-from-deps
1462#
1463# Function to determine ANT_TASKS from DEPEND variable for backwards
1464# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1465# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1466# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1467# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1468# be a problem, the worst it can do is activace all tasks when not needed.
1469# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1470# insufficient dependencies, otherwise all available tasks are used for
1471# backwards compatilbility.
1472#
1473# @return "all" or "none"
1474# ------------------------------------------------------------------------------
1475java-pkg_ant-tasks-from-deps() {
1476 local found_ant found_ant_tasks
1477
1478 for dep in ${DEPEND}
1479 do
1480 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1481 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1482 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1483 done
1484
1485 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1486 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1487 echo "all"
1488 else
1489 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1490 # so we deactivate all tasks that may be installed
1491 echo "none"
1492 fi
1493}
1494
1495# ------------------------------------------------------------------------------
1496# @internal-function java-pkg_ant-tasks-depend
1497#
1498# Translates the WANT_ANT_TASKS variable into valid dependencies.
1499# ------------------------------------------------------------------------------
1500java-pkg_ant-tasks-depend() {
1501 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1502
1503 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1504 local DEP=""
1505 for i in ${WANT_ANT_TASKS}
1506 do
1507 if [[ ${i} != ant-* ]]; then
1508 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1509 return 1
1510 fi
1511 DEP="${DEP}dev-java/${i} "
1512 done
1513 echo ${DEP}
1514 return 0
1515 else
1516 return 0
1517 fi
1148} 1518}
1149 1519
1150# ------------------------------------------------------------------------------ 1520# ------------------------------------------------------------------------------
1151# @section-end helper 1521# @section-end helper
1152# ------------------------------------------------------------------------------ 1522# ------------------------------------------------------------------------------
1161 1531
1162# ------------------------------------------------------------------------------ 1532# ------------------------------------------------------------------------------
1163# @ebuild-function eant 1533# @ebuild-function eant
1164# 1534#
1165# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1535# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1166# compiler. 1536# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1167# 1537# variables:
1538# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1539# gentoo.classpath property. Be sure to call
1540# java-ant_rewrite-classpath in src_unpack.
1541# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1168# ------------------------------------------------------------------------------ 1542# ------------------------------------------------------------------------------
1169eant() { 1543eant() {
1170 debug-print-function ${FUNCNAME} $* 1544 debug-print-function ${FUNCNAME} $*
1171 1545
1172 local antflags 1546 # FIXME get this working
1547# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1548# java-pkg_announce-qa-violation \
1549# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1550# fi
1551
1552 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1553 local msg="You should inherit java-ant-2 when using eant"
1554 java-pkg_announce-qa-violation ${msg}
1555 die ${msg}
1556 fi
1557
1558 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1173 java-pkg_init-compiler_ 1559 java-pkg_init-compiler_
1174 local compiler="${GENTOO_COMPILER}" 1560 local compiler="${GENTOO_COMPILER}"
1175 1561
1176 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1562 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1177 1563
1179 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1565 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1180 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1566 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1181 fi 1567 fi
1182 1568
1183 if [[ ${compiler} != "javac" ]]; then 1569 if [[ ${compiler} != "javac" ]]; then
1184 antflags="-Dbuild.compiler=${build_compiler}" 1570 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1185 # Figure out any extra stuff to put on the classpath for compilers aside 1571 # Figure out any extra stuff to put on the classpath for compilers aside
1186 # from javac 1572 # from javac
1187 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1573 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1188 # java-config -p 1574 # java-config -p
1189 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1575 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1190 if [[ -n ${build_compiler_deps} ]]; then 1576 if [[ -n ${build_compiler_deps} ]]; then
1191 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1577 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1192 fi 1578 fi
1193 fi 1579 fi
1194 1580
1195 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1581 if is-java-strict; then
1196 antflags="${antflags} -debug" 1582 einfo "Disabling system classpath for ant"
1583 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1584 fi
1585
1586 for arg in "${@}"; do
1587 if [[ ${arg} = -lib ]]; then
1588 if is-java-strict; then
1589 eerror "You should not use the -lib argument to eant because it will fail"
1590 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1591 eerror "or ant properties to make dependencies available."
1592 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1593 eerror "split ant (>=dev-java/ant-core-1.7)."
1594 die "eant -lib is deprecated/forbidden"
1595 else
1596 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1597 echo "more info."
1598 fi
1197 fi 1599 fi
1198 1600 done
1601
1602 if has_version ">=dev-java/ant-core-1.7.0"; then
1603 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1604 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1605
1606 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1607 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1608
1609 if is-java-strict; then
1610 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1611 if [[ -z "${ANT_TASKS}" ]]; then
1612 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1613 fi
1614 else
1615 # if ant-tasks is not set by ebuild or forced, activate all of them
1616 ANT_TASKS="${ANT_TASKS:-all}"
1617 fi
1618
1619 # at this point, ANT_TASKS should be "all", "none" or explicit list
1620 if [[ "${ANT_TASKS}" == "all" ]]; then
1621 einfo "Using all available ANT_TASKS"
1622 elif [[ "${ANT_TASKS}" == "none" ]]; then
1623 einfo "Disabling all optional ANT_TASKS"
1624 else
1625 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1626 fi
1627
1628 export ANT_TASKS
1629 fi
1630
1631 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1632 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1633
1634 local gcp="${EANT_GENTOO_CLASSPATH}"
1635
1636 if [[ "${gcp}" ]]; then
1637 local cp="$(java-pkg_getjars ${gcp})"
1638 # It seems ant does not like single quotes around ${cp}
1639 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1640 fi
1641
1199 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1642 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1643 debug-print "Calling ant: ${antflags} ${@}"
1200 ant ${antflags} "${@}" || die "eant failed" 1644 ant ${antflags} "${@}" || die "eant failed"
1201 1645
1202} 1646}
1203 1647
1204# ------------------------------------------------------------------------------ 1648# ------------------------------------------------------------------------------
1205# @ebuild-function ejavac 1649# @ebuild-function ejavac
1206# 1650#
1207# Javac wrapper function. Will use the appropriate compiler, based on 1651# Javac wrapper function. Will use the appropriate compiler, based on
1208# /etc/java-config/compilers.conf 1652# /etc/java-config/compilers.conf
1209# 1653#
1210# @param $@ - Arguments to be passed to the compiler 1654# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 1655# ------------------------------------------------------------------------------
1212ejavac() { 1656ejavac() {
1213 debug-print-function ${FUNCNAME} $* 1657 debug-print-function ${FUNCNAME} $*
1214 1658
1659 java-pkg_init-compiler_
1660
1661 local compiler_executable
1215 local compiler_executable=$(java-pkg_get-javac) 1662 compiler_executable=$(java-pkg_get-javac)
1663 if [[ ${?} != 0 ]]; then
1664 eerror "There was a problem determining compiler: ${compiler_executable}"
1665 die "get-javac failed"
1666 fi
1216 1667
1668 local javac_args
1669 javac_args="$(java-pkg_javac-args)"
1670 if [[ ${?} != 0 ]]; then
1671 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1672 die "java-pkg_javac-args failed"
1673 fi
1674
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1675 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1676 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1219} 1677}
1220 1678
1221# ------------------------------------------------------------------------------ 1679# ------------------------------------------------------------------------------
1222# @ebuild-function java-pkg_filter-compiler 1680# @ebuild-function java-pkg_filter-compiler
1223# 1681#
1224# Used to prevent the use of some compilers. Should be used in src_compile. 1682# Used to prevent the use of some compilers. Should be used in src_compile.
1225# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1683# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1226# 1684#
1227# @param $@ - compilers to filter 1685# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 1686# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 1687java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1688 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1231} 1689}
1232 1690
1233# ------------------------------------------------------------------------------ 1691# ------------------------------------------------------------------------------
1692# @ebuild-function java-pkg_force-compiler
1693#
1694# Used to force the use of particular compilers. Should be used in src_compile.
1695# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1696# OutOfMemoryErrors that may come up.
1697#
1698# @param $@ - compilers to force
1699# ------------------------------------------------------------------------------
1700java-pkg_force-compiler() {
1701 JAVA_PKG_FORCE_COMPILER="$@"
1702}
1703
1704# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 1705# @ebuild-function use_doc
1235# 1706#
1236# Helper function for getting ant to build javadocs. If the user has USE=doc, 1707# Helper function for getting ant to build javadocs. If the user has USE=doc,
1237# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1708# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1238# 1709#
1239# The output of this should be passed to ant. 1710# The output of this should be passed to ant.
1240# 1711#
1241# Example: build javadocs by calling 'javadoc' target 1712# Example: build javadocs by calling 'javadoc' target
1242# eant $(use_doc) 1713# eant $(use_doc)
1243# Example: build javadocs by calling 'apidoc' target 1714# Example: build javadocs by calling 'apidoc' target
1248# ------------------------------------------------------------------------------ 1719# ------------------------------------------------------------------------------
1249use_doc() { 1720use_doc() {
1250 use doc && echo ${@:-javadoc} 1721 use doc && echo ${@:-javadoc}
1251} 1722}
1252 1723
1724
1253# ------------------------------------------------------------------------------ 1725# ------------------------------------------------------------------------------
1254# @section-end build 1726# @section-end build
1255# ------------------------------------------------------------------------------ 1727# ------------------------------------------------------------------------------
1256 1728
1257# ------------------------------------------------------------------------------ 1729# ------------------------------------------------------------------------------
1258# @section-begin internal 1730# @section-begin internal
1259# @section-summary Internal functions 1731# @section-summary Internal functions
1260# 1732#
1261# Do __NOT__ use any of these from an ebuild! These are only to be used from 1733# Do __NOT__ use any of these from an ebuild! These are only to be used from
1262# within the java eclasses. 1734# within the java eclasses.
1263# ------------------------------------------------------------------------------ 1735# ------------------------------------------------------------------------------
1264 1736
1265# ----------------------------------------------------------------------------- 1737# -----------------------------------------------------------------------------
1266# @function-internal java-pkg_init 1738# @function-internal java-pkg_init
1267# 1739#
1268# The purpose of this function, as the name might imply, is to initialize the 1740# The purpose of this function, as the name might imply, is to initialize the
1269# Java environment. It ensures that that there aren't any environment variables 1741# Java environment. It ensures that that there aren't any environment variables
1270# that'll muss things up. It initializes some variables, which are used 1742# that'll muss things up. It initializes some variables, which are used
1271# internally. And most importantly, it'll switch the VM if necessary. 1743# internally. And most importantly, it'll switch the VM if necessary.
1272# 1744#
1284 # TODO we will probably want to set JAVAC and JAVACFLAGS 1756 # TODO we will probably want to set JAVAC and JAVACFLAGS
1285 1757
1286 # Do some QA checks 1758 # Do some QA checks
1287 java-pkg_check-jikes 1759 java-pkg_check-jikes
1288 1760
1289 # When users have crazy classpaths some packages can fail to compile. 1761 # When users have crazy classpaths some packages can fail to compile.
1290 # and everything should work with empty CLASSPATH. 1762 # and everything should work with empty CLASSPATH.
1291 # This also helps prevent unexpected dependencies on random things 1763 # This also helps prevent unexpected dependencies on random things
1292 # from the CLASSPATH. 1764 # from the CLASSPATH.
1293 unset CLASSPATH 1765 unset CLASSPATH
1766
1767 # Unset external ANT_ stuff
1768 unset ANT_TASKS
1769 unset ANT_OPTS
1294} 1770}
1295 1771
1296# ------------------------------------------------------------------------------ 1772# ------------------------------------------------------------------------------
1297# @function-internal java-pkg-init-compiler_ 1773# @function-internal java-pkg-init-compiler_
1298# 1774#
1299# This function attempts to figure out what compiler should be used. It does 1775# This function attempts to figure out what compiler should be used. It does
1300# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1776# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1301# COMPILERS variable defined there. 1777# COMPILERS variable defined there.
1302# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1778# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1303# 1779#
1304# It will go through the list of compilers, and verify that it supports the 1780# It will go through the list of compilers, and verify that it supports the
1305# target and source that are needed. If it is not suitable, then the next 1781# target and source that are needed. If it is not suitable, then the next
1306# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1782# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1307# isn't done. 1783# isn't done.
1308# 1784#
1330 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1806 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1331 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1807 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1332 else 1808 else
1333 compilers=${JAVA_PKG_FORCE_COMPILER} 1809 compilers=${JAVA_PKG_FORCE_COMPILER}
1334 fi 1810 fi
1335 1811
1336 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1812 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1337 1813
1338 # Figure out if we should announce what compiler we're using 1814 # Figure out if we should announce what compiler we're using
1339 local compiler 1815 local compiler
1340 for compiler in ${compilers}; do 1816 for compiler in ${compilers}; do
1343 if [[ ${compiler} = "javac" ]]; then 1819 if [[ ${compiler} = "javac" ]]; then
1344 debug-print "Found javac... breaking" 1820 debug-print "Found javac... breaking"
1345 export GENTOO_COMPILER="javac" 1821 export GENTOO_COMPILER="javac"
1346 break 1822 break
1347 fi 1823 fi
1348 1824
1349 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1825 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1350 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1826 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1351 einfo "Filtering ${compiler}" 1827 einfo "Filtering ${compiler}"
1352 continue 1828 continue
1353 fi 1829 fi
1354 fi 1830 fi
1355 1831
1356 # for non-javac, we need to make sure it supports the right target and 1832 # for non-javac, we need to make sure it supports the right target and
1357 # source 1833 # source
1358 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1834 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1359 if [[ -f ${compiler_env} ]]; then 1835 if [[ -f ${compiler_env} ]]; then
1360 local desired_target="$(java-pkg_get-target)" 1836 local desired_target="$(java-pkg_get-target)"
1442# Writes the package.env out to disk. 1918# Writes the package.env out to disk.
1443# 1919#
1444# ------------------------------------------------------------------------------ 1920# ------------------------------------------------------------------------------
1445# TODO change to do-write, to match everything else 1921# TODO change to do-write, to match everything else
1446java-pkg_do_write_() { 1922java-pkg_do_write_() {
1923 java-pkg_init_paths_
1447 # Create directory for package.env 1924 # Create directory for package.env
1448 dodir "${JAVA_PKG_SHAREPATH}" 1925 dodir "${JAVA_PKG_SHAREPATH}"
1449 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1926 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1450 # Create package.env 1927 # Create package.env
1451 ( 1928 (
1456 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1933 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1457 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1934 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1458 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1935 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1459 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1936 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1460 ) > "${JAVA_PKG_ENV}" 1937 ) > "${JAVA_PKG_ENV}"
1461 1938
1462 # register target/source 1939 # register target/source
1463 local target="$(java-pkg_get-target)" 1940 local target="$(java-pkg_get-target)"
1464 local source="$(java-pkg_get-source)" 1941 local source="$(java-pkg_get-source)"
1465 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1942 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1466 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1943 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1479 # Strip unnecessary leading and trailing colons 1956 # Strip unnecessary leading and trailing colons
1480 # TODO try to cleanup if possible 1957 # TODO try to cleanup if possible
1481 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1958 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1482 fi 1959 fi
1483} 1960}
1484
1485 1961
1486# ------------------------------------------------------------------------------ 1962# ------------------------------------------------------------------------------
1487# @internal-function java-pkg_record-jar_ 1963# @internal-function java-pkg_record-jar_
1488# 1964#
1489# Record a dependency to the package.env 1965# Record a dependency to the package.env
1533 fi 2009 fi
1534} 2010}
1535 2011
1536# ------------------------------------------------------------------------------ 2012# ------------------------------------------------------------------------------
1537# @internal-function java-pkg_expand_dir_ 2013# @internal-function java-pkg_expand_dir_
1538# 2014#
1539# Gets the full path of the file/directory's parent. 2015# Gets the full path of the file/directory's parent.
1540# @param $1 - file/directory to find parent directory for 2016# @param $1 - file/directory to find parent directory for
1541# @return - path to $1's parent directory 2017# @return - path to $1's parent directory
1542# ------------------------------------------------------------------------------ 2018# ------------------------------------------------------------------------------
1543java-pkg_expand_dir_() { 2019java-pkg_expand_dir_() {
1570# ------------------------------------------------------------------------------ 2046# ------------------------------------------------------------------------------
1571java-pkg_setup-vm() { 2047java-pkg_setup-vm() {
1572 debug-print-function ${FUNCNAME} $* 2048 debug-print-function ${FUNCNAME} $*
1573 2049
1574 local vendor="$(java-pkg_get-vm-vendor)" 2050 local vendor="$(java-pkg_get-vm-vendor)"
1575 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2051 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1576 addpredict "/dev/random" 2052 addpredict "/dev/random"
1577 elif [[ "${vendor}" == "ibm" ]]; then 2053 elif [[ "${vendor}" == "ibm" ]]; then
1578 addpredict "/proc/self/maps" 2054 addpredict "/proc/self/maps"
1579 addpredict "/proc/cpuinfo" 2055 addpredict "/proc/cpuinfo"
1580 export LANG="C" LC_ALL="C" 2056 export LANG="C" LC_ALL="C"
1629# @return - The version of the current VM 2105# @return - The version of the current VM
1630# ------------------------------------------------------------------------------ 2106# ------------------------------------------------------------------------------
1631java-pkg_get-vm-version() { 2107java-pkg_get-vm-version() {
1632 debug-print-function ${FUNCNAME} $* 2108 debug-print-function ${FUNCNAME} $*
1633 2109
1634 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 2110 java-config -g PROVIDES_VERSION
1635} 2111}
1636 2112
1637# ------------------------------------------------------------------------------ 2113# ------------------------------------------------------------------------------
1638# @internal-function java-pkg_switch-vm 2114# @internal-function java-pkg_switch-vm
1639# 2115#
1640# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2116# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1641# verify that the current VM is sufficient. 2117# verify that the current VM is sufficient.
1642# Setup the environment for the VM being used. 2118# Setup the environment for the VM being used.
1643# ------------------------------------------------------------------------------ 2119# ------------------------------------------------------------------------------
1644java-pkg_switch-vm() { 2120java-pkg_switch-vm() {
2121 debug-print-function ${FUNCNAME} $*
2122
1645 if java-pkg_needs-vm; then 2123 if java-pkg_needs-vm; then
1646 # Use the VM specified by JAVA_PKG_FORCE_VM 2124 # Use the VM specified by JAVA_PKG_FORCE_VM
1647 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2125 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1648 # If you're forcing the VM, I hope you know what your doing... 2126 # If you're forcing the VM, I hope you know what your doing...
2127 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1649 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2128 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1650 # if we're allowed to switch the vm... 2129 # if we're allowed to switch the vm...
1651 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2130 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1652 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2131 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1653 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2132 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1654 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2133 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1655 else 2134 else
1656 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2135 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2136 fi
2137 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2138 eerror "Unable to determine VM for building from dependencies:"
2139 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2140 echo "VNEED: ${JAVA_PKG_VNEED}"
2141 die "Failed to determine VM for building."
2142 else
2143 export GENTOO_VM
1657 fi 2144 fi
1658 # otherwise just make sure the current VM is sufficient 2145 # otherwise just make sure the current VM is sufficient
1659 else 2146 else
1660 java-pkg_ensure-vm-version-sufficient 2147 java-pkg_ensure-vm-version-sufficient
1661 fi 2148 fi
1662 debug-print "Using: $(java-config -f)" 2149 debug-print "Using: $(java-config -f)"
1663 2150
1664 java-pkg_setup-vm 2151 java-pkg_setup-vm
1665 2152
1666 export JAVA=$(java-config -java) 2153 export JAVA=$(java-config --java)
1667 export JAVAC=$(java-config -javac) 2154 export JAVAC=$(java-config --javac)
1668 export JAVACFLAGS="$(java-pkg_javac-args)" 2155 JAVACFLAGS="$(java-pkg_javac-args)"
2156 if [[ ${?} != 0 ]]; then
2157 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2158 die "java-pkg_javac-args failed"
2159 fi
1669 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2160 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2161 export JAVACFLAGS
1670 2162
1671 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2163 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1672 export JDK_HOME=${JAVA_HOME} 2164 export JDK_HOME=${JAVA_HOME}
1673 2165
1674 #TODO If you know a better solution let us know. 2166 #TODO If you know a better solution let us know.
1675 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2167 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1676 2168
1677 local tann="${T}/announced-vm" 2169 local tann="${T}/announced-vm"
1678 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2170 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1679 # Add a check for setup/preinst phase... to avoid duplicate outputs 2171 # Add a check for setup/preinst phase... to avoid duplicate outputs
1680 # for when FEATURES=buildpkg 2172 # for when FEATURES=buildpkg
1681 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 2173 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1706 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 2198 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1707 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 2199 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1708 echo "and of course, the output of emerge --info" >&2 2200 echo "and of course, the output of emerge --info" >&2
1709} 2201}
1710 2202
2203
2204# TODO document
2205# List jars in the source directory, ${S}
2206java-pkg_jar-list() {
2207 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
2208 einfo "Linked Jars"
2209 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2210 einfo "Jars"
2211 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2212 einfo "Classes"
2213 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2214 fi
2215}
2216
2217# ------------------------------------------------------------------------------
2218# @internal-function java-pkg_verify-classes
2219#
2220# Verify that the classes were compiled for the right source / target. Dies if
2221# not.
2222# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2223# ------------------------------------------------------------------------------
2224java-pkg_verify-classes() {
2225 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2226 local target=$(java-pkg_get-target)
2227 local result
2228 local log="${T}/class-version-verify.log"
2229 if [[ -n "${1}" ]]; then
2230 class-version-verify.py -v -t ${target} "${1}" > "${log}"
2231 result=$?
2232 else
2233 ebegin "Verifying java class versions (target: ${target})"
2234 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2235 result=$?
2236 eend ${result}
2237 fi
2238 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2239 if [[ ${result} != 0 ]]; then
2240 eerror "Incorrect bytecode version found"
2241 [[ -n "${1}" ]] && eerror "in file: ${1}"
2242 eerror "See ${log} for more details."
2243 die "Incorrect bytecode found"
2244 fi
2245}
2246
1711# ------------------------------------------------------------------------------ 2247# ------------------------------------------------------------------------------
1712# @section-end internal 2248# @section-end internal
1713# ------------------------------------------------------------------------------ 2249# ------------------------------------------------------------------------------
1714 2250
1715java-pkg_check-phase() { 2251java-pkg_check-phase() {
1716 local phase=${1} 2252 local phase=${1}
1717 local funcname=${2} 2253 local funcname=${2}
1718 # TODO add check for java-stricter
1719 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 2254 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1720 java-pkg_announce-qa-violation \ 2255 java-pkg_announce-qa-violation \
1721 "${funcname} used outside of src_${phase}" 2256 "${funcname} used outside of src_${phase}"
1722 fi 2257 fi
1723} 2258}
1724 2259
1735 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2270 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1736 fi 2271 fi
1737} 2272}
1738 2273
1739java-pkg_announce-qa-violation() { 2274java-pkg_announce-qa-violation() {
1740 if hasq java-strict ${FEATURES}; then 2275 if is-java-strict; then
1741 echo "Java QA Notice: $@" >&2 2276 echo "Java QA Notice: $@" >&2
1742 increment-qa-violations 2277 increment-qa-violations
1743 fi 2278 fi
1744} 2279}
1745 2280
1746increment-qa-violations() { 2281increment-qa-violations() {
1747 let "JAVA_PKG_QA_VIOLATIONS+=1" 2282 let "JAVA_PKG_QA_VIOLATIONS+=1"
1748 export JAVA_PKG_QA_VIOLATIONS 2283 export JAVA_PKG_QA_VIOLATIONS
1749} 2284}
1750 2285
2286is-java-strict() {
2287 [[ -n ${JAVA_PKG_STRICT} ]]
2288 return $?
2289}
2290
1751# ------------------------------------------------------------------------------ 2291# ------------------------------------------------------------------------------
1752# @eclass-end 2292# @eclass-end
1753# ------------------------------------------------------------------------------ 2293# ------------------------------------------------------------------------------

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.56

  ViewVC Help
Powered by ViewVC 1.1.20