/[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.3 Revision 1.12
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#
206# Records an already installed jar in the package.env 209# Records an already installed jar in the package.env
207# This would mostly be used if the package has make or a custom script to 210# This would mostly be used if the package has make or a custom script to
208# install things. 211# install things.
209# 212#
210# Example: 213# Example:
211# java-pkg-regjar ${D}/opt/foo/lib/foo.jar 214# java-pkg_regjar ${D}/opt/foo/lib/foo.jar
215#
216# WARNING:
217# if you want to use shell expansion, you have to use ${D}/... as the for in
218# this function will not be able to expand the path, here's an example:
219#
220# java-pkg_regjar /opt/my-java/lib/*.jar
221#
222# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist
227#
228# you have to use it as:
229#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
212# 231#
213# @param $@ - jars to record 232# @param $@ - jars to record
214# ------------------------------------------------------------------------------ 233# ------------------------------------------------------------------------------
215# TODO fix me! 234# TODO should we be making sure the jar is present on ${D} or wherever?
216java-pkg_regjar() { 235java-pkg_regjar() {
217 debug-print-function ${FUNCNAME} $* 236 debug-print-function ${FUNCNAME} $*
218 237
219 java-pkg_check-phase install 238 java-pkg_check-phase install
220 239
224 243
225 local jar jar_dir jar_file 244 local jar jar_dir jar_file
226 for jar in "$@"; do 245 for jar in "$@"; do
227 # TODO use java-pkg_check-versioned-jar 246 # TODO use java-pkg_check-versioned-jar
228 if [[ -e "${jar}" ]]; then 247 if [[ -e "${jar}" ]]; then
248 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env
229 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar}" 253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
230 elif [[ -e "${D}${jar}" ]]; then 254 elif [[ -e "${D}${jar}" ]]; then
231 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
232 else 256 else
233 die "${jar} does not exist" 257 die "${jar} does not exist"
234 fi 258 fi
255 local original_jar="${1}" 279 local original_jar="${1}"
256 local new_jar="${2:-${PN}.jar}" 280 local new_jar="${2:-${PN}.jar}"
257 local new_jar_dest="${T}/${new_jar}" 281 local new_jar_dest="${T}/${new_jar}"
258 282
259 [[ -z ${original_jar} ]] && die "Must specify a jar to install" 283 [[ -z ${original_jar} ]] && die "Must specify a jar to install"
260 [[ ! -f ${original_jar} ]] && die "${new_jar} does not exist!" 284 [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist!"
261 285
262 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}"
263 cp "${original_jar}" "${new_jar_dest}" \ 287 cp "${original_jar}" "${new_jar_dest}" \
264 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 288 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
265 java-pkg_dojar "${new_jar_dest}" 289 java-pkg_dojar "${new_jar_dest}"
1027 return 1 1051 return 1
1028 fi 1052 fi
1029 fi 1053 fi
1030} 1054}
1031 1055
1056java-pkg_set-current-vm() {
1057 export GENTOO_VM=${1}
1058}
1059
1060java-pkg_get-current-vm() {
1061 echo ${GENTOO_VM}
1062}
1063
1064java-pkg_current-vm-matches() {
1065 hasq java-pkg_get-currenv-vm ${@}
1066 return $?
1067}
1068
1032# ------------------------------------------------------------------------------ 1069# ------------------------------------------------------------------------------
1033# @ebuild-function java-pkg_get-source 1070# @ebuild-function java-pkg_get-source
1034# 1071#
1035# Determines what source version should be used, for passing to -source. 1072# Determines what source version should be used, for passing to -source.
1036# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1073# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1139 1176
1140# TODO document 1177# TODO document
1141java-pkg_get-jni-cflags() { 1178java-pkg_get-jni-cflags() {
1142 local flags="-I${JAVA_HOME}/include" 1179 local flags="-I${JAVA_HOME}/include"
1143 1180
1181 # TODO do a check that the directories are valid
1144 # TODO figure out how to cope with other things than linux... 1182 # TODO figure out how to cope with other things than linux...
1145 flags="${flags} -I${JAVA_HOME}/include/linux" 1183 flags="${flags} -I${JAVA_HOME}/include/linux"
1146 1184
1147 echo ${flags} 1185 echo ${flags}
1148} 1186}
1149 1187
1188java-pkg_ensure-gcj() {
1189 if ! built_with_use sys-devel/gcc gcj ; then
1190 ewarn
1191 ewarn "You must build gcc with the gcj support to build with gcj"
1192 ewarn
1193 ebeep 5
1194 die "No GCJ support found!"
1195 fi
1196}
1197
1150# ------------------------------------------------------------------------------ 1198# ------------------------------------------------------------------------------
1151# @section-end helper 1199# @section-end helper
1152# ------------------------------------------------------------------------------ 1200# ------------------------------------------------------------------------------
1153 1201
1154# ------------------------------------------------------------------------------ 1202# ------------------------------------------------------------------------------
1166# compiler. 1214# compiler.
1167# 1215#
1168# ------------------------------------------------------------------------------ 1216# ------------------------------------------------------------------------------
1169eant() { 1217eant() {
1170 debug-print-function ${FUNCNAME} $* 1218 debug-print-function ${FUNCNAME} $*
1219
1220 # FIXME get this working
1221# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1222# java-pkg_announce-qa-violation \
1223# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1224# fi
1171 1225
1172 local antflags 1226 local antflags
1173 java-pkg_init-compiler_ 1227 java-pkg_init-compiler_
1174 local compiler="${GENTOO_COMPILER}" 1228 local compiler="${GENTOO_COMPILER}"
1175 1229
1189 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1243 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1190 if [[ -n ${build_compiler_deps} ]]; then 1244 if [[ -n ${build_compiler_deps} ]]; then
1191 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})" 1245 antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})"
1192 fi 1246 fi
1193 fi 1247 fi
1248
1249 if is-java-strict; then
1250 einfo "Disabling system classpath for ant"
1251 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1252 fi
1194 1253
1195 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1254 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1196 antflags="${antflags} -debug" 1255 antflags="${antflags} -debug"
1197 fi 1256 fi
1198 1257
1210# @param $@ - Arguments to be passed to the compiler 1269# @param $@ - Arguments to be passed to the compiler
1211# ------------------------------------------------------------------------------ 1270# ------------------------------------------------------------------------------
1212ejavac() { 1271ejavac() {
1213 debug-print-function ${FUNCNAME} $* 1272 debug-print-function ${FUNCNAME} $*
1214 1273
1274 # FIXME using get-javac ends up printing stuff with einfo
1215 local compiler_executable=$(java-pkg_get-javac) 1275# local compiler_executable=$(java-pkg_get-javac)
1276 local compiler_executable="javac"
1216 1277
1217 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1278 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}"
1218 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1279 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed"
1219} 1280}
1220 1281
1226# 1287#
1227# @param $@ - compilers to filter 1288# @param $@ - compilers to filter
1228# ------------------------------------------------------------------------------ 1289# ------------------------------------------------------------------------------
1229java-pkg_filter-compiler() { 1290java-pkg_filter-compiler() {
1230 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@" 1291 JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
1292}
1293
1294# ------------------------------------------------------------------------------
1295# @ebuild-function java-pkg_force-compiler
1296#
1297# Used to force the use of particular compilers. Should be used in src_compile.
1298# A common use of this would be to force ecj-3.1 to be used on amd64, to avoid
1299# OutOfMemoryErrors that may come up.
1300#
1301# @param $@ - compilers to force
1302# ------------------------------------------------------------------------------
1303java-pkg_force-compiler() {
1304 JAVA_PKG_FORCE_COMPILER="$@"
1231} 1305}
1232 1306
1233# ------------------------------------------------------------------------------ 1307# ------------------------------------------------------------------------------
1234# @ebuild-function use_doc 1308# @ebuild-function use_doc
1235# 1309#
1661 fi 1735 fi
1662 debug-print "Using: $(java-config -f)" 1736 debug-print "Using: $(java-config -f)"
1663 1737
1664 java-pkg_setup-vm 1738 java-pkg_setup-vm
1665 1739
1666 export JAVA=$(java-config -java) 1740 export JAVA=$(java-config --java)
1667 export JAVAC=$(java-config -javac) 1741 export JAVAC=$(java-config --javac)
1668 export JAVACFLAGS="$(java-pkg_javac-args)" 1742 export JAVACFLAGS="$(java-pkg_javac-args)"
1669 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1743 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1670 1744
1671 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1745 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1672 export JDK_HOME=${JAVA_HOME} 1746 export JDK_HOME=${JAVA_HOME}
1706 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 1780 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2
1707 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 1781 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2
1708 echo "and of course, the output of emerge --info" >&2 1782 echo "and of course, the output of emerge --info" >&2
1709} 1783}
1710 1784
1785
1786# TODO document
1787# List jars in the source directory, ${S}
1788java-pkg_jar-list() {
1789 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
1790 einfo "Linked Jars"
1791 find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1792 einfo "Jars"
1793 find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1794 einfo "Classes"
1795 find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},"
1796 fi
1797}
1798
1799# TODO document
1800# Verify that the classes were compiled for the right source / target
1801java-pkg_verify-classes() {
1802 ebegin "Verifying java class versions"
1803 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1804 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1805 result=$?
1806 eend ${result}
1807 if [[ ${result} == 0 ]]; then
1808 einfo "All good"
1809 else
1810 ewarn "Possible problem"
1811 die "Bad class files found"
1812 fi
1813}
1814
1815
1711# ------------------------------------------------------------------------------ 1816# ------------------------------------------------------------------------------
1712# @section-end internal 1817# @section-end internal
1713# ------------------------------------------------------------------------------ 1818# ------------------------------------------------------------------------------
1714 1819
1715java-pkg_check-phase() { 1820java-pkg_check-phase() {
1716 local phase=${1} 1821 local phase=${1}
1717 local funcname=${2} 1822 local funcname=${2}
1718 # TODO add check for java-stricter
1719 if [[ ${EBUILD_PHASE} != ${phase} ]]; then 1823 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then
1720 java-pkg_announce-qa-violation \ 1824 java-pkg_announce-qa-violation \
1721 "${funcname} used outside of src_${phase}" 1825 "${funcname} used outside of src_${phase}"
1722 fi 1826 fi
1723} 1827}
1724 1828
1735 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 1839 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
1736 fi 1840 fi
1737} 1841}
1738 1842
1739java-pkg_announce-qa-violation() { 1843java-pkg_announce-qa-violation() {
1740 if hasq java-strict ${FEATURES}; then 1844 if is-java-strict; then
1741 echo "Java QA Notice: $@" >&2 1845 echo "Java QA Notice: $@" >&2
1742 increment-qa-violations 1846 increment-qa-violations
1743 fi 1847 fi
1744} 1848}
1745 1849
1746increment-qa-violations() { 1850increment-qa-violations() {
1747 let "JAVA_PKG_QA_VIOLATIONS+=1" 1851 let "JAVA_PKG_QA_VIOLATIONS+=1"
1748 export JAVA_PKG_QA_VIOLATIONS 1852 export JAVA_PKG_QA_VIOLATIONS
1749} 1853}
1750 1854
1855is-java-strict() {
1856 hasq java-strict ${FEATURES} && ! hasq -java-strict ${FEATURES}
1857 return $?
1858}
1859
1751# ------------------------------------------------------------------------------ 1860# ------------------------------------------------------------------------------
1752# @eclass-end 1861# @eclass-end
1753# ------------------------------------------------------------------------------ 1862# ------------------------------------------------------------------------------

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20