/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

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

  ViewVC Help
Powered by ViewVC 1.1.20