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

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

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20