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