/[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.22 Revision 1.76
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.76 2007/04/20 16:17:49 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
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
27 28
29IUSE="elibc_FreeBSD"
30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
32# Summary of variables which control the behavior of building Java packges. 35# Summary of variables which control the behavior of building Java packges.
33# ----------------------------------------------------------------------------- 36# -----------------------------------------------------------------------------
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# TODO document 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# -----------------------------------------------------------------------------
61# @variable-internal JAVA_PKG_PORTAGE_DEP
62#
63# The version of portage we need to function properly. At this moment it's
64# portage with phase hooks support.
65# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40 67
41# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
43# 70#
44# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
45# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. We also need a recent version
46# portage, that includes phase hooks. 73# portage, that includes phase hooks.
47# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}"
49 76
50# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
52# @variable-default yes 79# @variable-default yes
53# 80#
127# @note This should only be used internally or for testing. 154# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 155# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 156# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 157# -----------------------------------------------------------------------------
131 158
159# -----------------------------------------------------------------------------
160# @variable-external JAVA_PKG_FORCE_ANT_TASKS
161#
162# An $IFS separated list of ant tasks. Can be set in environment before calling
163# emerge/ebuild to override variables set in ebuild, mainly for testing before
164# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
165# eant() call, not the dependencies specified in WANT_ANT_TASKS.
166#
167# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
168# ebuild foo.ebuild compile
169#
170# @seealso WANT_ANT_TASKS
171# -----------------------------------------------------------------------------
172
132# TODO document me 173# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 174JAVA_PKG_QA_VIOLATIONS=0
134 175
135# ----------------------------------------------------------------------------- 176# -----------------------------------------------------------------------------
136# @section-end variables 177# @section-end variables
143# 184#
144# These are used to install Java-related things, such as jars, Javadocs, JNI 185# These are used to install Java-related things, such as jars, Javadocs, JNI
145# libraries, etc. 186# libraries, etc.
146# ----------------------------------------------------------------------------- 187# -----------------------------------------------------------------------------
147 188
189# -----------------------------------------------------------------------------
190# @ebuild-function java-pkg_doexamples
191#
192# Installs given arguments to /usr/share/doc/${PF}/examples
193# If you give it only one parameter and it is a directory it will install
194# everything in that directory to the examples directory.
195#
196# @example
197# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/*
199#
200# @param $* - list of files to install
201# ------------------------------------------------------------------------------
202java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $*
204
205 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206
207 java-pkg_check-phase install
208
209 local dest=/usr/share/doc/${PF}/examples
210 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env
212 insinto "${dest}"
213 doins -r ${1}/*
214 ) || die "Installing examples failed"
215 else
216 ( # dont want to pollute calling env
217 insinto "${dest}"
218 doins -r "$@"
219 ) || die "Installing examples failed"
220 fi
221}
148 222
149# ----------------------------------------------------------------------------- 223# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 224# @ebuild-function java-pkg_dojar
151# 225#
152# Installs any number of jars. 226# Installs any number of jars.
171 # Create JARDEST if it doesn't exist 245 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 246 dodir ${JAVA_PKG_JARDEST}
173 247
174 local jar 248 local jar
175 # for each jar 249 # for each jar
176 for jar in "$@"; do 250 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 251 local jar_basename=$(basename "${jar}")
178 252
179 java-pkg_check-versioned-jar ${jar_basename} 253 java-pkg_check-versioned-jar ${jar_basename}
180 254
181 # check if it exists 255 # check if it exists
182 if [[ -e "${jar}" ]] ; then 256 if [[ -e "${jar}" ]] ; then
257 # Don't overwrite if jar has already been installed with the same
258 # name
259 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
260 if [[ -e "${dest}" ]]; then
261 ewarn "Overwriting ${dest}"
262 fi
263
183 # install it into JARDEST if it's a non-symlink 264 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 265 if [[ ! -L "${jar}" ]] ; then
266 #but first check class version when in strict mode.
267 is-java-strict && java-pkg_verify-classes "${jar}"
268
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 269 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 270 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 271 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
188 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 272 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
189 # make a symlink to the original jar if it's symlink 273 # make a symlink to the original jar if it's symlink
200 284
201 java-pkg_do_write_ 285 java-pkg_do_write_
202} 286}
203 287
204 288
289# ------------------------------------------------------------------------------
290# @internal-function depend-java-query
291#
292# Wrapper for the depend-java-query binary to enable passing USE in env.
293# Using env variables keeps this eclass working with java-config versions that
294# do not handle use flags.
295# ------------------------------------------------------------------------------
296
297depend-java-query() {
298 # Used to have a which call here but it caused endless loops for some people
299 # that had some weird bashrc voodoo for which.
300 USE="${USE}" /usr/bin/depend-java-query "${@}"
301}
205 302
206# ------------------------------------------------------------------------------ 303# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 304# @ebuild-function java-pkg_regjar
208# 305#
209# Records an already installed jar in the package.env 306# Records an already installed jar in the package.env
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 337 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 338
242 java-pkg_init_paths_ 339 java-pkg_init_paths_
243 340
244 local jar jar_dir jar_file 341 local jar jar_dir jar_file
245 for jar in "$@"; do 342 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 343 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 344 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
345 [[ -d "${jar}" || -d "${D}${jar}" ]] \
346 && die "Called ${FUNCNAME} on a directory $*"
347
348 #check that class version correct when in strict mode
349 is-java-strict && java-pkg_verify-classes "${jar}"
350
248 # nelchael: we should strip ${D} in this case too, here's why: 351 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 352 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 353 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 354 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 355 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 356 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 357 else
358 if [[ ${jar} = *\** ]]; then
359 eerror "The argument ${jar} to ${FUNCNAME}"
360 eerror "has * in it. If you want it to glob in"
361 eerror '${D} add ${D} to the argument.'
362 fi
257 die "${jar} does not exist" 363 die "${jar} does not exist"
258 fi 364 fi
259 done 365 done
260 366
261 java-pkg_do_write_ 367 java-pkg_do_write_
262} 368}
263
264 369
265# ------------------------------------------------------------------------------ 370# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 371# @ebuild-function java-pkg_newjar
267# 372#
268# Installs a jar with a new name 373# Installs a jar with a new name
279 local original_jar="${1}" 384 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 385 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 386 local new_jar_dest="${T}/${new_jar}"
282 387
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 388 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 389 [[ ! -f ${original_jar} ]] \
390 && die "${original_jar} does not exist or is not a file!"
285 391
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 392 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 393 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 394 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 395 java-pkg_dojar "${new_jar_dest}"
290} 396}
291 397
292
293# ------------------------------------------------------------------------------ 398# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 399# @ebuild-function java-pkg_addcp
295# 400#
296# Add something to the package's classpath. For jars, you should use dojar, 401# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 402# newjar, or regjar. This is typically used to add directories to the classpath.
301# ------------------------------------------------------------------------------ 406# ------------------------------------------------------------------------------
302java-pkg_addcp() { 407java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 408 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 409 java-pkg_do_write_
305} 410}
306
307 411
308# ------------------------------------------------------------------------------ 412# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 413# @ebuild-function java-pkg_doso
310# 414#
311# Installs any number of JNI libraries 415# Installs any number of JNI libraries
340 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 444 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
341 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 445 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
342 # otherwise make a symlink to the symlink's origin 446 # otherwise make a symlink to the symlink's origin
343 else 447 else
344 # TODO use dosym 448 # TODO use dosym
449 ln -s "$(readlink "${lib}")" \
345 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 450 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
346 debug-print "${lib} is a symlink, linking accordanly" 451 debug-print "${lib} is a symlink, linking accordanly"
347 fi 452 fi
348 # otherwise die 453 # otherwise die
349 else 454 else
350 die "${lib} does not exist" 455 die "${lib} does not exist"
428# ------------------------------------------------------------------------------ 533# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 534java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 535 debug-print-function ${FUNCNAME} $*
431 536
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 537 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 538
539 # from /usr/lib/portage/bin/dohtml -h
540 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 541 dohtml -f package-list "$@"
542
435 # this probably shouldn't be here but it provides 543 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 544 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 545 # old ebuilds.
438 java-pkg_recordjavadoc 546 java-pkg_recordjavadoc
439} 547}
440 548
441# TODO document 549# ------------------------------------------------------------------------------
550# @ebuild-function java-pkg_dojavadoc
551#
552# Installs javadoc documentation. This should be controlled by the doc use flag.
553#
554# @param $1: - The javadoc root directory.
555#
556# @example:
557# java-pkg_dojavadoc docs/api
558#
559# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 560java-pkg_dojavadoc() {
561 debug-print-function ${FUNCNAME} $*
443 local dir="$1" 562 local dir="$1"
563
564 # QA checks
444 565
445 java-pkg_check-phase install 566 java-pkg_check-phase install
446 567
447 [[ -z "${dir}" ]] && die "Must specify a directory!" 568 [[ -z "${dir}" ]] && die "Must specify a directory!"
448 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 569 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
570 if [[ ! -e "${dir}/index.html" ]]; then
571 local msg="No index.html in javadoc directory"
572 ewarn "${msg}"
573 is-java-strict && die "${msg}"
574 fi
575
576 # Renaming to match our directory layout
449 577
450 local dir_to_install="${dir}" 578 local dir_to_install="${dir}"
451 if [[ "$(basename "${dir}")" != "api" ]]; then 579 if [[ "$(basename "${dir}")" != "api" ]]; then
452 dir_to_install="${T}/api" 580 dir_to_install="${T}/api"
453 # TODO use doins 581 # TODO use doins
454 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 582 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
455 fi 583 fi
584
585 # Actual installation
456 586
457 java-pkg_dohtml -r ${dir_to_install} 587 java-pkg_dohtml -r ${dir_to_install}
458} 588}
459 589
460# ------------------------------------------------------------------------------ 590# ------------------------------------------------------------------------------
478# FIXME apparently this fails if you give it an empty directories 608# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 609java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 610 debug-print-function ${FUNCNAME} $*
481 611
482 [ ${#} -lt 1 ] && die "At least one argument needed" 612 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi
486 613
487 java-pkg_check-phase install 614 java-pkg_check-phase install
488 615
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 616 [[ ${#} -lt 1 ]] && die "At least one argument needed"
617
618 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
619 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
620 if is-java-strict; then
621 eerror "${msg}"
622 die "${msg}"
623 else
624 echo "${msg}"
625 echo "Please report this to http://bugs.gentoo.org."
626 fi
627 fi
490 628
491 java-pkg_init_paths_ 629 java-pkg_init_paths_
492 630
493 local zip_name="${PN}-src.zip" 631 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 632 local zip_path="${T}/${zip_name}"
495 local dir 633 local dir
496 for dir in ${@}; do 634 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 635 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 636 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 637 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 638 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 639 local result=$?
518# @ebuild-function java-pkg_dolauncher 656# @ebuild-function java-pkg_dolauncher
519# 657#
520# Make a wrapper script to lauch/start this package 658# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 659# If necessary, the wrapper will switch to the appropriate VM.
522# 660#
661# Can be called without parameters if the package installs only one jar
662# that has the Main-class attribute set. The wrapper will be named ${PN}.
663#
523# @param $1 - filename of launcher to create 664# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 665# @param $2 - options, as follows:
525# --main the.main.class.too.start 666# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 667# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 668# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 669# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 670# --pwd Directory the launcher changes to before executing java
530# -into 671# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 672# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 673# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 674java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 675 debug-print-function ${FUNCNAME} $*
535 676
536 java-pkg_check-phase install 677 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 678 java-pkg_init_paths_
541 679
680 if [[ ${#} = 0 ]]; then
681 local name="${PN}"
682 else
542 local name="${1}" 683 local name="${1}"
684 shift
685 fi
686
543 # TODO rename to launcher 687 # TODO rename to launcher
544 local target="${T}/${name}" 688 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 689 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 690 local target_dir pre
547 shift
548 691
549 # Process the other the rest of the arguments 692 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 693 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 694 local var="${1}" value="${2}"
552 if [[ "${var:0:2}" == "--" ]]; then 695 if [[ "${var:0:2}" == "--" ]]; then
696 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 697 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
698 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 699 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 700 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 701 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 702 pre="${value}"
558 fi 703 fi
559 shift 2 704 shift 2
560 done 705 done
561 706
707 # Test if no --jar and --main arguments were given and
708 # in that case check if the package only installs one jar
709 # and use that jar.
710 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
711 local cp="${JAVA_PKG_CLASSPATH}"
712 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
713 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
714 else
715 local msg="Not enough information to create a launcher given."
716 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
717 die "${msg}"
718 fi
719 fi
720
562 # Write the actual script 721 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 722 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 723 if [[ -n "${pre}" ]]; then
724 if [[ -f "${pre}" ]]; then
725 cat "${pre}" >> "${target}"
726 else
727 die "-pre specified file '${pre}' does not exist"
728 fi
729 fi
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 730 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
566 cat "${var_tmp}" >> "${target}" 731 cat "${var_tmp}" >> "${target}"
567 rm -f "${var_tmp}" 732 rm -f "${var_tmp}"
568 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 733 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
569 734
661# Example: get a specific jar from xerces slot 2, and name it diffrently 826# Example: get a specific jar from xerces slot 2, and name it diffrently
662# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 827# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
663# Example: get junit.jar which is needed only for building 828# Example: get junit.jar which is needed only for building
664# java-pkg_jar-from --build-only junit junit.jar 829# java-pkg_jar-from --build-only junit junit.jar
665# 830#
666# @param $1 - (optional) "--build-only" makes the jar(s) not added into 831# @param $opt
667# package.env DEPEND line. 832# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies
835# transitively.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of .
668# @param $1 - Package to get jars from. 837# @param $1 - Package to get jars from.
669# @param $2 - jar from package. If not specified, all jars will be used. 838# @param $2 - jar from package. If not specified, all jars will be used.
670# @param $3 - When a single jar is specified, destination filename of the 839# @param $3 - When a single jar is specified, destination filename of the
671# symlink. Defaults to the name of the jar. 840# symlink. Defaults to the name of the jar.
672# ------------------------------------------------------------------------------ 841# ------------------------------------------------------------------------------
673# TODO could probably be cleaned up a little 842# TODO could probably be cleaned up a little
674java-pkg_jar-from() { 843java-pkg_jar-from() {
675 debug-print-function ${FUNCNAME} $* 844 debug-print-function ${FUNCNAME} $*
676 845
677 local build_only="" 846 local build_only=""
847 local destdir="."
848 local deep=""
678 849
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
851
852 while [[ "${1}" == --* ]]; do
679 if [[ "${1}" = "--build-only" ]]; then 853 if [[ "${1}" = "--build-only" ]]; then
680 build_only="true" 854 build_only="true"
855 elif [[ "${1}" = "--with-dependencies" ]]; then
856 deep="--with-dependencies"
857 elif [[ "${1}" = "--into" ]]; then
858 destdir="${2}"
859 shift
860 else
861 die "java-pkg_jar-from called with unknown parameter: ${1}"
862 fi
681 shift 863 shift
682 fi 864 done
683 865
684 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 866 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
685 867
686 [[ -z ${target_pkg} ]] && die "Must specify a package" 868 [[ -z ${target_pkg} ]] && die "Must specify a package"
687 869
688 # default destjar to the target jar 870 # default destjar to the target jar
689 [[ -z "${destjar}" ]] && destjar="${target_jar}" 871 [[ -z "${destjar}" ]] && destjar="${target_jar}"
690 872
691 local error_msg="There was a problem getting the classpath for ${target_pkg}." 873 local error_msg="There was a problem getting the classpath for ${target_pkg}."
692 local classpath 874 local classpath
693 classpath="$(java-config --classpath=${target_pkg})" 875 classpath="$(java-config ${deep} --classpath=${target_pkg})"
694 [[ $? != 0 ]] && die ${error_msg} 876 [[ $? != 0 ]] && die ${error_msg}
877
878 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
879
880 pushd ${destdir} > /dev/null \
881 || die "failed to change directory to ${destdir}"
882
883 # When we have commas this functions is called to bring jars from multiple
884 # packages. This affects recording of dependencencies because that syntax uses :
885 # if we don't change them to : gjl and java-config -d -p break
886 if [[ ${target_pkg} = *,* ]]; then
887 build_only="true"
888 java-pkg_record-jar_ ${target_pkg//,/:}
889 fi
695 890
696 local jar 891 local jar
697 for jar in ${classpath//:/ }; do 892 for jar in ${classpath//:/ }; do
698 local jar_name=$(basename "${jar}") 893 local jar_name=$(basename "${jar}")
699 if [[ ! -f "${jar}" ]] ; then 894 if [[ ! -f "${jar}" ]] ; then
710 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 905 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
711 [[ -f "${destjar}" ]] && rm "${destjar}" 906 [[ -f "${destjar}" ]] && rm "${destjar}"
712 ln -snf "${jar}" "${destjar}" \ 907 ln -snf "${jar}" "${destjar}" \
713 || die "Failed to make symlink from ${jar} to ${destjar}" 908 || die "Failed to make symlink from ${jar} to ${destjar}"
714 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 909 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
910 popd > /dev/null
715 return 0 911 return 0
716 fi 912 fi
717 done 913 done
914 popd > /dev/null
718 # if no target was specified, we're ok 915 # if no target was specified, we're ok
719 if [[ -z "${target_jar}" ]] ; then 916 if [[ -z "${target_jar}" ]] ; then
720 return 0 917 return 0
721 # otherwise, die bitterly 918 # otherwise, die bitterly
722 else 919 else
741# The providing packages are recorded as dependencies into package.env DEPEND 938# The providing packages are recorded as dependencies into package.env DEPEND
742# line, unless "--build-only" is passed as the very first argument, for jars 939# line, unless "--build-only" is passed as the very first argument, for jars
743# that have to be present only at build time and are not needed on runtime 940# that have to be present only at build time and are not needed on runtime
744# (junit testing etc). 941# (junit testing etc).
745# 942#
746# Example: Get the classpath for xerces-2, 943# Example: Get the classpath for xerces-2 and xalan,
747# java-pkg_getjars xerces-2 xalan 944# java-pkg_getjars xerces-2,xalan
748# Example Return: 945# Example Return:
749# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 946# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
750# 947#
751# @param $1 - (optional) "--build-only" makes the jar(s) not added into 948# @param $opt
752# package.env DEPEND line. 949# --build-only - makes the jar(s) not added into package.env DEPEND line.
950# (assumed automatically when called inside src_test)
951# --with-dependencies - get jars also from requested package's dependencies
952# transitively.
753# @param $@ - list of packages to get jars from 953# @param $1 - list of packages to get jars from
954# (passed to java-config --classpath)
754# ------------------------------------------------------------------------------ 955# ------------------------------------------------------------------------------
755java-pkg_getjars() { 956java-pkg_getjars() {
756 debug-print-function ${FUNCNAME} $* 957 debug-print-function ${FUNCNAME} $*
757 958
758 local build_only="" 959 local build_only=""
960 local deep=""
759 961
962 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
963
964 while [[ "${1}" == --* ]]; do
760 if [[ "${1}" = "--build-only" ]]; then 965 if [[ "${1}" = "--build-only" ]]; then
761 build_only="true" 966 build_only="true"
967 elif [[ "${1}" = "--with-dependencies" ]]; then
968 deep="--with-dependencies"
969 else
970 die "java-pkg_jar-from called with unknown parameter: ${1}"
971 fi
762 shift 972 shift
763 fi
764
765 [[ ${#} -lt 1 ]] && die "At least one argument needed"
766
767 # NOTE could probably just pass $@ to java-config --classpath. and return it
768 local classpath pkg
769 for pkg in ${@//,/ }; do
770 #for pkg in $(echo "$@" | tr ',' ' '); do
771 jars="$(java-config --classpath=${pkg})"
772 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed"
773 debug-print "${pkg}:${jars}"
774
775 if [[ -z "${classpath}" ]]; then
776 classpath="${jars}"
777 else
778 classpath="${classpath}:${jars}"
779 fi
780 # Only record jars that aren't build-only
781 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
782 done 973 done
974
975 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
976
977
978 local classpath pkgs="${1}"
979 jars="$(java-config ${deep} --classpath=${pkgs})"
980 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
981 debug-print "${pkgs}:${jars}"
982
983 for pkg in ${pkgs//,/ }; do
984 java-pkg_ensure-dep "${build_only}" "${pkg}"
985 done
986
987 if [[ -z "${classpath}" ]]; then
988 classpath="${jars}"
989 else
990 classpath="${classpath}:${jars}"
991 fi
992
993 # Only record jars that aren't build-only
994 if [[ -z "${build_only}" ]]; then
995 oldifs="${IFS}"
996 IFS=","
997 for pkg in ${pkgs}; do
998 java-pkg_record-jar_ "${pkg}"
999 done
1000 IFS="${oldifs}"
1001 fi
1002
783 echo "${classpath}" 1003 echo "${classpath}"
784} 1004}
785 1005
786# ------------------------------------------------------------------------------ 1006# ------------------------------------------------------------------------------
787# @ebuild-function java-pkg_getjar 1007# @ebuild-function java-pkg_getjar
795# @example 1015# @example
796# java-pkg_getjar xerces-2 xml-apis.jar 1016# java-pkg_getjar xerces-2 xml-apis.jar
797# @example-return 1017# @example-return
798# /usr/share/xerces-2/lib/xml-apis.jar 1018# /usr/share/xerces-2/lib/xml-apis.jar
799# 1019#
800# @param $1 - (optional) "--build-only" makes the jar not added into 1020# @param $opt
801# package.env DEPEND line. 1021# --build-only - makes the jar not added into package.env DEPEND line.
802# @param $1 - package to use 1022# @param $1 - package to use
803# @param $2 - jar to get 1023# @param $2 - jar to get
804# ------------------------------------------------------------------------------ 1024# ------------------------------------------------------------------------------
805java-pkg_getjar() { 1025java-pkg_getjar() {
806 debug-print-function ${FUNCNAME} $* 1026 debug-print-function ${FUNCNAME} $*
807 1027
808 local build_only="" 1028 local build_only=""
809 1029
1030 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
1031
1032 while [[ "${1}" == --* ]]; do
810 if [[ "${1}" = "--build-only" ]]; then 1033 if [[ "${1}" = "--build-only" ]]; then
811 build_only="true" 1034 build_only="true"
1035 else
1036 die "java-pkg_jar-from called with unknown parameter: ${1}"
1037 fi
812 shift 1038 shift
813 fi 1039 done
1040
1041 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
814 1042
815 local pkg="${1}" target_jar="${2}" jar 1043 local pkg="${1}" target_jar="${2}" jar
816 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1044 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
817 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1045 [[ -z ${target_jar} ]] && die "Must specify jar to get"
818 1046
819 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?" 1047 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
820 local classpath 1048 local classpath
821 classpath=$(java-config --classpath=${pkg}) 1049 classpath=$(java-config --classpath=${pkg})
822 [[ $? != 0 ]] && die ${error_msg} 1050 [[ $? != 0 ]] && die ${error_msg}
1051
1052 java-pkg_ensure-dep "${build_only}" "${pkg}"
823 1053
824 for jar in ${classpath//:/ }; do 1054 for jar in ${classpath//:/ }; do
825 if [[ ! -f "${jar}" ]] ; then 1055 if [[ ! -f "${jar}" ]] ; then
826 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1056 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
827 fi 1057 fi
960# 1190#
961# export DEPEND="${DEPEND} ${depstr}" 1191# export DEPEND="${DEPEND} ${depstr}"
962# export RDEPEND="${RDEPEND} ${depstr}" 1192# export RDEPEND="${RDEPEND} ${depstr}"
963#} 1193#}
964 1194
1195# ------------------------------------------------------------------------------
1196# @ebuild-function java-pkg_find-normal-jars
1197#
1198# Find the files with suffix .jar file in the given directory or $WORKDIR
1199#
1200# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1201# ------------------------------------------------------------------------------
1202java-pkg_find-normal-jars() {
1203 local dir=$1
1204 [[ "${dir}" ]] || dir="${WORKDIR}"
1205 local found
1206 for jar in $(find "${dir}" -name "*.jar" -type f); do
1207 echo "${jar}"
1208 found="true"
1209 done
1210 [[ "${found}" ]]
1211 return $?
1212}
1213
1214# ------------------------------------------------------------------------------
1215# @ebuild-function java-pkg_ensure-no-bundled-jars
1216#
1217# Try to locate bundled jar files in ${WORKDIR} and die if found.
965# This should be used after S has been populated with symlinks to jars 1218# This function should be called after WORKDIR has been populated with symlink
966# TODO document 1219# to system jar files or bundled jars removed.
1220# ------------------------------------------------------------------------------
967java-pkg_ensure-no-bundled-jars() { 1221java-pkg_ensure-no-bundled-jars() {
968 debug-print-function ${FUNCNAME} $* 1222 debug-print-function ${FUNCNAME} $*
969 pushd ${WORKDIR} >/dev/null 2>/dev/null
970 1223
971 local bundled_jars=$(find . -name "*.jar" -type f) 1224 local bundled_jars=$(java-pkg_find-normal-jars)
972 if [[ -n ${bundled_jars} ]]; then 1225 if [[ -n ${bundled_jars} ]]; then
973 echo "Bundled jars found:" 1226 echo "Bundled jars found:"
974 local jar 1227 local jar
975 for jar in ${bundled_jars}; do 1228 for jar in ${bundled_jars}; do
976 echo $(pwd)${jar/./} 1229 echo $(pwd)${jar/./}
977 done 1230 done
978 die "Bundled jars found!" 1231 die "Bundled jars found!"
979
980 fi 1232 fi
981 popd >/dev/null 2>/dev/null
982} 1233}
983 1234
984# ------------------------------------------------------------------------------ 1235# ------------------------------------------------------------------------------
985# @internal-function java-pkg_ensure-vm-version-sufficient 1236# @internal-function java-pkg_ensure-vm-version-sufficient
986# 1237#
1135# @ebuild-function java-pkg_get-target 1386# @ebuild-function java-pkg_get-target
1136# 1387#
1137# Determines what target version should be used, for passing to -target. 1388# Determines what target version should be used, for passing to -target.
1138# If you don't care about lower versions, you can set _WANT_TARGET to the 1389# If you don't care about lower versions, you can set _WANT_TARGET to the
1139# version of your JDK. 1390# version of your JDK.
1140# Remember doing this will mostly like cause things to break.
1141# Doesn't allow it to be lower then the one in depend.
1142# Doesn't allow it to be higher then the active vm.
1143# 1391#
1144# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1392# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1145# ------------------------------------------------------------------------------ 1393# ------------------------------------------------------------------------------
1146java-pkg_get-target() { 1394java-pkg_get-target() {
1147 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1148 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1149 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1150 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1151 echo ${JAVA_PKG_WANT_TARGET}
1152 else
1153 echo ${min}
1154 fi
1155 else
1156 echo ${min}
1157 fi
1158
1159 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1395 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1160} 1396}
1161 1397
1162java-pkg_get-javac() { 1398java-pkg_get-javac() {
1163 debug-print-function ${FUNCNAME} $* 1399 debug-print-function ${FUNCNAME} $*
1164 1400
1165 java-pkg_init-compiler_ 1401
1166 local compiler="${GENTOO_COMPILER}" 1402 local compiler="${GENTOO_COMPILER}"
1167 1403
1168 local compiler_executable 1404 local compiler_executable
1169 if [[ "${compiler}" = "javac" ]]; then 1405 if [[ "${compiler}" = "javac" ]]; then
1170 # nothing fancy needs to be done for javac 1406 # nothing fancy needs to be done for javac
1178 unset JAVAC 1414 unset JAVAC
1179 # try to get value of JAVAC 1415 # try to get value of JAVAC
1180 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1416 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1181 export JAVAC=${old_javac} 1417 export JAVAC=${old_javac}
1182 1418
1183 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1419 if [[ -z ${compiler_executable} ]]; then
1420 echo "JAVAC is empty or undefined in ${compiler_env}"
1421 return 1
1422 fi
1184 1423
1185 # check that it's executable 1424 # check that it's executable
1186 if [[ ! -x ${compiler_executable} ]]; then 1425 if [[ ! -x ${compiler_executable} ]]; then
1187 eerror "Could not find ${compiler_executable}!"
1188 die "${compiler_executable} doesn't exist, or isn't executable" 1426 echo "${compiler_executable} doesn't exist, or isn't executable"
1427 return 1
1189 fi 1428 fi
1190 else 1429 else
1191 eerror "Could not find environment file for ${compiler}" 1430 echo "Could not find environment file for ${compiler}"
1192 die "Could not find ${compiler_env}" 1431 return 1
1193 fi 1432 fi
1194 fi 1433 fi
1195 echo ${compiler_executable} 1434 echo ${compiler_executable}
1196} 1435}
1197 1436
1214 1453
1215 debug-print "want source: ${want_source}" 1454 debug-print "want source: ${want_source}"
1216 debug-print "want target: ${want_target}" 1455 debug-print "want target: ${want_target}"
1217 1456
1218 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1457 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1219 debug-print "could not find valid -source/-target values" 1458 debug-print "could not find valid -source/-target values for javac"
1220 die "Could not find valid -source/-target values" 1459 echo "Could not find valid -source/-target values for javac"
1460 return 1
1221 else 1461 else
1222 if java-pkg_is-vm-version-ge "1.4"; then 1462 if java-pkg_is-vm-version-ge "1.4"; then
1223 echo "${source_str} ${target_str}" 1463 echo "${source_str} ${target_str}"
1224 else 1464 else
1225 echo "${target_str}" 1465 echo "${target_str}"
1229 1469
1230# TODO document 1470# TODO document
1231java-pkg_get-jni-cflags() { 1471java-pkg_get-jni-cflags() {
1232 local flags="-I${JAVA_HOME}/include" 1472 local flags="-I${JAVA_HOME}/include"
1233 1473
1474 local platform="linux"
1475 use elibc_FreeBSD && platform="freebsd"
1476
1234 # TODO do a check that the directories are valid 1477 # TODO do a check that the directories are valid
1235 # TODO figure out how to cope with other things than linux...
1236 flags="${flags} -I${JAVA_HOME}/include/linux" 1478 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1237 1479
1238 echo ${flags} 1480 echo ${flags}
1239} 1481}
1240 1482
1241java-pkg_ensure-gcj() { 1483java-pkg_ensure-gcj() {
1247 die "No GCJ support found!" 1489 die "No GCJ support found!"
1248 fi 1490 fi
1249} 1491}
1250 1492
1251java-pkg_ensure-test() { 1493java-pkg_ensure-test() {
1252 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1494 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1495 && hasq test ${IUSE} && ! use test;
1496 then
1253 eerror "You specified FEATURES=test, but USE=test is needed" 1497 eerror "You specified FEATURES=test, but USE=test is needed"
1254 eerror "to pull in the additional dependencies for testing" 1498 eerror "to pull in the additional dependencies for testing"
1255 die "Need USE=test enabled" 1499 die "Need USE=test enabled"
1256 fi 1500 fi
1257} 1501}
1258 1502
1259# ------------------------------------------------------------------------------ 1503# ------------------------------------------------------------------------------
1504# @ebuild-function java-pkg_register-ant-task
1505#
1506# Register this package as ant task, so that ant will load it when no specific
1507# ANT_TASKS are specified. Note that even without this registering, all packages
1508# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1509# packages, but can be also used by other ebuilds that used to symlink their
1510# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1511# compatibility.
1512#
1513# @param --version x.y Register only for ant version x.y (otherwise for any ant
1514# version). Used by the ant-* packages to prevent loading of mismatched
1515# ant-core ant tasks after core was updated, before the tasks are updated,
1516# without a need for blockers.
1517# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1518# ------------------------------------------------------------------------------
1519java-pkg_register-ant-task() {
1520 local TASKS_DIR="tasks"
1521
1522 # check for --version x.y parameters
1523 while [[ -n "${1}" && -n "${2}" ]]; do
1524 local var="${1#--}"
1525 local val="${2}"
1526 if [[ "${var}" == "version" ]]; then
1527 TASKS_DIR="tasks-${val}"
1528 else
1529 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1530 fi
1531 shift 2
1532 done
1533
1534 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1535
1536 dodir /usr/share/ant/${TASKS_DIR}
1537 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1538}
1539
1540# ------------------------------------------------------------------------------
1541# @internal-function java-pkg_ant-tasks-from-deps
1542#
1543# Function to determine ANT_TASKS from DEPEND variable for backwards
1544# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1545# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1546# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1547# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1548# be a problem, the worst it can do is activace all tasks when not needed.
1549# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1550# insufficient dependencies, otherwise all available tasks are used for
1551# backwards compatilbility.
1552#
1553# @return "all" or "none"
1554# ------------------------------------------------------------------------------
1555java-pkg_ant-tasks-from-deps() {
1556 local found_ant found_ant_tasks
1557
1558 for dep in ${DEPEND}
1559 do
1560 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1561 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1562 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1563 done
1564
1565 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1566 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1567 echo "all"
1568 else
1569 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1570 # so we deactivate all tasks that may be installed
1571 echo "none"
1572 fi
1573}
1574
1575# ------------------------------------------------------------------------------
1576# @internal-function java-pkg_ant-tasks-depend
1577#
1578# Translates the WANT_ANT_TASKS variable into valid dependencies.
1579# ------------------------------------------------------------------------------
1580java-pkg_ant-tasks-depend() {
1581 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1582
1583 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1584 local DEP=""
1585 for i in ${WANT_ANT_TASKS}
1586 do
1587 if [[ ${i} != ant-* ]]; then
1588 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1589 return 1
1590 fi
1591 DEP="${DEP}dev-java/${i} "
1592 done
1593 echo ${DEP}
1594 return 0
1595 else
1596 return 0
1597 fi
1598}
1599
1600# ------------------------------------------------------------------------------
1260# @section-end helper 1601# @section-end helper
1261# ------------------------------------------------------------------------------ 1602# ------------------------------------------------------------------------------
1262 1603
1263# ------------------------------------------------------------------------------ 1604# ------------------------------------------------------------------------------
1264# @section-begin build 1605# @section-begin build
1270 1611
1271# ------------------------------------------------------------------------------ 1612# ------------------------------------------------------------------------------
1272# @ebuild-function eant 1613# @ebuild-function eant
1273# 1614#
1274# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1615# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1275# compiler. 1616# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1276# 1617# variables:
1618# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1619# gentoo.classpath property. Be sure to call
1620# java-ant_rewrite-classpath in src_unpack.
1621# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1277# ------------------------------------------------------------------------------ 1622# ------------------------------------------------------------------------------
1278eant() { 1623eant() {
1279 debug-print-function ${FUNCNAME} $* 1624 debug-print-function ${FUNCNAME} $*
1280 1625
1281 # FIXME get this working 1626 # FIXME get this working
1282# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1627# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1283# java-pkg_announce-qa-violation \ 1628# java-pkg_announce-qa-violation \
1284# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1629# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1285# fi 1630# fi
1286 1631
1287 local antflags 1632 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1633 local msg="You should inherit java-ant-2 when using eant"
1634 java-pkg_announce-qa-violation ${msg}
1635 die ${msg}
1636 fi
1637
1638 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1639
1288 java-pkg_init-compiler_ 1640 java-pkg_init-compiler_
1289 local compiler="${GENTOO_COMPILER}" 1641 local compiler="${GENTOO_COMPILER}"
1290 1642
1291 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1643 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1292 1644
1294 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1646 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1295 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1647 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1296 fi 1648 fi
1297 1649
1298 if [[ ${compiler} != "javac" ]]; then 1650 if [[ ${compiler} != "javac" ]]; then
1299 antflags="-Dbuild.compiler=${build_compiler}" 1651 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1300 # Figure out any extra stuff to put on the classpath for compilers aside 1652 # Figure out any extra stuff to put on the classpath for compilers aside
1301 # from javac 1653 # from javac
1302 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1654 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1303 # java-config -p 1655 # java-config -p
1304 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1656 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1310 if is-java-strict; then 1662 if is-java-strict; then
1311 einfo "Disabling system classpath for ant" 1663 einfo "Disabling system classpath for ant"
1312 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1664 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1313 fi 1665 fi
1314 1666
1315 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1667 for arg in "${@}"; do
1316 antflags="${antflags} -debug" 1668 if [[ ${arg} = -lib ]]; then
1669 if is-java-strict; then
1670 eerror "You should not use the -lib argument to eant because it will fail"
1671 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1672 eerror "or ant properties to make dependencies available."
1673 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1674 eerror "split ant (>=dev-java/ant-core-1.7)."
1675 die "eant -lib is deprecated/forbidden"
1676 else
1677 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1678 echo "more info."
1679 fi
1680 fi
1681 done
1682
1683 if has_version ">=dev-java/ant-core-1.7.0"; then
1684 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1685 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1686
1687 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1688 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1689
1690 if is-java-strict; then
1691 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1692 if [[ -z "${ANT_TASKS}" ]]; then
1693 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1694 fi
1695 else
1696 # if ant-tasks is not set by ebuild or forced, activate all of them
1697 ANT_TASKS="${ANT_TASKS:-all}"
1698 fi
1699
1700 # at this point, ANT_TASKS should be "all", "none" or explicit list
1701 if [[ "${ANT_TASKS}" == "all" ]]; then
1702 einfo "Using all available ANT_TASKS"
1703 elif [[ "${ANT_TASKS}" == "none" ]]; then
1704 einfo "Disabling all optional ANT_TASKS"
1705 else
1706 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1707 fi
1708
1709 export ANT_TASKS
1710 fi
1711
1712 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1713 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1714
1715 local gcp="${EANT_GENTOO_CLASSPATH}"
1716 local getjarsarg=""
1717
1718 if [[ ${EBUILD_PHASE} = "test" ]]; then
1719 antflags="${antflags} -DJunit.present=true"
1720 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1721 getjarsarg="--with-dependencies"
1722 fi
1723
1724 local cp
1725
1726 for atom in ${gcp}; do
1727 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1728 done
1729
1730 if [[ ${cp} ]]; then
1731 # It seems ant does not like single quotes around ${cp}
1732 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1317 fi 1733 fi
1318 1734
1319 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1735 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1736 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1320 ant ${antflags} "${@}" || die "eant failed" 1737 ant ${antflags} "${@}" || die "eant failed"
1321
1322} 1738}
1323 1739
1324# ------------------------------------------------------------------------------ 1740# ------------------------------------------------------------------------------
1325# @ebuild-function ejavac 1741# @ebuild-function ejavac
1326# 1742#
1330# @param $@ - Arguments to be passed to the compiler 1746# @param $@ - Arguments to be passed to the compiler
1331# ------------------------------------------------------------------------------ 1747# ------------------------------------------------------------------------------
1332ejavac() { 1748ejavac() {
1333 debug-print-function ${FUNCNAME} $* 1749 debug-print-function ${FUNCNAME} $*
1334 1750
1335 # FIXME using get-javac ends up printing stuff with einfo 1751 java-pkg_init-compiler_
1752
1753 local compiler_executable
1336# local compiler_executable=$(java-pkg_get-javac) 1754 compiler_executable=$(java-pkg_get-javac)
1337 local compiler_executable="javac" 1755 if [[ ${?} != 0 ]]; then
1756 eerror "There was a problem determining compiler: ${compiler_executable}"
1757 die "get-javac failed"
1758 fi
1338 1759
1760 local javac_args
1761 javac_args="$(java-pkg_javac-args)"
1762 if [[ ${?} != 0 ]]; then
1763 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1764 die "java-pkg_javac-args failed"
1765 fi
1766
1339 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1767 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1340 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1768 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1341} 1769}
1342 1770
1343# ------------------------------------------------------------------------------ 1771# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_filter-compiler 1772# @ebuild-function java-pkg_filter-compiler
1345# 1773#
1383# ------------------------------------------------------------------------------ 1811# ------------------------------------------------------------------------------
1384use_doc() { 1812use_doc() {
1385 use doc && echo ${@:-javadoc} 1813 use doc && echo ${@:-javadoc}
1386} 1814}
1387 1815
1816
1388# ------------------------------------------------------------------------------ 1817# ------------------------------------------------------------------------------
1389# @section-end build 1818# @section-end build
1390# ------------------------------------------------------------------------------ 1819# ------------------------------------------------------------------------------
1391 1820
1392# ------------------------------------------------------------------------------ 1821# ------------------------------------------------------------------------------
1410# 1839#
1411# ----------------------------------------------------------------------------- 1840# -----------------------------------------------------------------------------
1412java-pkg_init() { 1841java-pkg_init() {
1413 unset JAVAC 1842 unset JAVAC
1414 unset JAVA_HOME 1843 unset JAVA_HOME
1844
1845 # People do all kinds of weird things.
1846 # http://forums.gentoo.org/viewtopic-p-3943166.html
1847 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
1848 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
1849 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
1850 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
1851 ewarn "sun-jdk vms and and as such break configure scripts that"
1852 ewarn "use it (for example app-office/openoffice) so we filter it out."
1853 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
1854 ewarn "make.conf for example) to silence this warning or"
1855 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1856 fi
1857
1858 if [[ -z ${accept} ]]; then
1859 unset _JAVA_OPTIONS
1860 # phase hooks make this run many times without this
1861 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1862 fi
1863
1415 java-pkg_init_paths_ 1864 java-pkg_init_paths_
1416 java-pkg_switch-vm 1865 java-pkg_switch-vm
1417 PATH=${JAVA_HOME}/bin:${PATH} 1866 PATH=${JAVA_HOME}/bin:${PATH}
1418 1867
1419 # TODO we will probably want to set JAVAC and JAVACFLAGS 1868 # TODO we will probably want to set JAVAC and JAVACFLAGS
1424 # When users have crazy classpaths some packages can fail to compile. 1873 # When users have crazy classpaths some packages can fail to compile.
1425 # and everything should work with empty CLASSPATH. 1874 # and everything should work with empty CLASSPATH.
1426 # This also helps prevent unexpected dependencies on random things 1875 # This also helps prevent unexpected dependencies on random things
1427 # from the CLASSPATH. 1876 # from the CLASSPATH.
1428 unset CLASSPATH 1877 unset CLASSPATH
1878
1879 # Unset external ANT_ stuff
1880 unset ANT_TASKS
1881 unset ANT_OPTS
1429} 1882}
1430 1883
1431# ------------------------------------------------------------------------------ 1884# ------------------------------------------------------------------------------
1432# @function-internal java-pkg-init-compiler_ 1885# @function-internal java-pkg-init-compiler_
1433# 1886#
1577# Writes the package.env out to disk. 2030# Writes the package.env out to disk.
1578# 2031#
1579# ------------------------------------------------------------------------------ 2032# ------------------------------------------------------------------------------
1580# TODO change to do-write, to match everything else 2033# TODO change to do-write, to match everything else
1581java-pkg_do_write_() { 2034java-pkg_do_write_() {
2035 java-pkg_init_paths_
1582 # Create directory for package.env 2036 # Create directory for package.env
1583 dodir "${JAVA_PKG_SHAREPATH}" 2037 dodir "${JAVA_PKG_SHAREPATH}"
1584 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2038 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1585 # Create package.env 2039 # Create package.env
1586 ( 2040 (
1614 # Strip unnecessary leading and trailing colons 2068 # Strip unnecessary leading and trailing colons
1615 # TODO try to cleanup if possible 2069 # TODO try to cleanup if possible
1616 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2070 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1617 fi 2071 fi
1618} 2072}
1619
1620 2073
1621# ------------------------------------------------------------------------------ 2074# ------------------------------------------------------------------------------
1622# @internal-function java-pkg_record-jar_ 2075# @internal-function java-pkg_record-jar_
1623# 2076#
1624# Record a dependency to the package.env 2077# Record a dependency to the package.env
1705# ------------------------------------------------------------------------------ 2158# ------------------------------------------------------------------------------
1706java-pkg_setup-vm() { 2159java-pkg_setup-vm() {
1707 debug-print-function ${FUNCNAME} $* 2160 debug-print-function ${FUNCNAME} $*
1708 2161
1709 local vendor="$(java-pkg_get-vm-vendor)" 2162 local vendor="$(java-pkg_get-vm-vendor)"
1710 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2163 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1711 addpredict "/dev/random" 2164 addpredict "/dev/random"
1712 elif [[ "${vendor}" == "ibm" ]]; then 2165 elif [[ "${vendor}" == "ibm" ]]; then
1713 addpredict "/proc/self/maps" 2166 addpredict "/proc/self/maps"
1714 addpredict "/proc/cpuinfo" 2167 addpredict "/proc/cpuinfo"
1715 export LANG="C" LC_ALL="C" 2168 export LANG="C" LC_ALL="C"
1775# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2228# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1776# verify that the current VM is sufficient. 2229# verify that the current VM is sufficient.
1777# Setup the environment for the VM being used. 2230# Setup the environment for the VM being used.
1778# ------------------------------------------------------------------------------ 2231# ------------------------------------------------------------------------------
1779java-pkg_switch-vm() { 2232java-pkg_switch-vm() {
2233 debug-print-function ${FUNCNAME} $*
2234
1780 if java-pkg_needs-vm; then 2235 if java-pkg_needs-vm; then
1781 # Use the VM specified by JAVA_PKG_FORCE_VM 2236 # Use the VM specified by JAVA_PKG_FORCE_VM
1782 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2237 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1783 # If you're forcing the VM, I hope you know what your doing... 2238 # If you're forcing the VM, I hope you know what your doing...
2239 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1784 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2240 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1785 # if we're allowed to switch the vm... 2241 # if we're allowed to switch the vm...
1786 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2242 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1787 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2243 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1788 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2244 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1789 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2245 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1790 else 2246 else
1791 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2247 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2248 fi
2249 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2250 eerror "Unable to determine VM for building from dependencies:"
2251 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2252 echo "VNEED: ${JAVA_PKG_VNEED}"
2253 die "Failed to determine VM for building."
2254 else
2255 export GENTOO_VM
1792 fi 2256 fi
1793 # otherwise just make sure the current VM is sufficient 2257 # otherwise just make sure the current VM is sufficient
1794 else 2258 else
1795 java-pkg_ensure-vm-version-sufficient 2259 java-pkg_ensure-vm-version-sufficient
1796 fi 2260 fi
1798 2262
1799 java-pkg_setup-vm 2263 java-pkg_setup-vm
1800 2264
1801 export JAVA=$(java-config --java) 2265 export JAVA=$(java-config --java)
1802 export JAVAC=$(java-config --javac) 2266 export JAVAC=$(java-config --javac)
1803 export JAVACFLAGS="$(java-pkg_javac-args)" 2267 JAVACFLAGS="$(java-pkg_javac-args)"
2268 if [[ ${?} != 0 ]]; then
2269 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2270 die "java-pkg_javac-args failed"
2271 fi
1804 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2272 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2273 export JAVACFLAGS
1805 2274
1806 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2275 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1807 export JDK_HOME=${JAVA_HOME} 2276 export JDK_HOME=${JAVA_HOME}
1808 2277
1809 #TODO If you know a better solution let us know. 2278 #TODO If you know a better solution let us know.
1855 einfo "Classes" 2324 einfo "Classes"
1856 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2325 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1857 fi 2326 fi
1858} 2327}
1859 2328
1860# TODO document 2329# ------------------------------------------------------------------------------
2330# @internal-function java-pkg_verify-classes
2331#
1861# Verify that the classes were compiled for the right source / target 2332# Verify that the classes were compiled for the right source / target. Dies if
2333# not.
2334# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2335# ------------------------------------------------------------------------------
1862java-pkg_verify-classes() { 2336java-pkg_verify-classes() {
1863 ebegin "Verifying java class versions"
1864 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2337 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1865 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2338 local target=$(java-pkg_get-target)
2339 local result
2340 local log="${T}/class-version-verify.log"
2341 if [[ -n "${1}" ]]; then
2342 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1866 result=$? 2343 result=$?
1867 eend ${result}
1868 if [[ ${result} == 0 ]]; then
1869 einfo "All good"
1870 else 2344 else
1871 ewarn "Possible problem" 2345 ebegin "Verifying java class versions (target: ${target})"
1872 die "Bad class files found" 2346 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2347 result=$?
2348 eend ${result}
2349 fi
2350 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2351 if [[ ${result} != 0 ]]; then
2352 eerror "Incorrect bytecode version found"
2353 [[ -n "${1}" ]] && eerror "in file: ${1}"
2354 eerror "See ${log} for more details."
2355 die "Incorrect bytecode found"
2356 fi
2357}
2358
2359# ----------------------------------------------------------------------------
2360# @internal-function java-pkg_ensure-dep
2361# Check that a package being used in jarfrom, getjars and getjar is contained
2362# within DEPEND or RDEPEND.
2363# @param $1 - Is the package a runtime dependency
2364# @param $2 - Package name and slot.
2365
2366java-pkg_ensure-dep() {
2367 debug-print-function ${FUNCNAME} $*
2368
2369 local build_only="${1}"
2370 local target_pkg="${2}"
2371 local dev_error=""
2372
2373 local stripped_pkg=$(echo "${target_pkg}" | sed \
2374 's/-[0-9]*\(\.[0-9]\)*$//')
2375
2376 if [[ ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2377 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2378 dev_error="${dev_error} declared in DEPEND."
2379 if is-java-strict; then
2380 die "${dev_error}"
2381 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2382 eerror "${dev_error}"
2383 elog "Because you have this package installed the package will"
2384 elog "build without problems, but please report this to"
2385 elog "http://bugs.gentoo.org"
1873 fi 2386 fi
1874} 2387 fi
1875 2388
2389 if [[ -z ${build_only} && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2390 dev_error="The ebuild is attempting to use ${target_pkg},"
2391 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND."
2392 if is-java-strict; then
2393 die "${dev_error}"
2394 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2395 eerror "${dev_error}"
2396 elog "Because you have this package installed the package will"
2397 elog "build without problems, but please report this to"
2398 elog "http://bugs.gentoo.org"
2399 fi
2400 fi
2401}
1876 2402
1877# ------------------------------------------------------------------------------ 2403# ------------------------------------------------------------------------------
1878# @section-end internal 2404# @section-end internal
1879# ------------------------------------------------------------------------------ 2405# ------------------------------------------------------------------------------
1880 2406

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.76

  ViewVC Help
Powered by ViewVC 1.1.20