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

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

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

Revision 1.160 Revision 1.168
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2015, Gentoo Foundation 5# Copyright (c) 2004-2015, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.160 2015/05/02 20:23:56 chewi Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.168 2015/07/31 07:56:17 monsieurp Exp $
10 10
11# @ECLASS: java-utils-2.eclass 11# @ECLASS: java-utils-2.eclass
12# @MAINTAINER: 12# @MAINTAINER:
13# java@gentoo.org 13# java@gentoo.org
14# @AUTHOR: 14# @AUTHOR:
41# @INTERNAL 41# @INTERNAL
42# @DESCRIPTION: 42# @DESCRIPTION:
43# This is a convience variable to be used from the other java eclasses. This is 43# This is a convience variable to be used from the other java eclasses. This is
44# the version of java-config we want to use. Usually the latest stable version 44# the version of java-config we want to use. Usually the latest stable version
45# so that ebuilds can use new features without depending on specific versions. 45# so that ebuilds can use new features without depending on specific versions.
46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}" 46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0 ${JAVA_PKG_PORTAGE_DEP}"
47has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 47has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
48 48
49# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH 49# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
50# @DEFAULT_UNSET 50# @DEFAULT_UNSET
51# @DESCRIPTION: 51# @DESCRIPTION:
122# Should generallyonly be used for testing and debugging. 122# Should generallyonly be used for testing and debugging.
123# 123#
124# emerge bar to be compatible with 1.3 124# emerge bar to be compatible with 1.3
125# @CODE 125# @CODE
126# JAVA_PKG_WANT_TARGET=1.3 emerge bar 126# JAVA_PKG_WANT_TARGET=1.3 emerge bar
127# @CODE
128
129# @ECLASS-VARIABLE: JAVA_RM_FILES
130# @DEFAULT_UNSET
131# @DESCRIPTION:
132# An array containing a list of files to remove. If defined, this array will be
133# automatically handed over to java-pkg_rm_files for processing during the
134# src_prepare phase.
135#
136# @CODE
137# JAVA_RM_FILES=(
138# path/to/File1.java
139# DELETEME.txt
140# )
127# @CODE 141# @CODE
128 142
129# @VARIABLE: JAVA_PKG_COMPILER_DIR 143# @VARIABLE: JAVA_PKG_COMPILER_DIR
130# @INTERNAL 144# @INTERNAL
131# @DESCRIPTION: 145# @DESCRIPTION:
213 ) || die "Installing examples failed" 227 ) || die "Installing examples failed"
214 fi 228 fi
215 229
216 # Let's make a symlink to the directory we have everything else under 230 # Let's make a symlink to the directory we have everything else under
217 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die 231 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
232}
233
234# @FUNCTION: java-pkg_addres
235# @USAGE: <jar> <dir> [<find arguments> ...]
236# @DESCRIPTION:
237# Adds resource files to an existing jar.
238# It is important that the directory given is actually the root of the
239# corresponding resource tree. The target directory as well as
240# sources.lst, MANIFEST.MF, *.class, *.jar, and *.java files are
241# automatically excluded. Symlinks are always followed. Additional
242# arguments are passed through to find.
243#
244# @CODE
245# java-pkg_addres ${PN}.jar resources ! -name "*.html"
246# @CODE
247#
248# @param $1 - jar file
249# @param $2 - resource tree directory
250# @param $* - arguments to pass to find
251java-pkg_addres() {
252 debug-print-function ${FUNCNAME} $*
253
254 [[ ${#} -lt 2 ]] && die "at least two arguments needed"
255
256 local jar=$(realpath "$1" || die "realpath $1 failed")
257 local dir="$2"
258 shift 2
259
260 pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
261 find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -0 jar uf "${jar}" || die "jar failed"
262 popd > /dev/null || die "popd failed"
263}
264
265# @FUNCTION: java-pkg_rm_files
266# @USAGE: java-pkg_rm_files File1.java File2.java ...
267# @DESCRIPTION:
268# Remove unneeded files in ${S}.
269#
270# Every now and then, you'll run into situations whereby a file needs removing,
271# be it a unit test or a regular java class.
272#
273# You can use this function by either:
274# - calling it yourself in java_prepare() and feeding java-pkg_rm_files with
275# the list of files you wish to remove.
276# - defining an array in the ebuild named JAVA_RM_FILES with the list of files
277# you wish to remove.
278#
279# Both way work and it is left to the developer's preferences. If the
280# JAVA_RM_FILES array is defined, it will be automatically handed over to
281# java-pkg_rm_files during the src_prepare phase.
282#
283# See java-utils-2_src_prepare.
284#
285# @CODE
286# java-pkg_rm_files File1.java File2.java
287# @CODE
288#
289# @param $* - list of files to remove.
290java-pkg_rm_files() {
291 debug-print-function ${FUNCNAME} $*
292 local IFS="\n"
293 for filename in "$@"; do
294 [[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting."
295 einfo "Removing unneeded file ${filename}"
296 rm -f "${S}/${filename}" || die "cannot remove ${filename}"
297 eend $?
298 done
218} 299}
219 300
220# @FUNCTION: java-pkg_dojar 301# @FUNCTION: java-pkg_dojar
221# @USAGE: <jar1> [<jar2> ...] 302# @USAGE: <jar1> [<jar2> ...]
222# @DESCRIPTION: 303# @DESCRIPTION:
278 die "${jar} does not exist" 359 die "${jar} does not exist"
279 fi 360 fi
280 done 361 done
281 362
282 java-pkg_do_write_ 363 java-pkg_do_write_
283}
284
285# @FUNCTION: depend-java-query
286# @INTERNAL
287# @DESCRIPTION:
288# Wrapper for the depend-java-query binary to enable passing USE in env.
289# Using env variables keeps this eclass working with java-config versions that
290# do not handle use flags.
291depend-java-query() {
292 # Used to have a which call here but it caused endless loops for some people
293 # that had some weird bashrc voodoo for which.
294 USE="${USE}" /usr/bin/depend-java-query "${@}"
295} 364}
296 365
297# @FUNCTION: java-pkg_regjar 366# @FUNCTION: java-pkg_regjar
298# @USAGE: </path/to/installed/jar> 367# @USAGE: </path/to/installed/jar>
299# @DESCRIPTION: 368# @DESCRIPTION:
1571 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1640 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1572 debug-print "could not find valid -source/-target values for javac" 1641 debug-print "could not find valid -source/-target values for javac"
1573 echo "Could not find valid -source/-target values for javac" 1642 echo "Could not find valid -source/-target values for javac"
1574 return 1 1643 return 1
1575 else 1644 else
1576 if java-pkg_is-vm-version-ge "1.4"; then
1577 echo "${source_str} ${target_str}" 1645 echo "${source_str} ${target_str}"
1578 else
1579 echo "${target_str}"
1580 fi
1581 fi 1646 fi
1582} 1647}
1583 1648
1584# @FUNCTION: java-pkg_get-jni-cflags 1649# @FUNCTION: java-pkg_get-jni-cflags
1585# @DESCRIPTION: 1650# @DESCRIPTION:
1762# @FUNCTION: java-utils-2_src_prepare 1827# @FUNCTION: java-utils-2_src_prepare
1763# @DESCRIPTION: 1828# @DESCRIPTION:
1764# src_prepare Searches for bundled jars 1829# src_prepare Searches for bundled jars
1765# Don't call directly, but via java-pkg-2_src_prepare! 1830# Don't call directly, but via java-pkg-2_src_prepare!
1766java-utils-2_src_prepare() { 1831java-utils-2_src_prepare() {
1767 [[ ${EBUILD_PHASE} == prepare ]] &&
1768 java-pkg_func-exists java_prepare && java_prepare 1832 java-pkg_func-exists java_prepare && java_prepare
1769 1833
1770 # Remember that eant will call this unless called via Portage 1834 # Check for files in JAVA_RM_FILES array.
1771 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then 1835 if [[ ${JAVA_RM_FILES[@]} ]]; then
1836 debug-print "$FUNCNAME: removing unneeded files"
1837 java-pkg_rm_files "${JAVA_RM_FILES[@]}"
1838 fi
1839
1840 if is-java-strict; then
1772 echo "Searching for bundled jars:" 1841 echo "Searching for bundled jars:"
1773 java-pkg_find-normal-jars || echo "None found." 1842 java-pkg_find-normal-jars || echo "None found."
1774 echo "Searching for bundled classes (no output if none found):" 1843 echo "Searching for bundled classes (no output if none found):"
1775 find "${WORKDIR}" -name "*.class" 1844 find "${WORKDIR}" -name "*.class"
1776 echo "Search done." 1845 echo "Search done."
1777 fi 1846 fi
1778 touch "${T}/java-utils-2_src_prepare-run"
1779} 1847}
1780 1848
1781# @FUNCTION: java-utils-2_pkg_preinst 1849# @FUNCTION: java-utils-2_pkg_preinst
1782# @DESCRIPTION: 1850# @DESCRIPTION:
1783# pkg_preinst Searches for missing and unneeded dependencies 1851# pkg_preinst Searches for missing and unneeded dependencies
1816eant() { 1884eant() {
1817 debug-print-function ${FUNCNAME} $* 1885 debug-print-function ${FUNCNAME} $*
1818 1886
1819 if [[ ${EBUILD_PHASE} = compile ]]; then 1887 if [[ ${EBUILD_PHASE} = compile ]]; then
1820 java-ant-2_src_configure 1888 java-ant-2_src_configure
1821 java-utils-2_src_prepare
1822 fi 1889 fi
1823 1890
1824 if ! has java-ant-2 ${INHERITED}; then 1891 if ! has java-ant-2 ${INHERITED}; then
1825 local msg="You should inherit java-ant-2 when using eant" 1892 local msg="You should inherit java-ant-2 when using eant"
1826 java-pkg_announce-qa-violation "${msg}" 1893 java-pkg_announce-qa-violation "${msg}"
1913 fi 1980 fi
1914 1981
1915 local cp 1982 local cp
1916 1983
1917 for atom in ${gcp}; do 1984 for atom in ${gcp}; do
1918 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 1985 cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})"
1919 done 1986 done
1920 1987
1921 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)" 1988 [[ ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)"
1989 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}"
1922 1990
1923 if [[ ${cp} ]]; then 1991 if [[ ${cp#:} ]]; then
1924 # It seems ant does not like single quotes around ${cp} 1992 # It seems ant does not like single quotes around ${cp}
1925 cp=${cp#:}
1926 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
1927 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1928 antflags="${antflags} -Dgentoo.classpath=\"${cp}\"" 1993 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\""
1929 fi 1994 fi
1930 1995
1931 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1996 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1932 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 1997 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1933 ant ${antflags} "${@}" || die "eant failed" 1998 ant ${antflags} "${@}" || die "eant failed"
2171 if ! has ${desired_target} ${supported_target}; then 2236 if ! has ${desired_target} ${supported_target}; then
2172 ewarn "${compiler} does not support -target ${desired_target}, skipping" 2237 ewarn "${compiler} does not support -target ${desired_target}, skipping"
2173 continue 2238 continue
2174 fi 2239 fi
2175 2240
2176 # -source was introduced in 1.3, so only check 1.3 and on
2177 if version_is_at_least "${desired_soure}" "1.3"; then
2178 # Verify that the compiler supports source 2241 # Verify that the compiler supports source
2179 local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE}) 2242 local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE})
2180 if ! has ${desired_source} ${supported_source}; then 2243 if ! has ${desired_source} ${supported_source}; then
2181 ewarn "${compiler} does not support -source ${desired_source}, skipping" 2244 ewarn "${compiler} does not support -source ${desired_source}, skipping"
2182 continue 2245 continue
2183 fi
2184 fi 2246 fi
2185 2247
2186 # if you get here, then the compiler should be good to go 2248 # if you get here, then the compiler should be good to go
2187 export GENTOO_COMPILER="${compiler}" 2249 export GENTOO_COMPILER="${compiler}"
2188 break 2250 break

Legend:
Removed from v.1.160  
changed lines
  Added in v.1.168

  ViewVC Help
Powered by ViewVC 1.1.20