/[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.4 Revision 1.150
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
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-2011, 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 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.150 2012/03/13 10:05:46 sera Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
15# 15#
16# This eclass provides functionality which is used by 16# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 18#
19# @warning 19# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 20# 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 21# 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. 22# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 23#
24# ----------------------------------------------------------------------------- 24# -----------------------------------------------------------------------------
25 25
26inherit eutils versionator multilib 26inherit eutils versionator multilib
27
28IUSE="elibc_FreeBSD"
27 29
28# ----------------------------------------------------------------------------- 30# -----------------------------------------------------------------------------
29# @section-begin variables 31# @section-begin variables
30# @section-title Variables 32# @section-title Variables
31# 33#
34 36
35# Make sure we use java-config-2 37# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 38export WANT_JAVA_CONFIG="2"
37 39
38# ----------------------------------------------------------------------------- 40# -----------------------------------------------------------------------------
41# @variable-external WANT_ANT_TASKS
42# @variable-default ""
43#
44# An $IFS separated list of ant tasks.
45# Ebuild can specify this variable before inheriting java-ant-2 eclass to
46# determine ANT_TASKS it needs. They will be automatically translated to
47# DEPEND variable and ANT_TASKS variable. JAVA_PKG_FORCE_ANT_TASKS can override
48# ANT_TASKS set by WANT_ANT_TASKS, but not the DEPEND due to caching.
49# Ebuilds that need to depend conditionally on certain tasks and specify them
50# differently for different eant calls can't use this simplified approach.
51# You also cannot specify version or anything else than ant-*.
52#
53# @example WANT_ANT_TASKS="ant-junit ant-trax"
54#
55# @seealso JAVA_PKG_FORCE_ANT_TASKS
56# -----------------------------------------------------------------------------
57#WANT_ANT_TASKS
58
59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP
61#
62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env
64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# -----------------------------------------------------------------------------
66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67
68# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
40# 70#
41# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
42# the version of java-config we want to use. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
43# portage, that includes phase hooks. 73# so that ebuilds can use new features without depending on specific versions.
44# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
46 94
47# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 97# @variable-default yes
50# 98#
66# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
67# 115#
68# ----------------------------------------------------------------------------- 116# -----------------------------------------------------------------------------
69 117
70# ----------------------------------------------------------------------------- 118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
129# -----------------------------------------------------------------------------
130
131# -----------------------------------------------------------------------------
71# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
72# 133#
73# Specify a specific VM version to compile for to use for -source. 134# Specify a specific VM version to compile for to use for -source.
74# Normally this is determined from DEPEND. 135# Normally this is determined from DEPEND.
75# See java-pkg_get-source function below. 136# See java-pkg_get-source function below.
97# ----------------------------------------------------------------------------- 158# -----------------------------------------------------------------------------
98 159
99# ----------------------------------------------------------------------------- 160# -----------------------------------------------------------------------------
100# @variable-internal JAVA_PKG_COMPILER_DIR 161# @variable-internal JAVA_PKG_COMPILER_DIR
101# @default /usr/share/java-config-2/compiler 162# @default /usr/share/java-config-2/compiler
102# 163#
103# Directory where compiler settings are saved, without trailing slash. 164# Directory where compiler settings are saved, without trailing slash.
104# Probably shouldn't touch this variable. 165# Probably shouldn't touch this variable.
105# ----------------------------------------------------------------------------- 166# -----------------------------------------------------------------------------
106JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 167JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
107 168
117 178
118# ----------------------------------------------------------------------------- 179# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_FORCE_COMPILER 180# @variable-external JAVA_PKG_FORCE_COMPILER
120# 181#
121# Explicitly set a list of compilers to use. This is normally read from 182# Explicitly set a list of compilers to use. This is normally read from
122# JAVA_PKG_COMPILERS_CONF. 183# JAVA_PKG_COMPILERS_CONF.
123# 184#
124# @note This should only be used internally or for testing. 185# @note This should only be used internally or for testing.
125# @example Use jikes and javac, in that order 186# @example Use jikes and javac, in that order
126# JAVA_PKG_FORCE_COMPILER="jikes javac" 187# JAVA_PKG_FORCE_COMPILER="jikes javac"
127# ----------------------------------------------------------------------------- 188# -----------------------------------------------------------------------------
128 189
190# -----------------------------------------------------------------------------
191# @variable-external JAVA_PKG_FORCE_ANT_TASKS
192#
193# An $IFS separated list of ant tasks. Can be set in environment before calling
194# emerge/ebuild to override variables set in ebuild, mainly for testing before
195# putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
196# eant() call, not the dependencies specified in WANT_ANT_TASKS.
197#
198# @example JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
199# ebuild foo.ebuild compile
200#
201# @seealso WANT_ANT_TASKS
202# -----------------------------------------------------------------------------
203
129# TODO document me 204# TODO document me
130JAVA_PKG_QA_VIOLATIONS=0 205JAVA_PKG_QA_VIOLATIONS=0
131 206
132# ----------------------------------------------------------------------------- 207# -----------------------------------------------------------------------------
133# @section-end variables 208# @section-end variables
140# 215#
141# These are used to install Java-related things, such as jars, Javadocs, JNI 216# These are used to install Java-related things, such as jars, Javadocs, JNI
142# libraries, etc. 217# libraries, etc.
143# ----------------------------------------------------------------------------- 218# -----------------------------------------------------------------------------
144 219
220# -----------------------------------------------------------------------------
221# @ebuild-function java-pkg_doexamples
222#
223# Installs given arguments to /usr/share/doc/${PF}/examples
224# If you give it only one parameter and it is a directory it will install
225# everything in that directory to the examples directory.
226#
227# @example
228# java-pkg_doexamples demo
229# java-pkg_doexamples demo/* examples/*
230#
231# @param --subdir - If the examples need a certain directory structure
232# @param $* - list of files to install
233# ------------------------------------------------------------------------------
234java-pkg_doexamples() {
235 debug-print-function ${FUNCNAME} $*
236
237 [[ ${#} -lt 1 ]] && die "At least one argument needed"
238
239 java-pkg_check-phase install
240
241 local dest=/usr/share/doc/${PF}/examples
242 if [[ ${1} == --subdir ]]; then
243 local dest=${dest}/${2}
244 dodir ${dest}
245 shift 2
246 fi
247
248 if [[ ${#} = 1 && -d ${1} ]]; then
249 ( # dont want to pollute calling env
250 insinto "${dest}"
251 doins -r ${1}/*
252 ) || die "Installing examples failed"
253 else
254 ( # dont want to pollute calling env
255 insinto "${dest}"
256 doins -r "$@"
257 ) || die "Installing examples failed"
258 fi
259
260 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
262}
145 263
146# ----------------------------------------------------------------------------- 264# -----------------------------------------------------------------------------
147# @ebuild-function java-pkg_dojar 265# @ebuild-function java-pkg_dojar
148# 266#
149# Installs any number of jars. 267# Installs any number of jars.
150# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 268# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
151# You can use java-pkg_jarinto to change this path. 269# You can use java-pkg_jarinto to change this path.
152# You should never install a jar with a package version in the filename. 270# You should never install a jar with a package version in the filename.
153# Instead, use java-pkg_newjar defined below. 271# Instead, use java-pkg_newjar defined below.
154# 272#
155# @example 273# @example
156# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 274# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
157# 275#
168 # Create JARDEST if it doesn't exist 286 # Create JARDEST if it doesn't exist
169 dodir ${JAVA_PKG_JARDEST} 287 dodir ${JAVA_PKG_JARDEST}
170 288
171 local jar 289 local jar
172 # for each jar 290 # for each jar
173 for jar in "$@"; do 291 for jar in "${@}"; do
174 local jar_basename=$(basename "${jar}") 292 local jar_basename=$(basename "${jar}")
175 293
176 java-pkg_check-versioned-jar ${jar_basename} 294 java-pkg_check-versioned-jar ${jar_basename}
177 295
178 # check if it exists 296 # check if it exists
179 if [[ -e "${jar}" ]] ; then 297 if [[ -e "${jar}" ]] ; then
298 # Don't overwrite if jar has already been installed with the same
299 # name
300 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
301 if [[ -e "${dest}" ]]; then
302 ewarn "Overwriting ${dest}"
303 fi
304
180 # install it into JARDEST if it's a non-symlink 305 # install it into JARDEST if it's a non-symlink
181 if [[ ! -L "${jar}" ]] ; then 306 if [[ ! -L "${jar}" ]] ; then
307 #but first check class version when in strict mode.
308 is-java-strict && java-pkg_verify-classes "${jar}"
309
182 INSDESTTREE="${JAVA_PKG_JARDEST}" \ 310 INSDESTTREE="${JAVA_PKG_JARDEST}" \
183 doins "${jar}" || die "failed to install ${jar}" 311 doins "${jar}" || die "failed to install ${jar}"
184 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}" 312 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
185 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}" 313 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
186 # make a symlink to the original jar if it's symlink 314 # make a symlink to the original jar if it's symlink
196 done 324 done
197 325
198 java-pkg_do_write_ 326 java-pkg_do_write_
199} 327}
200 328
329# ------------------------------------------------------------------------------
330# @internal-function depend-java-query
331#
332# Wrapper for the depend-java-query binary to enable passing USE in env.
333# Using env variables keeps this eclass working with java-config versions that
334# do not handle use flags.
335# ------------------------------------------------------------------------------
201 336
337depend-java-query() {
338 # Used to have a which call here but it caused endless loops for some people
339 # that had some weird bashrc voodoo for which.
340 USE="${USE}" /usr/bin/depend-java-query "${@}"
341}
202 342
203# ------------------------------------------------------------------------------ 343# ------------------------------------------------------------------------------
204# @ebuild-function java-pkg_regjar 344# @ebuild-function java-pkg_regjar
205# 345#
206# Records an already installed jar in the package.env 346# 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 347# This would mostly be used if the package has make or a custom script to
208# install things. 348# install things.
209# 349#
210# Example: 350# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 351# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
352#
353# WARNING:
354# if you want to use shell expansion, you have to use ${D}/... as the for in
355# this function will not be able to expand the path, here's an example:
356#
357# java-pkg_regjar /opt/my-java/lib/*.jar
358#
359# will not work, because:
360# * the `for jar in "$@"` can't expand the path to jar file names, as they
361# don't exist yet
362# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
363# doesn't exist
364#
365# you have to use it as:
366#
367# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 368#
213# @param $@ - jars to record 369# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 370# ------------------------------------------------------------------------------
215# TODO fix me! 371# TODO should we be making sure the jar is present on ${D} or wherever?
216java-pkg_regjar() { 372java-pkg_regjar() {
217 debug-print-function ${FUNCNAME} $* 373 debug-print-function ${FUNCNAME} $*
218 374
219 java-pkg_check-phase install 375 java-pkg_check-phase install
220 376
221 [[ ${#} -lt 1 ]] && die "at least one argument needed" 377 [[ ${#} -lt 1 ]] && die "at least one argument needed"
222 378
223 java-pkg_init_paths_ 379 java-pkg_init_paths_
224 380
225 local jar jar_dir jar_file 381 local jar jar_dir jar_file
226 for jar in "$@"; do 382 for jar in "${@}"; do
227 # TODO use java-pkg_check-versioned-jar 383 # 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 384 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
385 [[ -d "${jar}" || -d "${D}${jar}" ]] \
386 && die "Called ${FUNCNAME} on a directory $*"
387
388 #check that class version correct when in strict mode
389 is-java-strict && java-pkg_verify-classes "${jar}"
390
391 # nelchael: we should strip ${D} in this case too, here's why:
392 # imagine such call:
393 # java-pkg_regjar ${D}/opt/java/*.jar
394 # such call will fall into this case (-e ${jar}) and will
395 # record paths with ${D} in package.env
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 396 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 397 else
398 if [[ ${jar} = *\** ]]; then
399 eerror "The argument ${jar} to ${FUNCNAME}"
400 eerror "has * in it. If you want it to glob in"
401 eerror '${D} add ${D} to the argument.'
402 fi
403 debug-print "${jar} or ${D}${jar} not found"
233 die "${jar} does not exist" 404 die "${jar} does not exist"
234 fi 405 fi
235 done 406 done
236 407
237 java-pkg_do_write_ 408 java-pkg_do_write_
238} 409}
239
240 410
241# ------------------------------------------------------------------------------ 411# ------------------------------------------------------------------------------
242# @ebuild-function java-pkg_newjar 412# @ebuild-function java-pkg_newjar
243# 413#
244# Installs a jar with a new name 414# Installs a jar with a new name
255 local original_jar="${1}" 425 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 426 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 427 local new_jar_dest="${T}/${new_jar}"
258 428
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 429 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 430 [[ ! -f ${original_jar} ]] \
431 && die "${original_jar} does not exist or is not a file!"
261 432
262 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 433 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
263 cp "${original_jar}" "${new_jar_dest}" \ 434 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 435 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 436 java-pkg_dojar "${new_jar_dest}"
266} 437}
267 438
268
269# ------------------------------------------------------------------------------ 439# ------------------------------------------------------------------------------
270# @ebuild-function java-pkg_addcp 440# @ebuild-function java-pkg_addcp
271# 441#
272# Add something to the package's classpath. For jars, you should use dojar, 442# 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. 443# newjar, or regjar. This is typically used to add directories to the classpath.
278java-pkg_addcp() { 448java-pkg_addcp() {
279 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 449 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
280 java-pkg_do_write_ 450 java-pkg_do_write_
281} 451}
282 452
283
284# ------------------------------------------------------------------------------ 453# ------------------------------------------------------------------------------
285# @ebuild-function java-pkg_doso 454# @ebuild-function java-pkg_doso
286# 455#
287# Installs any number of JNI libraries 456# Installs any number of JNI libraries
288# They will be installed into /usr/lib by default, but java-pkg_sointo 457# They will be installed into /usr/lib by default, but java-pkg_sointo
289# can be used change this path 458# can be used change this path
290# 459#
291# Example: 460# Example:
294# @param $@ - JNI libraries to install 463# @param $@ - JNI libraries to install
295# ------------------------------------------------------------------------------ 464# ------------------------------------------------------------------------------
296java-pkg_doso() { 465java-pkg_doso() {
297 debug-print-function ${FUNCNAME} $* 466 debug-print-function ${FUNCNAME} $*
298 467
299 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
300 java-pkg_check-phase install 468 java-pkg_check-phase install
301 469
302 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 470 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
303 471
304 java-pkg_init_paths_ 472 java-pkg_init_paths_
305 473
306 local lib 474 local lib
307 # for each lib 475 # for each lib
310 if [[ -e "${lib}" ]] ; then 478 if [[ -e "${lib}" ]] ; then
311 # install if it isn't a symlink 479 # install if it isn't a symlink
312 if [[ ! -L "${lib}" ]] ; then 480 if [[ ! -L "${lib}" ]] ; then
313 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 481 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
314 INSOPTIONS="${LIBOPTIONS}" \ 482 INSOPTIONS="${LIBOPTIONS}" \
315 doins "${lib}" || "failed to install ${lib}" 483 doins "${lib}" || die "failed to install ${lib}"
316 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 484 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
317 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 485 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
318 # otherwise make a symlink to the symlink's origin 486 # otherwise make a symlink to the symlink's origin
319 else 487 else
320 # TODO use dosym
321 ln -s "$(readlink "${lib}")" "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")" 488 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
322 debug-print "${lib} is a symlink, linking accordanly" 489 debug-print "${lib} is a symlink, linking accordantly"
323 fi 490 fi
324 # otherwise die 491 # otherwise die
325 else 492 else
326 die "${lib} does not exist" 493 die "${lib} does not exist"
327 fi 494 fi
343java-pkg_regso() { 510java-pkg_regso() {
344 debug-print-function ${FUNCNAME} $* 511 debug-print-function ${FUNCNAME} $*
345 512
346 java-pkg_check-phase install 513 java-pkg_check-phase install
347 514
348 [[ ${#} -lt 1 ]] && "at least one argument needed" 515 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
349 516
350 java-pkg_init_paths_ 517 java-pkg_init_paths_
351 518
352 local lib target_dir 519 local lib target_dir
353 for lib in "$@" ; do 520 for lib in "$@" ; do
354 # Check the absolute path of the lib 521 # Check the absolute path of the lib
355 if [[ -e "${lib}" ]] ; then 522 if [[ -e "${lib}" ]] ; then
356 target_dir="$(java-pkg_expand_dir_ ${lib})" 523 target_dir="$(java-pkg_expand_dir_ ${lib})"
404# ------------------------------------------------------------------------------ 571# ------------------------------------------------------------------------------
405java-pkg_dohtml() { 572java-pkg_dohtml() {
406 debug-print-function ${FUNCNAME} $* 573 debug-print-function ${FUNCNAME} $*
407 574
408 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 575 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
409 # TODO-nichoj find out what exactly -f package-list does 576
577 # from /usr/lib/portage/bin/dohtml -h
578 # -f Set list of allowed extensionless file names.
410 dohtml -f package-list "$@" 579 dohtml -f package-list "$@"
580
411 # this probably shouldn't be here but it provides 581 # this probably shouldn't be here but it provides
412 # a reasonable way to catch # docs for all of the 582 # a reasonable way to catch # docs for all of the
413 # old ebuilds. 583 # old ebuilds.
414 java-pkg_recordjavadoc 584 java-pkg_recordjavadoc
415} 585}
416 586
417# TODO document 587# ------------------------------------------------------------------------------
588# @ebuild-function java-pkg_dojavadoc
589#
590# Installs javadoc documentation. This should be controlled by the doc use flag.
591#
592# @param $1: optional --symlink creates to symlink like this for html
593# documentation bundles.
594# @param $2: - The javadoc root directory.
595#
596# @example:
597# java-pkg_dojavadoc docs/api
598# java-pkg_dojavadoc --symlink apidocs docs/api
599#
600# ------------------------------------------------------------------------------
418java-pkg_dojavadoc() { 601java-pkg_dojavadoc() {
602 debug-print-function ${FUNCNAME} $*
603
604 # For html documentation bundles that link to Javadoc
605 local symlink
606 if [[ ${1} = --symlink ]]; then
607 symlink=${2}
608 shift 2
609 fi
610
419 local dir="$1" 611 local dir="$1"
612 local dest=/usr/share/doc/${PF}/html
613
614 # QA checks
420 615
421 java-pkg_check-phase install 616 java-pkg_check-phase install
422 617
423 [[ -z "${dir}" ]] && die "Must specify a directory!" 618 [[ -z "${dir}" ]] && die "Must specify a directory!"
424 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!" 619 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
620 if [[ ! -e "${dir}/index.html" ]]; then
621 local msg="No index.html in javadoc directory"
622 ewarn "${msg}"
623 is-java-strict && die "${msg}"
624 fi
625
626 if [[ -e ${D}/${dest}/api ]]; then
627 eerror "${dest} already exists. Will not overwrite."
628 die "${dest}"
629 fi
630
631 # Renaming to match our directory layout
425 632
426 local dir_to_install="${dir}" 633 local dir_to_install="${dir}"
427 if [[ "$(basename "${dir}")" != "api" ]]; then 634 if [[ "$(basename "${dir}")" != "api" ]]; then
428 dir_to_install="${T}/api" 635 dir_to_install="${T}/api"
429 # TODO use doins 636 # TODO use doins
430 cp -r "${dir}" "${dir_to_install}" || die "cp failed" 637 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
431 fi 638 fi
432 639
640 # Actual installation
641
433 java-pkg_dohtml -r ${dir_to_install} 642 java-pkg_dohtml -r "${dir_to_install}"
643
644 # Let's make a symlink to the directory we have everything else under
645 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
646
647 if [[ ${symlink} ]]; then
648 debug-print "symlinking ${dest}/{api,${symlink}}"
649 dosym ${dest}/{api,${symlink}} || die
650 fi
434} 651}
435 652
436# ------------------------------------------------------------------------------ 653# ------------------------------------------------------------------------------
437# @ebuild-function java-pkg_dosrc 654# @ebuild-function java-pkg_dosrc
438# 655#
439# Installs a zip containing the source for a package, so it can used in 656# Installs a zip containing the source for a package, so it can used in
440# from IDEs like eclipse and netbeans. 657# from IDEs like eclipse and netbeans.
441# 658#
442# Ebuild needs to DEPEND on app-arch/zip to use this. 659# Ebuild needs to DEPEND on app-arch/zip to use this.
443# 660#
444# It also should be controlled by USE=source. 661# It also should be controlled by USE=source.
445# 662#
446# @example: 663# @example:
447# java-pkg_dosrc src/* 664# java-pkg_dosrc src/*
448# 665#
449# ------------------------------------------------------------------------------ 666# ------------------------------------------------------------------------------
450# TODO change so it the arguments it takes are the base directories containing 667# TODO change so it the arguments it takes are the base directories containing
451# source -nichoj 668# source -nichoj
452# TODO should we be able to handle multiple calls to dosrc? -nichoj 669# TODO should we be able to handle multiple calls to dosrc? -nichoj
453# TODO maybe we can take an existing zip/jar? -nichoj 670# TODO maybe we can take an existing zip/jar? -nichoj
454# FIXME apparently this fails if you give it an empty directories 671# FIXME apparently this fails if you give it an empty directories
455java-pkg_dosrc() { 672java-pkg_dosrc() {
456 debug-print-function ${FUNCNAME} $* 673 debug-print-function ${FUNCNAME} $*
457 674
458 [ ${#} -lt 1 ] && die "At least one argument needed" 675 [ ${#} -lt 1 ] && die "At least one argument needed"
459 if ! hasq source ${IUSE}; then
460 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
461 fi
462 676
463 java-pkg_check-phase install 677 java-pkg_check-phase install
464 678
465 [[ ${#} -lt 1 ]] && die "At least one argument needed" 679 [[ ${#} -lt 1 ]] && die "At least one argument needed"
680
681 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
682 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
683 java-pkg_announce-qa-violation ${msg}
684 fi
466 685
467 java-pkg_init_paths_ 686 java-pkg_init_paths_
468 687
469 local zip_name="${PN}-src.zip" 688 local zip_name="${PN}-src.zip"
470 local zip_path="${T}/${zip_name}" 689 local zip_path="${T}/${zip_name}"
471 local dir 690 local dir
472 for dir in ${@}; do 691 for dir in "${@}"; do
473 local dir_parent=$(dirname "${dir}") 692 local dir_parent=$(dirname "${dir}")
474 local dir_name=$(basename "${dir}") 693 local dir_name=$(basename "${dir}")
475 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}" 694 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
476 zip -q -r ${zip_path} ${dir_name} -i '*.java' 695 zip -q -r ${zip_path} ${dir_name} -i '*.java'
477 local result=$? 696 local result=$?
494# @ebuild-function java-pkg_dolauncher 713# @ebuild-function java-pkg_dolauncher
495# 714#
496# Make a wrapper script to lauch/start this package 715# Make a wrapper script to lauch/start this package
497# If necessary, the wrapper will switch to the appropriate VM. 716# If necessary, the wrapper will switch to the appropriate VM.
498# 717#
718# Can be called without parameters if the package installs only one jar
719# that has the Main-class attribute set. The wrapper will be named ${PN}.
720#
499# @param $1 - filename of launcher to create 721# @param $1 - filename of launcher to create
500# @param $2 - options, as follows: 722# @param $2 - options, as follows:
501# --main the.main.class.too.start 723# --main the.main.class.too.start
502# --jar /the/jar/too/launch.jar 724# --jar /the/jar/too/launch.jar or just <name>.jar
503# --java_args 'Extra arguments to pass too jave' 725# --java_args 'Extra arguments to pass to java'
504# --pkg_args 'extra arguments too pass too the package' 726# --pkg_args 'Extra arguments to pass to the package'
505# --pwd 727# --pwd Directory the launcher changes to before executing java
506# -into 728# -into Directory to install the launcher to, instead of /usr/bin
507# -pre 729# -pre Prepend contents of this file to the launcher
508# ------------------------------------------------------------------------------ 730# ------------------------------------------------------------------------------
509java-pkg_dolauncher() { 731java-pkg_dolauncher() {
510 debug-print-function ${FUNCNAME} $* 732 debug-print-function ${FUNCNAME} $*
511 733
512 java-pkg_check-phase install 734 java-pkg_check-phase install
513
514 [[ ${#} -lt 1 ]] && die "Need at least one argument"
515
516 java-pkg_init_paths_ 735 java-pkg_init_paths_
517 736
737 if [[ ${#} = 0 ]]; then
738 local name="${PN}"
739 else
518 local name="${1}" 740 local name="${1}"
741 shift
742 fi
743
519 # TODO rename to launcher 744 # TODO rename to launcher
520 local target="${T}/${name}" 745 local target="${T}/${name}"
746 local var_tmp="${T}/launcher_variables_tmp"
521 local target_dir pre 747 local target_dir pre
522 shift
523 748
524 echo "#!/bin/bash" > "${target}" 749 # Process the other the rest of the arguments
525 while [[ -n "${1}" && -n "${2}" ]]; do 750 while [[ -n "${1}" && -n "${2}" ]]; do
526 local var=${1} value=${2} 751 local var="${1}" value="${2}"
527 if [[ "${var:0:2}" == "--" ]]; then 752 if [[ "${var:0:2}" == "--" ]]; then
753 local var=${var:2}
528 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 754 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
755 local gjl_${var}="${value}"
529 elif [[ "${var}" == "-into" ]]; then 756 elif [[ "${var}" == "-into" ]]; then
530 target_dir="${value}" 757 target_dir="${value}"
531 elif [[ "${var}" == "-pre" ]]; then 758 elif [[ "${var}" == "-pre" ]]; then
532 pre="${value}" 759 pre="${value}"
533 fi 760 fi
534 shift 2 761 shift 2
535 done 762 done
763
764 # Test if no --jar and --main arguments were given and
765 # in that case check if the package only installs one jar
766 # and use that jar.
767 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
768 local cp="${JAVA_PKG_CLASSPATH}"
769 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
770 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
771 else
772 local msg="Not enough information to create a launcher given."
773 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
774 die "${msg}"
775 fi
776 fi
777
778 # Write the actual script
779 echo "#!/bin/bash" > "${target}"
780 if [[ -n "${pre}" ]]; then
781 if [[ -f "${pre}" ]]; then
782 cat "${pre}" >> "${target}"
783 else
784 die "-pre specified file '${pre}' does not exist"
785 fi
786 fi
536 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 787 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
537 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 788 cat "${var_tmp}" >> "${target}"
789 rm -f "${var_tmp}"
538 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 790 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
539 791
540 if [[ -n "${into}" ]]; then 792 if [[ -n "${target_dir}" ]]; then
541 DESTTREE="${target_dir}" dobin "${target}" 793 DESTTREE="${target_dir}" dobin "${target}"
542 local ret=$? 794 local ret=$?
543 return ${ret} 795 return ${ret}
544 else 796 else
545 dobin "${target}" 797 dobin "${target}"
573 echo "dowar: warning, skipping directory ${war}" 825 echo "dowar: warning, skipping directory ${war}"
574 continue 826 continue
575 else 827 else
576 warpath="${war}" 828 warpath="${war}"
577 fi 829 fi
578 830
579 # Install those files like you mean it 831 # Install those files like you mean it
580 INSOPTIONS="-m 0644" \ 832 INSOPTIONS="-m 0644" \
581 INSDESTTREE=${JAVA_PKG_WARDEST} \ 833 INSDESTTREE=${JAVA_PKG_WARDEST} \
582 doins ${warpath} 834 doins ${warpath}
583 done 835 done
618# @ebuild-function java-pkg_jar-from 870# @ebuild-function java-pkg_jar-from
619# 871#
620# Makes a symlink to a jar from a certain package 872# Makes a symlink to a jar from a certain package
621# A lot of java packages include dependencies in a lib/ directory 873# A lot of java packages include dependencies in a lib/ directory
622# You can use this function to replace these bundled dependencies. 874# You can use this function to replace these bundled dependencies.
875# The dependency is recorded into package.env DEPEND line, unless "--build-only"
876# is passed as the very first argument, for jars that have to be present only
877# at build time and are not needed on runtime (junit testing etc).
623# 878#
624# Example: get all jars from xerces slot 2 879# Example: get all jars from xerces slot 2
625# java-pkg_jar-from xerces-2 880# java-pkg_jar-from xerces-2
626# Example: get a specific jar from xerces slot 2 881# Example: get a specific jar from xerces slot 2
627# java-pkg_jar-from xerces-2 xml-apis.jar 882# java-pkg_jar-from xerces-2 xml-apis.jar
628# Example get a specific jar from xerces slot 2, and name it diffrently 883# 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 884# java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
885# Example: get junit.jar which is needed only for building
886# java-pkg_jar-from --build-only junit junit.jar
630# 887#
631# @param $1 - Package to get jars from. 888# @param $opt
889# --build-only - makes the jar(s) not added into package.env DEPEND line.
890# (assumed automatically when called inside src_test)
891# --with-dependencies - get jars also from requested package's dependencies
892# transitively.
893# --virtual - Packages passed to this function are to be handled as virtuals
894# and will not have individual jar dependencies recorded.
895# --into $dir - symlink jar(s) into $dir (must exist) instead of .
896# @param $1 - Package to get jars from, or comma-separated list of packages in
897# case other parameters are not used.
632# @param $2 - jar from package. If not specified, all jars will be used. 898# @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 899# @param $3 - When a single jar is specified, destination filename of the
634# symlink. Defaults to the name of the jar. 900# symlink. Defaults to the name of the jar.
635# ------------------------------------------------------------------------------ 901# ------------------------------------------------------------------------------
636# TODO could probably be cleaned up a little 902# TODO could probably be cleaned up a little
637java-pkg_jar-from() { 903java-pkg_jar-from() {
638 debug-print-function ${FUNCNAME} $* 904 debug-print-function ${FUNCNAME} $*
639 905
906 local build_only=""
907 local destdir="."
908 local deep=""
909 local virtual=""
910 local record_jar=""
911
912 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
913
914 while [[ "${1}" == --* ]]; do
915 if [[ "${1}" = "--build-only" ]]; then
916 build_only="build"
917 elif [[ "${1}" = "--with-dependencies" ]]; then
918 deep="--with-dependencies"
919 elif [[ "${1}" = "--virtual" ]]; then
920 virtual="true"
921 elif [[ "${1}" = "--into" ]]; then
922 destdir="${2}"
923 shift
924 else
925 die "java-pkg_jar-from called with unknown parameter: ${1}"
926 fi
927 shift
928 done
929
640 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 930 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
641 931
642 [[ -z ${target_pkg} ]] && die "Must specify a package" 932 [[ -z ${target_pkg} ]] && die "Must specify a package"
933
934 if [[ "${EAPI}" == "1" ]]; then
935 target_pkg="${target_pkg//:/-}"
936 fi
643 937
644 # default destjar to the target jar 938 # default destjar to the target jar
645 [[ -z "${destjar}" ]] && destjar="${target_jar}" 939 [[ -z "${destjar}" ]] && destjar="${target_jar}"
646 940
941 local error_msg="There was a problem getting the classpath for ${target_pkg}."
942 local classpath
647 local classpath="$(java-config --classpath=${target_pkg})" 943 classpath="$(java-config ${deep} --classpath=${target_pkg})"
648 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 944 [[ $? != 0 ]] && die ${error_msg}
945
946 # When we have commas this functions is called to bring jars from multiple
947 # packages. This affects recording of dependencencies performed later
948 # which expects one package only, so we do it here.
949 if [[ ${target_pkg} = *,* ]]; then
950 for pkg in ${target_pkg//,/ }; do
951 java-pkg_ensure-dep "${build_only}" "${pkg}"
952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
953 done
954 # setting this disables further record-jar_ calls later
955 record_jar="true"
956 else
957 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
958 fi
959
960 # Record the entire virtual as a dependency so that
961 # no jars are missed.
962 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
963 java-pkg_record-jar_ "${target_pkg}"
964 # setting this disables further record-jars_ calls later
965 record_jar="true"
966 fi
967
968 pushd ${destdir} > /dev/null \
969 || die "failed to change directory to ${destdir}"
649 970
650 local jar 971 local jar
651 for jar in ${classpath//:/ }; do 972 for jar in ${classpath//:/ }; do
652 local jar_name=$(basename "${jar}") 973 local jar_name=$(basename "${jar}")
653 if [[ ! -f "${jar}" ]] ; then 974 if [[ ! -f "${jar}" ]] ; then
657 # If no specific target jar was indicated, link it 978 # If no specific target jar was indicated, link it
658 if [[ -z "${target_jar}" ]] ; then 979 if [[ -z "${target_jar}" ]] ; then
659 [[ -f "${target_jar}" ]] && rm "${target_jar}" 980 [[ -f "${target_jar}" ]] && rm "${target_jar}"
660 ln -snf "${jar}" \ 981 ln -snf "${jar}" \
661 || die "Failed to make symlink from ${jar} to ${jar_name}" 982 || die "Failed to make symlink from ${jar} to ${jar_name}"
983 if [[ -z "${record_jar}" ]]; then
984 if [[ -z "${build_only}" ]]; then
662 java-pkg_record-jar_ "${target_pkg}" "${jar}" 985 java-pkg_record-jar_ "${target_pkg}" "${jar}"
986 else
987 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
988 fi
989 fi
663 # otherwise, if the current jar is the target jar, link it 990 # otherwise, if the current jar is the target jar, link it
664 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 991 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
665 [[ -f "${destjar}" ]] && rm "${destjar}" 992 [[ -f "${destjar}" ]] && rm "${destjar}"
666 ln -snf "${jar}" "${destjar}" \ 993 ln -snf "${jar}" "${destjar}" \
667 || die "Failed to make symlink from ${jar} to ${destjar}" 994 || die "Failed to make symlink from ${jar} to ${destjar}"
995 if [[ -z "${record_jar}" ]]; then
996 if [[ -z "${build_only}" ]]; then
668 java-pkg_record-jar_ "${target_pkg}" "${jar}" 997 java-pkg_record-jar_ "${target_pkg}" "${jar}"
998 else
999 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
1000 fi
1001 fi
1002 popd > /dev/null
669 return 0 1003 return 0
670 fi 1004 fi
671 done 1005 done
1006 popd > /dev/null
672 # if no target was specified, we're ok 1007 # if no target was specified, we're ok
673 if [[ -z "${target_jar}" ]] ; then 1008 if [[ -z "${target_jar}" ]] ; then
674 return 0 1009 return 0
675 # otherwise, die bitterly 1010 # otherwise, die bitterly
676 else 1011 else
690# ------------------------------------------------------------------------------ 1025# ------------------------------------------------------------------------------
691# @ebuild-function java-pkg_getjars 1026# @ebuild-function java-pkg_getjars
692# 1027#
693# Get the classpath provided by any number of packages 1028# Get the classpath provided by any number of packages
694# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 1029# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
1030# The providing packages are recorded as dependencies into package.env DEPEND
1031# line, unless "--build-only" is passed as the very first argument, for jars
1032# that have to be present only at build time and are not needed on runtime
1033# (junit testing etc).
695# 1034#
696# Example: Get the classpath for xerces-2, 1035# Example: Get the classpath for xerces-2 and xalan,
697# java-pkg_getjars xerces-2 xalan 1036# java-pkg_getjars xerces-2,xalan
698# Example Return: 1037# Example Return:
699# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 1038# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
700# 1039#
1040# @param $opt
1041# --build-only - makes the jar(s) not added into package.env DEPEND line.
1042# (assumed automatically when called inside src_test)
1043# --with-dependencies - get jars also from requested package's dependencies
1044# transitively.
701# @param $@ - list of packages to get jars from 1045# @param $1 - list of packages to get jars from
1046# (passed to java-config --classpath)
702# ------------------------------------------------------------------------------ 1047# ------------------------------------------------------------------------------
703java-pkg_getjars() { 1048java-pkg_getjars() {
704 debug-print-function ${FUNCNAME} $* 1049 debug-print-function ${FUNCNAME} $*
705 1050
706 [[ ${#} -lt 1 ]] && die "At least one argument needed" 1051 local build_only=""
1052 local deep=""
707 1053
708 # NOTE could probably just pass $@ to java-config --classpath. and return it 1054 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
709 local classpath pkg 1055
710 for pkg in ${@//,/ }; do 1056 while [[ "${1}" == --* ]]; do
711 #for pkg in $(echo "$@" | tr ',' ' '); do 1057 if [[ "${1}" = "--build-only" ]]; then
712 jars="$(java-config --classpath=${pkg})" 1058 build_only="build"
713 debug-print "${pkg}:${jars}" 1059 elif [[ "${1}" = "--with-dependencies" ]]; then
714 # TODO should we ensure jars exist? 1060 deep="--with-dependencies"
715 if [[ -z "${classpath}" ]]; then
716 classpath="${jars}"
717 else 1061 else
718 classpath="${classpath}:${jars}" 1062 die "java-pkg_jar-from called with unknown parameter: ${1}"
719 fi 1063 fi
720 java-pkg_record-jar_ "${pkg}" 1064 shift
721 done 1065 done
722 echo "${classpath}" 1066
1067 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1068
1069
1070 local pkgs="${1}"
1071
1072 if [[ "${EAPI}" == "1" ]]; then
1073 pkgs="${pkgs//:/-}"
1074 fi
1075
1076 jars="$(java-config ${deep} --classpath=${pkgs})"
1077 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1078 debug-print "${pkgs}:${jars}"
1079
1080 for pkg in ${pkgs//,/ }; do
1081 java-pkg_ensure-dep "${build_only}" "${pkg}"
1082 done
1083
1084 for pkg in ${pkgs//,/ }; do
1085 if [[ -z "${build_only}" ]]; then
1086 java-pkg_record-jar_ "${pkg}"
1087 else
1088 java-pkg_record-jar_ --build-only "${pkg}"
1089 fi
1090 done
1091
1092 echo "${jars}"
723} 1093}
724 1094
725# ------------------------------------------------------------------------------ 1095# ------------------------------------------------------------------------------
726# @ebuild-function java-pkg_getjar 1096# @ebuild-function java-pkg_getjar
727# 1097#
728# Get the filename of a single jar from a package 1098# Get the filename of a single jar from a package
1099# The providing package is recorded as runtime dependency into package.env
1100# DEPEND line, unless "--build-only" is passed as the very first argument, for
1101# jars that have to be present only at build time and are not needed on runtime
1102# (junit testing etc).
729# 1103#
730# @example 1104# @example
731# java-pkg_getjar xerces-2 xml-apis.jar 1105# java-pkg_getjar xerces-2 xml-apis.jar
732# @example-return 1106# @example-return
733# /usr/share/xerces-2/lib/xml-apis.jar 1107# /usr/share/xerces-2/lib/xml-apis.jar
734# 1108#
1109# @param $opt
1110# --build-only - makes the jar not added into package.env DEPEND line.
1111# --virtual - Packages passed to this function are to be handled as virtuals
1112# and will not have individual jar dependencies recorded.
735# @param $1 - package to use 1113# @param $1 - package to use
736# @param $2 - jar to get 1114# @param $2 - jar to get
737# ------------------------------------------------------------------------------ 1115# ------------------------------------------------------------------------------
738java-pkg_getjar() { 1116java-pkg_getjar() {
739 debug-print-function ${FUNCNAME} $* 1117 debug-print-function ${FUNCNAME} $*
740 1118
1119 local build_only=""
1120 local virtual=""
1121 local record_jar=""
1122
1123 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1124
1125 while [[ "${1}" == --* ]]; do
1126 if [[ "${1}" = "--build-only" ]]; then
1127 build_only="build"
1128 elif [[ "${1}" == "--virtual" ]]; then
1129 virtual="true"
1130 else
1131 die "java-pkg_getjar called with unknown parameter: ${1}"
1132 fi
1133 shift
1134 done
1135
1136 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1137
741 local pkg="${1}" target_jar="${2}" jar 1138 local pkg="${1}" target_jar="${2}" jar
1139
1140 if [[ "${EAPI}" == "1" ]]; then
1141 pkg="${pkg//:/-}"
1142 fi
1143
742 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 1144 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
743 [[ -z ${target_jar} ]] && die "Must specify jar to get" 1145 [[ -z ${target_jar} ]] && die "Must specify jar to get"
744 1146
745 # TODO check that package is actually installed 1147 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1148 local classpath
746 local classpath=$(java-config --classpath=${pkg}) 1149 classpath=$(java-config --classpath=${pkg})
747 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 1150 [[ $? != 0 ]] && die ${error_msg}
1151
1152 java-pkg_ensure-dep "${build_only}" "${pkg}"
1153
1154 # Record the package(Virtual) as a dependency and then set build_only
1155 # So that individual jars are not recorded.
1156 if [[ -n "${virtual}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}"
1161 fi
1162 record_jar="true"
1163 fi
1164
748 for jar in ${classpath//:/ }; do 1165 for jar in ${classpath//:/ }; do
749 if [[ ! -f "${jar}" ]] ; then 1166 if [[ ! -f "${jar}" ]] ; then
750 die "Installation problems with jars in ${pkg} - is it installed?" 1167 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
751 fi 1168 fi
752 1169
753 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1170 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1171 # Only record jars that aren't build-only
1172 if [[ -z "${record_jar}" ]]; then
1173 if [[ -z "${build_only}" ]]; then
754 java-pkg_record-jar_ "${pkg}" "${jar}" 1174 java-pkg_record-jar_ "${pkg}" "${jar}"
1175 else
1176 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1177 fi
1178 fi
755 echo "${jar}" 1179 echo "${jar}"
756 return 0 1180 return 0
757 fi 1181 fi
758 done 1182 done
759 1183
760 die "Could not find ${target_jar} in ${pkg}" 1184 die "Could not find ${target_jar} in ${pkg}"
761 return 1 1185 return 1
762} 1186}
1187
1188# ------------------------------------------------------------------------------
1189# @ebuild-function java-pkg_register-dependency
1190#
1191# Registers runtime dependency on a package, list of packages, or a single jar
1192# from a package, into package.env DEPEND line. Can only be called in
1193# src_install phase.
1194# Intended for binary packages where you don't need to symlink the jars or get
1195# their classpath during build. As such, the dependencies only need to be
1196# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1197#
1198# @param $1 - comma-separated list of packages, or a single package
1199# @param $2 - if param $1 is a single package, optionally specify the jar
1200# to depend on
1201#
1202# Example: Record the dependency on whole xerces-2 and xalan,
1203# java-pkg_register-dependency xerces-2,xalan
1204# Example: Record the dependency on ant.jar from ant-core
1205# java-pkg_register-dependency ant-core ant.jar
1206#
1207# Note: Passing both list of packages as the first parameter AND specifying the
1208# jar as the second is not allowed and will cause the function to die. We assume
1209# that there's more chance one passes such combination as a mistake, than that
1210# there are more packages providing identically named jar without class
1211# collisions.
1212# ------------------------------------------------------------------------------
1213java-pkg_register-dependency() {
1214 debug-print-function ${FUNCNAME} $*
1215
1216 java-pkg_check-phase install
1217
1218 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1219
1220 local pkgs="${1}"
1221 local jar="${2}"
1222
1223 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1224
1225 if [[ "${EAPI}" == "1" ]]; then
1226 pkgs="${pkgs//:/-}"
1227 fi
1228
1229 if [[ -z "${jar}" ]]; then
1230 for pkg in ${pkgs//,/ }; do
1231 java-pkg_ensure-dep runtime "${pkg}"
1232 java-pkg_record-jar_ "${pkg}"
1233 done
1234 else
1235 [[ ${pkgs} == *,* ]] && \
1236 die "${FUNCNAME} called with both package list and jar name"
1237 java-pkg_ensure-dep runtime "${pkgs}"
1238 java-pkg_record-jar_ "${pkgs}" "${jar}"
1239 fi
1240
1241 java-pkg_do_write_
1242}
1243
1244# ------------------------------------------------------------------------------
1245# @ebuild-function java-pkg_register-optional-dependency
1246#
1247# Registers optional runtime dependency on a package, list of packages, or a
1248# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1249# called in src_install phase.
1250# Intended for packages that can use other packages when those are in classpath.
1251# Will be put on classpath by launcher if they are installed. Typical case is
1252# JDBC implementations for various databases. It's better than having USE flag
1253# for each implementation triggering hard dependency.
1254#
1255# @param $1 - comma-separated list of packages, or a single package
1256# @param $2 - if param $1 is a single package, optionally specify the jar
1257# to depend on
1258#
1259# Example: Record the optional dependency on some jdbc providers
1260# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1261#
1262# Note: Passing both list of packages as the first parameter AND specifying the
1263# jar as the second is not allowed and will cause the function to die. We assume
1264# that there's more chance one passes such combination as a mistake, than that
1265# there are more packages providing identically named jar without class
1266# collisions.
1267# ------------------------------------------------------------------------------
1268java-pkg_register-optional-dependency() {
1269 debug-print-function ${FUNCNAME} $*
1270
1271 java-pkg_check-phase install
1272
1273 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1274
1275 local pkgs="${1}"
1276 local jar="${2}"
1277
1278 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1279
1280 if [[ "${EAPI}" == "1" ]]; then
1281 pkgs="${pkgs//:/-}"
1282 fi
1283
1284 if [[ -z "${jar}" ]]; then
1285 for pkg in ${pkgs//,/ }; do
1286 java-pkg_record-jar_ --optional "${pkg}"
1287 done
1288 else
1289 [[ ${pkgs} == *,* ]] && \
1290 die "${FUNCNAME} called with both package list and jar name"
1291 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1292 fi
1293
1294 java-pkg_do_write_
1295}
1296
1297# ------------------------------------------------------------------------------
1298# @ebuild-function java-pkg_register-environment-variable
1299#
1300# Register an arbitrary environment variable into package.env. The gjl launcher
1301# for this package or any package depending on this will export it into
1302# environement before executing java command.
1303# Must only be called in src_install phase.
1304#
1305# @param $1 - variable name
1306# @param $2 - variable value
1307# ------------------------------------------------------------------------------
1308JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1309JAVA_PKG_EXTRA_ENV_VARS=""
1310java-pkg_register-environment-variable() {
1311 debug-print-function ${FUNCNAME} $*
1312
1313 java-pkg_check-phase install
1314
1315 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1316
1317 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1319
1320 java-pkg_do_write_
1321}
1322
1323# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_get-bootclasspath
1325#
1326# Returns classpath of a given bootclasspath-providing package version.
1327#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() {
1333 local version="${1}"
1334
1335 local bcp
1336 case "${version}" in
1337 auto)
1338 bcp="$(java-config -g BOOTCLASSPATH)"
1339 ;;
1340 1.5)
1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1342 ;;
1343 *)
1344 eerror "unknown parameter of java-pkg_get-bootclasspath"
1345 die "unknown parameter of java-pkg_get-bootclasspath"
1346 ;;
1347 esac
1348
1349 echo "${bcp}"
1350}
1351
763 1352
764# This function reads stdin, and based on that input, figures out how to 1353# This function reads stdin, and based on that input, figures out how to
765# populate jars from the filesystem. 1354# populate jars from the filesystem.
766# Need to figure out a good way of making use of this, ie be able to use a 1355# Need to figure out a good way of making use of this, ie be able to use a
767# string that was built instead of stdin 1356# string that was built instead of stdin
778# line="${line// /}" 1367# line="${line// /}"
779# 1368#
780# # format: path=jarinfo 1369# # format: path=jarinfo
781# local path=${line%%=*} 1370# local path=${line%%=*}
782# local jarinfo=${line##*=} 1371# local jarinfo=${line##*=}
783# 1372#
784# # format: jar@package 1373# # format: jar@package
785# local jar=${jarinfo%%@*}.jar 1374# local jar=${jarinfo%%@*}.jar
786# local package=${jarinfo##*@} 1375# local package=${jarinfo##*@}
787# if [[ -n ${replace_only} ]]; then 1376# if [[ -n ${replace_only} ]]; then
788# [[ ! -f $path ]] && die "No jar exists at ${path}" 1377# [[ ! -f $path ]] && die "No jar exists at ${path}"
801# @section-end query 1390# @section-end query
802# ------------------------------------------------------------------------------ 1391# ------------------------------------------------------------------------------
803 1392
804# ------------------------------------------------------------------------------ 1393# ------------------------------------------------------------------------------
805# @section-begin helper 1394# @section-begin helper
806# @section-summary Helper functions 1395# @section-summary Helper functions
807# 1396#
808# Various other functions to use from an ebuild 1397# Various other functions to use from an ebuild
809# ------------------------------------------------------------------------------ 1398# ------------------------------------------------------------------------------
810 1399
811# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
812# @ebuild-function java-pkg_need 1401# @ebuild-function java-pkg_find-normal-jars
813# 1402#
814# Adds virtual dependencies, which can optionally be controlled by a USE flag. 1403# Find the files with suffix .jar file in the given directory or $WORKDIR
815# Currently supported virtuals are:
816# javamail
817# jdbc-stdext
818# jaf
819# jdbc-rowset
820# jms
821# 1404#
822# @param $1 - Optionally indicate that the dependencies are controlled by 1405# @param $1 - The directory to search for jar files (default: ${WORKDIR})
823# a use flag by specifying '--use' Requires $2.
824# @param $2 - USE flag which will enable the dependencies.
825# @param $@ - virtual packages to add depenedencies for
826# ------------------------------------------------------------------------------ 1406# ------------------------------------------------------------------------------
827# TODO rewrite to parse a line based declaration file instead -- karltk 1407java-pkg_find-normal-jars() {
828#java-pkg_need() { 1408 local dir=$1
829# debug-print-function ${FUNCNAME} $* 1409 [[ "${dir}" ]] || dir="${WORKDIR}"
830# local useflag 1410 local found
831# if [[ ${1} == "--use" ]]; then 1411 for jar in $(find "${dir}" -name "*.jar" -type f); do
832# useflag="${2}" 1412 echo "${jar}"
833# shift 2 1413 found="true"
834# fi
835#
836# if [[ -z ${1} ]]; then
837# die "Must specify at least one virtual package."
838# fi
839#
840# local depstr newdepstr
841#
842# for virtual in ${@}; do
843# if has ${virtual} ${JAVA_PKG_VNEED}; then
844# debug-print "Already registered virtual ${virtual}"
845# continue
846# fi
847# case ${virtual} in
848# javamail)
849# debug-print "java-pkg_need: adding javamail dependencies"
850# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
851# ;;
852# jdbc-stdext)
853# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
854# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
855# ;;
856# jaf)
857# debug-print "java-pkg_need: adding jaf dependencies"
858# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
859# ;;
860# jdbc-rowset)
861# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
862# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
863# ;;
864# jms)
865# debug-print "java-pkg_need: adding jms dependencies"
866# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
867# ;;
868# *)
869# die "Invalid virtual: ${virtual}"
870# esac
871#
872# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
873#
874# if [[ -n ${useflag} ]]; then
875# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
876# else
877# depstr="${depstr} ${newdepstr}"
878# fi
879# done 1414 done
880# 1415 [[ "${found}" ]]
881# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}" 1416 return $?
882# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}" 1417}
883#
884# export DEPEND="${DEPEND} ${depstr}"
885# export RDEPEND="${RDEPEND} ${depstr}"
886#}
887 1418
1419# ------------------------------------------------------------------------------
1420# @ebuild-function java-pkg_ensure-no-bundled-jars
1421#
1422# 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 1423# This function should be called after WORKDIR has been populated with symlink
889# TODO document 1424# to system jar files or bundled jars removed.
1425# ------------------------------------------------------------------------------
890java-pkg_ensure-no-bundled-jars() { 1426java-pkg_ensure-no-bundled-jars() {
891 debug-print-function ${FUNCNAME} $* 1427 debug-print-function ${FUNCNAME} $*
892 pushd ${WORKDIR} >/dev/null 2>/dev/null
893 1428
894 local bundled_jars=$(find . -name "*.jar" -type f) 1429 local bundled_jars=$(java-pkg_find-normal-jars)
895 if [[ -n ${bundled_jars} ]]; then 1430 if [[ -n ${bundled_jars} ]]; then
896 echo "Bundled jars found:" 1431 echo "Bundled jars found:"
897 local jar 1432 local jar
898 for jar in ${bundled_jars}; do 1433 for jar in ${bundled_jars}; do
899 echo $(pwd)${jar/./} 1434 echo $(pwd)${jar/./}
900 done 1435 done
901 die "Bundled jars found!" 1436 die "Bundled jars found!"
902
903 fi 1437 fi
904 popd >/dev/null 2>/dev/null
905} 1438}
906 1439
907# ------------------------------------------------------------------------------ 1440# ------------------------------------------------------------------------------
908# @internal-function java-pkg_ensure-vm-version-sufficient 1441# @internal-function java-pkg_ensure-vm-version-sufficient
909# 1442#
921 fi 1454 fi
922} 1455}
923 1456
924# ------------------------------------------------------------------------------ 1457# ------------------------------------------------------------------------------
925# @internal-function java-pkg_is-vm-version-sufficient 1458# @internal-function java-pkg_is-vm-version-sufficient
926# 1459#
927# @return zero - VM is sufficient 1460# @return zero - VM is sufficient
928# @return non-zero - VM is not sufficient 1461# @return non-zero - VM is not sufficient
929# ------------------------------------------------------------------------------ 1462# ------------------------------------------------------------------------------
930java-pkg_is-vm-version-sufficient() { 1463java-pkg_is-vm-version-sufficient() {
931 debug-print-function ${FUNCNAME} $* 1464 debug-print-function ${FUNCNAME} $*
951 die "Active Java VM too old" 1484 die "Active Java VM too old"
952 fi 1485 fi
953} 1486}
954 1487
955# ------------------------------------------------------------------------------ 1488# ------------------------------------------------------------------------------
956# @internal-function java-pkg_is-vm-version-eq 1489# @internal-function java-pkg_is-vm-version-eq
957# 1490#
958# @param $@ - VM version to compare current VM to 1491# @param $@ - VM version to compare current VM to
959# @return zero - VM versions are equal 1492# @return zero - VM versions are equal
960# @return non-zero - VM version are not equal 1493# @return non-zero - VM version are not equal
961# ------------------------------------------------------------------------------ 1494# ------------------------------------------------------------------------------
962java-pkg_is-vm-version-eq() { 1495java-pkg_is-vm-version-eq() {
992# 1525#
993# @param $@ - VM version to compare current to 1526# @param $@ - VM version to compare current to
994# ------------------------------------------------------------------------------ 1527# ------------------------------------------------------------------------------
995java-pkg_ensure-vm-version-ge() { 1528java-pkg_ensure-vm-version-ge() {
996 debug-print-function ${FUNCNAME} $* 1529 debug-print-function ${FUNCNAME} $*
997 1530
998 if ! java-pkg_is-vm-version-ge "$@" ; then 1531 if ! java-pkg_is-vm-version-ge "$@" ; then
999 debug-print "vm is not suffient" 1532 debug-print "vm is not suffient"
1000 eerror "This package requires a Java VM version >= $@" 1533 eerror "This package requires a Java VM version >= $@"
1001 einfo "Please use java-config -S to set the correct one" 1534 einfo "Please use java-config -S to set the correct one"
1002 die "Active Java VM too old" 1535 die "Active Java VM too old"
1003 fi 1536 fi
1004} 1537}
1005 1538
1006# ------------------------------------------------------------------------------ 1539# ------------------------------------------------------------------------------
1007# @internal-function java-pkg_is-vm-version-ge 1540# @internal-function java-pkg_is-vm-version-ge
1008# 1541#
1009# @param $@ - VM version to compare current VM to 1542# @param $@ - VM version to compare current VM to
1010# @return zero - current VM version is greater than checked version 1543# @return zero - current VM version is greater than checked version
1011# @return non-zero - current VM version is not greater than checked version 1544# @return non-zero - current VM version is not greater than checked version
1012# ------------------------------------------------------------------------------ 1545# ------------------------------------------------------------------------------
1013java-pkg_is-vm-version-ge() { 1546java-pkg_is-vm-version-ge() {
1027 return 1 1560 return 1
1028 fi 1561 fi
1029 fi 1562 fi
1030} 1563}
1031 1564
1565java-pkg_set-current-vm() {
1566 export GENTOO_VM=${1}
1567}
1568
1569java-pkg_get-current-vm() {
1570 echo ${GENTOO_VM}
1571}
1572
1573java-pkg_current-vm-matches() {
1574 has $(java-pkg_get-current-vm) ${@}
1575 return $?
1576}
1577
1032# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1033# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1034# 1580#
1035# Determines what source version should be used, for passing to -source. 1581# 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 1582# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1037# 1583#
1038# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1584# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1039# ------------------------------------------------------------------------------ 1585# ------------------------------------------------------------------------------
1044# ------------------------------------------------------------------------------ 1590# ------------------------------------------------------------------------------
1045# @ebuild-function java-pkg_get-target 1591# @ebuild-function java-pkg_get-target
1046# 1592#
1047# Determines what target version should be used, for passing to -target. 1593# 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 1594# If you don't care about lower versions, you can set _WANT_TARGET to the
1049# version of your JDK. 1595# 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# 1596#
1054# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1597# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1055# ------------------------------------------------------------------------------ 1598# ------------------------------------------------------------------------------
1056java-pkg_get-target() { 1599java-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}")} 1600 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1070} 1601}
1071 1602
1072java-pkg_get-javac() { 1603java-pkg_get-javac() {
1073 debug-print-function ${FUNCNAME} $* 1604 debug-print-function ${FUNCNAME} $*
1074 1605
1075 java-pkg_init-compiler_ 1606
1076 local compiler="${GENTOO_COMPILER}" 1607 local compiler="${GENTOO_COMPILER}"
1077 1608
1078 local compiler_executable 1609 local compiler_executable
1079 if [[ "${compiler}" = "javac" ]]; then 1610 if [[ "${compiler}" = "javac" ]]; then
1080 # nothing fancy needs to be done for javac 1611 # nothing fancy needs to be done for javac
1088 unset JAVAC 1619 unset JAVAC
1089 # try to get value of JAVAC 1620 # try to get value of JAVAC
1090 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1621 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1091 export JAVAC=${old_javac} 1622 export JAVAC=${old_javac}
1092 1623
1093 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1624 if [[ -z ${compiler_executable} ]]; then
1094 1625 echo "JAVAC is empty or undefined in ${compiler_env}"
1626 return 1
1627 fi
1628
1095 # check that it's executable 1629 # check that it's executable
1096 if [[ ! -x ${compiler_executable} ]]; then 1630 if [[ ! -x ${compiler_executable} ]]; then
1097 eerror "Could not find ${compiler_executable}!"
1098 die "${compiler_executable} doesn't exist, or isn't executable" 1631 echo "${compiler_executable} doesn't exist, or isn't executable"
1632 return 1
1099 fi 1633 fi
1100 else 1634 else
1101 eerror "Could not find environment file for ${compiler}" 1635 echo "Could not find environment file for ${compiler}"
1102 die "Could not find ${compiler_env}" 1636 return 1
1103 fi 1637 fi
1104 fi 1638 fi
1105 echo ${compiler_executable} 1639 echo ${compiler_executable}
1106} 1640}
1107 1641
1108# ------------------------------------------------------------------------------ 1642# ------------------------------------------------------------------------------
1109# @ebuild-function java-pkg_javac-args 1643# @ebuild-function java-pkg_javac-args
1110# 1644#
1111# If an ebuild uses javac directly, instead of using ejavac, it should call this 1645# If an ebuild uses javac directly, instead of using ejavac, it should call this
1112# to know what -source/-target to use. 1646# to know what -source/-target to use.
1113# 1647#
1114# @return string - arguments to pass to javac, complete with -target and -source 1648# @return string - arguments to pass to javac, complete with -target and -source
1117 debug-print-function ${FUNCNAME} $* 1651 debug-print-function ${FUNCNAME} $*
1118 1652
1119 local want_source="$(java-pkg_get-source)" 1653 local want_source="$(java-pkg_get-source)"
1120 local want_target="$(java-pkg_get-target)" 1654 local want_target="$(java-pkg_get-target)"
1121 1655
1122 local source_str="-source ${want_source}" 1656 local source_str="-source ${want_source}"
1123 local target_str="-target ${want_target}" 1657 local target_str="-target ${want_target}"
1124 1658
1125 debug-print "want source: ${want_source}" 1659 debug-print "want source: ${want_source}"
1126 debug-print "want target: ${want_target}" 1660 debug-print "want target: ${want_target}"
1127 1661
1128 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1662 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1129 debug-print "could not find valid -source/-target values" 1663 debug-print "could not find valid -source/-target values for javac"
1130 die "Could not find valid -source/-target values" 1664 echo "Could not find valid -source/-target values for javac"
1665 return 1
1131 else 1666 else
1132 if java-pkg_is-vm-version-ge "1.4"; then 1667 if java-pkg_is-vm-version-ge "1.4"; then
1133 echo "${source_str} ${target_str}" 1668 echo "${source_str} ${target_str}"
1134 else 1669 else
1135 echo "${target_str}" 1670 echo "${target_str}"
1139 1674
1140# TODO document 1675# TODO document
1141java-pkg_get-jni-cflags() { 1676java-pkg_get-jni-cflags() {
1142 local flags="-I${JAVA_HOME}/include" 1677 local flags="-I${JAVA_HOME}/include"
1143 1678
1144 # TODO figure out how to cope with other things than linux... 1679 local platform="linux"
1680 use elibc_FreeBSD && platform="freebsd"
1681
1682 # TODO do a check that the directories are valid
1145 flags="${flags} -I${JAVA_HOME}/include/linux" 1683 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1146 1684
1147 echo ${flags} 1685 echo ${flags}
1148} 1686}
1149 1687
1688java-pkg_ensure-gcj() {
1689 if ! built_with_use sys-devel/gcc gcj ; then
1690 ewarn
1691 ewarn "You must build gcc with the gcj support to build with gcj"
1692 ewarn
1693 ebeep 5
1694 die "No GCJ support found!"
1695 fi
1696}
1697
1698java-pkg_ensure-test() {
1699 if has test ${FEATURES} && ! has -test ${FEATURES} \
1700 && has test ${IUSE} && ! use test;
1701 then
1702 eerror "You specified FEATURES=test, but USE=test is needed"
1703 eerror "to pull in the additional dependencies for testing"
1704 die "Need USE=test enabled"
1705 fi
1706}
1707
1708# ------------------------------------------------------------------------------
1709# @ebuild-function java-pkg_register-ant-task
1710#
1711# Register this package as ant task, so that ant will load it when no specific
1712# ANT_TASKS are specified. Note that even without this registering, all packages
1713# specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1714# packages, but can be also used by other ebuilds that used to symlink their
1715# .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1716# compatibility.
1717#
1718# @param --version x.y Register only for ant version x.y (otherwise for any ant
1719# version). Used by the ant-* packages to prevent loading of mismatched
1720# ant-core ant tasks after core was updated, before the tasks are updated,
1721# without a need for blockers.
1722# @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1723# ------------------------------------------------------------------------------
1724java-pkg_register-ant-task() {
1725 local TASKS_DIR="tasks"
1726
1727 # check for --version x.y parameters
1728 while [[ -n "${1}" && -n "${2}" ]]; do
1729 local var="${1#--}"
1730 local val="${2}"
1731 if [[ "${var}" == "version" ]]; then
1732 TASKS_DIR="tasks-${val}"
1733 else
1734 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1735 fi
1736 shift 2
1737 done
1738
1739 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1740
1741 dodir /usr/share/ant/${TASKS_DIR}
1742 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1743}
1744
1745# ------------------------------------------------------------------------------
1746# @internal-function java-pkg_ant-tasks-depend
1747#
1748# Translates the WANT_ANT_TASKS variable into valid dependencies.
1749# ------------------------------------------------------------------------------
1750java-pkg_ant-tasks-depend() {
1751 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1752
1753 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1754 local DEP=""
1755 for i in ${WANT_ANT_TASKS}
1756 do
1757 if [[ ${i} = ant-* ]]; then
1758 DEP="${DEP}dev-java/${i} "
1759 elif [[ ${i} = */*:* ]]; then
1760 DEP="${DEP}${i} "
1761 else
1762 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1763 return 1
1764 fi
1765 done
1766 echo ${DEP}
1767 return 0
1768 else
1769 return 0
1770 fi
1771}
1772
1773
1774# ------------------------------------------------------------------------------
1775# @internal-function ejunit_
1776#
1777# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1778# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1779#
1780# @param $1 - junit package (junit or junit-4)
1781# @param $2 - -cp or -classpath
1782# @param $3 - classpath; junit and recorded dependencies get appended
1783# @param $@ - the rest of the parameters are passed to java
1784ejunit_() {
1785 debug-print-function ${FUNCNAME} $*
1786
1787 local pkgs
1788 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1789 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1790 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1791 done
1792 fi
1793
1794 local junit=${1}
1795 shift 1
1796
1797 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1798 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1799 cp="${2}:${cp}"
1800 shift 2
1801 else
1802 cp=".:${cp}"
1803 fi
1804
1805 local runner=junit.textui.TestRunner
1806 if [[ "${junit}" == "junit-4" ]] ; then
1807 runner=org.junit.runner.JUnitCore
1808 fi
1809 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1810 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1811}
1812
1813# ------------------------------------------------------------------------------
1814# @ebuild-function ejunit
1815#
1816# Junit wrapper function. Makes it easier to run the tests and checks for
1817# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1818#
1819# Examples:
1820# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1821# ejunit org.blinkenlights.jid3.test.AllTests
1822# ejunit org.blinkenlights.jid3.test.FirstTest \
1823# org.blinkenlights.jid3.test.SecondTest
1824#
1825# @param $1 - -cp or -classpath
1826# @param $2 - classpath; junit and recorded dependencies get appended
1827# @param $@ - the rest of the parameters are passed to java
1828# ------------------------------------------------------------------------------
1829ejunit() {
1830 debug-print-function ${FUNCNAME} $*
1831
1832 ejunit_ "junit" "${@}"
1833}
1834
1835# ------------------------------------------------------------------------------
1836# @ebuild-function ejunit4
1837#
1838# Junit4 wrapper function. Makes it easier to run the tests and checks for
1839# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1840#
1841# Examples:
1842# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1843# ejunit4 org.blinkenlights.jid3.test.AllTests
1844# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1845# org.blinkenlights.jid3.test.SecondTest
1846#
1847# @param $1 - -cp or -classpath
1848# @param $2 - classpath; junit and recorded dependencies get appended
1849# @param $@ - the rest of the parameters are passed to java
1850# ------------------------------------------------------------------------------
1851ejunit4() {
1852 debug-print-function ${FUNCNAME} $*
1853
1854 ejunit_ "junit-4" "${@}"
1855}
1856
1150# ------------------------------------------------------------------------------ 1857# ------------------------------------------------------------------------------
1151# @section-end helper 1858# @section-end helper
1152# ------------------------------------------------------------------------------ 1859# ------------------------------------------------------------------------------
1860
1861# ------------------------------------------------------------------------------
1862# @eclass-src_prepare
1863#
1864# src_prepare Searches for bundled jars
1865# Don't call directly, but via java-pkg-2_src_prepare!
1866# ------------------------------------------------------------------------------
1867
1868java-utils-2_src_prepare() {
1869 [[ ${EBUILD_PHASE} == prepare ]] &&
1870 java-pkg_func-exists java_prepare && java_prepare
1871
1872 # Remember that eant will call this unless called via Portage
1873 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1874 echo "Searching for bundled jars:"
1875 java-pkg_find-normal-jars || echo "None found."
1876 echo "Searching for bundled classes (no output if none found):"
1877 find "${WORKDIR}" -name "*.class"
1878 echo "Search done."
1879 fi
1880 touch "${T}/java-utils-2_src_prepare-run"
1881}
1882
1883# ------------------------------------------------------------------------------
1884# @eclass-pkg_preinst
1885#
1886# pkg_preinst Searches for missing and unneeded dependencies
1887# Don't call directly, but via java-pkg-2_pkg_preinst!
1888# ------------------------------------------------------------------------------
1889
1890java-utils-2_pkg_preinst() {
1891 if is-java-strict; then
1892 if has_version dev-java/java-dep-check; then
1893 [[ -e "${JAVA_PKG_ENV}" ]] || return
1894 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1895 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1896 ewarn "Possibly unneeded dependencies found in package.env:"
1897 for dep in ${output}; do
1898 ewarn "\t${dep}"
1899 done
1900 fi
1901 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1902 ewarn "${output}"
1903 fi
1904 else
1905 eerror "Install dev-java/java-dep-check for dependency checking"
1906 fi
1907 fi
1908}
1153 1909
1154# ------------------------------------------------------------------------------ 1910# ------------------------------------------------------------------------------
1155# @section-begin build 1911# @section-begin build
1156# @section-summary Build functions 1912# @section-summary Build functions
1157# 1913#
1161 1917
1162# ------------------------------------------------------------------------------ 1918# ------------------------------------------------------------------------------
1163# @ebuild-function eant 1919# @ebuild-function eant
1164# 1920#
1165# Ant wrapper function. Will use the appropriate compiler, based on user-defined 1921# Ant wrapper function. Will use the appropriate compiler, based on user-defined
1166# compiler. 1922# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1167# 1923# variables:
1924# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1925# gentoo.classpath property. Be sure to call
1926# java-ant_rewrite-classpath in src_unpack.
1927# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1928# for build-time purposes, the dependency is not recorded to
1929# package.env!
1930# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1168# ------------------------------------------------------------------------------ 1931# ------------------------------------------------------------------------------
1169eant() { 1932eant() {
1170 debug-print-function ${FUNCNAME} $* 1933 debug-print-function ${FUNCNAME} $*
1171 1934
1172 local antflags 1935 if [[ ${EBUILD_PHASE} = compile ]]; then
1936 java-ant-2_src_configure
1937 java-utils-2_src_prepare
1938 fi
1939
1940 if ! has java-ant-2 ${INHERITED}; then
1941 local msg="You should inherit java-ant-2 when using eant"
1942 java-pkg_announce-qa-violation "${msg}"
1943 fi
1944
1945 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1946
1173 java-pkg_init-compiler_ 1947 java-pkg_init-compiler_
1174 local compiler="${GENTOO_COMPILER}" 1948 local compiler="${GENTOO_COMPILER}"
1175 1949
1176 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1950 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1177
1178 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1951 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1179 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1952 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1180 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1953 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1181 fi 1954 fi
1182 1955
1183 if [[ ${compiler} != "javac" ]]; then 1956 if [[ ${compiler} != "javac" ]]; then
1184 antflags="-Dbuild.compiler=${build_compiler}" 1957 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1185 # Figure out any extra stuff to put on the classpath for compilers aside 1958 # Figure out any extra stuff to put on the classpath for compilers aside
1186 # from javac 1959 # from javac
1187 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1960 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1188 # java-config -p 1961 # java-config -p
1189 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1962 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 1963 if [[ -n ${build_compiler_deps} ]]; then
1191 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1964 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1192 fi 1965 fi
1193 fi 1966 fi
1194 1967
1195 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1968 for arg in "${@}"; do
1196 antflags="${antflags} -debug" 1969 if [[ ${arg} = -lib ]]; then
1970 if is-java-strict; then
1971 eerror "You should not use the -lib argument to eant because it will fail"
1972 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1973 eerror "or ant properties to make dependencies available."
1974 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1975 eerror "split ant (>=dev-java/ant-core-1.7)."
1976 die "eant -lib is deprecated/forbidden"
1977 else
1978 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1979 echo "more info."
1980 fi
1197 fi 1981 fi
1198 1982 done
1983
1984 # parse WANT_ANT_TASKS for atoms
1985 local want_ant_tasks
1986 for i in ${WANT_ANT_TASKS}; do
1987 if [[ ${i} = */*:* ]]; then
1988 i=${i#*/}
1989 i=${i%:0}
1990 want_ant_tasks+="${i/:/-} "
1991 else
1992 want_ant_tasks+="${i} "
1993 fi
1994 done
1995 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1996 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1997
1998 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1999 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
2000
2001 # if ant-tasks is not set by ebuild or forced, use none
2002 ANT_TASKS="${ANT_TASKS:-none}"
2003
2004 # at this point, ANT_TASKS should be "all", "none" or explicit list
2005 if [[ "${ANT_TASKS}" == "all" ]]; then
2006 einfo "Using all available ANT_TASKS"
2007 elif [[ "${ANT_TASKS}" == "none" ]]; then
2008 einfo "Disabling all optional ANT_TASKS"
2009 else
2010 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
2011 fi
2012
2013 export ANT_TASKS
2014
2015 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
2016 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
2017
2018 local gcp="${EANT_GENTOO_CLASSPATH}"
2019 local getjarsarg=""
2020
2021 if [[ ${EBUILD_PHASE} = "test" ]]; then
2022 antflags="${antflags} -DJunit.present=true"
2023 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
2024 getjarsarg="--with-dependencies"
2025 else
2026 antflags="${antflags} -Dmaven.test.skip=true"
2027 fi
2028
2029 local cp
2030
2031 for atom in ${gcp}; do
2032 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
2033 done
2034
2035 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2036
2037 if [[ ${cp} ]]; then
2038 # It seems ant does not like single quotes around ${cp}
2039 cp=${cp#:}
2040 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2041 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
2042 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
2043 fi
2044
1199 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2045 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
2046 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1200 ant ${antflags} "${@}" || die "eant failed" 2047 ant ${antflags} "${@}" || die "eant failed"
1201
1202} 2048}
1203 2049
1204# ------------------------------------------------------------------------------ 2050# ------------------------------------------------------------------------------
1205# @ebuild-function ejavac 2051# @ebuild-function ejavac
1206# 2052#
1207# Javac wrapper function. Will use the appropriate compiler, based on 2053# Javac wrapper function. Will use the appropriate compiler, based on
1208# /etc/java-config/compilers.conf 2054# /etc/java-config/compilers.conf
1209# 2055#
1210# @param $@ - Arguments to be passed to the compiler 2056# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 2057# ------------------------------------------------------------------------------
1212ejavac() { 2058ejavac() {
1213 debug-print-function ${FUNCNAME} $* 2059 debug-print-function ${FUNCNAME} $*
1214 2060
2061 java-pkg_init-compiler_
2062
2063 local compiler_executable
1215 local compiler_executable=$(java-pkg_get-javac) 2064 compiler_executable=$(java-pkg_get-javac)
2065 if [[ ${?} != 0 ]]; then
2066 eerror "There was a problem determining compiler: ${compiler_executable}"
2067 die "get-javac failed"
2068 fi
1216 2069
2070 local javac_args
2071 javac_args="$(java-pkg_javac-args)"
2072 if [[ ${?} != 0 ]]; then
2073 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
2074 die "java-pkg_javac-args failed"
2075 fi
2076
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 2077 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 2078 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1219} 2079}
1220 2080
1221# ------------------------------------------------------------------------------ 2081# ------------------------------------------------------------------------------
1222# @ebuild-function java-pkg_filter-compiler 2082# @ebuild-function java-pkg_filter-compiler
1223# 2083#
1224# Used to prevent the use of some compilers. Should be used in src_compile. 2084# Used to prevent the use of some compilers. Should be used in src_compile.
1225# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 2085# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1226# 2086#
1227# @param $@ - compilers to filter 2087# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 2088# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 2089java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 2090 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1231} 2091}
1232 2092
1233# ------------------------------------------------------------------------------ 2093# ------------------------------------------------------------------------------
2094# @ebuild-function java-pkg_force-compiler
2095#
2096# Used to force the use of particular compilers. Should be used in src_compile.
2097# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
2098# OutOfMemoryErrors that may come up.
2099#
2100# @param $@ - compilers to force
2101# ------------------------------------------------------------------------------
2102java-pkg_force-compiler() {
2103 JAVA_PKG_FORCE_COMPILER="$@"
2104}
2105
2106# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 2107# @ebuild-function use_doc
1235# 2108#
1236# Helper function for getting ant to build javadocs. If the user has USE=doc, 2109# 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. 2110# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1238# 2111#
1239# The output of this should be passed to ant. 2112# The output of this should be passed to ant.
1240# 2113#
1241# Example: build javadocs by calling 'javadoc' target 2114# Example: build javadocs by calling 'javadoc' target
1242# eant $(use_doc) 2115# eant $(use_doc)
1243# Example: build javadocs by calling 'apidoc' target 2116# Example: build javadocs by calling 'apidoc' target
1248# ------------------------------------------------------------------------------ 2121# ------------------------------------------------------------------------------
1249use_doc() { 2122use_doc() {
1250 use doc && echo ${@:-javadoc} 2123 use doc && echo ${@:-javadoc}
1251} 2124}
1252 2125
2126
1253# ------------------------------------------------------------------------------ 2127# ------------------------------------------------------------------------------
1254# @section-end build 2128# @section-end build
1255# ------------------------------------------------------------------------------ 2129# ------------------------------------------------------------------------------
1256 2130
1257# ------------------------------------------------------------------------------ 2131# ------------------------------------------------------------------------------
1258# @section-begin internal 2132# @section-begin internal
1259# @section-summary Internal functions 2133# @section-summary Internal functions
1260# 2134#
1261# Do __NOT__ use any of these from an ebuild! These are only to be used from 2135# Do __NOT__ use any of these from an ebuild! These are only to be used from
1262# within the java eclasses. 2136# within the java eclasses.
1263# ------------------------------------------------------------------------------ 2137# ------------------------------------------------------------------------------
1264 2138
1265# ----------------------------------------------------------------------------- 2139# -----------------------------------------------------------------------------
1266# @function-internal java-pkg_init 2140# @function-internal java-pkg_init
1267# 2141#
1268# The purpose of this function, as the name might imply, is to initialize the 2142# 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 2143# 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 2144# that'll muss things up. It initializes some variables, which are used
1271# internally. And most importantly, it'll switch the VM if necessary. 2145# internally. And most importantly, it'll switch the VM if necessary.
1272# 2146#
1273# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will 2147# This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
1274# call it during each of the phases of the merge process. 2148# call it during each of the phases of the merge process.
1275# 2149#
1276# ----------------------------------------------------------------------------- 2150# -----------------------------------------------------------------------------
1277java-pkg_init() { 2151java-pkg_init() {
2152 debug-print-function ${FUNCNAME} $*
2153
2154 # Don't set up build environment if installing from binary. #206024 #258423
2155 [[ "${MERGE_TYPE}" == "binary" ]] && return
2156 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2157 # work nothing is lost.
2158 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2159
1278 unset JAVAC 2160 unset JAVAC
1279 unset JAVA_HOME 2161 unset JAVA_HOME
2162
2163 java-config --help >/dev/null || {
2164 eerror ""
2165 eerror "Can't run java-config --help"
2166 eerror "Have you upgraded python recently but haven't"
2167 eerror "run python-updater yet?"
2168 die "Can't run java-config --help"
2169 }
2170
2171 # People do all kinds of weird things.
2172 # http://forums.gentoo.org/viewtopic-p-3943166.html
2173 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2174 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2175 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2176 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2177 ewarn "sun-jdk vms and and as such break configure scripts that"
2178 ewarn "use it (for example app-office/openoffice) so we filter it out."
2179 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2180 ewarn "make.conf for example) to silence this warning or"
2181 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2182 fi
2183
2184 if [[ -z ${accept} ]]; then
2185 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2186 # -version output
2187 unset _JAVA_OPTIONS
2188 # phase hooks make this run many times without this
2189 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2190 fi
2191
2192 if java-pkg_func-exists ant_src_unpack; then
2193 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2194 fi
2195
1280 java-pkg_init_paths_ 2196 java-pkg_init_paths_
1281 java-pkg_switch-vm 2197 java-pkg_switch-vm
1282 PATH=${JAVA_HOME}/bin:${PATH} 2198 PATH=${JAVA_HOME}/bin:${PATH}
1283 2199
1284 # TODO we will probably want to set JAVAC and JAVACFLAGS 2200 # TODO we will probably want to set JAVAC and JAVACFLAGS
1285 2201
1286 # Do some QA checks 2202 # Do some QA checks
1287 java-pkg_check-jikes 2203 java-pkg_check-jikes
1288 2204
2205 # Can't use unset here because Portage does not save the unset
2206 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2207
1289 # When users have crazy classpaths some packages can fail to compile. 2208 # When users have crazy classpaths some packages can fail to compile.
1290 # and everything should work with empty CLASSPATH. 2209 # and everything should work with empty CLASSPATH.
1291 # This also helps prevent unexpected dependencies on random things 2210 # This also helps prevent unexpected dependencies on random things
1292 # from the CLASSPATH. 2211 # from the CLASSPATH.
1293 unset CLASSPATH 2212 export CLASSPATH=
2213
2214 # Unset external ANT_ stuff
2215 export ANT_TASKS=
2216 export ANT_OPTS=
2217 export ANT_RESPECT_JAVA_HOME=
1294} 2218}
1295 2219
1296# ------------------------------------------------------------------------------ 2220# ------------------------------------------------------------------------------
1297# @function-internal java-pkg-init-compiler_ 2221# @function-internal java-pkg-init-compiler_
1298# 2222#
1299# This function attempts to figure out what compiler should be used. It does 2223# 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 2224# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1301# COMPILERS variable defined there. 2225# COMPILERS variable defined there.
1302# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 2226# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1303# 2227#
1304# It will go through the list of compilers, and verify that it supports the 2228# 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 2229# 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 2230# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1307# isn't done. 2231# isn't done.
1308# 2232#
1330 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2254 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1331 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 2255 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1332 else 2256 else
1333 compilers=${JAVA_PKG_FORCE_COMPILER} 2257 compilers=${JAVA_PKG_FORCE_COMPILER}
1334 fi 2258 fi
1335 2259
1336 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 2260 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1337 2261
1338 # Figure out if we should announce what compiler we're using 2262 # Figure out if we should announce what compiler we're using
1339 local compiler 2263 local compiler
1340 for compiler in ${compilers}; do 2264 for compiler in ${compilers}; do
1343 if [[ ${compiler} = "javac" ]]; then 2267 if [[ ${compiler} = "javac" ]]; then
1344 debug-print "Found javac... breaking" 2268 debug-print "Found javac... breaking"
1345 export GENTOO_COMPILER="javac" 2269 export GENTOO_COMPILER="javac"
1346 break 2270 break
1347 fi 2271 fi
1348 2272
1349 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 2273 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1350 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 2274 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1351 einfo "Filtering ${compiler}" 2275 einfo "Filtering ${compiler}"
1352 continue 2276 continue
1353 fi 2277 fi
1354 fi 2278 fi
1355 2279
1356 # for non-javac, we need to make sure it supports the right target and 2280 # for non-javac, we need to make sure it supports the right target and
1357 # source 2281 # source
1358 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 2282 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1359 if [[ -f ${compiler_env} ]]; then 2283 if [[ -f ${compiler_env} ]]; then
1360 local desired_target="$(java-pkg_get-target)" 2284 local desired_target="$(java-pkg_get-target)"
1389 done 2313 done
1390 2314
1391 # If it hasn't been defined already, default to javac 2315 # If it hasn't been defined already, default to javac
1392 if [[ -z ${GENTOO_COMPILER} ]]; then 2316 if [[ -z ${GENTOO_COMPILER} ]]; then
1393 if [[ -n ${compilers} ]]; then 2317 if [[ -n ${compilers} ]]; then
1394 einfo "No suitable compiler found: defaulting javac for compilation" 2318 einfo "No suitable compiler found: defaulting to JDK default for compilation"
1395 else 2319 else
1396 # probably don't need to notify users about the default. 2320 # probably don't need to notify users about the default.
1397 :;#einfo "Defaulting to javac for compilation" 2321 :;#einfo "Defaulting to javac for compilation"
1398 fi 2322 fi
2323 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2324 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2325 else
1399 export GENTOO_COMPILER=javac 2326 export GENTOO_COMPILER=javac
2327 fi
1400 else 2328 else
1401 einfo "Using ${GENTOO_COMPILER} for compilation" 2329 einfo "Using ${GENTOO_COMPILER} for compilation"
1402 fi 2330 fi
1403 2331
1404} 2332}
1420 fi 2348 fi
1421 2349
1422 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}" 2350 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
1423 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/" 2351 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
1424 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env" 2352 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2353 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2354 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
1425 2355
1426 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib" 2356 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
1427 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}" 2357 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
1428 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps" 2358 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
1429 2359
1442# Writes the package.env out to disk. 2372# Writes the package.env out to disk.
1443# 2373#
1444# ------------------------------------------------------------------------------ 2374# ------------------------------------------------------------------------------
1445# TODO change to do-write, to match everything else 2375# TODO change to do-write, to match everything else
1446java-pkg_do_write_() { 2376java-pkg_do_write_() {
2377 debug-print-function ${FUNCNAME} $*
2378 java-pkg_init_paths_
1447 # Create directory for package.env 2379 # Create directory for package.env
1448 dodir "${JAVA_PKG_SHAREPATH}" 2380 dodir "${JAVA_PKG_SHAREPATH}"
1449 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2381 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2382 "${JAVA_PKG_DEPEND_FILE}" || -f \
2383 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
1450 # Create package.env 2384 # Create package.env
1451 ( 2385 (
1452 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2386 echo "DESCRIPTION=\"${DESCRIPTION}\""
1453 echo "GENERATION=\"2\"" 2387 echo "GENERATION=\"2\""
2388 echo "SLOT=\"${SLOT}\""
2389 echo "CATEGORY=\"${CATEGORY}\""
2390 echo "PVR=\"${PVR}\""
1454 2391
1455 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2392 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
1456 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2393 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1457 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2394 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1458 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2395 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2396 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2397 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2398 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
1459 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2399 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2400 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2401 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
1460 ) > "${JAVA_PKG_ENV}" 2402 ) > "${JAVA_PKG_ENV}"
1461 2403
1462 # register target/source 2404 # register target/source
1463 local target="$(java-pkg_get-target)" 2405 local target="$(java-pkg_get-target)"
1464 local source="$(java-pkg_get-source)" 2406 local source="$(java-pkg_get-source)"
1465 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 2407 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1466 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 2408 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1474 2416
1475 2417
1476 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2418 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
1477 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2419 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
1478 2420
2421 # extra env variables
2422 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2423 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2424 # nested echo to remove leading/trailing spaces
2425 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2426 >> "${JAVA_PKG_ENV}" || die
2427 fi
2428
1479 # Strip unnecessary leading and trailing colons 2429 # Strip unnecessary leading and trailing colons
1480 # TODO try to cleanup if possible 2430 # TODO try to cleanup if possible
1481 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2431 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2432 else
2433 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2434 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2435 debug-print "write package.env."
1482 fi 2436 fi
1483} 2437}
1484
1485 2438
1486# ------------------------------------------------------------------------------ 2439# ------------------------------------------------------------------------------
1487# @internal-function java-pkg_record-jar_ 2440# @internal-function java-pkg_record-jar_
1488# 2441#
1489# Record a dependency to the package.env 2442# Record an (optional) dependency to the package.env
1490# 2443# @param --optional - record dependency as optional
2444# @param --build - record dependency as build_only
2445# @param $1 - package to record
2446# @param $2 - (optional) jar of package to record
1491# ------------------------------------------------------------------------------ 2447# ------------------------------------------------------------------------------
1492JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2448JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2449JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2450JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
1493 2451
1494java-pkg_record-jar_() { 2452java-pkg_record-jar_() {
1495 debug-print-function ${FUNCNAME} $* 2453 debug-print-function ${FUNCNAME} $*
2454
2455 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2456 case "${1}" in
2457 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2458 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2459 esac
1496 2460
1497 local pkg=${1} jar=${2} append 2461 local pkg=${1} jar=${2} append
1498 if [[ -z "${jar}" ]]; then 2462 if [[ -z "${jar}" ]]; then
1499 append="${pkg}" 2463 append="${pkg}"
1500 else 2464 else
1501 append="$(basename ${jar})@${pkg}" 2465 append="$(basename ${jar})@${pkg}"
1502 fi 2466 fi
1503 2467
1504 echo ${append} >> ${JAVA_PKG_DEPEND} 2468 echo "${append}" >> "${depend_file}"
1505} 2469}
1506 2470
1507# ------------------------------------------------------------------------------ 2471# ------------------------------------------------------------------------------
1508# @internal-function java-pkg_append_ 2472# @internal-function java-pkg_append_
1509# 2473#
1533 fi 2497 fi
1534} 2498}
1535 2499
1536# ------------------------------------------------------------------------------ 2500# ------------------------------------------------------------------------------
1537# @internal-function java-pkg_expand_dir_ 2501# @internal-function java-pkg_expand_dir_
1538# 2502#
1539# Gets the full path of the file/directory's parent. 2503# Gets the full path of the file/directory's parent.
1540# @param $1 - file/directory to find parent directory for 2504# @param $1 - file/directory to find parent directory for
1541# @return - path to $1's parent directory 2505# @return - path to $1's parent directory
1542# ------------------------------------------------------------------------------ 2506# ------------------------------------------------------------------------------
1543java-pkg_expand_dir_() { 2507java-pkg_expand_dir_() {
1553# 2517#
1554# @return 0 - function is declared 2518# @return 0 - function is declared
1555# @return 1 - function is undeclared 2519# @return 1 - function is undeclared
1556# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
1557java-pkg_func-exists() { 2521java-pkg_func-exists() {
1558 if [[ -n "$(declare -f ${1})" ]]; then 2522 declare -F ${1} > /dev/null
1559 return 0
1560 else
1561 return 1
1562 fi
1563} 2523}
1564 2524
1565# ------------------------------------------------------------------------------ 2525# ------------------------------------------------------------------------------
1566# @internal-function java-pkg_setup-vm 2526# @internal-function java-pkg_setup-vm
1567# 2527#
1570# ------------------------------------------------------------------------------ 2530# ------------------------------------------------------------------------------
1571java-pkg_setup-vm() { 2531java-pkg_setup-vm() {
1572 debug-print-function ${FUNCNAME} $* 2532 debug-print-function ${FUNCNAME} $*
1573 2533
1574 local vendor="$(java-pkg_get-vm-vendor)" 2534 local vendor="$(java-pkg_get-vm-vendor)"
1575 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 2535 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1576 addpredict "/dev/random" 2536 addpredict "/dev/random"
1577 elif [[ "${vendor}" == "ibm" ]]; then 2537 elif [[ "${vendor}" == "ibm" ]]; then
1578 addpredict "/proc/self/maps" 2538 addpredict "/proc/self/maps"
1579 addpredict "/proc/cpuinfo" 2539 addpredict "/proc/cpuinfo"
1580 export LANG="C" LC_ALL="C" 2540 addpredict "/proc/self/coredump_filter"
2541 elif [[ "${vendor}" == "oracle" ]]; then
2542 addpredict "/dev/random"
2543 addpredict "/proc/self/coredump_filter"
2544 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2545 addpredict "/dev/random"
2546 addpredict "/proc/self/coredump_filter"
1581 elif [[ "${vendor}" == "jrockit" ]]; then 2547 elif [[ "${vendor}" == "jrockit" ]]; then
1582 addpredict "/proc/cpuinfo" 2548 addpredict "/proc/cpuinfo"
1583 fi 2549 fi
1584} 2550}
1585 2551
1586# ------------------------------------------------------------------------------ 2552# ------------------------------------------------------------------------------
1587# @internal-function java-pkg_needs-vm 2553# @internal-function java-pkg_needs-vm
1588# 2554#
1589# Does the current package depend on virtual/jdk? 2555# Does the current package depend on virtual/jdk or does it set
2556# JAVA_PKG_WANT_BUILD_VM?
1590# 2557#
1591# @return 0 - Package depends on virtual/jdk 2558# @return 0 - Package depends on virtual/jdk
1592# @return 1 - Package does not depend on virtual/jdk 2559# @return 1 - Package does not depend on virtual/jdk
1593# ------------------------------------------------------------------------------ 2560# ------------------------------------------------------------------------------
1594java-pkg_needs-vm() { 2561java-pkg_needs-vm() {
1595 debug-print-function ${FUNCNAME} $* 2562 debug-print-function ${FUNCNAME} $*
1596 2563
1597 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2564 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
1598 return 0 2565 return 0
1599 fi 2566 fi
2567
2568 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
1600 2569
1601 return 1 2570 return 1
1602} 2571}
1603 2572
1604# ------------------------------------------------------------------------------ 2573# ------------------------------------------------------------------------------
1629# @return - The version of the current VM 2598# @return - The version of the current VM
1630# ------------------------------------------------------------------------------ 2599# ------------------------------------------------------------------------------
1631java-pkg_get-vm-version() { 2600java-pkg_get-vm-version() {
1632 debug-print-function ${FUNCNAME} $* 2601 debug-print-function ${FUNCNAME} $*
1633 2602
1634 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 2603 java-config -g PROVIDES_VERSION
2604}
2605
2606# ------------------------------------------------------------------------------
2607# @internal-function java-pkg_build-vm-from-handle
2608#
2609# Selects a build vm from a list of vm handles. First checks for the system-vm
2610# beeing usable, then steps through the listed handles till a suitable vm is
2611# found.
2612#
2613# @return - VM handle of an available JDK
2614# ------------------------------------------------------------------------------
2615java-pkg_build-vm-from-handle() {
2616 debug-print-function ${FUNCNAME} "$*"
2617
2618 local vm
2619 vm=$(java-pkg_get-current-vm)
2620 if [[ $? != 0 ]]; then
2621 eerror "${FUNCNAME}: Failed to get active vm"
2622 return 1
2623 fi
2624
2625 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2626 echo ${vm}
2627 return 0
2628 fi
2629
2630 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2631 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2632 echo ${vm}
2633 return 0
2634 fi
2635 done
2636
2637 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2638 return 1
1635} 2639}
1636 2640
1637# ------------------------------------------------------------------------------ 2641# ------------------------------------------------------------------------------
1638# @internal-function java-pkg_switch-vm 2642# @internal-function java-pkg_switch-vm
1639# 2643#
1640# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 2644# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1641# verify that the current VM is sufficient. 2645# verify that the current VM is sufficient.
1642# Setup the environment for the VM being used. 2646# Setup the environment for the VM being used.
1643# ------------------------------------------------------------------------------ 2647# ------------------------------------------------------------------------------
1644java-pkg_switch-vm() { 2648java-pkg_switch-vm() {
2649 debug-print-function ${FUNCNAME} $*
2650
1645 if java-pkg_needs-vm; then 2651 if java-pkg_needs-vm; then
1646 # Use the VM specified by JAVA_PKG_FORCE_VM 2652 # Use the VM specified by JAVA_PKG_FORCE_VM
1647 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 2653 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1648 # If you're forcing the VM, I hope you know what your doing... 2654 # If you're forcing the VM, I hope you know what your doing...
2655 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1649 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2656 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1650 # if we're allowed to switch the vm... 2657 # if we're allowed to switch the vm...
1651 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2658 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}" 2659 # if there is an explicit list of handles to choose from
1653 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2660 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
1654 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2661 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2662 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2663 if [[ $? != 0 ]]; then
2664 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2665 die "${FUNCNAME}: Failed to determine VM for building"
2666 fi
2667 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2668 # they can't be deduced from handles.
2669 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2670 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2671 die "Specify JAVA_PKG_WANT_SOURCE"
2672 fi
2673 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2674 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2675 die "Specify JAVA_PKG_WANT_TARGET"
2676 fi
2677 # otherwise determine a vm from dep string
1655 else 2678 else
2679 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1656 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2680 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2681 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2682 eerror "Unable to determine VM for building from dependencies:"
2683 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2684 die "Failed to determine VM for building."
2685 fi
1657 fi 2686 fi
2687 export GENTOO_VM
1658 # otherwise just make sure the current VM is sufficient 2688 # otherwise just make sure the current VM is sufficient
1659 else 2689 else
1660 java-pkg_ensure-vm-version-sufficient 2690 java-pkg_ensure-vm-version-sufficient
1661 fi 2691 fi
1662 debug-print "Using: $(java-config -f)" 2692 debug-print "Using: $(java-config -f)"
1663 2693
1664 java-pkg_setup-vm 2694 java-pkg_setup-vm
1665 2695
1666 export JAVA=$(java-config --java) 2696 export JAVA=$(java-config --java)
1667 export JAVAC=$(java-config --javac) 2697 export JAVAC=$(java-config --javac)
1668 export JAVACFLAGS="$(java-pkg_javac-args)" 2698 JAVACFLAGS="$(java-pkg_javac-args)"
2699 if [[ ${?} != 0 ]]; then
2700 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
2701 die "java-pkg_javac-args failed"
2702 fi
1669 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 2703 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2704 export JAVACFLAGS
1670 2705
1671 export JAVA_HOME="$(java-config -g JAVA_HOME)" 2706 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1672 export JDK_HOME=${JAVA_HOME} 2707 export JDK_HOME=${JAVA_HOME}
1673 2708
1674 #TODO If you know a better solution let us know. 2709 #TODO If you know a better solution let us know.
1675 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2710 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1676 2711
1677 local tann="${T}/announced-vm" 2712 local tann="${T}/announced-vm"
2713 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2714 # if people have for example modified eclasses some where
1678 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2715 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1679 # Add a check for setup/preinst phase... to avoid duplicate outputs
1680 # for when FEATURES=buildpkg
1681 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1682 then
1683 einfo "Using: $(java-config -f)" 2716 einfo "Using: $(java-config -f)"
1684 [[ ! -f "${tann}" ]] && touch "${tann}" 2717 [[ ! -f "${tann}" ]] && touch "${tann}"
1685 fi
1686 fi 2718 fi
1687 2719
1688 else 2720 else
1689 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2721 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
1690 fi 2722 fi
1695# 2727#
1696# Enhanced die for Java packages, which displays some information that may be 2728# Enhanced die for Java packages, which displays some information that may be
1697# useful for debugging bugs on bugzilla. 2729# useful for debugging bugs on bugzilla.
1698# ------------------------------------------------------------------------------ 2730# ------------------------------------------------------------------------------
1699#register_die_hook java-pkg_die 2731#register_die_hook java-pkg_die
1700if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2732if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
1701 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2733 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
1702fi 2734fi
1703 2735
1704java-pkg_die() { 2736java-pkg_die() {
1705 echo "!!! When you file a bug report, please include the following information:" >&2 2737 echo "!!! When you file a bug report, please include the following information:" >&2
1706 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 2738 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1707 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 2739 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1708 echo "and of course, the output of emerge --info" >&2 2740 echo "and of course, the output of emerge --info" >&2
1709} 2741}
1710 2742
2743
2744# TODO document
2745# List jars in the source directory, ${S}
2746java-pkg_jar-list() {
2747 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
2748 einfo "Linked Jars"
2749 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2750 einfo "Jars"
2751 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2752 einfo "Classes"
2753 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2754 fi
2755}
2756
2757# ------------------------------------------------------------------------------
2758# @internal-function java-pkg_verify-classes
2759#
2760# Verify that the classes were compiled for the right source / target. Dies if
2761# not.
2762# @param $1 (optional) - the file to check, otherwise checks whole ${D}
2763# ------------------------------------------------------------------------------
2764java-pkg_verify-classes() {
2765 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2766
2767 local version_verify="/usr/bin/class-version-verify.py"
2768
2769 if [[ ! -x "${version_verify}" ]]; then
2770 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2771 fi
2772
2773 if [[ ! -x "${version_verify}" ]]; then
2774 ewarn "Unable to perform class version checks as"
2775 ewarn "class-version-verify.py is unavailable"
2776 ewarn "Please install dev-java/javatoolkit."
2777 return
2778 fi
2779
2780 local target=$(java-pkg_get-target)
2781 local result
2782 local log="${T}/class-version-verify.log"
2783 if [[ -n "${1}" ]]; then
2784 ${version_verify} -v -t ${target} "${1}" > "${log}"
2785 result=$?
2786 else
2787 ebegin "Verifying java class versions (target: ${target})"
2788 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2789 result=$?
2790 eend ${result}
2791 fi
2792 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2793 if [[ ${result} != 0 ]]; then
2794 eerror "Incorrect bytecode version found"
2795 [[ -n "${1}" ]] && eerror "in file: ${1}"
2796 eerror "See ${log} for more details."
2797 die "Incorrect bytecode found"
2798 fi
2799}
2800
2801# ----------------------------------------------------------------------------
2802# @internal-function java-pkg_ensure-dep
2803# Check that a package being used in jarfrom, getjars and getjar is contained
2804# within DEPEND or RDEPEND.
2805# @param $1 - empty - check both vars; "runtime" or "build" - check only
2806# RDEPEND, resp. DEPEND
2807# @param $2 - Package name and slot.
2808
2809java-pkg_ensure-dep() {
2810 debug-print-function ${FUNCNAME} $*
2811
2812 local limit_to="${1}"
2813 local target_pkg="${2}"
2814 local dev_error=""
2815
2816 # remove the version specification, which may include globbing (* and [123])
2817 local stripped_pkg=$(echo "${target_pkg}" | sed \
2818 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2819
2820 debug-print "Matching against: ${stripped_pkg}"
2821
2822 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2823 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2824 dev_error="${dev_error} declared in DEPEND."
2825 if is-java-strict; then
2826 eerror "${dev_error}"
2827 die "${dev_error}"
2828 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2829 eerror "${dev_error}"
2830 elog "Because you have this package installed the package will"
2831 elog "build without problems, but please report this to"
2832 elog "http://bugs.gentoo.org"
2833 fi
2834 fi
2835
2836 if [[ ${limit_to} != build ]]; then
2837 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2838 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2839 dev_error="The ebuild is attempting to use ${target_pkg},"
2840 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2841 dev_error="${dev_error} or PDEPEND."
2842 if is-java-strict; then
2843 eerror "${dev_error}"
2844 die "${dev_error}"
2845 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2846 eerror "${dev_error}"
2847 elog "The package will build without problems, but may fail to run"
2848 elog "if you don't have ${target_pkg} installed, so please report"
2849 elog "this to http://bugs.gentoo.org"
2850 fi
2851 fi
2852 fi
2853 fi
2854}
2855
1711# ------------------------------------------------------------------------------ 2856# ------------------------------------------------------------------------------
1712# @section-end internal 2857# @section-end internal
1713# ------------------------------------------------------------------------------ 2858# ------------------------------------------------------------------------------
1714 2859
1715java-pkg_check-phase() { 2860java-pkg_check-phase() {
1716 local phase=${1} 2861 local phase=${1}
1717 local funcname=${2} 2862 local funcname=${FUNCNAME[1]}
1718 # TODO add check for java-stricter
1719 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 2863 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
1720 java-pkg_announce-qa-violation \
1721 "${funcname} used outside of src_${phase}" 2864 local msg="${funcname} used outside of src_${phase}"
2865 java-pkg_announce-qa-violation "${msg}"
1722 fi 2866 fi
1723} 2867}
1724 2868
1725java-pkg_check-versioned-jar() { 2869java-pkg_check-versioned-jar() {
1726 local jar=${1} 2870 local jar=${1}
1729 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2873 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
1730 fi 2874 fi
1731} 2875}
1732 2876
1733java-pkg_check-jikes() { 2877java-pkg_check-jikes() {
1734 if hasq jikes ${IUSE}; then 2878 if has jikes ${IUSE}; then
1735 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2879 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1736 fi 2880 fi
1737} 2881}
1738 2882
1739java-pkg_announce-qa-violation() { 2883java-pkg_announce-qa-violation() {
1740 if hasq java-strict ${FEATURES}; then 2884 local nodie
2885 if [[ ${1} == "--nodie" ]]; then
2886 nodie="true"
2887 shift
2888 fi
1741 echo "Java QA Notice: $@" >&2 2889 echo "Java QA Notice: $@" >&2
1742 increment-qa-violations 2890 increment-qa-violations
1743 fi 2891 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
1744} 2892}
1745 2893
1746increment-qa-violations() { 2894increment-qa-violations() {
1747 let "JAVA_PKG_QA_VIOLATIONS+=1" 2895 let "JAVA_PKG_QA_VIOLATIONS+=1"
1748 export JAVA_PKG_QA_VIOLATIONS 2896 export JAVA_PKG_QA_VIOLATIONS
1749} 2897}
1750 2898
2899is-java-strict() {
2900 [[ -n ${JAVA_PKG_STRICT} ]]
2901 return $?
2902}
2903
2904
1751# ------------------------------------------------------------------------------ 2905# ------------------------------------------------------------------------------
1752# @eclass-end 2906# @eclass-end
1753# ------------------------------------------------------------------------------ 2907# ------------------------------------------------------------------------------

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.150

  ViewVC Help
Powered by ViewVC 1.1.20