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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.95 - (hide annotations) (download)
Tue Nov 13 19:36:50 2007 UTC (6 years, 9 months ago) by betelgeuse
Branch: MAIN
Changes since 1.94: +2 -1 lines
Make JAVA_PKG_IUSE work with java-pkg-opt-2 too.

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

  ViewVC Help
Powered by ViewVC 1.1.20