/[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.12 Revision 1.66
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.66 2007/03/17 13:26:12 betelgeuse 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#
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# @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# -----------------------------------------------------------------------------
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 65JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40 66
41# ----------------------------------------------------------------------------- 67# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 68# @variable-internal JAVA_PKG_E_DEPEND
43# 69#
44# 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
45# 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
46# portage, that includes phase hooks. 72# portage, that includes phase hooks.
47# ----------------------------------------------------------------------------- 73# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}"
49 75
50# ----------------------------------------------------------------------------- 76# -----------------------------------------------------------------------------
51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
52# @variable-default yes 78# @variable-default yes
53# 79#
100# ----------------------------------------------------------------------------- 126# -----------------------------------------------------------------------------
101 127
102# ----------------------------------------------------------------------------- 128# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 129# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 130# @default /usr/share/java-config-2/compiler
105# 131#
106# Directory where compiler settings are saved, without trailing slash. 132# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 133# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 134# -----------------------------------------------------------------------------
109JAVA_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"}
110 136
120 146
121# ----------------------------------------------------------------------------- 147# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 148# @variable-external JAVA_PKG_FORCE_COMPILER
123# 149#
124# 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
125# JAVA_PKG_COMPILERS_CONF. 151# JAVA_PKG_COMPILERS_CONF.
126# 152#
127# @note This should only be used internally or for testing. 153# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 154# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 155# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 156# -----------------------------------------------------------------------------
131 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
132# TODO document me 172# TODO document me
133JAVA_PKG_QA_VIOLATIONS=0 173JAVA_PKG_QA_VIOLATIONS=0
134 174
135# ----------------------------------------------------------------------------- 175# -----------------------------------------------------------------------------
136# @section-end variables 176# @section-end variables
143# 183#
144# These are used to install Java-related things, such as jars, Javadocs, JNI 184# These are used to install Java-related things, such as jars, Javadocs, JNI
145# libraries, etc. 185# libraries, etc.
146# ----------------------------------------------------------------------------- 186# -----------------------------------------------------------------------------
147 187
188# -----------------------------------------------------------------------------
189# @ebuild-function java-pkg_doexamples
190#
191# Installs given arguments to /usr/share/doc/${PF}/examples
192# If you give it only one parameter and it is a directory it will install
193# everything in that directory to the examples directory.
194#
195# @example
196# java-pkg_doexamples demo
197# java-pkg_doexamples demo/* examples/*
198#
199# @param $* - list of files to install
200# ------------------------------------------------------------------------------
201java-pkg_doexamples() {
202 debug-print-function ${FUNCNAME} $*
203
204 [[ ${#} -lt 1 ]] && die "At least one argument needed"
205
206 java-pkg_check-phase install
207
208 local dest=/usr/share/doc/${PF}/examples
209 if [[ ${#} = 1 && -d ${1} ]]; then
210 INSDESTTREE="${dest}" doins -r ${1}/* || die "Installing examples failed"
211 else
212 INSDESTTREE="${dest}" doins -r "${@}" || die "Installing examples failed"
213 fi
214}
148 215
149# ----------------------------------------------------------------------------- 216# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 217# @ebuild-function java-pkg_dojar
151# 218#
152# Installs any number of jars. 219# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 220# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 221# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 222# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 223# Instead, use java-pkg_newjar defined below.
157# 224#
158# @example 225# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 226# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 227#
171 # Create JARDEST if it doesn't exist 238 # Create JARDEST if it doesn't exist
172 dodir ${JAVA_PKG_JARDEST} 239 dodir ${JAVA_PKG_JARDEST}
173 240
174 local jar 241 local jar
175 # for each jar 242 # for each jar
176 for jar in "$@"; do 243 for jar in "${@}"; do
177 local jar_basename=$(basename "${jar}") 244 local jar_basename=$(basename "${jar}")
178 245
179 java-pkg_check-versioned-jar ${jar_basename} 246 java-pkg_check-versioned-jar ${jar_basename}
180 247
181 # check if it exists 248 # check if it exists
182 if [[ -e "${jar}" ]] ; then 249 if [[ -e "${jar}" ]] ; then
250 # Don't overwrite if jar has already been installed with the same
251 # name
252 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
253 if [[ -e "${dest}" ]]; then
254 ewarn "Overwriting ${dest}"
255 fi
256
183 # install it into JARDEST if it's a non-symlink 257 # install it into JARDEST if it's a non-symlink
184 if [[ ! -L "${jar}" ]] ; then 258 if [[ ! -L "${jar}" ]] ; then
259 #but first check class version when in strict mode.
260 is-java-strict && java-pkg_verify-classes "${jar}"
261
185 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 262 INSDESTTREE="${JAVA_PKG_JARDEST}" \
186 doins "${jar}" || die "failed to install ${jar}" 263 doins "${jar}" || die "failed to install ${jar}"
187 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 264 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
188 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 265 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
189 # make a symlink to the original jar if it's symlink 266 # make a symlink to the original jar if it's symlink
200 277
201 java-pkg_do_write_ 278 java-pkg_do_write_
202} 279}
203 280
204 281
282# ------------------------------------------------------------------------------
283# @internal-function depend-java-query
284#
285# Wrapper for the depend-java-query binary to enable passing USE in env.
286# Using env variables keeps this eclass working with java-config versions that
287# do not handle use flags.
288# ------------------------------------------------------------------------------
289
290depend-java-query() {
291 # Used to have a which call here but it caused endless loops for some people
292 # that had some weird bashrc voodoo for which.
293 USE="${USE}" /usr/bin/depend-java-query "${@}"
294}
205 295
206# ------------------------------------------------------------------------------ 296# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 297# @ebuild-function java-pkg_regjar
208# 298#
209# Records an already installed jar in the package.env 299# Records an already installed jar in the package.env
222# will not work, because: 312# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 313# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 314# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 315# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 316# doesn't exist
227# 317#
228# you have to use it as: 318# you have to use it as:
229# 319#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 320# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 321#
232# @param $@ - jars to record 322# @param $@ - jars to record
240 [[ ${#} -lt 1 ]] && die "at least one argument needed" 330 [[ ${#} -lt 1 ]] && die "at least one argument needed"
241 331
242 java-pkg_init_paths_ 332 java-pkg_init_paths_
243 333
244 local jar jar_dir jar_file 334 local jar jar_dir jar_file
245 for jar in "$@"; do 335 for jar in "${@}"; do
246 # TODO use java-pkg_check-versioned-jar 336 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 337 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
338 [[ -d "${jar}" || -d "${D}${jar}" ]] \
339 && die "Called ${FUNCNAME} on a directory $*"
340
341 #check that class version correct when in strict mode
342 is-java-strict && java-pkg_verify-classes "${jar}"
343
248 # nelchael: we should strip ${D} in this case too, here's why: 344 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 345 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 346 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 347 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 348 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 349 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 350 else
257 die "${jar} does not exist" 351 die "${jar} does not exist"
258 fi 352 fi
259 done 353 done
260 354
261 java-pkg_do_write_ 355 java-pkg_do_write_
262} 356}
263
264 357
265# ------------------------------------------------------------------------------ 358# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 359# @ebuild-function java-pkg_newjar
267# 360#
268# Installs a jar with a new name 361# Installs a jar with a new name
279 local original_jar="${1}" 372 local original_jar="${1}"
280 local new_jar="${2:-${PN}.jar}" 373 local new_jar="${2:-${PN}.jar}"
281 local new_jar_dest="${T}/${new_jar}" 374 local new_jar_dest="${T}/${new_jar}"
282 375
283 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 376 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!" 377 [[ ! -f ${original_jar} ]] \
378 && die "${original_jar} does not exist or is not a file!"
285 379
286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 380 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
287 cp "${original_jar}" "${new_jar_dest}" \ 381 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 382 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 383 java-pkg_dojar "${new_jar_dest}"
290} 384}
291 385
292
293# ------------------------------------------------------------------------------ 386# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 387# @ebuild-function java-pkg_addcp
295# 388#
296# Add something to the package's classpath. For jars, you should use dojar, 389# 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. 390# newjar, or regjar. This is typically used to add directories to the classpath.
302java-pkg_addcp() { 395java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 396 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 397 java-pkg_do_write_
305} 398}
306 399
307
308# ------------------------------------------------------------------------------ 400# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 401# @ebuild-function java-pkg_doso
310# 402#
311# Installs any number of JNI libraries 403# Installs any number of JNI libraries
312# They will be installed into /usr/lib by default, but java-pkg_sointo 404# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 405# can be used change this path
314# 406#
315# Example: 407# Example:
340 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 432 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
341 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 433 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
342 # otherwise make a symlink to the symlink's origin 434 # otherwise make a symlink to the symlink's origin
343 else 435 else
344 # TODO use dosym 436 # TODO use dosym
437 ln -s "$(readlink "${lib}")" \
345 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 438 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
346 debug-print "${lib} is a symlink, linking accordanly" 439 debug-print "${lib} is a symlink, linking accordanly"
347 fi 440 fi
348 # otherwise die 441 # otherwise die
349 else 442 else
350 die "${lib} does not exist" 443 die "${lib} does not exist"
370 java-pkg_check-phase install 463 java-pkg_check-phase install
371 464
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 465 [[ ${#} -lt 1 ]] && "at least one argument needed"
373 466
374 java-pkg_init_paths_ 467 java-pkg_init_paths_
375 468
376 local lib target_dir 469 local lib target_dir
377 for lib in "$@" ; do 470 for lib in "$@" ; do
378 # Check the absolute path of the lib 471 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 472 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 473 target_dir="$(java-pkg_expand_dir_ ${lib})"
428# ------------------------------------------------------------------------------ 521# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 522java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 523 debug-print-function ${FUNCNAME} $*
431 524
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 525 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 526
527 # from /usr/lib/portage/bin/dohtml -h
528 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 529 dohtml -f package-list "$@"
530
435 # this probably shouldn't be here but it provides 531 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 532 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 533 # old ebuilds.
438 java-pkg_recordjavadoc 534 java-pkg_recordjavadoc
439} 535}
440 536
441# TODO document 537# ------------------------------------------------------------------------------
538# @ebuild-function java-pkg_dojavadoc
539#
540# Installs javadoc documentation. This should be controlled by the doc use flag.
541#
542# @param $1: - The javadoc root directory.
543#
544# @example:
545# java-pkg_dojavadoc docs/api
546#
547# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 548java-pkg_dojavadoc() {
443 local dir="$1" 549 local dir="$1"
444 550
445 java-pkg_check-phase install 551 java-pkg_check-phase install
446 552
458} 564}
459 565
460# ------------------------------------------------------------------------------ 566# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 567# @ebuild-function java-pkg_dosrc
462# 568#
463# Installs a zip containing the source for a package, so it can used in 569# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 570# from IDEs like eclipse and netbeans.
465# 571#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 572# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 573#
468# It also should be controlled by USE=source. 574# It also should be controlled by USE=source.
469# 575#
470# @example: 576# @example:
471# java-pkg_dosrc src/* 577# java-pkg_dosrc src/*
472# 578#
473# ------------------------------------------------------------------------------ 579# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 580# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 581# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 582# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 583# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 584# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 585java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 586 debug-print-function ${FUNCNAME} $*
481 587
482 [ ${#} -lt 1 ] && die "At least one argument needed" 588 [ ${#} -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 589
487 java-pkg_check-phase install 590 java-pkg_check-phase install
488 591
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 592 [[ ${#} -lt 1 ]] && die "At least one argument needed"
593
594 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
595 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
596 if is-java-strict; then
597 eerror "${msg}"
598 die "${msg}"
599 else
600 echo "${msg}"
601 echo "Please report this to http://bugs.gentoo.org."
602 fi
603 fi
490 604
491 java-pkg_init_paths_ 605 java-pkg_init_paths_
492 606
493 local zip_name="${PN}-src.zip" 607 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 608 local zip_path="${T}/${zip_name}"
495 local dir 609 local dir
496 for dir in ${@}; do 610 for dir in "${@}"; do
497 local dir_parent=$(dirname "${dir}") 611 local dir_parent=$(dirname "${dir}")
498 local dir_name=$(basename "${dir}") 612 local dir_name=$(basename "${dir}")
499 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 613 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
500 zip -q -r ${zip_path} ${dir_name} -i '*.java' 614 zip -q -r ${zip_path} ${dir_name} -i '*.java'
501 local result=$? 615 local result=$?
518# @ebuild-function java-pkg_dolauncher 632# @ebuild-function java-pkg_dolauncher
519# 633#
520# Make a wrapper script to lauch/start this package 634# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 635# If necessary, the wrapper will switch to the appropriate VM.
522# 636#
637# Can be called without parameters if the package installs only one jar
638# that has the Main-class attribute set. The wrapper will be named ${PN}.
639#
523# @param $1 - filename of launcher to create 640# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 641# @param $2 - options, as follows:
525# --main the.main.class.too.start 642# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 643# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass too jave' 644# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 645# --pkg_args 'Extra arguments to pass to the package'
529# --pwd 646# --pwd Directory the launcher changes to before executing java
530# -into 647# -into Directory to install the launcher to, instead of /usr/bin
531# -pre 648# -pre Prepend contents of this file to the launcher
532# ------------------------------------------------------------------------------ 649# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 650java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 651 debug-print-function ${FUNCNAME} $*
535 652
536 java-pkg_check-phase install 653 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 654 java-pkg_init_paths_
541 655
656 if [[ ${#} = 0 ]]; then
657 local name="${PN}"
658 else
542 local name="${1}" 659 local name="${1}"
660 shift
661 fi
662
543 # TODO rename to launcher 663 # TODO rename to launcher
544 local target="${T}/${name}" 664 local target="${T}/${name}"
665 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 666 local target_dir pre
546 shift
547 667
548 echo "#!/bin/bash" > "${target}" 668 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 669 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 670 local var="${1}" value="${2}"
551 if [[ "${var:0:2}" == "--" ]]; then 671 if [[ "${var:0:2}" == "--" ]]; then
672 local var=${var:2}
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 673 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
674 local gjl_${var}="${value}"
553 elif [[ "${var}" == "-into" ]]; then 675 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 676 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 677 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 678 pre="${value}"
557 fi 679 fi
558 shift 2 680 shift 2
559 done 681 done
682
683 # Test if no --jar and --main arguments were given and
684 # in that case check if the package only installs one jar
685 # and use that jar.
686 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
687 local cp="${JAVA_PKG_CLASSPATH}"
688 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
689 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
690 else
691 local msg="Not enough information to create a launcher given."
692 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
693 die "${msg}"
694 fi
695 fi
696
697 # Write the actual script
698 echo "#!/bin/bash" > "${target}"
699 if [[ -n "${pre}" ]]; then
700 if [[ -f "${pre}" ]]; then
701 cat "${pre}" >> "${target}"
702 else
703 die "-pre specified file '${pre}' does not exist"
704 fi
705 fi
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 706 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 707 cat "${var_tmp}" >> "${target}"
708 rm -f "${var_tmp}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 709 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 710
564 if [[ -n "${into}" ]]; then 711 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 712 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 713 local ret=$?
567 return ${ret} 714 return ${ret}
568 else 715 else
569 dobin "${target}" 716 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 744 echo "dowar: warning, skipping directory ${war}"
598 continue 745 continue
599 else 746 else
600 warpath="${war}" 747 warpath="${war}"
601 fi 748 fi
602 749
603 # Install those files like you mean it 750 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 751 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 752 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 753 doins ${warpath}
607 done 754 done
642# @ebuild-function java-pkg_jar-from 789# @ebuild-function java-pkg_jar-from
643# 790#
644# Makes a symlink to a jar from a certain package 791# Makes a symlink to a jar from a certain package
645# A lot of java packages include dependencies in a lib/ directory 792# A lot of java packages include dependencies in a lib/ directory
646# You can use this function to replace these bundled dependencies. 793# You can use this function to replace these bundled dependencies.
794# The dependency is recorded into package.env DEPEND line, unless "--build-only"
795# is passed as the very first argument, for jars that have to be present only
796# at build time and are not needed on runtime (junit testing etc).
647# 797#
648# Example: get all jars from xerces slot 2 798# Example: get all jars from xerces slot 2
649# java-pkg_jar-from xerces-2 799# java-pkg_jar-from xerces-2
650# Example: get a specific jar from xerces slot 2 800# Example: get a specific jar from xerces slot 2
651# java-pkg_jar-from xerces-2 xml-apis.jar 801# java-pkg_jar-from xerces-2 xml-apis.jar
652# Example get a specific jar from xerces slot 2, and name it diffrently 802# Example: get a specific jar from xerces slot 2, and name it diffrently
653# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar 803# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
804# Example: get junit.jar which is needed only for building
805# java-pkg_jar-from --build-only junit junit.jar
654# 806#
807# @param $opt
808# --build-only - makes the jar(s) not added into package.env DEPEND line.
809# (assumed automatically when called inside src_test)
810# --with-dependencies - get jars also from requested package's dependencies
811# transitively.
812# --into $dir - symlink jar(s) into $dir (must exist) instead of .
655# @param $1 - Package to get jars from. 813# @param $1 - Package to get jars from.
656# @param $2 - jar from package. If not specified, all jars will be used. 814# @param $2 - jar from package. If not specified, all jars will be used.
657# @param $3 - When a single jar is specified, destination filename of the 815# @param $3 - When a single jar is specified, destination filename of the
658# symlink. Defaults to the name of the jar. 816# symlink. Defaults to the name of the jar.
659# ------------------------------------------------------------------------------ 817# ------------------------------------------------------------------------------
660# TODO could probably be cleaned up a little 818# TODO could probably be cleaned up a little
661java-pkg_jar-from() { 819java-pkg_jar-from() {
662 debug-print-function ${FUNCNAME} $* 820 debug-print-function ${FUNCNAME} $*
663 821
822 local build_only=""
823 local destdir="."
824 local deep=""
825
826 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
827
828 while [[ "${1}" == --* ]]; do
829 if [[ "${1}" = "--build-only" ]]; then
830 build_only="true"
831 elif [[ "${1}" = "--with-dependencies" ]]; then
832 deep="--with-dependencies"
833 elif [[ "${1}" = "--into" ]]; then
834 destdir="${2}"
835 shift
836 else
837 die "java-pkg_jar-from called with unknown parameter: ${1}"
838 fi
839 shift
840 done
841
664 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 842 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
665 843
666 [[ -z ${target_pkg} ]] && die "Must specify a package" 844 [[ -z ${target_pkg} ]] && die "Must specify a package"
667 845
668 # default destjar to the target jar 846 # default destjar to the target jar
669 [[ -z "${destjar}" ]] && destjar="${target_jar}" 847 [[ -z "${destjar}" ]] && destjar="${target_jar}"
670 848
849 local error_msg="There was a problem getting the classpath for ${target_pkg}."
850 local classpath
671 local classpath="$(java-config --classpath=${target_pkg})" 851 classpath="$(java-config ${deep} --classpath=${target_pkg})"
672 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 852 [[ $? != 0 ]] && die ${error_msg}
853
854 pushd ${destdir} > /dev/null \
855 || die "failed to change directory to ${destdir}"
856
857 # When we have commas this functions is called to bring jars from multiple
858 # packages. This affects recording of dependencencies because that syntax uses :
859 # if we don't change them to : gjl and java-config -d -p break
860 if [[ ${target_pkg} = *,* ]]; then
861 build_only="true"
862 java-pkg_record-jar_ ${target_pkg//,/:}
863 fi
673 864
674 local jar 865 local jar
675 for jar in ${classpath//:/ }; do 866 for jar in ${classpath//:/ }; do
676 local jar_name=$(basename "${jar}") 867 local jar_name=$(basename "${jar}")
677 if [[ ! -f "${jar}" ]] ; then 868 if [[ ! -f "${jar}" ]] ; then
681 # If no specific target jar was indicated, link it 872 # If no specific target jar was indicated, link it
682 if [[ -z "${target_jar}" ]] ; then 873 if [[ -z "${target_jar}" ]] ; then
683 [[ -f "${target_jar}" ]] && rm "${target_jar}" 874 [[ -f "${target_jar}" ]] && rm "${target_jar}"
684 ln -snf "${jar}" \ 875 ln -snf "${jar}" \
685 || die "Failed to make symlink from ${jar} to ${jar_name}" 876 || die "Failed to make symlink from ${jar} to ${jar_name}"
686 java-pkg_record-jar_ "${target_pkg}" "${jar}" 877 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
687 # otherwise, if the current jar is the target jar, link it 878 # otherwise, if the current jar is the target jar, link it
688 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 879 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
689 [[ -f "${destjar}" ]] && rm "${destjar}" 880 [[ -f "${destjar}" ]] && rm "${destjar}"
690 ln -snf "${jar}" "${destjar}" \ 881 ln -snf "${jar}" "${destjar}" \
691 || die "Failed to make symlink from ${jar} to ${destjar}" 882 || die "Failed to make symlink from ${jar} to ${destjar}"
692 java-pkg_record-jar_ "${target_pkg}" "${jar}" 883 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
884 popd > /dev/null
693 return 0 885 return 0
694 fi 886 fi
695 done 887 done
888 popd > /dev/null
696 # if no target was specified, we're ok 889 # if no target was specified, we're ok
697 if [[ -z "${target_jar}" ]] ; then 890 if [[ -z "${target_jar}" ]] ; then
698 return 0 891 return 0
699 # otherwise, die bitterly 892 # otherwise, die bitterly
700 else 893 else
714# ------------------------------------------------------------------------------ 907# ------------------------------------------------------------------------------
715# @ebuild-function java-pkg_getjars 908# @ebuild-function java-pkg_getjars
716# 909#
717# Get the classpath provided by any number of packages 910# Get the classpath provided by any number of packages
718# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 911# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
912# The providing packages are recorded as dependencies into package.env DEPEND
913# line, unless "--build-only" is passed as the very first argument, for jars
914# that have to be present only at build time and are not needed on runtime
915# (junit testing etc).
719# 916#
720# Example: Get the classpath for xerces-2, 917# Example: Get the classpath for xerces-2 and xalan,
721# java-pkg_getjars xerces-2 xalan 918# java-pkg_getjars xerces-2,xalan
722# Example Return: 919# Example Return:
723# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 920# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
724# 921#
922# @param $opt
923# --build-only - makes the jar(s) not added into package.env DEPEND line.
924# (assumed automatically when called inside src_test)
925# --with-dependencies - get jars also from requested package's dependencies
926# transitively.
725# @param $@ - list of packages to get jars from 927# @param $1 - list of packages to get jars from
928# (passed to java-config --classpath)
726# ------------------------------------------------------------------------------ 929# ------------------------------------------------------------------------------
727java-pkg_getjars() { 930java-pkg_getjars() {
728 debug-print-function ${FUNCNAME} $* 931 debug-print-function ${FUNCNAME} $*
729 932
730 [[ ${#} -lt 1 ]] && die "At least one argument needed" 933 local build_only=""
934 local deep=""
731 935
732 # NOTE could probably just pass $@ to java-config --classpath. and return it 936 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
733 local classpath pkg 937
734 for pkg in ${@//,/ }; do 938 while [[ "${1}" == --* ]]; do
735 #for pkg in $(echo "$@" | tr ',' ' '); do 939 if [[ "${1}" = "--build-only" ]]; then
736 jars="$(java-config --classpath=${pkg})" 940 build_only="true"
737 debug-print "${pkg}:${jars}" 941 elif [[ "${1}" = "--with-dependencies" ]]; then
738 # TODO should we ensure jars exist? 942 deep="--with-dependencies"
739 if [[ -z "${classpath}" ]]; then
740 classpath="${jars}"
741 else 943 else
742 classpath="${classpath}:${jars}" 944 die "java-pkg_jar-from called with unknown parameter: ${1}"
743 fi 945 fi
744 java-pkg_record-jar_ "${pkg}" 946 shift
745 done 947 done
948
949 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
950
951 local classpath pkgs="${1}"
952 jars="$(java-config ${deep} --classpath=${pkgs})"
953 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
954 debug-print "${pkgs}:${jars}"
955
956 if [[ -z "${classpath}" ]]; then
957 classpath="${jars}"
958 else
959 classpath="${classpath}:${jars}"
960 fi
961
962 # Only record jars that aren't build-only
963 if [[ -z "${build_only}" ]]; then
964 oldifs="${IFS}"
965 IFS=","
966 for pkg in ${pkgs}; do
967 java-pkg_record-jar_ "${pkg}"
968 done
969 IFS="${oldifs}"
970 fi
971
746 echo "${classpath}" 972 echo "${classpath}"
747} 973}
748 974
749# ------------------------------------------------------------------------------ 975# ------------------------------------------------------------------------------
750# @ebuild-function java-pkg_getjar 976# @ebuild-function java-pkg_getjar
751# 977#
752# Get the filename of a single jar from a package 978# Get the filename of a single jar from a package
979# The providing package is recorded as runtime dependency into package.env
980# DEPEND line, unless "--build-only" is passed as the very first argument, for
981# jars that have to be present only at build time and are not needed on runtime
982# (junit testing etc).
753# 983#
754# @example 984# @example
755# java-pkg_getjar xerces-2 xml-apis.jar 985# java-pkg_getjar xerces-2 xml-apis.jar
756# @example-return 986# @example-return
757# /usr/share/xerces-2/lib/xml-apis.jar 987# /usr/share/xerces-2/lib/xml-apis.jar
758# 988#
989# @param $opt
990# --build-only - makes the jar not added into package.env DEPEND line.
759# @param $1 - package to use 991# @param $1 - package to use
760# @param $2 - jar to get 992# @param $2 - jar to get
761# ------------------------------------------------------------------------------ 993# ------------------------------------------------------------------------------
762java-pkg_getjar() { 994java-pkg_getjar() {
763 debug-print-function ${FUNCNAME} $* 995 debug-print-function ${FUNCNAME} $*
996
997 local build_only=""
998
999 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true"
1000
1001 while [[ "${1}" == --* ]]; do
1002 if [[ "${1}" = "--build-only" ]]; then
1003 build_only="true"
1004 else
1005 die "java-pkg_jar-from called with unknown parameter: ${1}"
1006 fi
1007 shift
1008 done
1009
1010 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
764 1011
765 local pkg="${1}" target_jar="${2}" jar 1012 local pkg="${1}" target_jar="${2}" jar
766 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1013 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
767 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1014 [[ -z ${target_jar} ]] && die "Must specify jar to get"
768 1015
769 # TODO check that package is actually installed 1016 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1017 local classpath
770 local classpath=$(java-config --classpath=${pkg}) 1018 classpath=$(java-config --classpath=${pkg})
771 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 1019 [[ $? != 0 ]] && die ${error_msg}
1020
772 for jar in ${classpath//:/ }; do 1021 for jar in ${classpath//:/ }; do
773 if [[ ! -f "${jar}" ]] ; then 1022 if [[ ! -f "${jar}" ]] ; then
774 die "Installation problems with jars in ${pkg} - is it installed?" 1023 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
775 fi 1024 fi
776 1025
777 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1026 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
778 java-pkg_record-jar_ "${pkg}" "${jar}" 1027 # Only record jars that aren't build-only
1028 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
779 echo "${jar}" 1029 echo "${jar}"
780 return 0 1030 return 0
781 fi 1031 fi
782 done 1032 done
783 1033
784 die "Could not find ${target_jar} in ${pkg}" 1034 die "Could not find ${target_jar} in ${pkg}"
785 return 1 1035 return 1
786} 1036}
787 1037
788# This function reads stdin, and based on that input, figures out how to 1038# This function reads stdin, and based on that input, figures out how to
802# line="${line// /}" 1052# line="${line// /}"
803# 1053#
804# # format: path=jarinfo 1054# # format: path=jarinfo
805# local path=${line%%=*} 1055# local path=${line%%=*}
806# local jarinfo=${line##*=} 1056# local jarinfo=${line##*=}
807# 1057#
808# # format: jar@package 1058# # format: jar@package
809# local jar=${jarinfo%%@*}.jar 1059# local jar=${jarinfo%%@*}.jar
810# local package=${jarinfo##*@} 1060# local package=${jarinfo##*@}
811# if [[ -n ${replace_only} ]]; then 1061# if [[ -n ${replace_only} ]]; then
812# [[ ! -f $path ]] && die "No jar exists at ${path}" 1062# [[ ! -f $path ]] && die "No jar exists at ${path}"
825# @section-end query 1075# @section-end query
826# ------------------------------------------------------------------------------ 1076# ------------------------------------------------------------------------------
827 1077
828# ------------------------------------------------------------------------------ 1078# ------------------------------------------------------------------------------
829# @section-begin helper 1079# @section-begin helper
830# @section-summary Helper functions 1080# @section-summary Helper functions
831# 1081#
832# Various other functions to use from an ebuild 1082# Various other functions to use from an ebuild
833# ------------------------------------------------------------------------------ 1083# ------------------------------------------------------------------------------
834 1084
835# ------------------------------------------------------------------------------ 1085# ------------------------------------------------------------------------------
841# jdbc-stdext 1091# jdbc-stdext
842# jaf 1092# jaf
843# jdbc-rowset 1093# jdbc-rowset
844# jms 1094# jms
845# 1095#
846# @param $1 - Optionally indicate that the dependencies are controlled by 1096# @param $1 - Optionally indicate that the dependencies are controlled by
847# a use flag by specifying '--use' Requires $2. 1097# a use flag by specifying '--use' Requires $2.
848# @param $2 - USE flag which will enable the dependencies. 1098# @param $2 - USE flag which will enable the dependencies.
849# @param $@ - virtual packages to add depenedencies for 1099# @param $@ - virtual packages to add depenedencies for
850# ------------------------------------------------------------------------------ 1100# ------------------------------------------------------------------------------
851# TODO rewrite to parse a line based declaration file instead -- karltk 1101# TODO rewrite to parse a line based declaration file instead -- karltk
907# 1157#
908# export DEPEND="${DEPEND} ${depstr}" 1158# export DEPEND="${DEPEND} ${depstr}"
909# export RDEPEND="${RDEPEND} ${depstr}" 1159# export RDEPEND="${RDEPEND} ${depstr}"
910#} 1160#}
911 1161
1162# ------------------------------------------------------------------------------
1163# @ebuild-function java-pkg_find-normal-jars
1164#
1165# Find the files with suffix .jar file in the given directory or $WORKDIR
1166#
1167# @param $1 - The directory to search for jar files (default: ${WORKDIR})
1168# ------------------------------------------------------------------------------
1169java-pkg_find-normal-jars() {
1170 local dir=$1
1171 [[ "${dir}" ]] || dir="${WORKDIR}"
1172 local found
1173 for jar in $(find "${dir}" -name "*.jar" -type f); do
1174 echo "${jar}"
1175 found="true"
1176 done
1177 [[ "${found}" ]]
1178 return $?
1179}
1180
1181# ------------------------------------------------------------------------------
1182# @ebuild-function java-pkg_ensure-no-bundled-jars
1183#
1184# Try to locate bundled jar files in ${WORKDIR} and die if found.
912# This should be used after S has been populated with symlinks to jars 1185# This function should be called after WORKDIR has been populated with symlink
913# TODO document 1186# to system jar files or bundled jars removed.
1187# ------------------------------------------------------------------------------
914java-pkg_ensure-no-bundled-jars() { 1188java-pkg_ensure-no-bundled-jars() {
915 debug-print-function ${FUNCNAME} $* 1189 debug-print-function ${FUNCNAME} $*
916 pushd ${WORKDIR} >/dev/null 2>/dev/null
917 1190
918 local bundled_jars=$(find . -name "*.jar" -type f) 1191 local bundled_jars=$(java-pkg_find-normal-jars)
919 if [[ -n ${bundled_jars} ]]; then 1192 if [[ -n ${bundled_jars} ]]; then
920 echo "Bundled jars found:" 1193 echo "Bundled jars found:"
921 local jar 1194 local jar
922 for jar in ${bundled_jars}; do 1195 for jar in ${bundled_jars}; do
923 echo $(pwd)${jar/./} 1196 echo $(pwd)${jar/./}
924 done 1197 done
925 die "Bundled jars found!" 1198 die "Bundled jars found!"
926
927 fi 1199 fi
928 popd >/dev/null 2>/dev/null
929} 1200}
930 1201
931# ------------------------------------------------------------------------------ 1202# ------------------------------------------------------------------------------
932# @internal-function java-pkg_ensure-vm-version-sufficient 1203# @internal-function java-pkg_ensure-vm-version-sufficient
933# 1204#
945 fi 1216 fi
946} 1217}
947 1218
948# ------------------------------------------------------------------------------ 1219# ------------------------------------------------------------------------------
949# @internal-function java-pkg_is-vm-version-sufficient 1220# @internal-function java-pkg_is-vm-version-sufficient
950# 1221#
951# @return zero - VM is sufficient 1222# @return zero - VM is sufficient
952# @return non-zero - VM is not sufficient 1223# @return non-zero - VM is not sufficient
953# ------------------------------------------------------------------------------ 1224# ------------------------------------------------------------------------------
954java-pkg_is-vm-version-sufficient() { 1225java-pkg_is-vm-version-sufficient() {
955 debug-print-function ${FUNCNAME} $* 1226 debug-print-function ${FUNCNAME} $*
975 die "Active Java VM too old" 1246 die "Active Java VM too old"
976 fi 1247 fi
977} 1248}
978 1249
979# ------------------------------------------------------------------------------ 1250# ------------------------------------------------------------------------------
980# @internal-function java-pkg_is-vm-version-eq 1251# @internal-function java-pkg_is-vm-version-eq
981# 1252#
982# @param $@ - VM version to compare current VM to 1253# @param $@ - VM version to compare current VM to
983# @return zero - VM versions are equal 1254# @return zero - VM versions are equal
984# @return non-zero - VM version are not equal 1255# @return non-zero - VM version are not equal
985# ------------------------------------------------------------------------------ 1256# ------------------------------------------------------------------------------
986java-pkg_is-vm-version-eq() { 1257java-pkg_is-vm-version-eq() {
1016# 1287#
1017# @param $@ - VM version to compare current to 1288# @param $@ - VM version to compare current to
1018# ------------------------------------------------------------------------------ 1289# ------------------------------------------------------------------------------
1019java-pkg_ensure-vm-version-ge() { 1290java-pkg_ensure-vm-version-ge() {
1020 debug-print-function ${FUNCNAME} $* 1291 debug-print-function ${FUNCNAME} $*
1021 1292
1022 if ! java-pkg_is-vm-version-ge "$@" ; then 1293 if ! java-pkg_is-vm-version-ge "$@" ; then
1023 debug-print "vm is not suffient" 1294 debug-print "vm is not suffient"
1024 eerror "This package requires a Java VM version >= $@" 1295 eerror "This package requires a Java VM version >= $@"
1025 einfo "Please use java-config -S to set the correct one" 1296 einfo "Please use java-config -S to set the correct one"
1026 die "Active Java VM too old" 1297 die "Active Java VM too old"
1027 fi 1298 fi
1028} 1299}
1029 1300
1030# ------------------------------------------------------------------------------ 1301# ------------------------------------------------------------------------------
1031# @internal-function java-pkg_is-vm-version-ge 1302# @internal-function java-pkg_is-vm-version-ge
1032# 1303#
1033# @param $@ - VM version to compare current VM to 1304# @param $@ - VM version to compare current VM to
1034# @return zero - current VM version is greater than checked version 1305# @return zero - current VM version is greater than checked version
1035# @return non-zero - current VM version is not greater than checked version 1306# @return non-zero - current VM version is not greater than checked version
1036# ------------------------------------------------------------------------------ 1307# ------------------------------------------------------------------------------
1037java-pkg_is-vm-version-ge() { 1308java-pkg_is-vm-version-ge() {
1060java-pkg_get-current-vm() { 1331java-pkg_get-current-vm() {
1061 echo ${GENTOO_VM} 1332 echo ${GENTOO_VM}
1062} 1333}
1063 1334
1064java-pkg_current-vm-matches() { 1335java-pkg_current-vm-matches() {
1065 hasq java-pkg_get-currenv-vm ${@} 1336 hasq $(java-pkg_get-current-vm) ${@}
1066 return $? 1337 return $?
1067} 1338}
1068 1339
1069# ------------------------------------------------------------------------------ 1340# ------------------------------------------------------------------------------
1070# @ebuild-function java-pkg_get-source 1341# @ebuild-function java-pkg_get-source
1071# 1342#
1072# Determines what source version should be used, for passing to -source. 1343# Determines what source version should be used, for passing to -source.
1073# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1344# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1074# 1345#
1075# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1346# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1076# ------------------------------------------------------------------------------ 1347# ------------------------------------------------------------------------------
1081# ------------------------------------------------------------------------------ 1352# ------------------------------------------------------------------------------
1082# @ebuild-function java-pkg_get-target 1353# @ebuild-function java-pkg_get-target
1083# 1354#
1084# Determines what target version should be used, for passing to -target. 1355# Determines what target version should be used, for passing to -target.
1085# If you don't care about lower versions, you can set _WANT_TARGET to the 1356# If you don't care about lower versions, you can set _WANT_TARGET to the
1086# version of your JDK. 1357# version of your JDK.
1087# Remember doing this will mostly like cause things to break.
1088# Doesn't allow it to be lower then the one in depend.
1089# Doesn't allow it to be higher then the active vm.
1090# 1358#
1091# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1359# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1092# ------------------------------------------------------------------------------ 1360# ------------------------------------------------------------------------------
1093java-pkg_get-target() { 1361java-pkg_get-target() {
1094 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1095 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1096 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1097 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1098 echo ${JAVA_PKG_WANT_TARGET}
1099 else
1100 echo ${min}
1101 fi
1102 else
1103 echo ${min}
1104 fi
1105
1106 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1362 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1107} 1363}
1108 1364
1109java-pkg_get-javac() { 1365java-pkg_get-javac() {
1110 debug-print-function ${FUNCNAME} $* 1366 debug-print-function ${FUNCNAME} $*
1111 1367
1112 java-pkg_init-compiler_ 1368
1113 local compiler="${GENTOO_COMPILER}" 1369 local compiler="${GENTOO_COMPILER}"
1114 1370
1115 local compiler_executable 1371 local compiler_executable
1116 if [[ "${compiler}" = "javac" ]]; then 1372 if [[ "${compiler}" = "javac" ]]; then
1117 # nothing fancy needs to be done for javac 1373 # nothing fancy needs to be done for javac
1125 unset JAVAC 1381 unset JAVAC
1126 # try to get value of JAVAC 1382 # try to get value of JAVAC
1127 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1383 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1128 export JAVAC=${old_javac} 1384 export JAVAC=${old_javac}
1129 1385
1130 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1386 if [[ -z ${compiler_executable} ]]; then
1131 1387 echo "JAVAC is empty or undefined in ${compiler_env}"
1388 return 1
1389 fi
1390
1132 # check that it's executable 1391 # check that it's executable
1133 if [[ ! -x ${compiler_executable} ]]; then 1392 if [[ ! -x ${compiler_executable} ]]; then
1134 eerror "Could not find ${compiler_executable}!"
1135 die "${compiler_executable} doesn't exist, or isn't executable" 1393 echo "${compiler_executable} doesn't exist, or isn't executable"
1394 return 1
1136 fi 1395 fi
1137 else 1396 else
1138 eerror "Could not find environment file for ${compiler}" 1397 echo "Could not find environment file for ${compiler}"
1139 die "Could not find ${compiler_env}" 1398 return 1
1140 fi 1399 fi
1141 fi 1400 fi
1142 echo ${compiler_executable} 1401 echo ${compiler_executable}
1143} 1402}
1144 1403
1145# ------------------------------------------------------------------------------ 1404# ------------------------------------------------------------------------------
1146# @ebuild-function java-pkg_javac-args 1405# @ebuild-function java-pkg_javac-args
1147# 1406#
1148# If an ebuild uses javac directly, instead of using ejavac, it should call this 1407# If an ebuild uses javac directly, instead of using ejavac, it should call this
1149# to know what -source/-target to use. 1408# to know what -source/-target to use.
1150# 1409#
1151# @return string - arguments to pass to javac, complete with -target and -source 1410# @return string - arguments to pass to javac, complete with -target and -source
1154 debug-print-function ${FUNCNAME} $* 1413 debug-print-function ${FUNCNAME} $*
1155 1414
1156 local want_source="$(java-pkg_get-source)" 1415 local want_source="$(java-pkg_get-source)"
1157 local want_target="$(java-pkg_get-target)" 1416 local want_target="$(java-pkg_get-target)"
1158 1417
1159 local source_str="-source ${want_source}" 1418 local source_str="-source ${want_source}"
1160 local target_str="-target ${want_target}" 1419 local target_str="-target ${want_target}"
1161 1420
1162 debug-print "want source: ${want_source}" 1421 debug-print "want source: ${want_source}"
1163 debug-print "want target: ${want_target}" 1422 debug-print "want target: ${want_target}"
1164 1423
1165 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1424 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1166 debug-print "could not find valid -source/-target values" 1425 debug-print "could not find valid -source/-target values for javac"
1167 die "Could not find valid -source/-target values" 1426 echo "Could not find valid -source/-target values for javac"
1427 return 1
1168 else 1428 else
1169 if java-pkg_is-vm-version-ge "1.4"; then 1429 if java-pkg_is-vm-version-ge "1.4"; then
1170 echo "${source_str} ${target_str}" 1430 echo "${source_str} ${target_str}"
1171 else 1431 else
1172 echo "${target_str}" 1432 echo "${target_str}"
1176 1436
1177# TODO document 1437# TODO document
1178java-pkg_get-jni-cflags() { 1438java-pkg_get-jni-cflags() {
1179 local flags="-I${JAVA_HOME}/include" 1439 local flags="-I${JAVA_HOME}/include"
1180 1440
1441 local platform="linux"
1442 use elibc_FreeBSD && platform="freebsd"
1443
1181 # TODO do a check that the directories are valid 1444 # TODO do a check that the directories are valid
1182 # TODO figure out how to cope with other things than linux...
1183 flags="${flags} -I${JAVA_HOME}/include/linux" 1445 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1184 1446
1185 echo ${flags} 1447 echo ${flags}
1186} 1448}
1187 1449
1188java-pkg_ensure-gcj() { 1450java-pkg_ensure-gcj() {
1193 ebeep 5 1455 ebeep 5
1194 die "No GCJ support found!" 1456 die "No GCJ support found!"
1195 fi 1457 fi
1196} 1458}
1197 1459
1460java-pkg_ensure-test() {
1461 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1462 && hasq test ${IUSE} && ! use test;
1463 then
1464 eerror "You specified FEATURES=test, but USE=test is needed"
1465 eerror "to pull in the additional dependencies for testing"
1466 die "Need USE=test enabled"
1467 fi
1468}
1469
1470# ------------------------------------------------------------------------------
1471# @ebuild-function java-pkg_register-ant-task
1472#
1473# Register this package as ant task, so that ant will load it when no specific
1474# ANT_TASKS are specified. Note that even without this registering, all packages
1475# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1476# packages, but can be also used by other ebuilds that used to symlink their
1477# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1478# compatibility.
1479#
1480# @param --version x.y Register only for ant version x.y (otherwise for any ant
1481# version). Used by the ant-* packages to prevent loading of mismatched
1482# ant-core ant tasks after core was updated, before the tasks are updated,
1483# without a need for blockers.
1484# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1485# ------------------------------------------------------------------------------
1486java-pkg_register-ant-task() {
1487 local TASKS_DIR="tasks"
1488
1489 # check for --version x.y parameters
1490 while [[ -n "${1}" && -n "${2}" ]]; do
1491 local var="${1#--}"
1492 local val="${2}"
1493 if [[ "${var}" == "version" ]]; then
1494 TASKS_DIR="tasks-${val}"
1495 else
1496 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1497 fi
1498 shift 2
1499 done
1500
1501 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1502
1503 dodir /usr/share/ant/${TASKS_DIR}
1504 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1505}
1506
1507# ------------------------------------------------------------------------------
1508# @internal-function java-pkg_ant-tasks-from-deps
1509#
1510# Function to determine ANT_TASKS from DEPEND variable for backwards
1511# compatibility with ebuilds that don't set ANT_TASKS before calling eant() or
1512# WANT_ANT_TASKS before inheriting java-pkg-2. If the DEPEND string contains
1513# "dev-java/ant" or "dev-java/ant-tasks", then it returns "all", otherwise
1514# "none". It's not smart enough to cope with USE flag depends but that shouldn't
1515# be a problem, the worst it can do is activace all tasks when not needed.
1516# Note that this is called only with JAVA_PKG_STRICT=1, to find ebuilds with
1517# insufficient dependencies, otherwise all available tasks are used for
1518# backwards compatilbility.
1519#
1520# @return "all" or "none"
1521# ------------------------------------------------------------------------------
1522java-pkg_ant-tasks-from-deps() {
1523 local found_ant found_ant_tasks
1524
1525 for dep in ${DEPEND}
1526 do
1527 local ant="$(awk '/(dev-java\/ant)/ { if (match($1, "(dev-java/ant)((-[0-9])+|$)", m)) print m[1] }' <<< ${dep})"
1528 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1529 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1530 done
1531
1532 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1533 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks"
1534 echo "all"
1535 else
1536 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1537 # so we deactivate all tasks that may be installed
1538 echo "none"
1539 fi
1540}
1541
1542# ------------------------------------------------------------------------------
1543# @internal-function java-pkg_ant-tasks-depend
1544#
1545# Translates the WANT_ANT_TASKS variable into valid dependencies.
1546# ------------------------------------------------------------------------------
1547java-pkg_ant-tasks-depend() {
1548 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1549
1550 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1551 local DEP=""
1552 for i in ${WANT_ANT_TASKS}
1553 do
1554 if [[ ${i} != ant-* ]]; then
1555 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1556 return 1
1557 fi
1558 DEP="${DEP}dev-java/${i} "
1559 done
1560 echo ${DEP}
1561 return 0
1562 else
1563 return 0
1564 fi
1565}
1566
1198# ------------------------------------------------------------------------------ 1567# ------------------------------------------------------------------------------
1199# @section-end helper 1568# @section-end helper
1200# ------------------------------------------------------------------------------ 1569# ------------------------------------------------------------------------------
1201 1570
1202# ------------------------------------------------------------------------------ 1571# ------------------------------------------------------------------------------
1209 1578
1210# ------------------------------------------------------------------------------ 1579# ------------------------------------------------------------------------------
1211# @ebuild-function eant 1580# @ebuild-function eant
1212# 1581#
1213# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1582# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1214# compiler. 1583# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1215# 1584# variables:
1585# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1586# gentoo.classpath property. Be sure to call
1587# java-ant_rewrite-classpath in src_unpack.
1588# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1216# ------------------------------------------------------------------------------ 1589# ------------------------------------------------------------------------------
1217eant() { 1590eant() {
1218 debug-print-function ${FUNCNAME} $* 1591 debug-print-function ${FUNCNAME} $*
1219 1592
1220 # FIXME get this working 1593 # FIXME get this working
1221# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1594# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1222# java-pkg_announce-qa-violation \ 1595# java-pkg_announce-qa-violation \
1223# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1596# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1224# fi 1597# fi
1225 1598
1226 local antflags 1599 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then
1600 local msg="You should inherit java-ant-2 when using eant"
1601 java-pkg_announce-qa-violation ${msg}
1602 die ${msg}
1603 fi
1604
1605 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1606
1227 java-pkg_init-compiler_ 1607 java-pkg_init-compiler_
1228 local compiler="${GENTOO_COMPILER}" 1608 local compiler="${GENTOO_COMPILER}"
1229 1609
1230 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1610 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1231 1611
1233 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1613 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1234 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1614 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1235 fi 1615 fi
1236 1616
1237 if [[ ${compiler} != "javac" ]]; then 1617 if [[ ${compiler} != "javac" ]]; then
1238 antflags="-Dbuild.compiler=${build_compiler}" 1618 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1239 # Figure out any extra stuff to put on the classpath for compilers aside 1619 # Figure out any extra stuff to put on the classpath for compilers aside
1240 # from javac 1620 # from javac
1241 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1621 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1242 # java-config -p 1622 # java-config -p
1243 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1623 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1248 1628
1249 if is-java-strict; then 1629 if is-java-strict; then
1250 einfo "Disabling system classpath for ant" 1630 einfo "Disabling system classpath for ant"
1251 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1631 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1252 fi 1632 fi
1253 1633
1254 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1634 for arg in "${@}"; do
1255 antflags="${antflags} -debug" 1635 if [[ ${arg} = -lib ]]; then
1636 if is-java-strict; then
1637 eerror "You should not use the -lib argument to eant because it will fail"
1638 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1639 eerror "or ant properties to make dependencies available."
1640 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1641 eerror "split ant (>=dev-java/ant-core-1.7)."
1642 die "eant -lib is deprecated/forbidden"
1643 else
1644 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1645 echo "more info."
1646 fi
1256 fi 1647 fi
1257 1648 done
1649
1650 if has_version ">=dev-java/ant-core-1.7.0"; then
1651 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1652 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1653
1654 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1655 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1656
1657 if is-java-strict; then
1658 # if ant-tasks were not set by ebuild or forced, try to determine them from depends
1659 if [[ -z "${ANT_TASKS}" ]]; then
1660 ANT_TASKS="$(java-pkg_ant-tasks-from-deps)"
1661 fi
1662 else
1663 # if ant-tasks is not set by ebuild or forced, activate all of them
1664 ANT_TASKS="${ANT_TASKS:-all}"
1665 fi
1666
1667 # at this point, ANT_TASKS should be "all", "none" or explicit list
1668 if [[ "${ANT_TASKS}" == "all" ]]; then
1669 einfo "Using all available ANT_TASKS"
1670 elif [[ "${ANT_TASKS}" == "none" ]]; then
1671 einfo "Disabling all optional ANT_TASKS"
1672 else
1673 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1674 fi
1675
1676 export ANT_TASKS
1677 fi
1678
1679 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1680 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1681
1682 local gcp="${EANT_GENTOO_CLASSPATH}"
1683
1684 if [[ ${EBUILD_PHASE} = "test" ]]; then
1685 antflags="${antflags} -DJunit.present=true"
1686 [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1687 fi
1688
1689 local cp
1690
1691 for atom in ${gcp}; do
1692 cp="${cp}:$(java-pkg_getjars ${atom})"
1693 done
1694
1695 if [[ ${cp} ]]; then
1696 # It seems ant does not like single quotes around ${cp}
1697 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1698 fi
1699
1258 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1700 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1701 debug-print "Calling ant: ${antflags} ${@}"
1259 ant ${antflags} "${@}" || die "eant failed" 1702 ant ${antflags} "${@}" || die "eant failed"
1260 1703
1261} 1704}
1262 1705
1263# ------------------------------------------------------------------------------ 1706# ------------------------------------------------------------------------------
1264# @ebuild-function ejavac 1707# @ebuild-function ejavac
1265# 1708#
1266# Javac wrapper function. Will use the appropriate compiler, based on 1709# Javac wrapper function. Will use the appropriate compiler, based on
1267# /etc/java-config/compilers.conf 1710# /etc/java-config/compilers.conf
1268# 1711#
1269# @param $@ - Arguments to be passed to the compiler 1712# @param $@ - Arguments to be passed to the compiler
1270# ------------------------------------------------------------------------------ 1713# ------------------------------------------------------------------------------
1271ejavac() { 1714ejavac() {
1272 debug-print-function ${FUNCNAME} $* 1715 debug-print-function ${FUNCNAME} $*
1273 1716
1274 # FIXME using get-javac ends up printing stuff with einfo 1717 java-pkg_init-compiler_
1718
1719 local compiler_executable
1275# local compiler_executable=$(java-pkg_get-javac) 1720 compiler_executable=$(java-pkg_get-javac)
1276 local compiler_executable="javac" 1721 if [[ ${?} != 0 ]]; then
1722 eerror "There was a problem determining compiler: ${compiler_executable}"
1723 die "get-javac failed"
1724 fi
1277 1725
1726 local javac_args
1727 javac_args="$(java-pkg_javac-args)"
1728 if [[ ${?} != 0 ]]; then
1729 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1730 die "java-pkg_javac-args failed"
1731 fi
1732
1278 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1733 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1279 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1734 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1280} 1735}
1281 1736
1282# ------------------------------------------------------------------------------ 1737# ------------------------------------------------------------------------------
1283# @ebuild-function java-pkg_filter-compiler 1738# @ebuild-function java-pkg_filter-compiler
1284# 1739#
1285# Used to prevent the use of some compilers. Should be used in src_compile. 1740# Used to prevent the use of some compilers. Should be used in src_compile.
1286# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1741# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1287# 1742#
1288# @param $@ - compilers to filter 1743# @param $@ - compilers to filter
1289# ------------------------------------------------------------------------------ 1744# ------------------------------------------------------------------------------
1307# ------------------------------------------------------------------------------ 1762# ------------------------------------------------------------------------------
1308# @ebuild-function use_doc 1763# @ebuild-function use_doc
1309# 1764#
1310# Helper function for getting ant to build javadocs. If the user has USE=doc, 1765# Helper function for getting ant to build javadocs. If the user has USE=doc,
1311# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1766# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1312# 1767#
1313# The output of this should be passed to ant. 1768# The output of this should be passed to ant.
1314# 1769#
1315# Example: build javadocs by calling 'javadoc' target 1770# Example: build javadocs by calling 'javadoc' target
1316# eant $(use_doc) 1771# eant $(use_doc)
1317# Example: build javadocs by calling 'apidoc' target 1772# Example: build javadocs by calling 'apidoc' target
1322# ------------------------------------------------------------------------------ 1777# ------------------------------------------------------------------------------
1323use_doc() { 1778use_doc() {
1324 use doc && echo ${@:-javadoc} 1779 use doc && echo ${@:-javadoc}
1325} 1780}
1326 1781
1782
1327# ------------------------------------------------------------------------------ 1783# ------------------------------------------------------------------------------
1328# @section-end build 1784# @section-end build
1329# ------------------------------------------------------------------------------ 1785# ------------------------------------------------------------------------------
1330 1786
1331# ------------------------------------------------------------------------------ 1787# ------------------------------------------------------------------------------
1332# @section-begin internal 1788# @section-begin internal
1333# @section-summary Internal functions 1789# @section-summary Internal functions
1334# 1790#
1335# Do __NOT__ use any of these from an ebuild! These are only to be used from 1791# Do __NOT__ use any of these from an ebuild! These are only to be used from
1336# within the java eclasses. 1792# within the java eclasses.
1337# ------------------------------------------------------------------------------ 1793# ------------------------------------------------------------------------------
1338 1794
1339# ----------------------------------------------------------------------------- 1795# -----------------------------------------------------------------------------
1340# @function-internal java-pkg_init 1796# @function-internal java-pkg_init
1341# 1797#
1342# The purpose of this function, as the name might imply, is to initialize the 1798# The purpose of this function, as the name might imply, is to initialize the
1343# Java environment. It ensures that that there aren't any environment variables 1799# Java environment. It ensures that that there aren't any environment variables
1344# that'll muss things up. It initializes some variables, which are used 1800# that'll muss things up. It initializes some variables, which are used
1345# internally. And most importantly, it'll switch the VM if necessary. 1801# internally. And most importantly, it'll switch the VM if necessary.
1346# 1802#
1349# 1805#
1350# ----------------------------------------------------------------------------- 1806# -----------------------------------------------------------------------------
1351java-pkg_init() { 1807java-pkg_init() {
1352 unset JAVAC 1808 unset JAVAC
1353 unset JAVA_HOME 1809 unset JAVA_HOME
1810
1811 # People do all kinds of weird things.
1812 # http://forums.gentoo.org/viewtopic-p-3943166.html
1813 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
1814 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
1815 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
1816 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
1817 ewarn "sun-jdk vms and and as such break configure scripts that"
1818 ewarn "use it (for example app-office/openoffice) so we filter it out."
1819 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
1820 ewarn "make.conf for example) to silence this warning or"
1821 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
1822 fi
1823
1824 if [[ -z ${accept} ]]; then
1825 unset _JAVA_OPTIONS
1826 # phase hooks make this run many times without this
1827 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1828 fi
1829
1354 java-pkg_init_paths_ 1830 java-pkg_init_paths_
1355 java-pkg_switch-vm 1831 java-pkg_switch-vm
1356 PATH=${JAVA_HOME}/bin:${PATH} 1832 PATH=${JAVA_HOME}/bin:${PATH}
1357 1833
1358 # TODO we will probably want to set JAVAC and JAVACFLAGS 1834 # TODO we will probably want to set JAVAC and JAVACFLAGS
1359 1835
1360 # Do some QA checks 1836 # Do some QA checks
1361 java-pkg_check-jikes 1837 java-pkg_check-jikes
1362 1838
1363 # When users have crazy classpaths some packages can fail to compile. 1839 # When users have crazy classpaths some packages can fail to compile.
1364 # and everything should work with empty CLASSPATH. 1840 # and everything should work with empty CLASSPATH.
1365 # This also helps prevent unexpected dependencies on random things 1841 # This also helps prevent unexpected dependencies on random things
1366 # from the CLASSPATH. 1842 # from the CLASSPATH.
1367 unset CLASSPATH 1843 unset CLASSPATH
1844
1845 # Unset external ANT_ stuff
1846 unset ANT_TASKS
1847 unset ANT_OPTS
1368} 1848}
1369 1849
1370# ------------------------------------------------------------------------------ 1850# ------------------------------------------------------------------------------
1371# @function-internal java-pkg-init-compiler_ 1851# @function-internal java-pkg-init-compiler_
1372# 1852#
1373# This function attempts to figure out what compiler should be used. It does 1853# This function attempts to figure out what compiler should be used. It does
1374# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1854# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1375# COMPILERS variable defined there. 1855# COMPILERS variable defined there.
1376# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1856# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1377# 1857#
1378# It will go through the list of compilers, and verify that it supports the 1858# It will go through the list of compilers, and verify that it supports the
1379# target and source that are needed. If it is not suitable, then the next 1859# target and source that are needed. If it is not suitable, then the next
1380# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1860# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1381# isn't done. 1861# isn't done.
1382# 1862#
1404 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1884 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1405 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1885 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1406 else 1886 else
1407 compilers=${JAVA_PKG_FORCE_COMPILER} 1887 compilers=${JAVA_PKG_FORCE_COMPILER}
1408 fi 1888 fi
1409 1889
1410 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1890 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1411 1891
1412 # Figure out if we should announce what compiler we're using 1892 # Figure out if we should announce what compiler we're using
1413 local compiler 1893 local compiler
1414 for compiler in ${compilers}; do 1894 for compiler in ${compilers}; do
1417 if [[ ${compiler} = "javac" ]]; then 1897 if [[ ${compiler} = "javac" ]]; then
1418 debug-print "Found javac... breaking" 1898 debug-print "Found javac... breaking"
1419 export GENTOO_COMPILER="javac" 1899 export GENTOO_COMPILER="javac"
1420 break 1900 break
1421 fi 1901 fi
1422 1902
1423 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1903 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1424 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1904 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1425 einfo "Filtering ${compiler}" 1905 einfo "Filtering ${compiler}"
1426 continue 1906 continue
1427 fi 1907 fi
1428 fi 1908 fi
1429 1909
1430 # for non-javac, we need to make sure it supports the right target and 1910 # for non-javac, we need to make sure it supports the right target and
1431 # source 1911 # source
1432 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1912 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1433 if [[ -f ${compiler_env} ]]; then 1913 if [[ -f ${compiler_env} ]]; then
1434 local desired_target="$(java-pkg_get-target)" 1914 local desired_target="$(java-pkg_get-target)"
1516# Writes the package.env out to disk. 1996# Writes the package.env out to disk.
1517# 1997#
1518# ------------------------------------------------------------------------------ 1998# ------------------------------------------------------------------------------
1519# TODO change to do-write, to match everything else 1999# TODO change to do-write, to match everything else
1520java-pkg_do_write_() { 2000java-pkg_do_write_() {
2001 java-pkg_init_paths_
1521 # Create directory for package.env 2002 # Create directory for package.env
1522 dodir "${JAVA_PKG_SHAREPATH}" 2003 dodir "${JAVA_PKG_SHAREPATH}"
1523 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2004 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1524 # Create package.env 2005 # Create package.env
1525 ( 2006 (
1530 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2011 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1531 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2012 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1532 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2013 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1533 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2014 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1534 ) > "${JAVA_PKG_ENV}" 2015 ) > "${JAVA_PKG_ENV}"
1535 2016
1536 # register target/source 2017 # register target/source
1537 local target="$(java-pkg_get-target)" 2018 local target="$(java-pkg_get-target)"
1538 local source="$(java-pkg_get-source)" 2019 local source="$(java-pkg_get-source)"
1539 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 2020 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1540 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 2021 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1553 # Strip unnecessary leading and trailing colons 2034 # Strip unnecessary leading and trailing colons
1554 # TODO try to cleanup if possible 2035 # TODO try to cleanup if possible
1555 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2036 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1556 fi 2037 fi
1557} 2038}
1558
1559 2039
1560# ------------------------------------------------------------------------------ 2040# ------------------------------------------------------------------------------
1561# @internal-function java-pkg_record-jar_ 2041# @internal-function java-pkg_record-jar_
1562# 2042#
1563# Record a dependency to the package.env 2043# Record a dependency to the package.env
1607 fi 2087 fi
1608} 2088}
1609 2089
1610# ------------------------------------------------------------------------------ 2090# ------------------------------------------------------------------------------
1611# @internal-function java-pkg_expand_dir_ 2091# @internal-function java-pkg_expand_dir_
1612# 2092#
1613# Gets the full path of the file/directory's parent. 2093# Gets the full path of the file/directory's parent.
1614# @param $1 - file/directory to find parent directory for 2094# @param $1 - file/directory to find parent directory for
1615# @return - path to $1's parent directory 2095# @return - path to $1's parent directory
1616# ------------------------------------------------------------------------------ 2096# ------------------------------------------------------------------------------
1617java-pkg_expand_dir_() { 2097java-pkg_expand_dir_() {
1644# ------------------------------------------------------------------------------ 2124# ------------------------------------------------------------------------------
1645java-pkg_setup-vm() { 2125java-pkg_setup-vm() {
1646 debug-print-function ${FUNCNAME} $* 2126 debug-print-function ${FUNCNAME} $*
1647 2127
1648 local vendor="$(java-pkg_get-vm-vendor)" 2128 local vendor="$(java-pkg_get-vm-vendor)"
1649 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2129 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1650 addpredict "/dev/random" 2130 addpredict "/dev/random"
1651 elif [[ "${vendor}" == "ibm" ]]; then 2131 elif [[ "${vendor}" == "ibm" ]]; then
1652 addpredict "/proc/self/maps" 2132 addpredict "/proc/self/maps"
1653 addpredict "/proc/cpuinfo" 2133 addpredict "/proc/cpuinfo"
1654 export LANG="C" LC_ALL="C" 2134 export LANG="C" LC_ALL="C"
1703# @return - The version of the current VM 2183# @return - The version of the current VM
1704# ------------------------------------------------------------------------------ 2184# ------------------------------------------------------------------------------
1705java-pkg_get-vm-version() { 2185java-pkg_get-vm-version() {
1706 debug-print-function ${FUNCNAME} $* 2186 debug-print-function ${FUNCNAME} $*
1707 2187
1708 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 2188 java-config -g PROVIDES_VERSION
1709} 2189}
1710 2190
1711# ------------------------------------------------------------------------------ 2191# ------------------------------------------------------------------------------
1712# @internal-function java-pkg_switch-vm 2192# @internal-function java-pkg_switch-vm
1713# 2193#
1714# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2194# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1715# verify that the current VM is sufficient. 2195# verify that the current VM is sufficient.
1716# Setup the environment for the VM being used. 2196# Setup the environment for the VM being used.
1717# ------------------------------------------------------------------------------ 2197# ------------------------------------------------------------------------------
1718java-pkg_switch-vm() { 2198java-pkg_switch-vm() {
2199 debug-print-function ${FUNCNAME} $*
2200
1719 if java-pkg_needs-vm; then 2201 if java-pkg_needs-vm; then
1720 # Use the VM specified by JAVA_PKG_FORCE_VM 2202 # Use the VM specified by JAVA_PKG_FORCE_VM
1721 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2203 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1722 # If you're forcing the VM, I hope you know what your doing... 2204 # If you're forcing the VM, I hope you know what your doing...
2205 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1723 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2206 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1724 # if we're allowed to switch the vm... 2207 # if we're allowed to switch the vm...
1725 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2208 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1726 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2209 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1727 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2210 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1728 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2211 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1729 else 2212 else
1730 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2213 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2214 fi
2215 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2216 eerror "Unable to determine VM for building from dependencies:"
2217 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2218 echo "VNEED: ${JAVA_PKG_VNEED}"
2219 die "Failed to determine VM for building."
2220 else
2221 export GENTOO_VM
1731 fi 2222 fi
1732 # otherwise just make sure the current VM is sufficient 2223 # otherwise just make sure the current VM is sufficient
1733 else 2224 else
1734 java-pkg_ensure-vm-version-sufficient 2225 java-pkg_ensure-vm-version-sufficient
1735 fi 2226 fi
1736 debug-print "Using: $(java-config -f)" 2227 debug-print "Using: $(java-config -f)"
1737 2228
1738 java-pkg_setup-vm 2229 java-pkg_setup-vm
1739 2230
1740 export JAVA=$(java-config --java) 2231 export JAVA=$(java-config --java)
1741 export JAVAC=$(java-config --javac) 2232 export JAVAC=$(java-config --javac)
1742 export JAVACFLAGS="$(java-pkg_javac-args)" 2233 JAVACFLAGS="$(java-pkg_javac-args)"
2234 if [[ ${?} != 0 ]]; then
2235 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2236 die "java-pkg_javac-args failed"
2237 fi
1743 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2238 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2239 export JAVACFLAGS
1744 2240
1745 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2241 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1746 export JDK_HOME=${JAVA_HOME} 2242 export JDK_HOME=${JAVA_HOME}
1747 2243
1748 #TODO If you know a better solution let us know. 2244 #TODO If you know a better solution let us know.
1749 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2245 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1750 2246
1751 local tann="${T}/announced-vm" 2247 local tann="${T}/announced-vm"
1752 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2248 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1753 # Add a check for setup/preinst phase... to avoid duplicate outputs 2249 # Add a check for setup/preinst phase... to avoid duplicate outputs
1754 # for when FEATURES=buildpkg 2250 # for when FEATURES=buildpkg
1755 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 2251 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1794 einfo "Classes" 2290 einfo "Classes"
1795 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR}," 2291 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1796 fi 2292 fi
1797} 2293}
1798 2294
1799# TODO document 2295# ------------------------------------------------------------------------------
2296# @internal-function java-pkg_verify-classes
2297#
1800# Verify that the classes were compiled for the right source / target 2298# Verify that the classes were compiled for the right source / target. Dies if
2299# not.
2300# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2301# ------------------------------------------------------------------------------
1801java-pkg_verify-classes() { 2302java-pkg_verify-classes() {
1802 ebegin "Verifying java class versions"
1803 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 2303 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1804 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 2304 local target=$(java-pkg_get-target)
2305 local result
2306 local log="${T}/class-version-verify.log"
2307 if [[ -n "${1}" ]]; then
2308 class-version-verify.py -v -t ${target} "${1}" > "${log}"
1805 result=$? 2309 result=$?
1806 eend ${result}
1807 if [[ ${result} == 0 ]]; then
1808 einfo "All good"
1809 else 2310 else
1810 ewarn "Possible problem" 2311 ebegin "Verifying java class versions (target: ${target})"
1811 die "Bad class files found" 2312 class-version-verify.py -v -t ${target} -r "${D}" > "${log}"
2313 result=$?
2314 eend ${result}
1812 fi 2315 fi
2316 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2317 if [[ ${result} != 0 ]]; then
2318 eerror "Incorrect bytecode version found"
2319 [[ -n "${1}" ]] && eerror "in file: ${1}"
2320 eerror "See ${log} for more details."
2321 die "Incorrect bytecode found"
2322 fi
1813} 2323}
1814
1815 2324
1816# ------------------------------------------------------------------------------ 2325# ------------------------------------------------------------------------------
1817# @section-end internal 2326# @section-end internal
1818# ------------------------------------------------------------------------------ 2327# ------------------------------------------------------------------------------
1819 2328
1851 let "JAVA_PKG_QA_VIOLATIONS+=1" 2360 let "JAVA_PKG_QA_VIOLATIONS+=1"
1852 export JAVA_PKG_QA_VIOLATIONS 2361 export JAVA_PKG_QA_VIOLATIONS
1853} 2362}
1854 2363
1855is-java-strict() { 2364is-java-strict() {
1856 hasq java-strict ${FEATURES} && ! hasq -java-strict ${FEATURES} 2365 [[ -n ${JAVA_PKG_STRICT} ]]
1857 return $? 2366 return $?
1858} 2367}
1859 2368
1860# ------------------------------------------------------------------------------ 2369# ------------------------------------------------------------------------------
1861# @eclass-end 2370# @eclass-end

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.66

  ViewVC Help
Powered by ViewVC 1.1.20