1 # Copyright 2004-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: java-utils-2.eclass
9 # Thomas Matthijs <axxo@gentoo.org>, Karl Trygve Kalleberg <karltk@gentoo.org>
10 # @BLURB: Base eclass for Java packages
12 # This eclass provides functionality which is used by java-pkg-2.eclass,
13 # java-pkg-opt-2.eclass and java-ant-2 eclass, as well as from ebuilds.
15 # This eclass should not be inherited this directly from an ebuild. Instead,
16 # you should inherit java-pkg-2 for Java packages or java-pkg-opt-2 for packages
17 # that have optional Java support. In addition you can inherit java-ant-2 for
19 inherit eutils versionator multilib
23 # Make sure we use java-config-2
24 export WANT_JAVA_CONFIG="2"
26 # @VARIABLE: JAVA_PKG_PORTAGE_DEP
29 # The version of portage we need to function properly. Previously it was
30 # portage with phase hooks support but now we use a version with proper env
31 # saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
32 has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
34 # @VARIABLE: JAVA_PKG_E_DEPEND
37 # This is a convience variable to be used from the other java eclasses. This is
38 # the version of java-config we want to use. Usually the latest stable version
39 # so that ebuilds can use new features without depending on specific versions.
40 JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0 ${JAVA_PKG_PORTAGE_DEP}"
41 has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
43 # @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
46 # The version of bootclasspath the package needs to work. Translates to a proper
47 # dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath
48 if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
49 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
50 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
52 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
53 # since die in global scope doesn't work, this will make repoman fail
54 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
58 # @ECLASS-VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE
60 # Allow this eclass to change the active VM?
61 # If your system VM isn't sufficient for the package, the build will fail
62 # instead of trying to switch to another VM.
64 # Overriding the default can be useful for testing specific VMs locally, but
65 # should not be used in the final ebuild.
66 JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
68 # @ECLASS-VARIABLE: JAVA_PKG_FORCE_VM
71 # Explicitly set a particular VM to use. If its not valid, it'll fall back to
72 # whatever /etc/java-config-2/build/jdk.conf would elect to use.
74 # Should only be used for testing and debugging.
76 # Example: use sun-jdk-1.5 to emerge foo:
78 # JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
81 # @ECLASS-VARIABLE: JAVA_PKG_WANT_BUILD_VM
84 # A list of VM handles to choose a build VM from. If the list contains the
85 # currently active VM use that one, otherwise step through the list till a
86 # usable/installed VM is found.
88 # This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
89 # Users of this variable must make sure at least one of the listed handles is
91 # Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
93 # @ECLASS-VARIABLE: JAVA_PKG_WANT_SOURCE
96 # Specify a non-standard Java source version for compilation (via javac -source
97 # parameter or Ant equivalent via build.xml rewriting done by java-ant-2 eclass).
98 # Normally this is determined from the jdk version specified in DEPEND.
99 # See java-pkg_get-source function below.
101 # Should generally only be used for testing and debugging.
103 # Use 1.4 source to emerge baz
105 # JAVA_PKG_WANT_SOURCE=1.4 emerge baz
108 # @ECLASS-VARIABLE: JAVA_PKG_WANT_TARGET
111 # Same as JAVA_PKG_WANT_SOURCE (see above) but for javac -target parameter,
112 # which affects the version of generated bytecode.
113 # Normally this is determined from the jre/jdk version specified in RDEPEND.
114 # See java-pkg_get-target function below.
116 # Should generallyonly be used for testing and debugging.
118 # emerge bar to be compatible with 1.3
120 # JAVA_PKG_WANT_TARGET=1.3 emerge bar
123 # @ECLASS-VARIABLE: JAVA_PKG_DEBUG
126 # A variable to be set with "yes" or "y", or ANY string of length non equal to
127 # zero. When set, verbosity across java eclasses is increased and extra
128 # logging is displayed.
130 # JAVA_PKG_DEBUG="yes"
133 # @ECLASS-VARIABLE: JAVA_RM_FILES
136 # An array containing a list of files to remove. If defined, this array will be
137 # automatically handed over to java-pkg_rm_files for processing during the
147 # @VARIABLE: JAVA_PKG_COMPILER_DIR
150 # Directory where compiler settings are saved, without trailing slash.
151 # You probably shouldn't touch this variable except local testing.
152 JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
154 # @VARIABLE: JAVA_PKG_COMPILERS_CONF
157 # Path to file containing information about which compiler to use.
158 # Can be overloaded, but it should be overloaded only for local testing.
159 JAVA_PKG_COMPILERS_CONF=${JAVA_PKG_COMPILERS_CONF:="/etc/java-config-2/build/compilers.conf"}
161 # @ECLASS-VARIABLE: JAVA_PKG_FORCE_COMPILER
165 # Explicitly set a list of compilers to choose from. This is normally read from
166 # JAVA_PKG_COMPILERS_CONF.
168 # Useful for local testing.
170 # Use jikes and javac, in that order
172 # JAVA_PKG_FORCE_COMPILER="jikes javac"
175 # @ECLASS-VARIABLE: JAVA_PKG_FORCE_ANT_TASKS
178 # An $IFS separated list of ant tasks. Can be set in environment before calling
179 # emerge/ebuild to override variables set in ebuild, mainly for testing before
180 # putting the resulting (WANT_)ANT_TASKS into ebuild. Affects only ANT_TASKS in
181 # eant() call, not the dependencies specified in WANT_ANT_TASKS.
184 # JAVA_PKG_FORCE_ANT_TASKS="ant-junit ant-trax" \
185 # ebuild foo.ebuild compile
189 JAVA_PKG_QA_VIOLATIONS=0
191 # @FUNCTION: java-pkg_doexamples
192 # @USAGE: [--subdir <subdir>] <file1/dir1> [<file2> ...]
194 # Installs given arguments to /usr/share/doc/${PF}/examples
195 # If you give it only one parameter and it is a directory it will install
196 # everything in that directory to the examples directory.
200 # --subdir - If the examples need a certain directory structure
201 # $* - list of files to install
204 # java-pkg_doexamples demo
205 # java-pkg_doexamples demo/* examples/*
207 java-pkg_doexamples() {
208 debug-print-function ${FUNCNAME} $*
210 [[ ${#} -lt 1 ]] && die "At least one argument needed"
212 java-pkg_check-phase install
215 local dest=/usr/share/doc/${PF}/examples
216 if [[ ${1} == --subdir ]]; then
217 local dest=${dest}/${2}
222 if [[ ${#} = 1 && -d ${1} ]]; then
223 ( # dont want to pollute calling env
226 ) || die "Installing examples failed"
228 ( # dont want to pollute calling env
231 ) || die "Installing examples failed"
234 # Let's make a symlink to the directory we have everything else under
235 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
238 # @FUNCTION: java-pkg_addres
239 # @USAGE: <jar> <dir> [<find arguments> ...]
241 # Adds resource files to an existing jar.
242 # It is important that the directory given is actually the root of the
243 # corresponding resource tree. The target directory as well as
244 # sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are
245 # automatically excluded. Symlinks are always followed. Additional
246 # arguments are passed through to find.
249 # java-pkg_addres ${PN}.jar resources ! -name "*.html"
252 # @param $1 - jar file
253 # @param $2 - resource tree directory
254 # @param $* - arguments to pass to find
256 debug-print-function ${FUNCNAME} $*
258 [[ ${#} -lt 2 ]] && die "at least two arguments needed"
260 local jar=$(realpath "$1" || die "realpath $1 failed")
264 pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
265 find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -0 jar uf "${jar}" || die "jar failed"
266 popd > /dev/null || die "popd failed"
269 # @FUNCTION: java-pkg_rm_files
270 # @USAGE: java-pkg_rm_files File1.java File2.java ...
272 # Remove unneeded files in ${S}.
274 # Every now and then, you'll run into situations whereby a file needs removing,
275 # be it a unit test or a regular java class.
277 # You can use this function by either:
278 # - calling it yourself in java_prepare() and feeding java-pkg_rm_files with
279 # the list of files you wish to remove.
280 # - defining an array in the ebuild named JAVA_RM_FILES with the list of files
281 # you wish to remove.
283 # Both way work and it is left to the developer's preferences. If the
284 # JAVA_RM_FILES array is defined, it will be automatically handed over to
285 # java-pkg_rm_files during the src_prepare phase.
287 # See java-utils-2_src_prepare.
290 # java-pkg_rm_files File1.java File2.java
293 # @param $* - list of files to remove.
294 java-pkg_rm_files() {
295 debug-print-function ${FUNCNAME} $*
297 for filename in "$@"; do
298 [[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting."
299 einfo "Removing unneeded file ${filename}"
300 rm -f "${S}/${filename}" || die "cannot remove ${filename}"
305 # @FUNCTION: java-pkg_dojar
306 # @USAGE: <jar1> [<jar2> ...]
308 # Installs any number of jars.
309 # Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
310 # You can use java-pkg_jarinto to change this path.
311 # You should never install a jar with a package version in the filename.
312 # Instead, use java-pkg_newjar defined below.
315 # java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
318 # @param $* - list of jars to install
320 debug-print-function ${FUNCNAME} $*
322 [[ ${#} -lt 1 ]] && die "At least one argument needed"
324 java-pkg_check-phase install
327 # Create JARDEST if it doesn't exist
328 dodir ${JAVA_PKG_JARDEST}
332 for jar in "${@}"; do
333 local jar_basename=$(basename "${jar}")
335 java-pkg_check-versioned-jar ${jar_basename}
338 if [[ -e "${jar}" ]] ; then
339 # Don't overwrite if jar has already been installed with the same
341 local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}"
342 if [[ -e "${dest}" ]]; then
343 ewarn "Overwriting ${dest}"
346 # install it into JARDEST if it's a non-symlink
347 if [[ ! -L "${jar}" ]] ; then
348 #but first check class version when in strict mode.
349 is-java-strict && java-pkg_verify-classes "${jar}"
351 INSDESTTREE="${JAVA_PKG_JARDEST}" \
352 doins "${jar}" || die "failed to install ${jar}"
353 java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}"
354 debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}"
355 # make a symlink to the original jar if it's symlink
357 # TODO use dosym, once we find something that could use it
359 ln -s "$(readlink "${jar}")" "${D}${JAVA_PKG_JARDEST}/${jar_basename}"
360 debug-print "${jar} is a symlink, linking accordingly"
363 die "${jar} does not exist"
367 # Extra logging if enabled.
368 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
369 einfo "Verbose logging for \"${FUNCNAME}\" function"
370 einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}"
371 einfo "Jar file(s) created: ${@}"
372 einfo "Complete command:"
373 einfo "${FUNCNAME} ${@}"
379 # @FUNCTION: java-pkg_regjar
380 # @USAGE: </path/to/installed/jar>
382 # Records an already installed (in ${D}) jar in the package.env
383 # This would mostly be used if the package has make or a custom script to
387 # if you want to use shell expansion, you have to use ${D}/... as the for in
388 # this function will not be able to expand the path, here's an example:
391 # java-pkg_regjar ${D}/opt/my-java/lib/*.jar
395 # TODO should we be making sure the jar is present on ${D} or wherever?
397 debug-print-function ${FUNCNAME} $*
399 java-pkg_check-phase install
401 [[ ${#} -lt 1 ]] && die "at least one argument needed"
405 local jar jar_dir jar_file
406 for jar in "${@}"; do
407 # TODO use java-pkg_check-versioned-jar
408 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
409 [[ -d "${jar}" || -d "${D}${jar}" ]] \
410 && die "Called ${FUNCNAME} on a directory $*"
412 #check that class version correct when in strict mode
413 is-java-strict && java-pkg_verify-classes "${jar}"
415 # nelchael: we should strip ${D} in this case too, here's why:
417 # java-pkg_regjar ${D}/opt/java/*.jar
418 # such call will fall into this case (-e ${jar}) and will
419 # record paths with ${D} in package.env
420 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
422 if [[ ${jar} = *\** ]]; then
423 eerror "The argument ${jar} to ${FUNCNAME}"
424 eerror "has * in it. If you want it to glob in"
425 eerror '${D} add ${D} to the argument.'
427 debug-print "${jar} or ${D}${jar} not found"
428 die "${jar} does not exist"
435 # @FUNCTION: java-pkg_newjar
436 # @USAGE: <path/to/oldname.jar> [<newname.jar>]
438 # Installs a jar with a new name (defaults to $PN.jar)
440 # For example, installs a versioned jar without the version
442 debug-print-function ${FUNCNAME} $*
444 local original_jar="${1}"
445 local new_jar="${2:-${PN}.jar}"
446 local new_jar_dest="${T}/${new_jar}"
448 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
449 [[ ! -f ${original_jar} ]] \
450 && die "${original_jar} does not exist or is not a file!"
452 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
453 cp "${original_jar}" "${new_jar_dest}" \
454 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
455 java-pkg_dojar "${new_jar_dest}"
458 # @FUNCTION: java-pkg_addcp
459 # @USAGE: <classpath>
461 # Add something to the package's classpath. For jars, you should use dojar,
462 # newjar, or regjar. This is typically used to add directories to the classpath.
463 # The parameters of this function are appended to JAVA_PKG_CLASSPATH
465 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
469 # @FUNCTION: java-pkg_doso
470 # @USAGE: <path/to/file1.so> [...]
472 # Installs any number of JNI libraries
473 # They will be installed into /usr/lib by default, but java-pkg_sointo
474 # can be used change this path
481 debug-print-function ${FUNCNAME} $*
483 java-pkg_check-phase install
485 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
492 # if the lib exists...
493 if [[ -e "${lib}" ]] ; then
494 # install if it isn't a symlink
495 if [[ ! -L "${lib}" ]] ; then
496 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
497 INSOPTIONS="-m0755" \
498 doins "${lib}" || die "failed to install ${lib}"
499 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
500 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
501 # otherwise make a symlink to the symlink's origin
503 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
504 debug-print "${lib} is a symlink, linking accordantly"
508 die "${lib} does not exist"
515 # @FUNCTION: java-pkg_regso
516 # @USAGE: <file1.so> [...]
518 # Registers an already installed JNI library in package.env.
522 # $@ - JNI libraries to register
525 # java-pkg_regso *.so /path/*.so
528 debug-print-function ${FUNCNAME} $*
530 java-pkg_check-phase install
532 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
538 # Check the absolute path of the lib
539 if [[ -e "${lib}" ]] ; then
540 target_dir="$(java-pkg_expand_dir_ ${lib})"
541 java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}"
542 # Check the path of the lib relative to ${D}
543 elif [[ -e "${D}${lib}" ]]; then
544 target_dir="$(java-pkg_expand_dir_ ${D}${lib})"
545 java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}"
547 die "${lib} does not exist"
554 # @FUNCTION: java-pkg_jarinto
555 # @USAGE: </path/to/install/jars/into>
557 # Changes the path jars are installed into via subsequent java-pkg_dojar calls.
559 debug-print-function ${FUNCNAME} $*
561 JAVA_PKG_JARDEST="${1}"
564 # @FUNCTION: java-pkg_sointo
565 # @USAGE: </path/to/install/sofiles/into>
567 # Changes the path that JNI libraries are installed into via subsequent
568 # java-pkg_doso calls.
570 debug-print-function ${FUNCNAME} $*
572 JAVA_PKG_LIBDEST="${1}"
575 # @FUNCTION: java-pkg_dohtml
576 # @USAGE: <path/to/javadoc/documentation> [...]
578 # Install Javadoc HTML documentation. Usage of java-pkg_dojavadoc is preferred.
581 # java-pkg_dohtml dist/docs/
584 debug-print-function ${FUNCNAME} $*
586 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
588 # from /usr/lib/portage/bin/dohtml -h
589 # -f Set list of allowed extensionless file names.
590 dohtml -f package-list "$@"
592 # this probably shouldn't be here but it provides
593 # a reasonable way to catch # docs for all of the
595 java-pkg_recordjavadoc
598 # @FUNCTION: java-pkg_dojavadoc
599 # @USAGE: [--symlink destination] <path/to/javadocs/root>
601 # Installs javadoc documentation. This should be controlled by the doc use flag.
605 # $1: optional --symlink creates to symlink like this for html
606 # documentation bundles.
607 # $2: - The javadoc root directory.
610 # java-pkg_dojavadoc docs/api
611 # java-pkg_dojavadoc --symlink apidocs docs/api
613 java-pkg_dojavadoc() {
614 debug-print-function ${FUNCNAME} $*
616 # For html documentation bundles that link to Javadoc
618 if [[ ${1} = --symlink ]]; then
624 local dest=/usr/share/doc/${PF}/html
628 java-pkg_check-phase install
631 [[ -z "${dir}" ]] && die "Must specify a directory!"
632 [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!"
633 if [[ ! -e "${dir}/index.html" ]]; then
634 local msg="No index.html in javadoc directory"
636 is-java-strict && die "${msg}"
639 if [[ -e ${D}/${dest}/api ]]; then
640 eerror "${dest} already exists. Will not overwrite."
644 # Renaming to match our directory layout
646 local dir_to_install="${dir}"
647 if [[ "$(basename "${dir}")" != "api" ]]; then
648 dir_to_install="${T}/api"
650 cp -r "${dir}" "${dir_to_install}" || die "cp failed"
653 # Actual installation
654 java-pkg_dohtml -r "${dir_to_install}"
656 # Let's make a symlink to the directory we have everything else under
657 dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die
659 if [[ ${symlink} ]]; then
660 debug-print "symlinking ${dest}/{api,${symlink}}"
661 dosym ${dest}/{api,${symlink}} || die
664 # Extra logging if enabled.
665 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
666 einfo "Verbose logging for \"${FUNCNAME}\" function"
667 einfo "Documentation destination: ${dest}"
668 einfo "Directory to install: ${dir_to_install}"
669 einfo "Complete command:"
670 einfo "${FUNCNAME} ${@}"
674 # @FUNCTION: java-pkg_dosrc
675 # @USAGE: <path/to/sources> [...]
677 # Installs a zip containing the source for a package, so it can used in
678 # from IDEs like eclipse and netbeans.
679 # Ebuild needs to DEPEND on app-arch/zip to use this. It also should be controlled by USE=source.
683 # java-pkg_dosrc src/*
686 # TODO change so it the arguments it takes are the base directories containing
689 # TODO should we be able to handle multiple calls to dosrc? -nichoj
691 # TODO maybe we can take an existing zip/jar? -nichoj
693 # FIXME apparently this fails if you give it an empty directories
695 debug-print-function ${FUNCNAME} $*
697 [ ${#} -lt 1 ] && die "At least one argument needed"
699 java-pkg_check-phase install
701 [[ ${#} -lt 1 ]] && die "At least one argument needed"
703 if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
704 local msg="${FUNCNAME} called without app-arch/zip in DEPEND"
705 java-pkg_announce-qa-violation ${msg}
710 local zip_name="${PN}-src.zip"
711 local zip_path="${T}/${zip_name}"
713 for dir in "${@}"; do
714 local dir_parent=$(dirname "${dir}")
715 local dir_name=$(basename "${dir}")
716 pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}"
717 zip -q -r ${zip_path} ${dir_name} -i '*.java'
719 # 12 means zip has nothing to do
720 if [[ ${result} != 12 && ${result} != 0 ]]; then
721 die "failed to zip ${dir_name}"
723 popd >/dev/null || die
727 INSDESTTREE=${JAVA_PKG_SOURCESPATH} \
728 doins ${zip_path} || die "Failed to install source"
730 JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}"
732 # Extra logging if enabled.
733 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
734 einfo "Verbose logging for \"${FUNCNAME}\" function"
735 einfo "Zip filename created: ${zip_name}"
736 einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}"
737 einfo "Directories zipped: ${@}"
738 einfo "Complete command:"
739 einfo "${FUNCNAME} ${@}"
745 # @FUNCTION: java-pkg_dolauncher
746 # @USAGE: <filename> [options]
748 # Make a wrapper script to lauch/start this package
749 # If necessary, the wrapper will switch to the appropriate VM.
751 # Can be called without parameters if the package installs only one jar
752 # that has the Main-class attribute set. The wrapper will be named ${PN}.
756 # $1 - filename of launcher to create
757 # $2 - options, as follows:
758 # --main the.main.class.to.start
759 # --jar /the/jar/too/launch.jar or just <name>.jar
760 # --java_args 'Extra arguments to pass to java'
761 # --pkg_args 'Extra arguments to pass to the package'
762 # --pwd Directory the launcher changes to before executing java
763 # -into Directory to install the launcher to, instead of /usr/bin
764 # -pre Prepend contents of this file to the launcher
766 java-pkg_dolauncher() {
767 debug-print-function ${FUNCNAME} $*
769 java-pkg_check-phase install
772 if [[ ${#} = 0 ]]; then
779 # TODO rename to launcher
780 local target="${T}/${name}"
781 local var_tmp="${T}/launcher_variables_tmp"
784 # Process the other the rest of the arguments
785 while [[ -n "${1}" && -n "${2}" ]]; do
786 local var="${1}" value="${2}"
787 if [[ "${var:0:2}" == "--" ]]; then
789 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
790 local gjl_${var}="${value}"
791 elif [[ "${var}" == "-into" ]]; then
792 target_dir="${value}"
793 elif [[ "${var}" == "-pre" ]]; then
799 # Test if no --jar and --main arguments were given and
800 # in that case check if the package only installs one jar
802 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
803 local cp="${JAVA_PKG_CLASSPATH}"
804 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
805 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
807 local msg="Not enough information to create a launcher given."
808 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
813 # Write the actual script
814 echo "#!/bin/bash" > "${target}"
815 if [[ -n "${pre}" ]]; then
816 if [[ -f "${pre}" ]]; then
817 cat "${pre}" >> "${target}"
819 die "-pre specified file '${pre}' does not exist"
822 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
823 cat "${var_tmp}" >> "${target}"
825 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
827 if [[ -n "${target_dir}" ]]; then
828 DESTTREE="${target_dir}" dobin "${target}"
836 # @FUNCTION: java-pkg_dowar
841 debug-print-function ${FUNCNAME} $*
843 # Check for arguments
844 [[ ${#} -lt 1 ]] && die "At least one argument needed"
845 java-pkg_check-phase install
852 # TODO evaluate if we want to handle symlinks differently -nichoj
854 if [[ -L "${war}" ]] ; then
856 warpath="${T}$(basename "${war}")"
857 # Check for directory
858 # TODO evaluate if we want to handle directories differently -nichoj
859 elif [[ -d "${war}" ]] ; then
860 echo "dowar: warning, skipping directory ${war}"
866 # Install those files like you mean it
867 INSOPTIONS="-m 0644" \
868 INSDESTTREE=${JAVA_PKG_WARDEST} \
873 # @FUNCTION: java-pkg_recordjavadoc
876 # Scan for JavaDocs, and record their existence in the package.env file
878 # TODO make sure this in the proper section
879 java-pkg_recordjavadoc()
881 debug-print-function ${FUNCNAME} $*
882 # the find statement is important
883 # as some packages include multiple trees of javadoc
884 JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')"
885 # remove $D - TODO: check this is ok with all cases of the above
886 JAVADOC_PATH="${JAVADOC_PATH//${D}}"
887 if [[ -n "${JAVADOC_PATH}" ]] ; then
888 debug-print "javadocs found in ${JAVADOC_PATH%:}"
891 debug-print "No javadocs found"
896 # @FUNCTION: java-pkg_jar-from
897 # @USAGE: [--build-only] [--with-dependencies] [--virtual] [--into dir] <package> [<package.jar>] [<destination.jar>]
899 # Makes a symlink to a jar from a certain package
900 # A lot of java packages include dependencies in a lib/ directory
901 # You can use this function to replace these bundled dependencies.
902 # The dependency is recorded into package.env DEPEND line, unless "--build-only"
903 # is passed as the very first argument, for jars that have to be present only
904 # at build time and are not needed on runtime (junit testing etc).
907 # Example: get all jars from xerces slot 2
908 # java-pkg_jar-from xerces-2
910 # Example: get a specific jar from xerces slot 2
911 # java-pkg_jar-from xerces-2 xml-apis.jar
913 # Example: get a specific jar from xerces slot 2, and name it diffrently
914 # java-pkg_jar-from xerces-2 xml-apis.jar xml.jar
916 # Example: get junit.jar which is needed only for building
917 # java-pkg_jar-from --build-only junit junit.jar
922 # --build-only - makes the jar(s) not added into package.env DEPEND line.
923 # (assumed automatically when called inside src_test)
924 # --with-dependencies - get jars also from requested package's dependencies
926 # --virtual - Packages passed to this function are to be handled as virtuals
927 # and will not have individual jar dependencies recorded.
928 # --into $dir - symlink jar(s) into $dir (must exist) instead of .
929 # $1 - Package to get jars from, or comma-separated list of packages in
930 # case other parameters are not used.
931 # $2 - jar from package. If not specified, all jars will be used.
932 # $3 - When a single jar is specified, destination filename of the
933 # symlink. Defaults to the name of the jar.
936 # TODO could probably be cleaned up a little
937 java-pkg_jar-from() {
938 debug-print-function ${FUNCNAME} $*
946 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
948 while [[ "${1}" == --* ]]; do
949 if [[ "${1}" = "--build-only" ]]; then
951 elif [[ "${1}" = "--with-dependencies" ]]; then
952 deep="--with-dependencies"
953 elif [[ "${1}" = "--virtual" ]]; then
955 elif [[ "${1}" = "--into" ]]; then
959 die "java-pkg_jar-from called with unknown parameter: ${1}"
964 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
966 [[ -z ${target_pkg} ]] && die "Must specify a package"
968 if [[ "${EAPI}" == "1" ]]; then
969 target_pkg="${target_pkg//:/-}"
972 # default destjar to the target jar
973 [[ -z "${destjar}" ]] && destjar="${target_jar}"
975 local error_msg="There was a problem getting the classpath for ${target_pkg}."
977 classpath="$(java-config ${deep} --classpath=${target_pkg})"
978 [[ $? != 0 ]] && die ${error_msg}
980 # When we have commas this functions is called to bring jars from multiple
981 # packages. This affects recording of dependencencies performed later
982 # which expects one package only, so we do it here.
983 if [[ ${target_pkg} = *,* ]]; then
984 for pkg in ${target_pkg//,/ }; do
985 java-pkg_ensure-dep "${build_only}" "${pkg}"
986 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
988 # setting this disables further record-jar_ calls later
991 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
994 # Record the entire virtual as a dependency so that
995 # no jars are missed.
996 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
997 java-pkg_record-jar_ "${target_pkg}"
998 # setting this disables further record-jars_ calls later
1002 pushd ${destdir} > /dev/null \
1003 || die "failed to change directory to ${destdir}"
1006 for jar in ${classpath//:/ }; do
1007 local jar_name=$(basename "${jar}")
1008 if [[ ! -f "${jar}" ]] ; then
1009 debug-print "${jar} from ${target_pkg} does not exist"
1010 die "Installation problems with jars in ${target_pkg} - is it installed?"
1012 # If no specific target jar was indicated, link it
1013 if [[ -z "${target_jar}" ]] ; then
1014 [[ -f "${target_jar}" ]] && rm "${target_jar}"
1016 || die "Failed to make symlink from ${jar} to ${jar_name}"
1017 if [[ -z "${record_jar}" ]]; then
1018 if [[ -z "${build_only}" ]]; then
1019 java-pkg_record-jar_ "${target_pkg}" "${jar}"
1021 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
1024 # otherwise, if the current jar is the target jar, link it
1025 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
1026 [[ -f "${destjar}" ]] && rm "${destjar}"
1027 ln -snf "${jar}" "${destjar}" \
1028 || die "Failed to make symlink from ${jar} to ${destjar}"
1029 if [[ -z "${record_jar}" ]]; then
1030 if [[ -z "${build_only}" ]]; then
1031 java-pkg_record-jar_ "${target_pkg}" "${jar}"
1033 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
1036 popd > /dev/null || die
1040 popd > /dev/null || die
1041 # if no target was specified, we're ok
1042 if [[ -z "${target_jar}" ]] ; then
1044 # otherwise, die bitterly
1046 die "Failed to find ${target_jar:-jar} in ${target_pkg}"
1050 # @FUNCTION: java-pkg_jarfrom
1052 # See java-pkg_jar-from
1053 java-pkg_jarfrom() {
1054 java-pkg_jar-from "$@"
1057 # @FUNCTION: java-pkg_getjars
1058 # @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...]
1060 # Get the classpath provided by any number of packages
1061 # Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
1062 # The providing packages are recorded as dependencies into package.env DEPEND
1063 # line, unless "--build-only" is passed as the very first argument, for jars
1064 # that have to be present only at build time and are not needed on runtime
1065 # (junit testing etc).
1068 # Example: Get the classpath for xerces-2 and xalan,
1069 # java-pkg_getjars xerces-2,xalan
1072 # /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
1076 # --build-only - makes the jar(s) not added into package.env DEPEND line.
1077 # (assumed automatically when called inside src_test)
1078 # --with-dependencies - get jars also from requested package's dependencies
1080 # $1 - list of packages to get jars from
1081 # (passed to java-config --classpath)
1083 java-pkg_getjars() {
1084 debug-print-function ${FUNCNAME} $*
1089 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1091 while [[ "${1}" == --* ]]; do
1092 if [[ "${1}" = "--build-only" ]]; then
1094 elif [[ "${1}" = "--with-dependencies" ]]; then
1095 deep="--with-dependencies"
1097 die "java-pkg_jar-from called with unknown parameter: ${1}"
1102 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*"
1107 if [[ "${EAPI}" == "1" ]]; then
1111 jars="$(java-config ${deep} --classpath=${pkgs})"
1112 [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed"
1113 debug-print "${pkgs}:${jars}"
1115 for pkg in ${pkgs//,/ }; do
1116 java-pkg_ensure-dep "${build_only}" "${pkg}"
1119 for pkg in ${pkgs//,/ }; do
1120 if [[ -z "${build_only}" ]]; then
1121 java-pkg_record-jar_ "${pkg}"
1123 java-pkg_record-jar_ --build-only "${pkg}"
1130 # @FUNCTION: java-pkg_getjar
1131 # @USAGE: [--build-only] [--virtual] <package> <jarfile>
1133 # Get the complete path of a single jar from a package
1134 # The providing package is recorded as runtime dependency into package.env
1135 # DEPEND line, unless "--build-only" is passed as the very first argument, for
1136 # jars that have to be present only at build time and are not needed on runtime
1137 # (junit testing etc).
1141 # java-pkg_getjar xerces-2 xml-apis.jar
1143 # /usr/share/xerces-2/lib/xml-apis.jar
1146 # --build-only - makes the jar not added into package.env DEPEND line.
1147 # --virtual - Packages passed to this function are to be handled as virtuals
1148 # and will not have individual jar dependencies recorded.
1149 # $1 - package to use
1153 debug-print-function ${FUNCNAME} $*
1159 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1161 while [[ "${1}" == --* ]]; do
1162 if [[ "${1}" = "--build-only" ]]; then
1164 elif [[ "${1}" == "--virtual" ]]; then
1167 die "java-pkg_getjar called with unknown parameter: ${1}"
1172 [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*"
1174 local pkg="${1}" target_jar="${2}" jar
1176 if [[ "${EAPI}" == "1" ]]; then
1180 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
1181 [[ -z ${target_jar} ]] && die "Must specify jar to get"
1183 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
1185 classpath=$(java-config --classpath=${pkg})
1186 [[ $? != 0 ]] && die ${error_msg}
1188 java-pkg_ensure-dep "${build_only}" "${pkg}"
1190 # Record the package(Virtual) as a dependency and then set build_only
1191 # So that individual jars are not recorded.
1192 if [[ -n "${virtual}" ]]; then
1193 if [[ -z "${build_only}" ]]; then
1194 java-pkg_record-jar_ "${pkg}"
1196 java-pkg_record-jar_ --build-only "${pkg}"
1201 for jar in ${classpath//:/ }; do
1202 if [[ ! -f "${jar}" ]] ; then
1203 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1206 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1207 # Only record jars that aren't build-only
1208 if [[ -z "${record_jar}" ]]; then
1209 if [[ -z "${build_only}" ]]; then
1210 java-pkg_record-jar_ "${pkg}" "${jar}"
1212 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1220 die "Could not find ${target_jar} in ${pkg}"
1224 # @FUNCTION: java-pkg_register-dependency
1225 # @USAGE: <package>[,<package2>...] [<jarfile>]
1227 # Registers runtime dependency on a package, list of packages, or a single jar
1228 # from a package, into package.env DEPEND line. Can only be called in
1229 # src_install phase.
1230 # Intended for binary packages where you don't need to symlink the jars or get
1231 # their classpath during build. As such, the dependencies only need to be
1232 # specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1236 # $1 - comma-separated list of packages, or a single package
1237 # $2 - if param $1 is a single package, optionally specify the jar
1241 # Record the dependency on whole xerces-2 and xalan,
1242 # java-pkg_register-dependency xerces-2,xalan
1244 # Record the dependency on ant.jar from ant-core
1245 # java-pkg_register-dependency ant-core ant.jar
1248 # Note: Passing both list of packages as the first parameter AND specifying the
1249 # jar as the second is not allowed and will cause the function to die. We assume
1250 # that there's more chance one passes such combination as a mistake, than that
1251 # there are more packages providing identically named jar without class
1253 java-pkg_register-dependency() {
1254 debug-print-function ${FUNCNAME} $*
1256 java-pkg_check-phase install
1258 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1263 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1265 if [[ "${EAPI}" == "1" ]]; then
1269 if [[ -z "${jar}" ]]; then
1270 for pkg in ${pkgs//,/ }; do
1271 java-pkg_ensure-dep runtime "${pkg}"
1272 java-pkg_record-jar_ "${pkg}"
1275 [[ ${pkgs} == *,* ]] && \
1276 die "${FUNCNAME} called with both package list and jar name"
1277 java-pkg_ensure-dep runtime "${pkgs}"
1278 java-pkg_record-jar_ "${pkgs}" "${jar}"
1284 # @FUNCTION: java-pkg_register-optional-dependency
1285 # @USAGE: <package>[,<package2>...] [<jarfile>]
1287 # Registers optional runtime dependency on a package, list of packages, or a
1288 # single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1289 # called in src_install phase.
1290 # Intended for packages that can use other packages when those are in classpath.
1291 # Will be put on classpath by launcher if they are installed. Typical case is
1292 # JDBC implementations for various databases. It's better than having USE flag
1293 # for each implementation triggering hard dependency.
1297 # $1 - comma-separated list of packages, or a single package
1298 # $2 - if param $1 is a single package, optionally specify the jar to depend on
1301 # Record the optional dependency on some jdbc providers
1302 # java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1305 # Note: Passing both list of packages as the first parameter AND specifying the
1306 # jar as the second is not allowed and will cause the function to die. We assume
1307 # that there's more chance one passes such combination as a mistake, than that
1308 # there are more packages providing identically named jar without class
1310 java-pkg_register-optional-dependency() {
1311 debug-print-function ${FUNCNAME} $*
1313 java-pkg_check-phase install
1315 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1320 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1322 if [[ "${EAPI}" == "1" ]]; then
1326 if [[ -z "${jar}" ]]; then
1327 for pkg in ${pkgs//,/ }; do
1328 java-pkg_record-jar_ --optional "${pkg}"
1331 [[ ${pkgs} == *,* ]] && \
1332 die "${FUNCNAME} called with both package list and jar name"
1333 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1339 # @FUNCTION: java-pkg_register-environment-variable
1340 # @USAGE: <name> <value>
1342 # Register an arbitrary environment variable into package.env. The gjl launcher
1343 # for this package or any package depending on this will export it into
1344 # environement before executing java command.
1345 # Must only be called in src_install phase.
1346 JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1347 JAVA_PKG_EXTRA_ENV_VARS=""
1348 java-pkg_register-environment-variable() {
1349 debug-print-function ${FUNCNAME} $*
1351 java-pkg_check-phase install
1353 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1355 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1356 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1361 # @FUNCTION: java-pkg_get-bootclasspath
1364 # Returns classpath of a given bootclasspath-providing package version.
1366 # @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1367 # of the current JDK
1368 java-pkg_get-bootclasspath() {
1369 local version="${1}"
1372 case "${version}" in
1374 bcp="$(java-config -g BOOTCLASSPATH)"
1377 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1380 eerror "unknown parameter of java-pkg_get-bootclasspath"
1381 die "unknown parameter of java-pkg_get-bootclasspath"
1389 # This function reads stdin, and based on that input, figures out how to
1390 # populate jars from the filesystem.
1391 # Need to figure out a good way of making use of this, ie be able to use a
1392 # string that was built instead of stdin
1393 # NOTE: this isn't quite ready for primetime.
1394 #java-pkg_populate-jars() {
1398 # while [[ -n "${line}" ]]; do
1400 # [[ ${line%%#*} == "" ]] && continue
1402 # # get rid of any spaces
1403 # line="${line// /}"
1405 # # format: path=jarinfo
1406 # local path=${line%%=*}
1407 # local jarinfo=${line##*=}
1409 # # format: jar@package
1410 # local jar=${jarinfo%%@*}.jar
1411 # local package=${jarinfo##*@}
1412 # if [[ -n ${replace_only} ]]; then
1413 # [[ ! -f $path ]] && die "No jar exists at ${path}"
1415 # if [[ -n ${create_parent} ]]; then
1416 # local parent=$(dirname ${path})
1417 # mkdir -p "${parent}"
1419 # java-pkg_jar-from "${package}" "${jar}" "${path}"
1425 # @FUNCTION: java-pkg_find-normal-jars
1426 # @USAGE: [<path/to/directory>]
1428 # Find the files with suffix .jar file in the given directory (default: $WORKDIR)
1429 java-pkg_find-normal-jars() {
1431 [[ "${dir}" ]] || dir="${WORKDIR}"
1433 for jar in $(find "${dir}" -name "*.jar" -type f); do
1441 # @FUNCTION: java-pkg_ensure-no-bundled-jars
1443 # Try to locate bundled jar files in ${WORKDIR} and die if found.
1444 # This function should be called after WORKDIR has been populated with symlink
1445 # to system jar files or bundled jars removed.
1446 java-pkg_ensure-no-bundled-jars() {
1447 debug-print-function ${FUNCNAME} $*
1449 local bundled_jars=$(java-pkg_find-normal-jars)
1450 if [[ -n ${bundled_jars} ]]; then
1451 echo "Bundled jars found:"
1453 for jar in ${bundled_jars}; do
1454 echo $(pwd)${jar/./}
1456 die "Bundled jars found!"
1460 # @FUNCTION: java-pkg_ensure-vm-version-sufficient
1463 # Checks if we have a sufficient VM and dies if we don't.
1464 java-pkg_ensure-vm-version-sufficient() {
1465 debug-print-function ${FUNCNAME} $*
1467 if ! java-pkg_is-vm-version-sufficient; then
1468 debug-print "VM is not suffient"
1469 eerror "Current Java VM cannot build this package"
1470 einfo "Please use java-config -S to set the correct one"
1471 die "Active Java VM cannot build this package"
1475 # @FUNCTION: java-pkg_is-vm-version-sufficient
1478 # @RETURN: zero - VM is sufficient; non-zero - VM is not sufficient
1479 java-pkg_is-vm-version-sufficient() {
1480 debug-print-function ${FUNCNAME} $*
1482 depend-java-query --is-sufficient "${DEPEND}" > /dev/null
1486 # @FUNCTION: java-pkg_ensure-vm-version-eq
1489 # Die if the current VM is not equal to the argument passed.
1491 # @param $@ - Desired VM version to ensure
1492 java-pkg_ensure-vm-version-eq() {
1493 debug-print-function ${FUNCNAME} $*
1495 if ! java-pkg_is-vm-version-eq $@ ; then
1496 debug-print "VM is not suffient"
1497 eerror "This package requires a Java VM version = $@"
1498 einfo "Please use java-config -S to set the correct one"
1499 die "Active Java VM too old"
1503 # @FUNCTION: java-pkg_is-vm-version-eq
1506 # @RETURN: zero - VM versions are equal; non-zero - VM version are not equal
1507 java-pkg_is-vm-version-eq() {
1508 debug-print-function ${FUNCNAME} $*
1510 local needed_version="$@"
1512 [[ -z "${needed_version}" ]] && die "need an argument"
1514 local vm_version="$(java-pkg_get-vm-version)"
1516 vm_version="$(get_version_component_range 1-2 "${vm_version}")"
1517 needed_version="$(get_version_component_range 1-2 "${needed_version}")"
1519 if [[ -z "${vm_version}" ]]; then
1520 debug-print "Could not get JDK version from DEPEND"
1523 if [[ "${vm_version}" == "${needed_version}" ]]; then
1524 debug-print "Detected a JDK(${vm_version}) = ${needed_version}"
1527 debug-print "Detected a JDK(${vm_version}) != ${needed_version}"
1533 # @FUNCTION: java-pkg_ensure-vm-version-ge
1536 # Die if the current VM is not greater than the desired version
1538 # @param $@ - VM version to compare current to
1539 java-pkg_ensure-vm-version-ge() {
1540 debug-print-function ${FUNCNAME} $*
1542 if ! java-pkg_is-vm-version-ge "$@" ; then
1543 debug-print "vm is not suffient"
1544 eerror "This package requires a Java VM version >= $@"
1545 einfo "Please use java-config -S to set the correct one"
1546 die "Active Java VM too old"
1550 # @FUNCTION: java-pkg_is-vm-version-ge
1555 # $@ - VM version to compare current VM to
1557 # @RETURN: zero - current VM version is greater than checked version;
1558 # non-zero - current VM version is not greater than checked version
1559 java-pkg_is-vm-version-ge() {
1560 debug-print-function ${FUNCNAME} $*
1562 local needed_version=$@
1563 local vm_version=$(java-pkg_get-vm-version)
1564 if [[ -z "${vm_version}" ]]; then
1565 debug-print "Could not get JDK version from DEPEND"
1568 if version_is_at_least "${needed_version}" "${vm_version}"; then
1569 debug-print "Detected a JDK(${vm_version}) >= ${needed_version}"
1572 debug-print "Detected a JDK(${vm_version}) < ${needed_version}"
1578 java-pkg_set-current-vm() {
1579 export GENTOO_VM=${1}
1582 java-pkg_get-current-vm() {
1586 java-pkg_current-vm-matches() {
1587 has $(java-pkg_get-current-vm) ${@}
1591 # @FUNCTION: java-pkg_get-source
1593 # Determines what source version should be used, for passing to -source.
1594 # Unless you want to break things you probably shouldn't set _WANT_SOURCE
1596 # @RETURN: string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1597 java-pkg_get-source() {
1598 echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1601 # @FUNCTION: java-pkg_get-target
1603 # Determines what target version should be used, for passing to -target.
1604 # If you don't care about lower versions, you can set _WANT_TARGET to the
1605 # version of your JDK.
1607 # @RETURN: string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1608 java-pkg_get-target() {
1609 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1612 # @FUNCTION: java-pkg_get-javac
1614 # Returns the compiler executable
1615 java-pkg_get-javac() {
1616 debug-print-function ${FUNCNAME} $*
1618 java-pkg_init-compiler_
1619 local compiler="${GENTOO_COMPILER}"
1621 local compiler_executable
1622 if [[ "${compiler}" = "javac" ]]; then
1623 # nothing fancy needs to be done for javac
1624 compiler_executable="javac"
1626 # for everything else, try to determine from an env file
1628 local compiler_env="/usr/share/java-config-2/compiler/${compiler}"
1629 if [[ -f ${compiler_env} ]]; then
1630 local old_javac=${JAVAC}
1632 # try to get value of JAVAC
1633 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1634 export JAVAC=${old_javac}
1636 if [[ -z ${compiler_executable} ]]; then
1637 die "JAVAC is empty or undefined in ${compiler_env}"
1640 # check that it's executable
1641 if [[ ! -x ${compiler_executable} ]]; then
1642 die "${compiler_executable} doesn't exist, or isn't executable"
1645 die "Could not find environment file for ${compiler}"
1648 echo ${compiler_executable}
1651 # @FUNCTION: java-pkg_javac-args
1653 # If an ebuild uses javac directly, instead of using ejavac, it should call this
1654 # to know what -source/-target to use.
1656 # @RETURN: string - arguments to pass to javac, complete with -target and -source
1657 java-pkg_javac-args() {
1658 debug-print-function ${FUNCNAME} $*
1660 local want_source="$(java-pkg_get-source)"
1661 local want_target="$(java-pkg_get-target)"
1663 local source_str="-source ${want_source}"
1664 local target_str="-target ${want_target}"
1666 debug-print "want source: ${want_source}"
1667 debug-print "want target: ${want_target}"
1669 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1670 die "Could not find valid -source/-target values for javac"
1672 echo "${source_str} ${target_str}"
1676 # @FUNCTION: java-pkg_get-jni-cflags
1678 # Echos the CFLAGS for JNI compilations
1679 java-pkg_get-jni-cflags() {
1680 local flags="-I${JAVA_HOME}/include"
1682 local platform="linux"
1683 use elibc_FreeBSD && platform="freebsd"
1685 # TODO do a check that the directories are valid
1686 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1691 java-pkg_ensure-gcj() {
1692 # was enforcing sys-devel/gcc[gcj]
1693 die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
1696 java-pkg_ensure-test() {
1697 # was enforcing USE=test if FEATURES=test
1698 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1701 # @FUNCTION: java-pkg_register-ant-task
1702 # @USAGE: [--version x.y] [<name>]
1704 # Register this package as ant task, so that ant will load it when no specific
1705 # ANT_TASKS are specified. Note that even without this registering, all packages
1706 # specified in ANT_TASKS will be loaded. Mostly used by the actual ant tasks
1707 # packages, but can be also used by other ebuilds that used to symlink their
1708 # .jar into /usr/share/ant-core/lib to get autoloaded, for backwards
1713 # --version x.y Register only for ant version x.y (otherwise for any ant
1714 # version). Used by the ant-* packages to prevent loading of mismatched
1715 # ant-core ant tasks after core was updated, before the tasks are updated,
1716 # without a need for blockers.
1717 # $1 Name to register as. Defaults to JAVA_PKG_NAME ($PN[-$SLOT])
1719 java-pkg_register-ant-task() {
1720 local TASKS_DIR="tasks"
1722 # check for --version x.y parameters
1723 while [[ -n "${1}" && -n "${2}" ]]; do
1726 if [[ "${var}" == "version" ]]; then
1727 TASKS_DIR="tasks-${val}"
1729 die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}"
1734 local TASK_NAME="${1:-${JAVA_PKG_NAME}}"
1736 dodir /usr/share/ant/${TASKS_DIR}
1737 touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
1740 # @FUNCTION: java-pkg_ant-tasks-depend
1743 # Translates the WANT_ANT_TASKS variable into valid dependencies.
1744 java-pkg_ant-tasks-depend() {
1745 debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS}
1747 if [[ -n "${WANT_ANT_TASKS}" ]]; then
1749 for i in ${WANT_ANT_TASKS}
1751 if [[ ${i} = ant-* ]]; then
1752 DEP="${DEP}dev-java/${i} "
1753 elif [[ ${i} = */*:* ]]; then
1756 echo "Invalid atom in WANT_ANT_TASKS: ${i}"
1768 # @FUNCTION: ejunit_
1771 # Internal Junit wrapper function. Makes it easier to run the tests and checks for
1772 # dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1775 # $1 - junit package (junit or junit-4)
1776 # $2 - -cp or -classpath
1777 # $3 - classpath; junit and recorded dependencies get appended
1778 # $@ - the rest of the parameters are passed to java
1781 debug-print-function ${FUNCNAME} $*
1784 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1785 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1786 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1793 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1794 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1801 local runner=junit.textui.TestRunner
1802 if [[ "${junit}" == "junit-4" ]] ; then
1803 runner=org.junit.runner.JUnitCore
1805 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1806 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1811 # Junit wrapper function. Makes it easier to run the tests and checks for
1812 # dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1816 # $1 - -cp or -classpath
1817 # $2 - classpath; junit and recorded dependencies get appended
1818 # $@ - the rest of the parameters are passed to java
1821 # ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1822 # ejunit org.blinkenlights.jid3.test.AllTests
1823 # ejunit org.blinkenlights.jid3.test.FirstTest org.blinkenlights.jid3.test.SecondTest
1826 debug-print-function ${FUNCNAME} $*
1828 ejunit_ "junit" "${@}"
1831 # @FUNCTION: ejunit4
1833 # Junit4 wrapper function. Makes it easier to run the tests and checks for
1834 # dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1838 # $1 - -cp or -classpath
1839 # $2 - classpath; junit and recorded dependencies get appended
1840 # $@ - the rest of the parameters are passed to java
1843 # ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1844 # ejunit4 org.blinkenlights.jid3.test.AllTests
1845 # ejunit4 org.blinkenlights.jid3.test.FirstTest \
1846 # org.blinkenlights.jid3.test.SecondTest
1849 debug-print-function ${FUNCNAME} $*
1851 ejunit_ "junit-4" "${@}"
1854 # @FUNCTION: java-utils-2_src_prepare
1856 # src_prepare Searches for bundled jars
1857 # Don't call directly, but via java-pkg-2_src_prepare!
1858 java-utils-2_src_prepare() {
1859 java-pkg_func-exists java_prepare && java_prepare
1861 # Check for files in JAVA_RM_FILES array.
1862 if [[ ${JAVA_RM_FILES[@]} ]]; then
1863 debug-print "$FUNCNAME: removing unneeded files"
1864 java-pkg_rm_files "${JAVA_RM_FILES[@]}"
1867 if is-java-strict; then
1868 echo "Searching for bundled jars:"
1869 java-pkg_find-normal-jars || echo "None found."
1870 echo "Searching for bundled classes (no output if none found):"
1871 find "${WORKDIR}" -name "*.class"
1876 # @FUNCTION: java-utils-2_pkg_preinst
1878 # pkg_preinst Searches for missing and unneeded dependencies
1879 # Don't call directly, but via java-pkg-2_pkg_preinst!
1880 java-utils-2_pkg_preinst() {
1881 if is-java-strict; then
1882 if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
1886 if has_version dev-java/java-dep-check; then
1887 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1888 [[ ${output} ]] && ewarn "${output}"
1890 eerror "Install dev-java/java-dep-check for dependency checking"
1896 # @USAGE: <ant_build_target(s)>
1898 # Ant wrapper function. Will use the appropriate compiler, based on user-defined
1899 # compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1904 # EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1905 # gentoo.classpath property. Be sure to call java-ant_rewrite-classpath in src_unpack.
1906 # EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1907 # for build-time purposes, the dependency is not recorded to
1909 # ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1912 debug-print-function ${FUNCNAME} $*
1914 if [[ ${EBUILD_PHASE} = compile ]]; then
1915 java-ant-2_src_configure
1918 if ! has java-ant-2 ${INHERITED}; then
1919 local msg="You should inherit java-ant-2 when using eant"
1920 java-pkg_announce-qa-violation "${msg}"
1923 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1925 java-pkg_init-compiler_
1926 local compiler="${GENTOO_COMPILER}"
1928 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1929 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1930 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1931 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1934 if [[ ${compiler} != "javac" ]]; then
1935 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1936 # Figure out any extra stuff to put on the classpath for compilers aside
1938 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1940 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1941 if [[ -n ${build_compiler_deps} ]]; then
1942 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1946 for arg in "${@}"; do
1947 if [[ ${arg} = -lib ]]; then
1948 if is-java-strict; then
1949 eerror "You should not use the -lib argument to eant because it will fail"
1950 eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from"
1951 eerror "or ant properties to make dependencies available."
1952 eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from."
1953 eerror "split ant (>=dev-java/ant-core-1.7)."
1954 die "eant -lib is deprecated/forbidden"
1956 echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for"
1962 # parse WANT_ANT_TASKS for atoms
1963 local want_ant_tasks
1964 for i in ${WANT_ANT_TASKS}; do
1965 if [[ ${i} = */*:* ]]; then
1968 want_ant_tasks+="${i/:/-} "
1970 want_ant_tasks+="${i} "
1973 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1974 ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}"
1976 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1977 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1979 # if ant-tasks is not set by ebuild or forced, use none
1980 ANT_TASKS="${ANT_TASKS:-none}"
1982 # at this point, ANT_TASKS should be "all", "none" or explicit list
1983 if [[ "${ANT_TASKS}" == "all" ]]; then
1984 einfo "Using all available ANT_TASKS"
1985 elif [[ "${ANT_TASKS}" == "none" ]]; then
1986 einfo "Disabling all optional ANT_TASKS"
1988 einfo "Using following ANT_TASKS: ${ANT_TASKS}"
1993 [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug"
1994 [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q"
1996 local gcp="${EANT_GENTOO_CLASSPATH}"
1999 if [[ ${EBUILD_PHASE} = "test" ]]; then
2000 antflags="${antflags} -DJunit.present=true"
2001 getjarsarg="--with-dependencies"
2003 local re="\bant-junit4?([-:]\S+)?\b"
2004 [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}"
2006 antflags="${antflags} -Dmaven.test.skip=true"
2011 for atom in ${gcp}; do
2012 cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})"
2015 [[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)"
2016 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}"
2018 if [[ ${cp#:} ]]; then
2019 # It seems ant does not like single quotes around ${cp}
2020 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
2023 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
2024 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
2025 ant ${antflags} "${@}" || die "eant failed"
2029 # @USAGE: <javac_arguments>
2031 # Javac wrapper function. Will use the appropriate compiler, based on
2032 # /etc/java-config/compilers.conf
2034 debug-print-function ${FUNCNAME} $*
2036 local compiler_executable
2037 compiler_executable=$(java-pkg_get-javac)
2040 javac_args="$(java-pkg_javac-args)"
2042 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
2043 einfo "Verbose logging for \"${FUNCNAME}\" function"
2044 einfo "Compiler executable: ${compiler_executable}"
2045 einfo "Extra arguments: ${javac_args}"
2046 einfo "Complete command:"
2047 einfo "${compiler_executable} ${javac_args} ${@}"
2051 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
2054 # @FUNCTION: ejavadoc
2055 # @USAGE: <javadoc_arguments>
2057 # javadoc wrapper function. Will set some flags based on the VM version
2058 # due to strict javadoc rules in 1.8.
2060 debug-print-function ${FUNCNAME} $*
2062 local javadoc_args=""
2064 if java-pkg_is-vm-version-ge "1.8" ; then
2065 javadoc_args="-Xdoclint:none"
2068 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
2069 einfo "Verbose logging for \"${FUNCNAME}\" function"
2070 einfo "Javadoc executable: javadoc"
2071 einfo "Extra arguments: ${javadoc_args}"
2072 einfo "Complete command:"
2073 einfo "javadoc ${javadoc_args} ${@}"
2076 ebegin "Generating JavaDoc"
2077 javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
2080 # @FUNCTION: java-pkg_filter-compiler
2081 # @USAGE: <compiler(s)_to_filter>
2083 # Used to prevent the use of some compilers. Should be used in src_compile.
2084 # Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
2085 java-pkg_filter-compiler() {
2086 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
2089 # @FUNCTION: java-pkg_force-compiler
2090 # @USAGE: <compiler(s)_to_force>
2092 # Used to force the use of particular compilers. Should be used in src_compile.
2093 # A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
2094 # OutOfMemoryErrors that may come up.
2095 java-pkg_force-compiler() {
2096 JAVA_PKG_FORCE_COMPILER="$@"
2099 # @FUNCTION: use_doc
2102 # Helper function for getting ant to build javadocs. If the user has USE=doc,
2103 # then 'javadoc' or the argument are returned. Otherwise, there is no return.
2105 # The output of this should be passed to ant.
2108 # $@ - Option value to return. Defaults to 'javadoc'
2111 # build javadocs by calling 'javadoc' target
2114 # build javadocs by calling 'apidoc' target
2115 # eant $(use_doc apidoc)
2117 # @RETURN string - Name of the target to create javadocs
2119 use doc && echo ${@:-javadoc}
2123 # @FUNCTION: java-pkg_init
2126 # The purpose of this function, as the name might imply, is to initialize the
2127 # Java environment. It ensures that that there aren't any environment variables
2128 # that'll muss things up. It initializes some variables, which are used
2129 # internally. And most importantly, it'll switch the VM if necessary.
2131 # This shouldn't be used directly. Instead, java-pkg and java-pkg-opt will
2132 # call it during each of the phases of the merge process.
2134 debug-print-function ${FUNCNAME} $*
2136 # Don't set up build environment if installing from binary. #206024 #258423
2137 [[ "${MERGE_TYPE}" == "binary" ]] && return
2138 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2139 # work nothing is lost.
2140 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2145 java-config --help >/dev/null || {
2147 eerror "Can't run java-config --help"
2148 eerror "Have you upgraded python recently but haven't"
2149 eerror "run python-updater yet?"
2150 die "Can't run java-config --help"
2153 # People do all kinds of weird things.
2154 # https://forums.gentoo.org/viewtopic-p-3943166.html
2155 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2156 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2157 if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
2158 ewarn "_JAVA_OPTIONS changes what java -version outputs at least for"
2159 ewarn "sun-jdk vms and and as such break configure scripts that"
2160 ewarn "use it (for example app-office/openoffice) so we filter it out."
2161 ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use"
2162 ewarn "make.conf for example) to silence this warning or"
2163 ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it."
2166 if [[ -z ${accept} ]]; then
2167 # export _JAVA_OPTIONS= doesn't work because it will show up in java
2170 # phase hooks make this run many times without this
2171 I_WANT_GLOBAL_JAVA_OPTIONS="true"
2174 if java-pkg_func-exists ant_src_unpack; then
2175 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2179 PATH=${JAVA_HOME}/bin:${PATH}
2181 # TODO we will probably want to set JAVAC and JAVACFLAGS
2184 java-pkg_check-jikes
2186 # Can't use unset here because Portage does not save the unset
2187 # see https://bugs.gentoo.org/show_bug.cgi?id=189417#c11
2189 # When users have crazy classpaths some packages can fail to compile.
2190 # and everything should work with empty CLASSPATH.
2191 # This also helps prevent unexpected dependencies on random things
2192 # from the CLASSPATH.
2195 # Unset external ANT_ stuff
2198 export ANT_RESPECT_JAVA_HOME=
2201 # @FUNCTION: java-pkg-init-compiler_
2204 # This function attempts to figure out what compiler should be used. It does
2205 # this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
2206 # COMPILERS variable defined there.
2207 # This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
2209 # It will go through the list of compilers, and verify that it supports the
2210 # target and source that are needed. If it is not suitable, then the next
2211 # compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
2214 # Once the which compiler to use has been figured out, it is set to
2217 # If you hadn't guessed, JAVA_PKG_FORCE_COMPILER is for testing only.
2219 # If the user doesn't defined anything in JAVA_PKG_COMPILERS_CONF, or no
2220 # suitable compiler was found there, then the default is to use javac provided
2221 # by the current VM.
2224 # @RETURN name of the compiler to use
2225 java-pkg_init-compiler_() {
2226 debug-print-function ${FUNCNAME} $*
2228 if [[ -n ${GENTOO_COMPILER} ]]; then
2229 debug-print "GENTOO_COMPILER already set"
2234 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
2235 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
2237 compilers=${JAVA_PKG_FORCE_COMPILER}
2240 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
2242 # Figure out if we should announce what compiler we're using
2244 for compiler in ${compilers}; do
2245 debug-print "Checking ${compiler}..."
2246 # javac should always be alright
2247 if [[ ${compiler} = "javac" ]]; then
2248 debug-print "Found javac... breaking"
2249 export GENTOO_COMPILER="javac"
2253 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
2254 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
2255 einfo "Filtering ${compiler}" >&2
2260 # for non-javac, we need to make sure it supports the right target and
2262 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
2263 if [[ -f ${compiler_env} ]]; then
2264 local desired_target="$(java-pkg_get-target)"
2265 local desired_source="$(java-pkg_get-source)"
2268 # Verify that the compiler supports target
2269 local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET})
2270 if ! has ${desired_target} ${supported_target}; then
2271 ewarn "${compiler} does not support -target ${desired_target}, skipping"
2275 # Verify that the compiler supports source
2276 local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
2277 if ! has ${desired_source} ${supported_source}; then
2278 ewarn "${compiler} does not support -source ${desired_source}, skipping"
2282 # if you get here, then the compiler should be good to go
2283 export GENTOO_COMPILER="${compiler}"
2286 ewarn "Could not find configuration for ${compiler}, skipping"
2287 ewarn "Perhaps it is not installed?"
2292 # If it hasn't been defined already, default to javac
2293 if [[ -z ${GENTOO_COMPILER} ]]; then
2294 if [[ -n ${compilers} ]]; then
2295 einfo "No suitable compiler found: defaulting to JDK default for compilation" >&2
2297 # probably don't need to notify users about the default.
2298 :;#einfo "Defaulting to javac for compilation" >&2
2300 if java-config -g GENTOO_COMPILER 2> /dev/null; then
2301 export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER)
2303 export GENTOO_COMPILER=javac
2306 einfo "Using ${GENTOO_COMPILER} for compilation" >&2
2311 # @FUNCTION: init_paths_
2314 # Initializes some variables that will be used. These variables are mostly used
2315 # to determine where things will eventually get installed.
2316 java-pkg_init_paths_() {
2317 debug-print-function ${FUNCNAME} $*
2320 if [[ "${SLOT%/*}" == "0" ]] ; then
2321 JAVA_PKG_NAME="${PN}"
2323 JAVA_PKG_NAME="${PN}-${SLOT%/*}"
2326 JAVA_PKG_SHAREPATH="${DESTTREE}/share/${JAVA_PKG_NAME}"
2327 JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/"
2328 JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env"
2329 JAVA_PKG_VIRTUALS_PATH="${DESTTREE}/share/java-config-2/virtuals"
2330 JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}"
2332 [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib"
2333 [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="${DESTTREE}/$(get_libdir)/${JAVA_PKG_NAME}"
2334 [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps"
2336 # TODO maybe only print once?
2337 debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}"
2338 debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}"
2339 debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}"
2340 debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}"
2341 debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
2344 # @FUNCTION: java-pkg_do_write_
2347 # Writes the package.env out to disk.
2349 # TODO change to do-write, to match everything else
2350 java-pkg_do_write_() {
2351 debug-print-function ${FUNCNAME} $*
2352 java-pkg_init_paths_
2353 # Create directory for package.env
2354 dodir "${JAVA_PKG_SHAREPATH}"
2355 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2356 "${JAVA_PKG_DEPEND_FILE}" || -f \
2357 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2358 # Create package.env
2360 echo "DESCRIPTION=\"${DESCRIPTION}\""
2361 echo "GENERATION=\"2\""
2362 echo "SLOT=\"${SLOT}\""
2363 echo "CATEGORY=\"${CATEGORY}\""
2364 echo "PVR=\"${PVR}\""
2366 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2367 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2368 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2369 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2370 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2371 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2372 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2373 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2374 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2375 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2376 ) > "${JAVA_PKG_ENV}"
2378 # register target/source
2379 local target="$(java-pkg_get-target)"
2380 local source="$(java-pkg_get-source)"
2381 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
2382 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
2384 # register javadoc info
2385 [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \
2387 # register source archives
2388 [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \
2392 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2393 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2395 # extra env variables
2396 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2397 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2398 # nested echo to remove leading/trailing spaces
2399 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2400 >> "${JAVA_PKG_ENV}" || die
2403 # Strip unnecessary leading and trailing colons
2404 # TODO try to cleanup if possible
2405 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2407 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2408 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2409 debug-print "write package.env."
2413 # @FUNCTION: java-pkg_record-jar_
2416 # Record an (optional) dependency to the package.env
2419 # --optional - record dependency as optional
2420 # --build - record dependency as build_only
2421 # $1 - package to record
2422 # $2 - (optional) jar of package to record
2424 JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2425 JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2426 JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2428 java-pkg_record-jar_() {
2429 debug-print-function ${FUNCNAME} $*
2431 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2433 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2434 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2437 local pkg=${1} jar=${2} append
2438 if [[ -z "${jar}" ]]; then
2441 append="$(basename ${jar})@${pkg}"
2444 echo "${append}" >> "${depend_file}"
2447 # @FUNCTION: java-pkg_append_
2450 # Appends a value to a variable
2454 # $1 variable name to modify
2455 # $2 value to append
2458 # java-pkg_append_ CLASSPATH foo.jar
2460 java-pkg_append_() {
2461 debug-print-function ${FUNCNAME} $*
2463 local var="${1}" value="${2}"
2464 if [[ -z "${!var}" ]] ; then
2465 export ${var}="${value}"
2467 local oldIFS=${IFS} cur haveit
2469 for cur in ${!var}; do
2470 if [[ ${cur} == ${value} ]]; then
2475 [[ -z ${haveit} ]] && export ${var}="${!var}:${value}"
2480 # @FUNCTION: java-pkg_expand_dir_
2483 # Gets the full path of the file/directory's parent.
2486 # $1 - file/directory to find parent directory for
2488 # @RETURN: path to $1's parent directory
2489 java-pkg_expand_dir_() {
2490 pushd "$(dirname "${1}")" >/dev/null 2>&1 || die
2492 popd >/dev/null 2>&1 || die
2495 # @FUNCTION: java-pkg_func-exists
2498 # Does the indicated function exist?
2499 # @RETURN: 0 - function is declared, 1 - function is undeclared
2500 java-pkg_func-exists() {
2501 declare -F ${1} > /dev/null
2504 # @FUNCTION: java-pkg_setup-vm
2507 # Sets up the environment for a specific VM
2508 java-pkg_setup-vm() {
2509 debug-print-function ${FUNCNAME} $*
2511 local vendor="$(java-pkg_get-vm-vendor)"
2512 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2513 addpredict "/dev/random"
2514 elif [[ "${vendor}" == "ibm" ]]; then
2515 addpredict "/proc/self/maps"
2516 addpredict "/proc/cpuinfo"
2517 addpredict "/proc/self/coredump_filter"
2518 elif [[ "${vendor}" == "oracle" ]]; then
2519 addpredict "/dev/random"
2520 addpredict "/proc/self/coredump_filter"
2521 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2522 addpredict "/dev/random"
2523 addpredict "/proc/self/coredump_filter"
2524 elif [[ "${vendor}" == "jrockit" ]]; then
2525 addpredict "/proc/cpuinfo"
2529 # @FUNCTION: java-pkg_needs-vm
2532 # Does the current package depend on virtual/jdk or does it set
2533 # JAVA_PKG_WANT_BUILD_VM?
2535 # @RETURN: 0 - Package depends on virtual/jdk; 1 - Package does not depend on virtual/jdk
2536 java-pkg_needs-vm() {
2537 debug-print-function ${FUNCNAME} $*
2539 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2543 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2548 # @FUNCTION: java-pkg_get-current-vm
2550 # @RETURN - The current VM being used
2551 java-pkg_get-current-vm() {
2555 # @FUNCTION: java-pkg_get-vm-vendor
2557 # @RETURN - The vendor of the current VM
2558 java-pkg_get-vm-vendor() {
2559 debug-print-function ${FUNCNAME} $*
2561 local vm="$(java-pkg_get-current-vm)"
2566 # @FUNCTION: java-pkg_get-vm-version
2568 # @RETURN - The version of the current VM
2569 java-pkg_get-vm-version() {
2570 debug-print-function ${FUNCNAME} $*
2572 java-config -g PROVIDES_VERSION
2575 # @FUNCTION: java-pkg_build-vm-from-handle
2578 # Selects a build vm from a list of vm handles. First checks for the system-vm
2579 # beeing usable, then steps through the listed handles till a suitable vm is
2582 # @RETURN - VM handle of an available JDK
2583 java-pkg_build-vm-from-handle() {
2584 debug-print-function ${FUNCNAME} "$*"
2587 vm=$(java-pkg_get-current-vm 2>/dev/null)
2588 if [[ $? -eq 0 ]]; then
2589 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2595 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2596 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2602 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2606 # @FUNCTION: java-pkg_switch-vm
2609 # Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
2610 # verify that the current VM is sufficient.
2611 # Setup the environment for the VM being used.
2612 java-pkg_switch-vm() {
2613 debug-print-function ${FUNCNAME} $*
2615 if java-pkg_needs-vm; then
2616 # Use the VM specified by JAVA_PKG_FORCE_VM
2617 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
2618 # If you're forcing the VM, I hope you know what your doing...
2619 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2620 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2621 # if we're allowed to switch the vm...
2622 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2623 # if there is an explicit list of handles to choose from
2624 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2625 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2626 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2627 if [[ $? != 0 ]]; then
2628 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2629 die "${FUNCNAME}: Failed to determine VM for building"
2631 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2632 # they can't be deduced from handles.
2633 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2634 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2635 die "Specify JAVA_PKG_WANT_SOURCE"
2637 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2638 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2639 die "Specify JAVA_PKG_WANT_TARGET"
2641 # otherwise determine a vm from dep string
2643 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2644 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2645 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2646 eerror "Unable to determine VM for building from dependencies:"
2647 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2648 die "Failed to determine VM for building."
2652 # otherwise just make sure the current VM is sufficient
2654 java-pkg_ensure-vm-version-sufficient
2656 debug-print "Using: $(java-config -f)"
2660 export JAVA=$(java-config --java)
2661 export JAVAC=$(java-config --javac)
2662 JAVACFLAGS="$(java-pkg_javac-args)"
2663 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
2666 export JAVA_HOME="$(java-config -g JAVA_HOME)"
2667 export JDK_HOME=${JAVA_HOME}
2669 #TODO If you know a better solution let us know.
2670 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2672 local tann="${T}/announced-vm"
2673 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2674 # if people have for example modified eclasses some where
2675 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2676 einfo "Using: $(java-config -f)"
2677 [[ ! -f "${tann}" ]] && touch "${tann}"
2681 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2685 # @FUNCTION: java-pkg_die
2688 # Enhanced die for Java packages, which displays some information that may be
2689 # useful for debugging bugs on bugzilla.
2690 #register_die_hook java-pkg_die
2691 if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2692 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2696 echo "!!! When you file a bug report, please include the following information:" >&2
2697 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
2698 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
2699 echo "and of course, the output of emerge --info =${P}" >&2
2704 # List jars in the source directory, ${S}
2705 java-pkg_jar-list() {
2706 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
2708 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2710 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2712 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
2716 # @FUNCTION: java-pkg_verify-classes
2719 # Verify that the classes were compiled for the right source / target. Dies if
2722 # $1 (optional) - the file to check, otherwise checks whole ${D}
2724 java-pkg_verify-classes() {
2725 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
2727 local version_verify="/usr/bin/class-version-verify.py"
2729 if [[ ! -x "${version_verify}" ]]; then
2730 version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py"
2733 if [[ ! -x "${version_verify}" ]]; then
2734 ewarn "Unable to perform class version checks as"
2735 ewarn "class-version-verify.py is unavailable"
2736 ewarn "Please install dev-java/javatoolkit."
2740 local target=$(java-pkg_get-target)
2742 local log="${T}/class-version-verify.log"
2743 if [[ -n "${1}" ]]; then
2744 ${version_verify} -v -t ${target} "${1}" > "${log}"
2747 ebegin "Verifying java class versions (target: ${target})"
2748 ${version_verify} -v -t ${target} -r "${D}" > "${log}"
2752 [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}"
2753 if [[ ${result} != 0 ]]; then
2754 eerror "Incorrect bytecode version found"
2755 [[ -n "${1}" ]] && eerror "in file: ${1}"
2756 eerror "See ${log} for more details."
2757 die "Incorrect bytecode found"
2761 # @FUNCTION: java-pkg_ensure-dep
2764 # Check that a package being used in jarfrom, getjars and getjar is contained
2765 # within DEPEND or RDEPEND with the correct SLOT. See this mail for details:
2766 # https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e
2769 # $1 - empty - check both vars; "runtime" or "build" - check only
2770 # RDEPEND, resp. DEPEND
2771 # $2 - Package name and slot.
2773 java-pkg_ensure-dep() {
2774 debug-print-function ${FUNCNAME} $*
2776 local limit_to="${1}"
2777 local target_pkg="${2}"
2780 # Transform into a regular expression to look for a matching package
2781 # and SLOT. SLOTs don't have to be numeric so foo-bar could either
2782 # mean foo-bar:0 or foo:bar. So you want to get your head around the
2785 # * The target package first has any dots escaped, e.g. foo-1.2
2788 # * sed then looks at the component following the last - or :
2789 # character, or the whole string if there is no - or :
2790 # character. It uses this to build a new regexp with two
2791 # significant branches.
2793 # * The first checks for the whole target package string, optionally
2794 # followed by a version number, and then :0.
2796 # * The second checks for the first part of the target package
2797 # string, optionally followed by a version number, followed by the
2798 # aforementioned component, treating that as a SLOT.
2800 local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b
2802 debug-print "Matching against: ${stripped_pkg}"
2804 # Uncomment the lines below once we've dealt with more of these
2805 # otherwise we'll be tempted to turn JAVA_PKG_STRICT off while
2806 # getting hit with a wave of bug reports. :(
2808 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
2809 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2810 dev_error+="declared with a SLOT in DEPEND."
2811 # if is-java-strict; then
2812 # die "${dev_error}"
2814 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2815 # eerror "Because you have ${target_pkg} installed,"
2816 # eerror "the package will build without problems, but please"
2817 # eerror "report this to https://bugs.gentoo.org."
2819 elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
2820 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2821 dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given."
2822 # if is-java-strict; then
2823 # die "${dev_error}"
2825 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2826 # eerror "The package will build without problems, but may fail to run"
2827 # eerror "if you don't have ${target_pkg} installed,"
2828 # eerror "so please report this to https://bugs.gentoo.org."
2833 java-pkg_check-phase() {
2835 local funcname=${FUNCNAME[1]}
2836 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2837 local msg="${funcname} used outside of src_${phase}"
2838 java-pkg_announce-qa-violation "${msg}"
2842 java-pkg_check-versioned-jar() {
2845 if [[ ${jar} =~ ${PV} ]]; then
2846 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2850 java-pkg_check-jikes() {
2851 if has jikes ${IUSE}; then
2852 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2856 java-pkg_announce-qa-violation() {
2858 if [[ ${1} == "--nodie" ]]; then
2862 echo "Java QA Notice: $@" >&2
2863 increment-qa-violations
2864 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2867 increment-qa-violations() {
2868 let "JAVA_PKG_QA_VIOLATIONS+=1"
2869 export JAVA_PKG_QA_VIOLATIONS
2873 [[ -n ${JAVA_PKG_STRICT} ]]
2877 # @FUNCTION: java-pkg_clean
2879 # Java package cleaner function. This will remove all *.class and *.jar
2880 # files, removing any bundled dependencies.
2882 if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then
2883 find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die