/[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.94 - (hide annotations) (download)
Thu Oct 4 09:59:29 2007 UTC (6 years, 6 months ago) by ali_bush
Branch: MAIN
Changes since 1.93: +28 -1 lines
Adding java-virtuals-2.eclass and updating java-utils-2.eclass to add support for java virtuals.

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

  ViewVC Help
Powered by ViewVC 1.1.20