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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.165

  ViewVC Help
Powered by ViewVC 1.1.20