/[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.5 Revision 1.10
33# ----------------------------------------------------------------------------- 33# -----------------------------------------------------------------------------
34 34
35# Make sure we use java-config-2 35# Make sure we use java-config-2
36export WANT_JAVA_CONFIG="2" 36export WANT_JAVA_CONFIG="2"
37 37
38# TODO document
39JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1"
40
38# ----------------------------------------------------------------------------- 41# -----------------------------------------------------------------------------
39# @variable-internal JAVA_PKG_E_DEPEND 42# @variable-internal JAVA_PKG_E_DEPEND
40# 43#
41# This is a convience variable to be used from the other java eclasses. This is 44# This is a convience variable to be used from the other java eclasses. This is
42# the version of java-config we want to use. We also need a recent version 45# the version of java-config we want to use. We also need a recent version
43# portage, that includes phase hooks. 46# portage, that includes phase hooks.
44# ----------------------------------------------------------------------------- 47# -----------------------------------------------------------------------------
45JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 >=sys-apps/portage-2.1_pre1" 48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
46 49
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 51# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
49# @variable-default yes 52# @variable-default yes
50# 53#
226# 229#
227# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
228# 231#
229# @param $@ - jars to record 232# @param $@ - jars to record
230# ------------------------------------------------------------------------------ 233# ------------------------------------------------------------------------------
231# TODO fix me! 234# TODO should we be making sure the jar is present on ${D} or wherever?
232java-pkg_regjar() { 235java-pkg_regjar() {
233 debug-print-function ${FUNCNAME} $* 236 debug-print-function ${FUNCNAME} $*
234 237
235 java-pkg_check-phase install 238 java-pkg_check-phase install
236 239
276 local original_jar="${1}" 279 local original_jar="${1}"
277 local new_jar="${2:-${PN}.jar}" 280 local new_jar="${2:-${PN}.jar}"
278 local new_jar_dest="${T}/${new_jar}" 281 local new_jar_dest="${T}/${new_jar}"
279 282
280 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 283 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
281 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
282 285
283 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}" 286 rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}"
284 cp "${original_jar}" "${new_jar_dest}" \ 287 cp "${original_jar}" "${new_jar_dest}" \
285 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 288 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
286 java-pkg_dojar "${new_jar_dest}" 289 java-pkg_dojar "${new_jar_dest}"
1160 1163
1161# TODO document 1164# TODO document
1162java-pkg_get-jni-cflags() { 1165java-pkg_get-jni-cflags() {
1163 local flags="-I${JAVA_HOME}/include" 1166 local flags="-I${JAVA_HOME}/include"
1164 1167
1168 # TODO do a check that the directories are valid
1165 # TODO figure out how to cope with other things than linux... 1169 # TODO figure out how to cope with other things than linux...
1166 flags="${flags} -I${JAVA_HOME}/include/linux" 1170 flags="${flags} -I${JAVA_HOME}/include/linux"
1167 1171
1168 echo ${flags} 1172 echo ${flags}
1173}
1174
1175java-pkg_ensure-gcj() {
1176 if ! built_with_use sys-devel/gcc gcj ; then
1177 ewarn
1178 ewarn "You must build gcc with the gcj support to build with gcj"
1179 ewarn
1180 ebeep 5
1181 die "No GCJ support found!"
1182 fi
1169} 1183}
1170 1184
1171# ------------------------------------------------------------------------------ 1185# ------------------------------------------------------------------------------
1172# @section-end helper 1186# @section-end helper
1173# ------------------------------------------------------------------------------ 1187# ------------------------------------------------------------------------------
1210 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1224 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1211 if [[ -n ${build_compiler_deps} ]]; then 1225 if [[ -n ${build_compiler_deps} ]]; then
1212 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1226 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1213 fi 1227 fi
1214 fi 1228 fi
1229
1230 if is-java-strict; then
1231 einfo "Disabling system classpath for ant"
1232 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1233 fi
1215 1234
1216 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1235 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1217 antflags="${antflags} -debug" 1236 antflags="${antflags} -debug"
1218 fi 1237 fi
1219 1238
1231# @param $@ - Arguments to be passed to the compiler 1250# @param $@ - Arguments to be passed to the compiler
1232# ------------------------------------------------------------------------------ 1251# ------------------------------------------------------------------------------
1233ejavac() { 1252ejavac() {
1234 debug-print-function ${FUNCNAME} $* 1253 debug-print-function ${FUNCNAME} $*
1235 1254
1255 # FIXME using get-javac ends up printing stuff with einfo
1236 local compiler_executable=$(java-pkg_get-javac) 1256# local compiler_executable=$(java-pkg_get-javac)
1257 local compiler_executable="javac"
1237 1258
1238 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1259 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}"
1239 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1260 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1240} 1261}
1241 1262
1247# 1268#
1248# @param $@ - compilers to filter 1269# @param $@ - compilers to filter
1249# ------------------------------------------------------------------------------ 1270# ------------------------------------------------------------------------------
1250java-pkg_filter-compiler() { 1271java-pkg_filter-compiler() {
1251 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1272 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1273}
1274
1275# ------------------------------------------------------------------------------
1276# @ebuild-function java-pkg_force-compiler
1277#
1278# Used to force the use of particular compilers. Should be used in src_compile.
1279# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1280# OutOfMemoryErrors that may come up.
1281#
1282# @param $@ - compilers to force
1283# ------------------------------------------------------------------------------
1284java-pkg_force-compiler() {
1285 JAVA_PKG_FORCE_COMPILER="$@"
1252} 1286}
1253 1287
1254# ------------------------------------------------------------------------------ 1288# ------------------------------------------------------------------------------
1255# @ebuild-function use_doc 1289# @ebuild-function use_doc
1256# 1290#
1727 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1761 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1728 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1762 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1729 echo "and of course, the output of emerge --info" >&2 1763 echo "and of course, the output of emerge --info" >&2
1730} 1764}
1731 1765
1766
1767# TODO document
1768# List jars in the source directory, ${S}
1769java-pkg_jar-list() {
1770 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1771 einfo "Linked Jars"
1772 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1773 einfo "Jars"
1774 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1775 einfo "Classes"
1776 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1777 fi
1778}
1779
1780# TODO document
1781# Verify that the classes were compiled for the right source / target
1782java-pkg_verify-classes() {
1783 ebegin "Verifying java class versions"
1784 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1785 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1786 result=$?
1787 eend ${result}
1788 if [[ ${result} == 0 ]]; then
1789 einfo "All good"
1790 else
1791 ewarn "Possible problem"
1792 die "Bad class files found"
1793 fi
1794}
1795
1796
1732# ------------------------------------------------------------------------------ 1797# ------------------------------------------------------------------------------
1733# @section-end internal 1798# @section-end internal
1734# ------------------------------------------------------------------------------ 1799# ------------------------------------------------------------------------------
1735 1800
1736java-pkg_check-phase() { 1801java-pkg_check-phase() {
1737 local phase=${1} 1802 local phase=${1}
1738 local funcname=${2} 1803 local funcname=${2}
1739 # TODO add check for java-stricter
1740 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1804 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1741 java-pkg_announce-qa-violation \ 1805 java-pkg_announce-qa-violation \
1742 "${funcname} used outside of src_${phase}" 1806 "${funcname} used outside of src_${phase}"
1743 fi 1807 fi
1744} 1808}
1745 1809
1756 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1820 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1757 fi 1821 fi
1758} 1822}
1759 1823
1760java-pkg_announce-qa-violation() { 1824java-pkg_announce-qa-violation() {
1761 if hasq java-strict ${FEATURES}; then 1825 if is-java-strict; then
1762 echo "Java QA Notice: $@" >&2 1826 echo "Java QA Notice: $@" >&2
1763 increment-qa-violations 1827 increment-qa-violations
1764 fi 1828 fi
1765} 1829}
1766 1830
1767increment-qa-violations() { 1831increment-qa-violations() {
1768 let "JAVA_PKG_QA_VIOLATIONS+=1" 1832 let "JAVA_PKG_QA_VIOLATIONS+=1"
1769 export JAVA_PKG_QA_VIOLATIONS 1833 export JAVA_PKG_QA_VIOLATIONS
1770} 1834}
1771 1835
1836is-java-strict() {
1837 hasq java-strict ${FEATURES};
1838 return $?
1839}
1840
1772# ------------------------------------------------------------------------------ 1841# ------------------------------------------------------------------------------
1773# @eclass-end 1842# @eclass-end
1774# ------------------------------------------------------------------------------ 1843# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20