ant-tasks.eclass 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License, v2 or later
  3. # @ECLASS: ant-tasks.eclass
  4. # @MAINTAINER:
  5. # java@gentoo.org
  6. # @AUTHOR:
  7. # Vlastimil Babka <caster@gentoo.org>
  8. # @BLURB: Eclass for building dev-java/ant-* packages
  9. # @DESCRIPTION:
  10. # This eclass provides functionality and default ebuild variables for building
  11. # dev-java/ant-* packages easily.
  12. # we set ant-core dep ourselves, restricted
  13. JAVA_ANT_DISABLE_ANT_CORE_DEP=true
  14. # rewriting build.xml for are the testcases has no reason atm
  15. JAVA_PKG_BSFIX_ALL=no
  16. inherit versionator java-pkg-2 java-ant-2
  17. EXPORT_FUNCTIONS src_unpack src_compile src_install
  18. # @ECLASS-VARIABLE: ANT_TASK_JDKVER
  19. # @DESCRIPTION:
  20. # Affects the >=virtual/jdk version set in DEPEND string. Defaults to 1.5, can
  21. # be overriden from ebuild BEFORE inheriting this eclass.
  22. ANT_TASK_JDKVER=${ANT_TASK_JDKVER-1.5}
  23. # @ECLASS-VARIABLE: ANT_TASK_JREVER
  24. # @DESCRIPTION:
  25. # Affects the >=virtual/jre version set in DEPEND string. Defaults to 1.5, can
  26. # be overriden from ebuild BEFORE inheriting this eclass.
  27. ANT_TASK_JREVER=${ANT_TASK_JREVER-1.5}
  28. # @ECLASS-VARIABLE: ANT_TASK_NAME
  29. # @DESCRIPTION:
  30. # The name of this ant task as recognized by ant's build.xml, derived from $PN
  31. # by removing the ant- prefix. Read-only.
  32. ANT_TASK_NAME="${PN#ant-}"
  33. # @ECLASS-VARIABLE: ANT_TASK_DEPNAME
  34. # @DESCRIPTION:
  35. # Specifies JAVA_PKG_NAME (PN{-SLOT} used with java-pkg_jar-from) of the package
  36. # that this one depends on. Defaults to the name of ant task, ebuild can
  37. # override it before inheriting this eclass.
  38. ANT_TASK_DEPNAME=${ANT_TASK_DEPNAME-${ANT_TASK_NAME}}
  39. # @ECLASS-VARIABLE: ANT_TASK_DISABLE_VM_DEPS
  40. # @DEFAULT_UNSET
  41. # @DESCRIPTION:
  42. # If set, no JDK/JRE deps are added.
  43. # @VARIABLE: ANT_TASK_PV
  44. # @INTERNAL
  45. # Version of ant-core this task is intended to register and thus load with.
  46. ANT_TASK_PV="${PV}"
  47. # special care for beta/RC releases
  48. if [[ ${PV} == *beta2* ]]; then
  49. MY_PV=${PV/_beta2/beta}
  50. UPSTREAM_PREFIX="http://people.apache.org/dist/ant/v1.7.1beta2/src"
  51. GENTOO_PREFIX="https://dev.gentoo.org/~caster/distfiles"
  52. ANT_TASK_PV=$(get_version_component_range 1-3)
  53. elif [[ ${PV} == *_rc* ]]; then
  54. MY_PV=${PV/_rc/RC}
  55. UPSTREAM_PREFIX="https://dev.gentoo.org/~caster/distfiles"
  56. GENTOO_PREFIX="https://dev.gentoo.org/~caster/distfiles"
  57. ANT_TASK_PV=$(get_version_component_range 1-3)
  58. else
  59. # default for final releases
  60. MY_PV=${PV}
  61. UPSTREAM_PREFIX="mirror://apache/ant/source"
  62. case ${PV} in
  63. 1.9.*)
  64. GENTOO_PREFIX="https://dev.gentoo.org/~tomwij/files/dist"
  65. ;;
  66. 1.8.4)
  67. GENTOO_PREFIX="https://dev.gentoo.org/~sera/distfiles"
  68. ;;
  69. *)
  70. GENTOO_PREFIX="https://dev.gentoo.org/~caster/distfiles"
  71. ;;
  72. esac
  73. fi
  74. # source/workdir name
  75. MY_P="apache-ant-${MY_PV}"
  76. # Default values for standard ebuild variables, can be overriden from ebuild.
  77. DESCRIPTION="Apache Ant's optional tasks depending on ${ANT_TASK_DEPNAME}"
  78. HOMEPAGE="http://ant.apache.org/"
  79. SRC_URI="${UPSTREAM_PREFIX}/${MY_P}-src.tar.bz2
  80. ${GENTOO_PREFIX}/ant-${PV}-gentoo.tar.bz2"
  81. LICENSE="Apache-2.0"
  82. SLOT="0"
  83. RDEPEND="~dev-java/ant-core-${PV}:0"
  84. DEPEND="${RDEPEND}"
  85. if [[ -z "${ANT_TASK_DISABLE_VM_DEPS}" ]]; then
  86. RDEPEND+=" >=virtual/jre-${ANT_TASK_JREVER}"
  87. DEPEND+=" >=virtual/jdk-${ANT_TASK_JDKVER}"
  88. fi
  89. # we need direct blockers with old ant-tasks for file collisions - bug #252324
  90. if version_is_at_least 1.7.1 ; then
  91. DEPEND+=" !dev-java/ant-tasks"
  92. fi
  93. # Would run the full ant test suite for every ant task
  94. RESTRICT="test"
  95. S="${WORKDIR}/${MY_P}"
  96. # @FUNCTION: ant-tasks_src_unpack
  97. # @USAGE: [ base ] [ jar-dep ] [ all ]
  98. # @DESCRIPTION:
  99. # The function Is split into two parts, defaults to both of them ('all').
  100. #
  101. # base: performs the unpack, build.xml replacement and symlinks ant.jar from
  102. # ant-core
  103. #
  104. # jar-dep: symlinks the jar file(s) from dependency package
  105. ant-tasks_src_unpack() {
  106. [[ -z "${1}" ]] && ant-tasks_src_unpack all
  107. while [[ -n "${1}" ]]; do
  108. case ${1} in
  109. base)
  110. unpack ${A}
  111. cd "${S}"
  112. # replace build.xml with our modified for split building
  113. mv -f "${WORKDIR}"/build.xml .
  114. cd lib
  115. # remove bundled xerces
  116. rm -f *.jar
  117. # ant.jar to build against
  118. java-pkg_jar-from --build-only ant-core ant.jar;;
  119. jar-dep)
  120. # get jar from the dependency package
  121. if [[ -n "${ANT_TASK_DEPNAME}" ]]; then
  122. java-pkg_jar-from ${ANT_TASK_DEPNAME}
  123. fi;;
  124. all)
  125. ant-tasks_src_unpack base jar-dep;;
  126. esac
  127. shift
  128. done
  129. }
  130. # @FUNCTION: ant-tasks_src_compile
  131. # @DESCRIPTION:
  132. # Compiles the jar with installed ant-core.
  133. ant-tasks_src_compile() {
  134. ANT_TASKS="none" eant -Dbuild.dep=${ANT_TASK_NAME} jar-dep
  135. }
  136. # @FUNCTION: ant-tasks_src_install
  137. # @DESCRIPTION:
  138. # Installs the jar and registers its presence for the ant launcher script.
  139. # Version param ensures it won't get loaded (thus break) when ant-core is
  140. # updated to newer version.
  141. ant-tasks_src_install() {
  142. java-pkg_dojar build/lib/${PN}.jar
  143. java-pkg_register-ant-task --version "${ANT_TASK_PV}"
  144. # create the compatibility symlink
  145. if version_is_at_least 1.7.1_beta2; then
  146. dodir /usr/share/ant/lib
  147. dosym /usr/share/${PN}/lib/${PN}.jar /usr/share/ant/lib/${PN}.jar
  148. fi
  149. }