/[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.105 - (hide annotations) (download)
Wed Mar 26 23:00:23 2008 UTC (6 years, 5 months ago) by ali_bush
Branch: MAIN
Changes since 1.104: +23 -1 lines
Adding EAPI=1 suppport to java functions.

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 ali_bush 1.105 # $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.104 2008/03/03 17:55:21 betelgeuse 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 betelgeuse 1.35 # ------------------------------------------------------------------------------
297     # @internal-function depend-java-query
298     #
299     # Wrapper for the depend-java-query binary to enable passing USE in env.
300     # Using env variables keeps this eclass working with java-config versions that
301     # do not handle use flags.
302     # ------------------------------------------------------------------------------
303    
304     depend-java-query() {
305 betelgeuse 1.61 # Used to have a which call here but it caused endless loops for some people
306 betelgeuse 1.62 # that had some weird bashrc voodoo for which.
307 betelgeuse 1.61 USE="${USE}" /usr/bin/depend-java-query "${@}"
308 betelgeuse 1.35 }
309 nichoj 1.1
310     # ------------------------------------------------------------------------------
311     # @ebuild-function java-pkg_regjar
312     #
313     # Records an already installed jar in the package.env
314     # This would mostly be used if the package has make or a custom script to
315     # install things.
316     #
317     # Example:
318 nelchael 1.5 # java-pkg_regjar ${D}/opt/foo/lib/foo.jar
319     #
320     # WARNING:
321     # if you want to use shell expansion, you have to use ${D}/... as the for in
322     # this function will not be able to expand the path, here's an example:
323     #
324     # java-pkg_regjar /opt/my-java/lib/*.jar
325     #
326     # will not work, because:
327     # * the `for jar in "$@"` can't expand the path to jar file names, as they
328     # don't exist yet
329     # * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
330     # doesn't exist
331 betelgeuse 1.19 #
332 nelchael 1.5 # you have to use it as:
333     #
334     # java-pkg_regjar ${D}/opt/my-java/lib/*.jar
335 nichoj 1.1 #
336     # @param $@ - jars to record
337     # ------------------------------------------------------------------------------
338 nichoj 1.10 # TODO should we be making sure the jar is present on ${D} or wherever?
339 nichoj 1.1 java-pkg_regjar() {
340     debug-print-function ${FUNCNAME} $*
341    
342     java-pkg_check-phase install
343    
344     [[ ${#} -lt 1 ]] && die "at least one argument needed"
345    
346     java-pkg_init_paths_
347    
348     local jar jar_dir jar_file
349 caster 1.50 for jar in "${@}"; do
350 nichoj 1.1 # TODO use java-pkg_check-versioned-jar
351 betelgeuse 1.38 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
352     [[ -d "${jar}" || -d "${D}${jar}" ]] \
353     && die "Called ${FUNCNAME} on a directory $*"
354 betelgeuse 1.55
355     #check that class version correct when in strict mode
356     is-java-strict && java-pkg_verify-classes "${jar}"
357    
358 nelchael 1.5 # nelchael: we should strip ${D} in this case too, here's why:
359     # imagine such call:
360     # java-pkg_regjar ${D}/opt/java/*.jar
361     # such call will fall into this case (-e ${jar}) and will
362     # record paths with ${D} in package.env
363     java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
364 nichoj 1.1 else
365 betelgeuse 1.68 if [[ ${jar} = *\** ]]; then
366     eerror "The argument ${jar} to ${FUNCNAME}"
367     eerror "has * in it. If you want it to glob in"
368     eerror '${D} add ${D} to the argument.'
369     fi
370 nichoj 1.1 die "${jar} does not exist"
371     fi
372     done
373    
374     java-pkg_do_write_
375     }
376    
377     # ------------------------------------------------------------------------------
378     # @ebuild-function java-pkg_newjar
379     #
380     # Installs a jar with a new name
381     #
382     # @example: install a versioned jar without the version
383     # java-pkg_newjar dist/${P}.jar ${PN}.jar
384     #
385     # @param $1 - jar to install
386     # @param $2 - new name for jar - defaults to ${PN}.jar if not specified
387     # ------------------------------------------------------------------------------
388     java-pkg_newjar() {
389     debug-print-function ${FUNCNAME} $*
390    
391     local original_jar="${1}"
392     local new_jar="${2:-${PN}.jar}"
393     local new_jar_dest="${T}/${new_jar}"
394    
395     [[ -z ${original_jar} ]] && die "Must specify a jar to install"
396 betelgeuse 1.44 [[ ! -f ${original_jar} ]] \
397     && die "${original_jar} does not exist or is not a file!"
398 nichoj 1.1
399     rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
400     cp "${original_jar}" "${new_jar_dest}" \
401     || die "Failed to copy ${original_jar} to ${new_jar_dest}"
402     java-pkg_dojar "${new_jar_dest}"
403     }
404    
405     # ------------------------------------------------------------------------------
406     # @ebuild-function java-pkg_addcp
407     #
408     # Add something to the package's classpath. For jars, you should use dojar,
409     # newjar, or regjar. This is typically used to add directories to the classpath.
410     #
411     # TODO add example
412     # @param $@ - value to append to JAVA_PKG_CLASSPATH
413     # ------------------------------------------------------------------------------
414     java-pkg_addcp() {
415     java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
416     java-pkg_do_write_
417     }
418    
419     # ------------------------------------------------------------------------------
420     # @ebuild-function java-pkg_doso
421 betelgeuse 1.19 #
422 nichoj 1.1 # Installs any number of JNI libraries
423     # They will be installed into /usr/lib by default, but java-pkg_sointo
424     # can be used change this path
425     #
426     # Example:
427     # java-pkg_doso *.so
428     #
429     # @param $@ - JNI libraries to install
430     # ------------------------------------------------------------------------------
431     java-pkg_doso() {
432     debug-print-function ${FUNCNAME} $*
433    
434     [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435     java-pkg_check-phase install
436    
437     [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
438    
439     java-pkg_init_paths_
440    
441     local lib
442     # for each lib
443     for lib in "$@" ; do
444     # if the lib exists...
445     if [[ -e "${lib}" ]] ; then
446     # install if it isn't a symlink
447     if [[ ! -L "${lib}" ]] ; then
448     INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449     INSOPTIONS="${LIBOPTIONS}" \
450     doins "${lib}" || "failed to install ${lib}"
451     java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452     debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453     # otherwise make a symlink to the symlink's origin
454     else
455     # TODO use dosym
456 betelgeuse 1.57 ln -s "$(readlink "${lib}")" \
457     "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 nichoj 1.1 debug-print "${lib} is a symlink, linking accordanly"
459     fi
460     # otherwise die
461     else
462     die "${lib} does not exist"
463     fi
464     done
465    
466     java-pkg_do_write_
467     }
468    
469     # ------------------------------------------------------------------------------
470     # @ebuild-function java-pkg_regso
471     #
472     # Registers an already JNI library in package.env.
473     #
474     # Example:
475     # java-pkg_regso *.so /path/*.so
476     #
477     # @param $@ - JNI libraries to register
478     # ------------------------------------------------------------------------------
479     java-pkg_regso() {
480     debug-print-function ${FUNCNAME} $*
481    
482     java-pkg_check-phase install
483    
484     [[ ${#} -lt 1 ]] && "at least one argument needed"
485    
486     java-pkg_init_paths_
487 betelgeuse 1.19
488 nichoj 1.1 local lib target_dir
489     for lib in "$@" ; do
490     # Check the absolute path of the lib
491     if [[ -e "${lib}" ]] ; then
492     target_dir="$(java-pkg_expand_dir_ ${lib})"
493     java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}"
494     # Check the path of the lib relative to ${D}
495     elif [[ -e "${D}${lib}" ]]; then
496     target_dir="$(java-pkg_expand_dir_ ${D}${lib})"
497     java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}"
498     else
499     die "${lib} does not exist"
500     fi
501     done
502    
503     java-pkg_do_write_
504     }
505    
506     # ------------------------------------------------------------------------------
507     # @ebuild-function java-pkg_jarinto
508     #
509     # Changes the path jars are installed into
510     #
511     # @param $1 - new location to install jars into.
512     # -----------------------------------------------------------------------------
513     java-pkg_jarinto() {
514     debug-print-function ${FUNCNAME} $*
515    
516     JAVA_PKG_JARDEST="${1}"
517     }
518    
519     # ------------------------------------------------------------------------------
520     # @ebuild-function java-pkg_sointo
521     #
522     # Changes the path that JNI libraries are installed into.
523     #
524     # @param $1 - new location to install JNI libraries into.
525     # ------------------------------------------------------------------------------
526     java-pkg_sointo() {
527     debug-print-function ${FUNCNAME} $*
528    
529     JAVA_PKG_LIBDEST="${1}"
530     }
531    
532     # ------------------------------------------------------------------------------
533     # @ebuild-function java-pkg_dohtml
534     #
535     # Install Javadoc HTML documentation
536     #
537     # @example
538     # java-pkg_dohtml dist/docs/
539     #
540     # ------------------------------------------------------------------------------
541     java-pkg_dohtml() {
542     debug-print-function ${FUNCNAME} $*
543    
544     [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
545 betelgeuse 1.27
546 betelgeuse 1.31 # from /usr/lib/portage/bin/dohtml -h
547     # -f Set list of allowed extensionless file names.
548 nichoj 1.1 dohtml -f package-list "$@"
549 betelgeuse 1.31
550 nichoj 1.1 # this probably shouldn't be here but it provides
551     # a reasonable way to catch # docs for all of the
552     # old ebuilds.
553     java-pkg_recordjavadoc
554     }
555    
556 betelgeuse 1.30 # ------------------------------------------------------------------------------
557     # @ebuild-function java-pkg_dojavadoc
558     #
559     # Installs javadoc documentation. This should be controlled by the doc use flag.
560     #
561 betelgeuse 1.99 # @param $1: optional --symlink creates to symlink like this for html
562     # documentation bundles.
563     # @param $2: - The javadoc root directory.
564 betelgeuse 1.30 #
565     # @example:
566     # java-pkg_dojavadoc docs/api
567 betelgeuse 1.99 # java-pkg_dojavadoc --symlink apidocs docs/api
568 betelgeuse 1.30 #
569     # ------------------------------------------------------------------------------
570 nichoj 1.1 java-pkg_dojavadoc() {
571 betelgeuse 1.74 debug-print-function ${FUNCNAME} $*
572 betelgeuse 1.99
573     # For html documentation bundles that link to Javadoc
574     local symlink
575     if [[ ${1} = --symlink ]]; then
576     symlink=${2}
577     shift 2
578     fi
579    
580 nichoj 1.1 local dir="$1"
581 betelgeuse 1.99 local dest=/usr/share/doc/${PF}/html
582 nichoj 1.1
583 betelgeuse 1.74 # QA checks
584    
585 nichoj 1.1 java-pkg_check-phase install
586    
587     [[ -z "${dir}" ]] && die "Must specify a directory!"
588     [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
589 betelgeuse 1.74 if [[ ! -e "${dir}/index.html" ]]; then
590     local msg="No index.html in javadoc directory"
591     ewarn "${msg}"
592     is-java-strict && die "${msg}"
593     fi
594    
595 betelgeuse 1.99 if [[ -e ${D}/${dest}/api ]]; then
596     eerror "${dest} already exists. Will not overwrite."
597     die "${dest}"
598     fi
599    
600 betelgeuse 1.74 # Renaming to match our directory layout
601 nichoj 1.1
602     local dir_to_install="${dir}"
603     if [[ "$(basename "${dir}")" != "api" ]]; then
604     dir_to_install="${T}/api"
605     # TODO use doins
606     cp -r "${dir}" "${dir_to_install}" || die "cp failed"
607     fi
608    
609 betelgeuse 1.74 # Actual installation
610    
611 betelgeuse 1.99 java-pkg_dohtml -r "${dir_to_install}"
612    
613     # Let's make a symlink to the directory we have everything else under
614 betelgeuse 1.100 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
615 betelgeuse 1.99
616     if [[ ${symlink} ]]; then
617     dosym ${dest}/{api,${symlink}} || die
618     fi
619 nichoj 1.1 }
620    
621     # ------------------------------------------------------------------------------
622     # @ebuild-function java-pkg_dosrc
623     #
624 betelgeuse 1.19 # Installs a zip containing the source for a package, so it can used in
625 nichoj 1.1 # from IDEs like eclipse and netbeans.
626     #
627     # Ebuild needs to DEPEND on app-arch/zip to use this.
628     #
629     # It also should be controlled by USE=source.
630     #
631     # @example:
632     # java-pkg_dosrc src/*
633     #
634     # ------------------------------------------------------------------------------
635 betelgeuse 1.19 # TODO change so it the arguments it takes are the base directories containing
636 nichoj 1.1 # source -nichoj
637     # TODO should we be able to handle multiple calls to dosrc? -nichoj
638     # TODO maybe we can take an existing zip/jar? -nichoj
639     # FIXME apparently this fails if you give it an empty directories
640     java-pkg_dosrc() {
641     debug-print-function ${FUNCNAME} $*
642    
643 betelgeuse 1.19 [ ${#} -lt 1 ] && die "At least one argument needed"
644 nichoj 1.1
645     java-pkg_check-phase install
646    
647 betelgeuse 1.19 [[ ${#} -lt 1 ]] && die "At least one argument needed"
648 nichoj 1.1
649 betelgeuse 1.66 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
650     local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
651 betelgeuse 1.104 java-pkg_announce-qa-violation ${msg}
652 betelgeuse 1.66 fi
653    
654 nichoj 1.1 java-pkg_init_paths_
655    
656     local zip_name="${PN}-src.zip"
657     local zip_path="${T}/${zip_name}"
658     local dir
659 caster 1.50 for dir in "${@}"; do
660 nichoj 1.1 local dir_parent=$(dirname "${dir}")
661     local dir_name=$(basename "${dir}")
662     pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
663     zip -q -r ${zip_path} ${dir_name} -i '*.java'
664     local result=$?
665     # 12 means zip has nothing to do
666     if [[ ${result} != 12 && ${result} != 0 ]]; then
667     die "failed to zip ${dir_name}"
668     fi
669     popd >/dev/null
670     done
671    
672     # Install the zip
673     INSDESTTREE=${JAVA_PKG_SOURCESPATH} \
674     doins ${zip_path} || die "Failed to install source"
675    
676     JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
677     java-pkg_do_write_
678     }
679    
680     # ------------------------------------------------------------------------------
681     # @ebuild-function java-pkg_dolauncher
682     #
683     # Make a wrapper script to lauch/start this package
684     # If necessary, the wrapper will switch to the appropriate VM.
685     #
686 betelgeuse 1.25 # Can be called without parameters if the package installs only one jar
687     # that has the Main-class attribute set. The wrapper will be named ${PN}.
688     #
689 nichoj 1.1 # @param $1 - filename of launcher to create
690     # @param $2 - options, as follows:
691     # --main the.main.class.too.start
692 betelgeuse 1.25 # --jar /the/jar/too/launch.jar or just <name>.jar
693 betelgeuse 1.20 # --java_args 'Extra arguments to pass to java'
694 caster 1.42 # --pkg_args 'Extra arguments to pass to the package'
695     # --pwd Directory the launcher changes to before executing java
696     # -into Directory to install the launcher to, instead of /usr/bin
697     # -pre Prepend contents of this file to the launcher
698 nichoj 1.1 # ------------------------------------------------------------------------------
699     java-pkg_dolauncher() {
700     debug-print-function ${FUNCNAME} $*
701    
702     java-pkg_check-phase install
703 betelgeuse 1.25 java-pkg_init_paths_
704 nichoj 1.1
705 betelgeuse 1.25 if [[ ${#} = 0 ]]; then
706     local name="${PN}"
707     else
708     local name="${1}"
709     shift
710     fi
711 nichoj 1.1
712     # TODO rename to launcher
713     local target="${T}/${name}"
714 betelgeuse 1.20 local var_tmp="${T}/launcher_variables_tmp"
715 nichoj 1.1 local target_dir pre
716    
717 betelgeuse 1.20 # Process the other the rest of the arguments
718 nichoj 1.1 while [[ -n "${1}" && -n "${2}" ]]; do
719 betelgeuse 1.38 local var="${1}" value="${2}"
720 betelgeuse 1.19 if [[ "${var:0:2}" == "--" ]]; then
721 betelgeuse 1.25 local var=${var:2}
722     echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
723 betelgeuse 1.26 local gjl_${var}="${value}"
724 nichoj 1.1 elif [[ "${var}" == "-into" ]]; then
725     target_dir="${value}"
726     elif [[ "${var}" == "-pre" ]]; then
727     pre="${value}"
728     fi
729     shift 2
730     done
731 betelgeuse 1.20
732 betelgeuse 1.25 # Test if no --jar and --main arguments were given and
733     # in that case check if the package only installs one jar
734     # and use that jar.
735     if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
736     local cp="${JAVA_PKG_CLASSPATH}"
737     if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
738     echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
739     else
740     local msg="Not enough information to create a launcher given."
741     msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
742     die "${msg}"
743     fi
744     fi
745    
746 betelgeuse 1.20 # Write the actual script
747     echo "#!/bin/bash" > "${target}"
748 caster 1.42 if [[ -n "${pre}" ]]; then
749     if [[ -f "${pre}" ]]; then
750     cat "${pre}" >> "${target}"
751     else
752     die "-pre specified file '${pre}' does not exist"
753     fi
754     fi
755 nichoj 1.1 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
756 betelgeuse 1.20 cat "${var_tmp}" >> "${target}"
757 caster 1.21 rm -f "${var_tmp}"
758 nichoj 1.1 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
759 betelgeuse 1.19
760 nichoj 1.17 if [[ -n "${target_dir}" ]]; then
761 nichoj 1.1 DESTTREE="${target_dir}" dobin "${target}"
762     local ret=$?
763     return ${ret}
764     else
765     dobin "${target}"
766     fi
767     }
768    
769     # ------------------------------------------------------------------------------
770     # Install war files.
771     # TODO document
772     # ------------------------------------------------------------------------------
773     java-pkg_dowar() {
774     debug-print-function ${FUNCNAME} $*
775    
776     # Check for arguments
777     [[ ${#} -lt 1 ]] && die "At least one argument needed"
778     java-pkg_check-phase install
779    
780     java-pkg_init_paths_
781    
782     local war
783     for war in $* ; do
784     local warpath
785     # TODO evaluate if we want to handle symlinks differently -nichoj
786     # Check for symlink
787     if [[ -L "${war}" ]] ; then
788     cp "${war}" "${T}"
789     warpath="${T}$(basename "${war}")"
790     # Check for directory
791     # TODO evaluate if we want to handle directories differently -nichoj
792     elif [[ -d "${war}" ]] ; then
793     echo "dowar: warning, skipping directory ${war}"
794     continue
795     else
796     warpath="${war}"
797     fi
798 betelgeuse 1.18
799 nichoj 1.1 # Install those files like you mean it
800     INSOPTIONS="-m 0644" \
801     INSDESTTREE=${JAVA_PKG_WARDEST} \
802     doins ${warpath}
803     done
804     }
805    
806     # ------------------------------------------------------------------------------
807     # @internal-function java-pkg_recordjavadoc
808     # Scan for JavaDocs, and record their existence in the package.env file
809     #
810     # TODO make sure this in the proper section
811     # ------------------------------------------------------------------------------
812     java-pkg_recordjavadoc()
813     {
814     debug-print-function ${FUNCNAME} $*
815     # the find statement is important
816     # as some packages include multiple trees of javadoc
817     JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')"
818     # remove $D - TODO: check this is ok with all cases of the above
819     JAVADOC_PATH="${JAVADOC_PATH//${D}}"
820     if [[ -n "${JAVADOC_PATH}" ]] ; then
821     debug-print "javadocs found in ${JAVADOC_PATH%:}"
822     java-pkg_do_write_
823     else
824     debug-print "No javadocs found"
825     fi
826     }
827    
828     # ------------------------------------------------------------------------------
829     # @section-end install
830     # ------------------------------------------------------------------------------
831    
832     # ------------------------------------------------------------------------------
833     # @begin-section query
834     # Use these to build the classpath for building a package.
835     # ------------------------------------------------------------------------------
836    
837     # ------------------------------------------------------------------------------
838     # @ebuild-function java-pkg_jar-from
839     #
840     # Makes a symlink to a jar from a certain package
841     # A lot of java packages include dependencies in a lib/ directory
842     # You can use this function to replace these bundled dependencies.
843 nichoj 1.16 # The dependency is recorded into package.env DEPEND line, unless "--build-only"
844     # is passed as the very first argument, for jars that have to be present only
845     # at build time and are not needed on runtime (junit testing etc).
846 nichoj 1.1 #
847     # Example: get all jars from xerces slot 2
848     # java-pkg_jar-from xerces-2
849     # Example: get a specific jar from xerces slot 2
850     # java-pkg_jar-from xerces-2 xml-apis.jar
851 nichoj 1.16 # Example: get a specific jar from xerces slot 2, and name it diffrently
852 nichoj 1.1 # java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
853 nichoj 1.16 # Example: get junit.jar which is needed only for building
854     # java-pkg_jar-from --build-only junit junit.jar
855 nichoj 1.1 #
856 betelgeuse 1.59 # @param $opt
857 caster 1.49 # --build-only - makes the jar(s) not added into package.env DEPEND line.
858     # (assumed automatically when called inside src_test)
859     # --with-dependencies - get jars also from requested package's dependencies
860     # transitively.
861 ali_bush 1.94 # --virtual - Packages passed to this function are to be handled as virtuals
862     # and will not have individual jar dependencies recorded.
863 caster 1.49 # --into $dir - symlink jar(s) into $dir (must exist) instead of .
864 caster 1.79 # @param $1 - Package to get jars from, or comma-separated list of packages in
865     # case other parameters are not used.
866 nichoj 1.1 # @param $2 - jar from package. If not specified, all jars will be used.
867     # @param $3 - When a single jar is specified, destination filename of the
868     # symlink. Defaults to the name of the jar.
869     # ------------------------------------------------------------------------------
870     # TODO could probably be cleaned up a little
871     java-pkg_jar-from() {
872     debug-print-function ${FUNCNAME} $*
873    
874 nichoj 1.16 local build_only=""
875 caster 1.49 local destdir="."
876     local deep=""
877 ali_bush 1.94 local virtual=""
878 betelgeuse 1.59
879 caster 1.78 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
880 nichoj 1.16
881 caster 1.49 while [[ "${1}" == --* ]]; do
882     if [[ "${1}" = "--build-only" ]]; then
883 caster 1.77 build_only="build"
884 caster 1.49 elif [[ "${1}" = "--with-dependencies" ]]; then
885     deep="--with-dependencies"
886 ali_bush 1.94 elif [[ "${1}" = "--virtual" ]]; then
887     virtual="true"
888 caster 1.49 elif [[ "${1}" = "--into" ]]; then
889     destdir="${2}"
890     shift
891     else
892     die "java-pkg_jar-from called with unknown parameter: ${1}"
893     fi
894 nichoj 1.16 shift
895 caster 1.49 done
896 betelgeuse 1.43
897 betelgeuse 1.18 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
898    
899 nichoj 1.1 [[ -z ${target_pkg} ]] && die "Must specify a package"
900    
901 ali_bush 1.105 if [[ "${EAPI}" == "1" ]]; then
902     target_pkg="${target_pkg//:/-}"
903     fi
904    
905 nichoj 1.1 # default destjar to the target jar
906     [[ -z "${destjar}" ]] && destjar="${target_jar}"
907    
908 betelgeuse 1.18 local error_msg="There was a problem getting the classpath for ${target_pkg}."
909     local classpath
910 betelgeuse 1.43 classpath="$(java-config ${deep} --classpath=${target_pkg})"
911 betelgeuse 1.18 [[ $? != 0 ]] && die ${error_msg}
912 nichoj 1.1
913 betelgeuse 1.60 # When we have commas this functions is called to bring jars from multiple
914 caster 1.79 # packages. This affects recording of dependencencies performed later
915     # which expects one package only, so we do it here.
916 betelgeuse 1.60 if [[ ${target_pkg} = *,* ]]; then
917 caster 1.79 for pkg in ${target_pkg//,/ }; do
918     java-pkg_ensure-dep "${build_only}" "${pkg}"
919     [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
920     done
921     # setting this disables further record-jar_ calls later
922 caster 1.78 build_only="build"
923 caster 1.79 else
924     java-pkg_ensure-dep "${build_only}" "${target_pkg}"
925 betelgeuse 1.60 fi
926    
927 ali_bush 1.94 # Record the entire virtual as a dependency so that
928     # no jars are missed.
929     if [[ -z "${build_only}" && -n "${virtual}" ]]; then
930     java-pkg_record-jar_ "${target_pkg}"
931     # setting this disables further record-jars_ calls later
932     build_only="build"
933     fi
934    
935 caster 1.79 pushd ${destdir} > /dev/null \
936     || die "failed to change directory to ${destdir}"
937    
938 nichoj 1.1 local jar
939     for jar in ${classpath//:/ }; do
940     local jar_name=$(basename "${jar}")
941     if [[ ! -f "${jar}" ]] ; then
942     debug-print "${jar} from ${target_pkg} does not exist"
943     die "Installation problems with jars in ${target_pkg} - is it installed?"
944     fi
945     # If no specific target jar was indicated, link it
946     if [[ -z "${target_jar}" ]] ; then
947     [[ -f "${target_jar}" ]] && rm "${target_jar}"
948     ln -snf "${jar}" \
949     || die "Failed to make symlink from ${jar} to ${jar_name}"
950 nichoj 1.16 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
951 nichoj 1.1 # otherwise, if the current jar is the target jar, link it
952     elif [[ "${jar_name}" == "${target_jar}" ]] ; then
953     [[ -f "${destjar}" ]] && rm "${destjar}"
954     ln -snf "${jar}" "${destjar}" \
955     || die "Failed to make symlink from ${jar} to ${destjar}"
956 nichoj 1.16 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}"
957 betelgeuse 1.54 popd > /dev/null
958 nichoj 1.1 return 0
959     fi
960     done
961 caster 1.49 popd > /dev/null
962 nichoj 1.1 # if no target was specified, we're ok
963     if [[ -z "${target_jar}" ]] ; then
964     return 0
965     # otherwise, die bitterly
966     else
967     die "Failed to find ${target_jar:-jar} in ${target_pkg}"
968     fi
969     }
970    
971     # ------------------------------------------------------------------------------
972     # @ebuild-function java-pkg_jarfrom
973     #
974     # See java-pkg_jar-from
975     # ------------------------------------------------------------------------------
976     java-pkg_jarfrom() {
977     java-pkg_jar-from "$@"
978     }
979    
980     # ------------------------------------------------------------------------------
981     # @ebuild-function java-pkg_getjars
982     #
983     # Get the classpath provided by any number of packages
984     # Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
985 nichoj 1.16 # The providing packages are recorded as dependencies into package.env DEPEND
986     # line, unless "--build-only" is passed as the very first argument, for jars
987     # that have to be present only at build time and are not needed on runtime
988     # (junit testing etc).
989 betelgeuse 1.19 #
990 betelgeuse 1.30 # Example: Get the classpath for xerces-2 and xalan,
991     # java-pkg_getjars xerces-2,xalan
992 nichoj 1.1 # Example Return:
993     # /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
994 betelgeuse 1.19 #
995 betelgeuse 1.59 # @param $opt
996 caster 1.49 # --build-only - makes the jar(s) not added into package.env DEPEND line.
997     # (assumed automatically when called inside src_test)
998     # --with-dependencies - get jars also from requested package's dependencies
999     # transitively.
1000     # @param $1 - list of packages to get jars from
1001 betelgeuse 1.30 # (passed to java-config --classpath)
1002 nichoj 1.1 # ------------------------------------------------------------------------------
1003     java-pkg_getjars() {
1004     debug-print-function ${FUNCNAME} $*
1005    
1006 caster 1.49 local build_only=""
1007     local deep=""
1008 betelgeuse 1.59
1009 caster 1.78 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1010 nichoj 1.16
1011 caster 1.49 while [[ "${1}" == --* ]]; do
1012     if [[ "${1}" = "--build-only" ]]; then
1013 caster 1.77 build_only="build"
1014 caster 1.49 elif [[ "${1}" = "--with-dependencies" ]]; then
1015     deep="--with-dependencies"
1016     else
1017     die "java-pkg_jar-from called with unknown parameter: ${1}"
1018     fi
1019 betelgeuse 1.43 shift
1020 caster 1.49 done
1021 betelgeuse 1.43
1022 caster 1.49 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1023 betelgeuse 1.38
1024 ali_bush 1.70
1025 betelgeuse 1.30 local classpath pkgs="${1}"
1026 ali_bush 1.105
1027     if [[ "${EAPI}" == "1" ]]; then
1028     pkgs="${pkgs//:/-}"
1029     fi
1030    
1031 betelgeuse 1.43 jars="$(java-config ${deep} --classpath=${pkgs})"
1032 ali_bush 1.70 [[ $? != 0 || -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
1033 betelgeuse 1.30 debug-print "${pkgs}:${jars}"
1034    
1035 betelgeuse 1.73 for pkg in ${pkgs//,/ }; do
1036 ali_bush 1.70 java-pkg_ensure-dep "${build_only}" "${pkg}"
1037     done
1038    
1039 betelgeuse 1.30 if [[ -z "${classpath}" ]]; then
1040     classpath="${jars}"
1041     else
1042     classpath="${classpath}:${jars}"
1043     fi
1044 nichoj 1.1
1045 betelgeuse 1.30 # Only record jars that aren't build-only
1046     if [[ -z "${build_only}" ]]; then
1047 caster 1.81 for pkg in ${pkgs//,/ }; do
1048 betelgeuse 1.30 java-pkg_record-jar_ "${pkg}"
1049     done
1050     fi
1051 betelgeuse 1.18
1052 nichoj 1.1 echo "${classpath}"
1053     }
1054    
1055     # ------------------------------------------------------------------------------
1056     # @ebuild-function java-pkg_getjar
1057     #
1058     # Get the filename of a single jar from a package
1059 nichoj 1.16 # The providing package is recorded as runtime dependency into package.env
1060     # DEPEND line, unless "--build-only" is passed as the very first argument, for
1061     # jars that have to be present only at build time and are not needed on runtime
1062     # (junit testing etc).
1063 nichoj 1.1 #
1064     # @example
1065     # java-pkg_getjar xerces-2 xml-apis.jar
1066     # @example-return
1067     # /usr/share/xerces-2/lib/xml-apis.jar
1068 betelgeuse 1.19 #
1069 caster 1.49 # @param $opt
1070     # --build-only - makes the jar not added into package.env DEPEND line.
1071 ali_bush 1.94 # --virtual - Packages passed to this function are to be handled as virtuals
1072     # and will not have individual jar dependencies recorded.
1073 nichoj 1.1 # @param $1 - package to use
1074     # @param $2 - jar to get
1075     # ------------------------------------------------------------------------------
1076     java-pkg_getjar() {
1077     debug-print-function ${FUNCNAME} $*
1078    
1079 nichoj 1.16 local build_only=""
1080 ali_bush 1.94 local virtual=""
1081 betelgeuse 1.59
1082 caster 1.78 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1083 nichoj 1.16
1084 caster 1.49 while [[ "${1}" == --* ]]; do
1085     if [[ "${1}" = "--build-only" ]]; then
1086 caster 1.77 build_only="build"
1087 caster 1.101 elif [[ "${1}" == "--virtual" ]]; then
1088 ali_bush 1.94 virtual="true"
1089 caster 1.49 else
1090 caster 1.102 die "java-pkg_getjar called with unknown parameter: ${1}"
1091 caster 1.49 fi
1092 nichoj 1.16 shift
1093 caster 1.49 done
1094    
1095     [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1096 nichoj 1.16
1097 nichoj 1.1 local pkg="${1}" target_jar="${2}" jar
1098 ali_bush 1.105
1099     if [[ "${EAPI}" == "1" ]]; then
1100     pkg="${pkg//:/-}"
1101     fi
1102    
1103 nichoj 1.1 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1104     [[ -z ${target_jar} ]] && die "Must specify jar to get"
1105    
1106 betelgeuse 1.18 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1107     local classpath
1108     classpath=$(java-config --classpath=${pkg})
1109     [[ $? != 0 ]] && die ${error_msg}
1110    
1111 ali_bush 1.70 java-pkg_ensure-dep "${build_only}" "${pkg}"
1112    
1113 ali_bush 1.94 # Record the package(Virtual) as a dependency and then set build_only
1114     # So that individual jars are not recorded.
1115     if [[ -n "${virtual}" ]]; then
1116     java-pkg_record-jar_ "${pkg}"
1117     build_only="true"
1118     fi
1119    
1120 nichoj 1.1 for jar in ${classpath//:/ }; do
1121     if [[ ! -f "${jar}" ]] ; then
1122 nichoj 1.16 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1123 nichoj 1.1 fi
1124    
1125     if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1126 nichoj 1.16 # Only record jars that aren't build-only
1127     [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
1128 nichoj 1.1 echo "${jar}"
1129     return 0
1130     fi
1131     done
1132 betelgeuse 1.19
1133 nichoj 1.1 die "Could not find ${target_jar} in ${pkg}"
1134     return 1
1135     }
1136    
1137 caster 1.77 # ------------------------------------------------------------------------------
1138     # @ebuild-function java-pkg_register-dependency
1139     #
1140     # Registers runtime dependency on a package, list of packages, or a single jar
1141     # from a package, into package.env DEPEND line. Can only be called in
1142     # src_install phase.
1143     # Intended for binary packages where you don't need to symlink the jars or get
1144     # their classpath during build. As such, the dependencies only need to be
1145     # specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1146     #
1147     # @param $1 - comma-separated list of packages, or a single package
1148     # @param $2 - if param $1 is a single package, optionally specify the jar
1149     # to depend on
1150     #
1151     # Example: Record the dependency on whole xerces-2 and xalan,
1152     # java-pkg_register-dependency xerces-2,xalan
1153     # Example: Record the dependency on ant.jar from ant-core
1154     # java-pkg_register-dependency ant-core ant.jar
1155     #
1156     # Note: Passing both list of packages as the first parameter AND specifying the
1157     # jar as the second is not allowed and will cause the function to die. We assume
1158     # that there's more chance one passes such combination as a mistake, than that
1159     # there are more packages providing identically named jar without class
1160     # collisions.
1161     # ------------------------------------------------------------------------------
1162     java-pkg_register-dependency() {
1163     debug-print-function ${FUNCNAME} $*
1164    
1165     java-pkg_check-phase install
1166    
1167     [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1168    
1169     local pkgs="${1}"
1170     local jar="${2}"
1171    
1172     [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1173    
1174 ali_bush 1.105 if [[ "${EAPI}" == "1" ]]; then
1175     pkgs="${pkgs//:/-}"
1176     fi
1177    
1178 caster 1.77 if [[ -z "${jar}" ]]; then
1179     for pkg in ${pkgs//,/ }; do
1180     java-pkg_ensure-dep runtime "${pkg}"
1181     java-pkg_record-jar_ "${pkg}"
1182     done
1183     else
1184     [[ ${pkgs} == *,* ]] && \
1185     die "${FUNCNAME} called with both package list and jar name"
1186     java-pkg_ensure-dep runtime "${pkgs}"
1187     java-pkg_record-jar_ "${pkgs}" "${jar}"
1188     fi
1189    
1190 caster 1.85 java-pkg_do_write_
1191     }
1192    
1193     # ------------------------------------------------------------------------------
1194 caster 1.88 # @ebuild-function java-pkg_register-optional-dependency
1195     #
1196     # Registers optional runtime dependency on a package, list of packages, or a
1197     # single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1198     # called in src_install phase.
1199     # Intended for packages that can use other packages when those are in classpath.
1200     # Will be put on classpath by launcher if they are installed. Typical case is
1201     # JDBC implementations for various databases. It's better than having USE flag
1202     # for each implementation triggering hard dependency.
1203     #
1204     # @param $1 - comma-separated list of packages, or a single package
1205     # @param $2 - if param $1 is a single package, optionally specify the jar
1206     # to depend on
1207     #
1208     # Example: Record the optional dependency on some jdbc providers
1209     # java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1210     #
1211     # Note: Passing both list of packages as the first parameter AND specifying the
1212     # jar as the second is not allowed and will cause the function to die. We assume
1213     # that there's more chance one passes such combination as a mistake, than that
1214     # there are more packages providing identically named jar without class
1215     # collisions.
1216     # ------------------------------------------------------------------------------
1217     java-pkg_register-optional-dependency() {
1218     debug-print-function ${FUNCNAME} $*
1219    
1220     java-pkg_check-phase install
1221    
1222     [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1223    
1224     local pkgs="${1}"
1225     local jar="${2}"
1226    
1227     [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1228    
1229 ali_bush 1.105 if [[ "${EAPI}" == "1" ]]; then
1230     pkgs="${pkgs//:/-}"
1231     fi
1232    
1233 caster 1.88 if [[ -z "${jar}" ]]; then
1234     for pkg in ${pkgs//,/ }; do
1235     java-pkg_record-jar_ --optional "${pkg}"
1236     done
1237     else
1238     [[ ${pkgs} == *,* ]] && \
1239     die "${FUNCNAME} called with both package list and jar name"
1240     java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1241     fi
1242    
1243     java-pkg_do_write_
1244     }
1245    
1246     # ------------------------------------------------------------------------------
1247 caster 1.85 # @ebuild-function java-pkg_register-environment-variable
1248     #
1249     # Register an arbitrary environment variable into package.env. The gjl launcher
1250     # for this package or any package depending on this will export it into
1251     # environement before executing java command.
1252     # Must only be called in src_install phase.
1253     #
1254     # @param $1 - variable name
1255     # @param $2 - variable value
1256     # ------------------------------------------------------------------------------
1257     JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1258     JAVA_PKG_EXTRA_ENV_VARS=""
1259     java-pkg_register-environment-variable() {
1260     debug-print-function ${FUNCNAME} $*
1261    
1262     java-pkg_check-phase install
1263    
1264     [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1265    
1266     echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1267     JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1268    
1269     java-pkg_do_write_
1270 caster 1.77 }
1271    
1272 nichoj 1.1 # This function reads stdin, and based on that input, figures out how to
1273     # populate jars from the filesystem.
1274     # Need to figure out a good way of making use of this, ie be able to use a
1275     # string that was built instead of stdin
1276     # NOTE: this isn't quite ready for primetime.
1277     #java-pkg_populate-jars() {
1278     # local line
1279     #
1280     # read line
1281     # while [[ -n "${line}" ]]; do
1282     # # Ignore comments
1283     # [[ ${line%%#*} == "" ]] && continue
1284     #
1285     # # get rid of any spaces
1286     # line="${line// /}"
1287     #
1288     # # format: path=jarinfo
1289     # local path=${line%%=*}
1290     # local jarinfo=${line##*=}
1291 betelgeuse 1.19 #
1292 nichoj 1.1 # # format: jar@package
1293     # local jar=${jarinfo%%@*}.jar
1294     # local package=${jarinfo##*@}
1295     # if [[ -n ${replace_only} ]]; then
1296     # [[ ! -f $path ]] && die "No jar exists at ${path}"
1297     # fi
1298     # if [[ -n ${create_parent} ]]; then
1299     # local parent=$(dirname ${path})
1300     # mkdir -p "${parent}"
1301     # fi
1302     # java-pkg_jar-from "${package}" "${jar}" "${path}"
1303     #
1304     # read line
1305     # done
1306     #}
1307    
1308     # ------------------------------------------------------------------------------
1309     # @section-end query
1310     # ------------------------------------------------------------------------------
1311    
1312     # ------------------------------------------------------------------------------
1313     # @section-begin helper
1314 betelgeuse 1.19 # @section-summary Helper functions
1315 nichoj 1.1 #
1316     # Various other functions to use from an ebuild
1317     # ------------------------------------------------------------------------------
1318    
1319     # ------------------------------------------------------------------------------
1320     # @ebuild-function java-pkg_need
1321     #
1322     # Adds virtual dependencies, which can optionally be controlled by a USE flag.
1323     # Currently supported virtuals are:
1324     # javamail
1325     # jdbc-stdext
1326     # jaf
1327     # jdbc-rowset
1328     # jms
1329     #
1330 betelgeuse 1.19 # @param $1 - Optionally indicate that the dependencies are controlled by
1331 nichoj 1.1 # a use flag by specifying '--use' Requires $2.
1332     # @param $2 - USE flag which will enable the dependencies.
1333     # @param $@ - virtual packages to add depenedencies for
1334     # ------------------------------------------------------------------------------
1335     # TODO rewrite to parse a line based declaration file instead -- karltk
1336     #java-pkg_need() {
1337     # debug-print-function ${FUNCNAME} $*
1338     # local useflag
1339     # if [[ ${1} == "--use" ]]; then
1340     # useflag="${2}"
1341     # shift 2
1342     # fi
1343     #
1344     # if [[ -z ${1} ]]; then
1345     # die "Must specify at least one virtual package."
1346     # fi
1347     #
1348     # local depstr newdepstr
1349     #
1350     # for virtual in ${@}; do
1351     # if has ${virtual} ${JAVA_PKG_VNEED}; then
1352     # debug-print "Already registered virtual ${virtual}"
1353     # continue
1354     # fi
1355     # case ${virtual} in
1356     # javamail)
1357     # debug-print "java-pkg_need: adding javamail dependencies"
1358     # newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1359     # ;;
1360     # jdbc-stdext)
1361     # debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1362     # newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1363     # ;;
1364     # jaf)
1365     # debug-print "java-pkg_need: adding jaf dependencies"
1366     # newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1367     # ;;
1368     # jdbc-rowset)
1369     # debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1370     # newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1371     # ;;
1372     # jms)
1373     # debug-print "java-pkg_need: adding jms dependencies"
1374     # newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1375     # ;;
1376     # *)
1377     # die "Invalid virtual: ${virtual}"
1378     # esac
1379     #
1380     # export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1381     #
1382     # if [[ -n ${useflag} ]]; then
1383     # depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1384     # else
1385     # depstr="${depstr} ${newdepstr}"
1386     # fi
1387     # done
1388     #
1389     # [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1390     # [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1391     #
1392     # export DEPEND="${DEPEND} ${depstr}"
1393     # export RDEPEND="${RDEPEND} ${depstr}"
1394     #}
1395    
1396 betelgeuse 1.40 # ------------------------------------------------------------------------------
1397     # @ebuild-function java-pkg_find-normal-jars
1398     #
1399     # Find the files with suffix .jar file in the given directory or $WORKDIR
1400     #
1401     # @param $1 - The directory to search for jar files (default: ${WORKDIR})
1402     # ------------------------------------------------------------------------------
1403     java-pkg_find-normal-jars() {
1404     local dir=$1
1405     [[ "${dir}" ]] || dir="${WORKDIR}"
1406     local found
1407     for jar in $(find "${dir}" -name "*.jar" -type f); do
1408     echo "${jar}"
1409     found="true"
1410     done
1411     [[ "${found}" ]]
1412     return $?
1413     }
1414    
1415     # ------------------------------------------------------------------------------
1416     # @ebuild-function java-pkg_ensure-no-bundled-jars
1417     #
1418     # Try to locate bundled jar files in ${WORKDIR} and die if found.
1419     # This function should be called after WORKDIR has been populated with symlink
1420     # to system jar files or bundled jars removed.
1421     # ------------------------------------------------------------------------------
1422 nichoj 1.1 java-pkg_ensure-no-bundled-jars() {
1423     debug-print-function ${FUNCNAME} $*
1424    
1425 betelgeuse 1.40 local bundled_jars=$(java-pkg_find-normal-jars)
1426 nichoj 1.1 if [[ -n ${bundled_jars} ]]; then
1427     echo "Bundled jars found:"
1428     local jar
1429     for jar in ${bundled_jars}; do
1430     echo $(pwd)${jar/./}
1431     done
1432     die "Bundled jars found!"
1433     fi
1434     }
1435    
1436     # ------------------------------------------------------------------------------
1437     # @internal-function java-pkg_ensure-vm-version-sufficient
1438     #
1439     # Checks if we have a sufficient VM and dies if we don't.
1440     #
1441     # ------------------------------------------------------------------------------
1442     java-pkg_ensure-vm-version-sufficient() {
1443     debug-print-function ${FUNCNAME} $*
1444    
1445     if ! java-pkg_is-vm-version-sufficient; then
1446     debug-print "VM is not suffient"
1447     eerror "Current Java VM cannot build this package"
1448     einfo "Please use java-config -S to set the correct one"
1449     die "Active Java VM cannot build this package"
1450     fi
1451     }
1452    
1453     # ------------------------------------------------------------------------------
1454     # @internal-function java-pkg_is-vm-version-sufficient
1455 betelgeuse 1.19 #
1456 nichoj 1.1 # @return zero - VM is sufficient
1457     # @return non-zero - VM is not sufficient
1458     # ------------------------------------------------------------------------------
1459     java-pkg_is-vm-version-sufficient() {
1460     debug-print-function ${FUNCNAME} $*
1461    
1462     depend-java-query --is-sufficient "${DEPEND}" > /dev/null
1463     return $?
1464     }
1465    
1466     # ------------------------------------------------------------------------------
1467     # @internal-function java-pkg_ensure-vm-version-eq
1468     #
1469     # Die if the current VM is not equal to the argument passed.
1470     #
1471     # @param $@ - Desired VM version to ensure
1472     # ------------------------------------------------------------------------------
1473     java-pkg_ensure-vm-version-eq() {
1474     debug-print-function ${FUNCNAME} $*
1475    
1476     if ! java-pkg_is-vm-version-eq $@ ; then
1477     debug-print "VM is not suffient"
1478     eerror "This package requires a Java VM version = $@"
1479     einfo "Please use java-config -S to set the correct one"
1480     die "Active Java VM too old"
1481     fi
1482     }
1483    
1484     # ------------------------------------------------------------------------------
1485 betelgeuse 1.19 # @internal-function java-pkg_is-vm-version-eq
1486     #
1487 nichoj 1.1 # @param $@ - VM version to compare current VM to
1488     # @return zero - VM versions are equal
1489     # @return non-zero - VM version are not equal
1490     # ------------------------------------------------------------------------------
1491     java-pkg_is-vm-version-eq() {
1492     debug-print-function ${FUNCNAME} $*
1493    
1494     local needed_version="$@"
1495    
1496     [[ -z "${needed_version}" ]] && die "need an argument"
1497    
1498     local vm_version="$(java-pkg_get-vm-version)"
1499    
1500     vm_version="$(get_version_component_range 1-2 "${vm_version}")"
1501     needed_version="$(get_version_component_range 1-2 "${needed_version}")"
1502    
1503     if [[ -z "${vm_version}" ]]; then
1504     debug-print "Could not get JDK version from DEPEND"
1505     return 1
1506     else
1507     if [[ "${vm_version}" == "${needed_version}" ]]; then
1508     debug-print "Detected a JDK(${vm_version}) = ${needed_version}"
1509     return 0
1510     else
1511     debug-print "Detected a JDK(${vm_version}) != ${needed_version}"
1512     return 1
1513     fi
1514     fi
1515     }
1516    
1517     # ------------------------------------------------------------------------------
1518     # @internal-function java-pkg_ensure-vm-version-ge
1519     #
1520     # Die if the current VM is not greater than the desired version
1521     #
1522     # @param $@ - VM version to compare current to
1523     # ------------------------------------------------------------------------------
1524     java-pkg_ensure-vm-version-ge() {
1525     debug-print-function ${FUNCNAME} $*
1526 betelgeuse 1.19
1527 nichoj 1.1 if ! java-pkg_is-vm-version-ge "$@" ; then
1528     debug-print "vm is not suffient"
1529     eerror "This package requires a Java VM version >= $@"
1530     einfo "Please use java-config -S to set the correct one"
1531     die "Active Java VM too old"
1532     fi
1533     }
1534    
1535     # ------------------------------------------------------------------------------
1536 betelgeuse 1.19 # @internal-function java-pkg_is-vm-version-ge
1537     #
1538 nichoj 1.1 # @param $@ - VM version to compare current VM to
1539     # @return zero - current VM version is greater than checked version
1540     # @return non-zero - current VM version is not greater than checked version
1541     # ------------------------------------------------------------------------------
1542     java-pkg_is-vm-version-ge() {
1543     debug-print-function ${FUNCNAME} $*
1544    
1545     local needed_version=$@
1546     local vm_version=$(java-pkg_get-vm-version)
1547     if [[ -z "${vm_version}" ]]; then
1548     debug-print "Could not get JDK version from DEPEND"
1549     return 1
1550     else
1551     if version_is_at_least "${needed_version}" "${vm_version}"; then
1552     debug-print "Detected a JDK(${vm_version}) >= ${needed_version}"
1553     return 0
1554     else
1555     debug-print "Detected a JDK(${vm_version}) < ${needed_version}"
1556     return 1
1557     fi
1558     fi
1559     }
1560    
1561 nichoj 1.12 java-pkg_set-current-vm() {
1562     export GENTOO_VM=${1}
1563     }
1564    
1565     java-pkg_get-current-vm() {
1566     echo ${GENTOO_VM}
1567     }
1568    
1569     java-pkg_current-vm-matches() {
1570 nichoj 1.15 hasq $(java-pkg_get-current-vm) ${@}
1571 nichoj 1.12 return $?
1572     }
1573    
1574 nichoj 1.1 # ------------------------------------------------------------------------------
1575     # @ebuild-function java-pkg_get-source
1576 betelgeuse 1.19 #
1577 nichoj 1.1 # Determines what source version should be used, for passing to -source.
1578     # Unless you want to break things you probably shouldn't set _WANT_SOURCE
1579     #
1580     # @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1581     # ------------------------------------------------------------------------------
1582     java-pkg_get-source() {
1583     echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1584     }
1585    
1586     # ------------------------------------------------------------------------------
1587     # @ebuild-function java-pkg_get-target
1588     #
1589     # Determines what target version should be used, for passing to -target.
1590     # If you don't care about lower versions, you can set _WANT_TARGET to the
1591 betelgeuse 1.19 # version of your JDK.
1592 nichoj 1.1 #
1593     # @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1594     # ------------------------------------------------------------------------------
1595     java-pkg_get-target() {
1596 caster 1.37 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1597 nichoj 1.1 }
1598    
1599     java-pkg_get-javac() {
1600     debug-print-function ${FUNCNAME} $*
1601    
1602 caster 1.24
1603 nichoj 1.1 local compiler="${GENTOO_COMPILER}"
1604    
1605     local compiler_executable
1606     if [[ "${compiler}" = "javac" ]]; then
1607     # nothing fancy needs to be done for javac
1608     compiler_executable="javac"
1609     else
1610     # for everything else, try to determine from an env file
1611    
1612     local compiler_env="/usr/share/java-config-2/compiler/${compiler}"
1613     if [[ -f ${compiler_env} ]]; then
1614     local old_javac=${JAVAC}
1615     unset JAVAC
1616     # try to get value of JAVAC
1617     compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1618     export JAVAC=${old_javac}
1619    
1620 caster 1.24 if [[ -z ${compiler_executable} ]]; then
1621     echo "JAVAC is empty or undefined in ${compiler_env}"
1622     return 1
1623     fi
1624 betelgeuse 1.19
1625 nichoj 1.1 # check that it's executable
1626     if [[ ! -x ${compiler_executable} ]]; then
1627 caster 1.24 echo "${compiler_executable} doesn't exist, or isn't executable"
1628     return 1
1629 nichoj 1.1 fi
1630     else
1631 caster 1.24 echo "Could not find environment file for ${compiler}"
1632     return 1
1633 nichoj 1.1 fi
1634     fi
1635     echo ${compiler_executable}
1636     }
1637    
1638     # ------------------------------------------------------------------------------
1639 betelgeuse 1.19 # @ebuild-function java-pkg_javac-args
1640 nichoj 1.1 #
1641     # If an ebuild uses javac directly, instead of using ejavac, it should call this
1642     # to know what -source/-target to use.
1643     #
1644     # @return string - arguments to pass to javac, complete with -target and -source
1645     # ------------------------------------------------------------------------------
1646     java-pkg_javac-args() {
1647     debug-print-function ${FUNCNAME} $*
1648    
1649     local want_source="$(java-pkg_get-source)"
1650     local want_target="$(java-pkg_get-target)"
1651    
1652 betelgeuse 1.19 local source_str="-source ${want_source}"
1653 nichoj 1.1 local target_str="-target ${want_target}"
1654    
1655     debug-print "want source: ${want_source}"
1656     debug-print "want target: ${want_target}"
1657    
1658     if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1659 caster 1.24 debug-print "could not find valid -source/-target values for javac"
1660     echo "Could not find valid -source/-target values for javac"
1661     return 1
1662 nichoj 1.1 else
1663     if java-pkg_is-vm-version-ge "1.4"; then
1664     echo "${source_str} ${target_str}"
1665     else
1666     echo "${target_str}"
1667     fi
1668     fi
1669     }
1670    
1671     # TODO document
1672     java-pkg_get-jni-cflags() {
1673     local flags="-I${JAVA_HOME}/include"
1674    
1675 flameeyes 1.33 local platform="linux"
1676     use elibc_FreeBSD && platform="freebsd"
1677    
1678 nichoj 1.10 # TODO do a check that the directories are valid
1679 flameeyes 1.33 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1680 nichoj 1.1
1681     echo ${flags}
1682     }
1683    
1684 nichoj 1.10 java-pkg_ensure-gcj() {
1685     if ! built_with_use sys-devel/gcc gcj ; then
1686     ewarn
1687     ewarn "You must build gcc with the gcj support to build with gcj"
1688     ewarn
1689     ebeep 5
1690     die "No GCJ support found!"
1691     fi
1692     }
1693    
1694 nichoj 1.13 java-pkg_ensure-test() {
1695 betelgeuse 1.34 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1696     && hasq test ${IUSE} && ! use test;
1697     then
1698 nichoj 1.13 eerror "You specified FEATURES=test, but USE=test is needed"
1699     eerror "to pull in the additional dependencies for testing"
1700     die "Need USE=test enabled"
1701     fi
1702     }
1703    
1704 nichoj 1.1 # ------------------------------------------------------------------------------
1705 caster 1.46 # @ebuild-function java-pkg_register-ant-task
1706     #
1707     # Register this package as ant task, so that ant will load it when no specific
1708     # ANT_TASKS are specified. Note that even without this registering, all packages
1709     # specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1710     # packages, but can be also used by other ebuilds that used to symlink their
1711     # .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1712     # compatibility.
1713     #
1714     # @param --version x.y Register only for ant version x.y (otherwise for any ant
1715     # version). Used by the ant-* packages to prevent loading of mismatched
1716     # ant-core ant tasks after core was updated, before the tasks are updated,
1717     # without a need for blockers.
1718     # @param $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1719     # ------------------------------------------------------------------------------
1720     java-pkg_register-ant-task() {
1721     local TASKS_DIR="tasks"
1722    
1723     # check for --version x.y parameters
1724     while [[ -n "${1}" && -n "${2}" ]]; do
1725     local var="${1#--}"
1726     local val="${2}"
1727     if [[ "${var}" == "version" ]]; then
1728     TASKS_DIR="tasks-${val}"
1729     else
1730     die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1731     fi
1732     shift 2
1733     done
1734    
1735     local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1736    
1737     dodir /usr/share/ant/${TASKS_DIR}
1738     touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1739     }
1740    
1741     # ------------------------------------------------------------------------------
1742     # @internal-function java-pkg_ant-tasks-depend
1743     #
1744     # Translates the WANT_ANT_TASKS variable into valid dependencies.
1745     # ------------------------------------------------------------------------------
1746     java-pkg_ant-tasks-depend() {
1747     debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1748    
1749     if [[ -n "${WANT_ANT_TASKS}" ]]; then
1750     local DEP=""
1751     for i in ${WANT_ANT_TASKS}
1752     do
1753     if [[ ${i} != ant-* ]]; then
1754     echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1755     return 1
1756     fi
1757     DEP="${DEP}dev-java/${i} "
1758     done
1759     echo ${DEP}
1760     return 0
1761     else
1762     return 0
1763     fi
1764     }
1765    
1766     # ------------------------------------------------------------------------------
1767 betelgeuse 1.84 # @ebuild-function ejunit
1768     #
1769     # Junit wrapper function. Makes it easier to run the tests and checks for
1770     # dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1771     #
1772     # Examples:
1773     # ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1774     # ejunit org.blinkenlights.jid3.test.AllTests
1775     #
1776     # @param $1 - -cp or -classpath
1777 betelgeuse 1.87 # @param $2 - classpath; junit and recorded dependencies get appended
1778 betelgeuse 1.84 # @param $@ - the rest of the parameters are passed to java
1779     # ------------------------------------------------------------------------------
1780     ejunit() {
1781     debug-print-function ${FUNCNAME} $*
1782    
1783 betelgeuse 1.87 local pkgs
1784     for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1785     pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1786     done
1787    
1788     local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1789 betelgeuse 1.84 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1790 betelgeuse 1.87 cp="${2}:${cp}"
1791 betelgeuse 1.84 shift 2
1792     else
1793 betelgeuse 1.87 cp=".:${cp}"
1794 betelgeuse 1.84 fi
1795    
1796     local runner=junit.textui.TestRunner
1797     debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1798     java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1799     }
1800    
1801     # ------------------------------------------------------------------------------
1802 nichoj 1.1 # @section-end helper
1803     # ------------------------------------------------------------------------------
1804    
1805     # ------------------------------------------------------------------------------
1806     # @section-begin build
1807     # @section-summary Build functions
1808     #
1809     # These are some functions for building a package. In particular, it consists of
1810     # wrappers for javac and ant.
1811     # ------------------------------------------------------------------------------
1812    
1813     # ------------------------------------------------------------------------------
1814     # @ebuild-function eant
1815     #
1816     # Ant wrapper function. Will use the appropriate compiler, based on user-defined
1817 caster 1.46 # compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1818 betelgeuse 1.41 # variables:
1819     # EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1820     # gentoo.classpath property. Be sure to call
1821     # java-ant_rewrite-classpath in src_unpack.
1822 betelgeuse 1.92 # JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1823 caster 1.46 # *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1824 nichoj 1.1 # ------------------------------------------------------------------------------
1825     eant() {
1826     debug-print-function ${FUNCNAME} $*
1827    
1828 betelgeuse 1.92 if [[ ${EBUILD_PHASE} = compile ]]; then
1829     # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1830     # finally get rid of the hooks without breaking stuff
1831    
1832     [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1833     && java-ant_ignore-system-classes "${S}/build.xml"
1834    
1835     if hasq java-ant-2 ${INHERITED}; then
1836     java-ant_bsfix
1837     fi
1838    
1839     # eant can be called multiple times
1840     JAVA_PKG_BSFIX="off"
1841    
1842     if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1843     echo "Searching for bundled jars:"
1844     java-pkg_find-normal-jars || echo "None found."
1845     echo "Searching for bundled classes (no output if none found):"
1846     find "${WORKDIR}" -name "*.class"
1847     echo "Search done."
1848     JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1849     fi
1850     fi
1851    
1852 caster 1.82 if ! hasq java-ant-2 ${INHERITED}; then
1853 betelgeuse 1.52 local msg="You should inherit java-ant-2 when using eant"
1854 caster 1.82 java-pkg_announce-qa-violation "${msg}"
1855 betelgeuse 1.51 fi
1856    
1857 caster 1.96 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1858 betelgeuse 1.57
1859 nichoj 1.1 java-pkg_init-compiler_
1860     local compiler="${GENTOO_COMPILER}"
1861    
1862     local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1863     local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1864     if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1865     die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1866     fi
1867    
1868     if [[ ${compiler} != "javac" ]]; then
1869 caster 1.36 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1870 nichoj 1.1 # Figure out any extra stuff to put on the classpath for compilers aside
1871     # from javac
1872     # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1873     # java-config -p
1874     local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1875     if [[ -n ${build_compiler_deps} ]]; then
1876     antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1877     fi
1878     fi
1879 nichoj 1.9
1880 betelgeuse 1.52 for arg in "${@}"; do
1881     if [[ ${arg} = -lib ]]; then
1882     if is-java-strict; then
1883     eerror "You should not use the -lib argument to eant because it will fail"
1884 betelgeuse 1.53 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1885 betelgeuse 1.52 eerror "or ant properties to make dependencies available."
1886     eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1887     eerror "split ant (>=dev-java/ant-core-1.7)."
1888     die "eant -lib is deprecated/forbidden"
1889     else
1890     echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1891     echo "more info."
1892     fi
1893     fi
1894     done
1895    
1896 caster 1.103 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1897     ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1898 caster 1.46
1899 caster 1.103 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1900     ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1901 caster 1.46
1902 caster 1.103 # if ant-tasks is not set by ebuild or forced, use none
1903     ANT_TASKS="${ANT_TASKS:-none}"
1904 betelgeuse 1.52
1905 caster 1.103 # at this point, ANT_TASKS should be "all", "none" or explicit list
1906     if [[ "${ANT_TASKS}" == "all" ]]; then
1907     einfo "Using all available ANT_TASKS"
1908     elif [[ "${ANT_TASKS}" == "none" ]]; then
1909     einfo "Disabling all optional ANT_TASKS"
1910     else
1911     einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1912 caster 1.46 fi
1913    
1914 caster 1.103 export ANT_TASKS
1915    
1916 caster 1.46 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1917 betelgeuse 1.45 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1918 betelgeuse 1.19
1919 betelgeuse 1.41 local gcp="${EANT_GENTOO_CLASSPATH}"
1920 caster 1.76 local getjarsarg=""
1921 betelgeuse 1.41
1922 betelgeuse 1.57 if [[ ${EBUILD_PHASE} = "test" ]]; then
1923     antflags="${antflags} -DJunit.present=true"
1924     [[ ${gcp} && ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1925 caster 1.76 getjarsarg="--with-dependencies"
1926 betelgeuse 1.57 fi
1927    
1928     local cp
1929    
1930     for atom in ${gcp}; do
1931 betelgeuse 1.75 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1932 betelgeuse 1.57 done
1933    
1934     if [[ ${cp} ]]; then
1935 betelgeuse 1.41 # It seems ant does not like single quotes around ${cp}
1936 betelgeuse 1.57 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1937 betelgeuse 1.41 fi
1938    
1939 nichoj 1.1 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1940 betelgeuse 1.75 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1941 nichoj 1.1 ant ${antflags} "${@}" || die "eant failed"
1942     }
1943    
1944     # ------------------------------------------------------------------------------
1945     # @ebuild-function ejavac
1946     #
1947 betelgeuse 1.19 # Javac wrapper function. Will use the appropriate compiler, based on
1948 nichoj 1.1 # /etc/java-config/compilers.conf
1949     #
1950     # @param $@ - Arguments to be passed to the compiler
1951     # ------------------------------------------------------------------------------
1952     ejavac() {
1953     debug-print-function ${FUNCNAME} $*
1954    
1955 caster 1.24 java-pkg_init-compiler_
1956 nichoj 1.1
1957 caster 1.24 local compiler_executable
1958     compiler_executable=$(java-pkg_get-javac)
1959     if [[ ${?} != 0 ]]; then
1960     eerror "There was a problem determining compiler: ${compiler_executable}"
1961     die "get-javac failed"
1962     fi
1963    
1964     local javac_args
1965     javac_args="$(java-pkg_javac-args)"
1966     if [[ ${?} != 0 ]]; then
1967     eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1968     die "java-pkg_javac-args failed"
1969     fi
1970    
1971     [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1972     ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1973 nichoj 1.1 }
1974    
1975     # ------------------------------------------------------------------------------
1976     # @ebuild-function java-pkg_filter-compiler
1977 betelgeuse 1.19 #
1978 nichoj 1.1 # Used to prevent the use of some compilers. Should be used in src_compile.
1979     # Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1980     #
1981     # @param $@ - compilers to filter
1982     # ------------------------------------------------------------------------------
1983     java-pkg_filter-compiler() {
1984     JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1985     }
1986    
1987     # ------------------------------------------------------------------------------
1988 nichoj 1.8 # @ebuild-function java-pkg_force-compiler
1989     #
1990     # Used to force the use of particular compilers. Should be used in src_compile.
1991     # A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1992     # OutOfMemoryErrors that may come up.
1993     #
1994     # @param $@ - compilers to force
1995     # ------------------------------------------------------------------------------
1996     java-pkg_force-compiler() {
1997     JAVA_PKG_FORCE_COMPILER="$@"
1998     }
1999    
2000     # ------------------------------------------------------------------------------
2001 nichoj 1.1 # @ebuild-function use_doc
2002     #
2003     # Helper function for getting ant to build javadocs. If the user has USE=doc,
2004     # then 'javadoc' or the argument are returned. Otherwise, there is no return.
2005 betelgeuse 1.19 #
2006 nichoj 1.1 # The output of this should be passed to ant.
2007     #
2008     # Example: build javadocs by calling 'javadoc' target
2009     # eant $(use_doc)
2010     # Example: build javadocs by calling 'apidoc' target
2011     # eant $(use_doc apidoc)
2012     #
2013     # @param $@ - Option value to return. Defaults to 'javadoc'
2014     # @return string - Name of the target to create javadocs
2015     # ------------------------------------------------------------------------------
2016     use_doc() {
2017     use doc && echo ${@:-javadoc}
2018     }
2019    
2020 betelgeuse 1.38
2021 nichoj 1.1 # ------------------------------------------------------------------------------
2022     # @section-end build
2023     # ------------------------------------------------------------------------------
2024 betelgeuse 1.19
2025 nichoj 1.1 # ------------------------------------------------------------------------------
2026     # @section-begin internal
2027 betelgeuse 1.19 # @section-summary Internal functions
2028 nichoj 1.1 #
2029     # Do __NOT__ use any of these from an ebuild! These are only to be used from
2030     # within the java eclasses.
2031     # ------------------------------------------------------------------------------
2032    
2033     # -----------------------------------------------------------------------------
2034     # @function-internal java-pkg_init
2035 betelgeuse 1.19 #
2036 nichoj 1.1 # The purpose of this function, as the name might imply, is to initialize the
2037     # Java environment. It ensures that that there aren't any environment variables
2038     # that'll muss things up. It initializes some variables, which are used
2039     # internally. And most importantly, it'll switch the VM if necessary.
2040     #
2041     # This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2042     # call it during each of the phases of the merge process.
2043     #
2044     # -----------------------------------------------------------------------------
2045     java-pkg_init() {
2046 betelgeuse 1.97 debug-print-function ${FUNCNAME} $*
2047 nichoj 1.1 unset JAVAC
2048     unset JAVA_HOME
2049 betelgeuse 1.64
2050     # People do all kinds of weird things.
2051     # http://forums.gentoo.org/viewtopic-p-3943166.html
2052 betelgeuse 1.65 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2053 betelgeuse 1.64 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2054 betelgeuse 1.65 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2055 betelgeuse 1.64 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2056     ewarn "sun-jdk vms and and as such break configure scripts that"
2057     ewarn "use it (for example app-office/openoffice) so we filter it out."
2058     ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2059     ewarn "make.conf for example) to silence this warning or"
2060     ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2061     fi
2062    
2063     if [[ -z ${accept} ]]; then
2064 betelgeuse 1.98 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2065     # -version output
2066     unset _JAVA_OPTIONS
2067 betelgeuse 1.64 # phase hooks make this run many times without this
2068     I_WANT_GLOBAL_JAVA_OPTIONS="true"
2069     fi
2070    
2071 betelgeuse 1.92 if java-pkg_func-exists ant_src_unpack; then
2072     java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2073     fi
2074    
2075 nichoj 1.1 java-pkg_init_paths_
2076     java-pkg_switch-vm
2077     PATH=${JAVA_HOME}/bin:${PATH}
2078    
2079     # TODO we will probably want to set JAVAC and JAVACFLAGS
2080    
2081     # Do some QA checks
2082     java-pkg_check-jikes
2083    
2084 betelgeuse 1.97 # Can't use unset here because Portage does not save the unset
2085     # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2086    
2087 betelgeuse 1.19 # When users have crazy classpaths some packages can fail to compile.
2088 nichoj 1.1 # and everything should work with empty CLASSPATH.
2089     # This also helps prevent unexpected dependencies on random things
2090     # from the CLASSPATH.
2091 betelgeuse 1.97 export CLASSPATH=
2092 betelgeuse 1.59
2093 caster 1.46 # Unset external ANT_ stuff
2094 betelgeuse 1.97 export ANT_TASKS=
2095     export ANT_OPTS=
2096 nichoj 1.1 }
2097    
2098     # ------------------------------------------------------------------------------
2099     # @function-internal java-pkg-init-compiler_
2100     #
2101     # This function attempts to figure out what compiler should be used. It does
2102 betelgeuse 1.19 # this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
2103 nichoj 1.1 # COMPILERS variable defined there.
2104     # This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
2105 betelgeuse 1.19 #
2106 nichoj 1.1 # It will go through the list of compilers, and verify that it supports the
2107     # target and source that are needed. If it is not suitable, then the next
2108     # compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
2109     # isn't done.
2110     #
2111     # Once the which compiler to use has been figured out, it is set to
2112     # GENTOO_COMPILER.
2113     #
2114     # If you hadn't guessed, JAVA_PKG_FORCE_COMPILER is for testing only.
2115     #
2116     # If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
2117     # suitable compiler was found there, then the default is to use javac provided
2118     # by the current VM.
2119     #
2120     #
2121     # @return name of the compiler to use
2122     # ------------------------------------------------------------------------------
2123     java-pkg_init-compiler_() {
2124     debug-print-function ${FUNCNAME} $*
2125    
2126     if [[ -n ${GENTOO_COMPILER} ]]; then
2127     debug-print "GENTOO_COMPILER already set"
2128     return
2129     fi
2130    
2131 nichoj 1.3 local compilers;
2132     if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
2133     compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
2134     else
2135     compilers=${JAVA_PKG_FORCE_COMPILER}
2136     fi
2137 betelgeuse 1.19
2138 nichoj 1.1 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
2139    
2140     # Figure out if we should announce what compiler we're using
2141     local compiler
2142     for compiler in ${compilers}; do
2143     debug-print "Checking ${compiler}..."
2144     # javac should always be alright
2145     if [[ ${compiler} = "javac" ]]; then
2146     debug-print "Found javac... breaking"
2147     export GENTOO_COMPILER="javac"
2148     break
2149     fi
2150 betelgeuse 1.19
2151 nichoj 1.1 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
2152     if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
2153     einfo "Filtering ${compiler}"
2154     continue
2155     fi
2156     fi
2157 betelgeuse 1.19
2158 nichoj 1.1 # for non-javac, we need to make sure it supports the right target and
2159     # source
2160     local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
2161     if [[ -f ${compiler_env} ]]; then
2162     local desired_target="$(java-pkg_get-target)"
2163     local desired_source="$(java-pkg_get-source)"
2164    
2165    
2166     # Verify that the compiler supports target
2167     local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET})
2168     if ! has ${desired_target} ${supported_target}; then
2169     ewarn "${compiler} does not support -target ${desired_target}, skipping"
2170     continue
2171     fi
2172    
2173     # -source was introduced in 1.3, so only check 1.3 and on
2174     if version_is_at_least "${desired_soure}" "1.3"; then
2175     # Verify that the compiler supports source
2176     local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
2177     if ! has ${desired_source} ${supported_source}; then
2178     ewarn "${compiler} does not support -source ${desired_source}, skipping"
2179     continue
2180     fi
2181     fi
2182    
2183     # if you get here, then the compiler should be good to go
2184     export GENTOO_COMPILER="${compiler}"
2185     break
2186     else
2187     ewarn "Could not find configuration for ${compiler}, skipping"
2188     ewarn "Perhaps it is not installed?"
2189     continue
2190     fi
2191     done
2192    
2193     # If it hasn't been defined already, default to javac
2194     if [[ -z ${GENTOO_COMPILER} ]]; then
2195     if [[ -n ${compilers} ]]; then
2196 betelgeuse 1.104 einfo "No suitable compiler found: defaulting to JDK default for compilation"
2197 nichoj 1.1 else
2198     # probably don't need to notify users about the default.
2199     :;#einfo "Defaulting to javac for compilation"
2200     fi
2201 betelgeuse 1.104 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2202     export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2203     else
2204     export GENTOO_COMPILER=javac
2205     fi
2206 nichoj 1.1 else
2207     einfo "Using ${GENTOO_COMPILER} for compilation"
2208     fi
2209    
2210     }
2211    
2212     # ------------------------------------------------------------------------------
2213     # @internal-function init_paths_
2214     #
2215     # Initializes some variables that will be used. These variables are mostly used
2216     # to determine where things will eventually get installed.
2217     # ------------------------------------------------------------------------------
2218     java-pkg_init_paths_() {
2219     debug-print-function ${FUNCNAME} $*
2220    
2221     local pkg_name
2222     if [[ "$SLOT" == "0" ]] ; then
2223     JAVA_PKG_NAME="${PN}"
2224     else
2225     JAVA_PKG_NAME="${PN}-${SLOT}"
2226     fi
2227    
2228     JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2229     JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2230     JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2231 ali_bush 1.94 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2232     JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2233 nichoj 1.1
2234     [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2235     [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2236     [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2237    
2238    
2239     # TODO maybe only print once?
2240     debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}"
2241     debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}"
2242     debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
2243     debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
2244     debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
2245     }
2246    
2247     # ------------------------------------------------------------------------------
2248     # @internal-function java-pkg_do_write_
2249     #
2250     # Writes the package.env out to disk.
2251     #
2252     # ------------------------------------------------------------------------------
2253     # TODO change to do-write, to match everything else
2254     java-pkg_do_write_() {
2255 betelgeuse 1.87 debug-print-function ${FUNCNAME} $*
2256 betelgeuse 1.28 java-pkg_init_paths_
2257 nichoj 1.1 # Create directory for package.env
2258     dodir "${JAVA_PKG_SHAREPATH}"
2259 betelgeuse 1.87 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2260 caster 1.88 "${JAVA_PKG_DEPEND_FILE}" || -f \
2261     "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2262 nichoj 1.1 # Create package.env
2263     (
2264     echo "DESCRIPTION=\"${DESCRIPTION}\""
2265     echo "GENERATION=\"2\""
2266 betelgeuse 1.104 echo "SLOT=\"${SLOT}\""
2267 nichoj 1.1
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