1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License, v2 or later
4 # @ECLASS: ant-tasks.eclass
8 # Vlastimil Babka <caster@gentoo.org>
9 # @BLURB: Eclass for building dev-java/ant-* packages
11 # This eclass provides functionality and default ebuild variables for building
12 # dev-java/ant-* packages easily.
16 die "ant-tasks.eclass: EAPI ${EAPI} is too old."
21 die "ant-tasks.eclass: EAPI ${EAPI} is not supported yet."
25 # we set ant-core dep ourselves, restricted
26 JAVA_ANT_DISABLE_ANT_CORE_DEP=true
27 # rewriting build.xml for are the testcases has no reason atm
29 inherit java-pkg-2 java-ant-2
30 [[ ${EAPI:-0} == [56] ]] && inherit eapi7-ver
32 EXPORT_FUNCTIONS src_unpack src_compile src_install
34 # @ECLASS-VARIABLE: ANT_TASK_JDKVER
36 # Affects the >=virtual/jdk version set in DEPEND string. Defaults to 1.8, can
37 # be overridden from ebuild BEFORE inheriting this eclass.
38 ANT_TASK_JDKVER=${ANT_TASK_JDKVER-1.8}
40 # @ECLASS-VARIABLE: ANT_TASK_JREVER
42 # Affects the >=virtual/jre version set in DEPEND string. Defaults to 1.8, can
43 # be overridden from ebuild BEFORE inheriting this eclass.
44 ANT_TASK_JREVER=${ANT_TASK_JREVER-1.8}
46 # @ECLASS-VARIABLE: ANT_TASK_NAME
48 # The name of this ant task as recognized by ant's build.xml, derived from $PN
49 # by removing the ant- prefix. Read-only.
50 ANT_TASK_NAME="${PN#ant-}"
52 # @ECLASS-VARIABLE: ANT_TASK_DEPNAME
54 # Specifies JAVA_PKG_NAME (PN{-SLOT} used with java-pkg_jar-from) of the package
55 # that this one depends on. Defaults to the name of ant task, ebuild can
56 # override it before inheriting this eclass.
57 ANT_TASK_DEPNAME=${ANT_TASK_DEPNAME-${ANT_TASK_NAME}}
59 # @ECLASS-VARIABLE: ANT_TASK_DISABLE_VM_DEPS
62 # If set, no JDK/JRE deps are added.
64 # @VARIABLE: ANT_TASK_PV
66 # Version of ant-core this task is intended to register and thus load with.
69 # default for final releases
73 UPSTREAM_PREFIX="https://archive.apache.org/dist/ant/source"
74 GENTOO_PREFIX="https://dev.gentoo.org/~tomwij/files/dist"
77 UPSTREAM_PREFIX="mirror://apache/ant/source"
78 GENTOO_PREFIX="https://dev.gentoo.org/~fordfrog/distfiles"
83 MY_P="apache-ant-${MY_PV}"
85 # Default values for standard ebuild variables, can be overridden from ebuild.
86 DESCRIPTION="Apache Ant's optional tasks depending on ${ANT_TASK_DEPNAME}"
87 HOMEPAGE="http://ant.apache.org/"
88 SRC_URI="${UPSTREAM_PREFIX}/${MY_P}-src.tar.bz2
89 ${GENTOO_PREFIX}/ant-${PV}-gentoo.tar.bz2"
93 RDEPEND="~dev-java/ant-core-${PV}:0"
96 if [[ -z "${ANT_TASK_DISABLE_VM_DEPS}" ]]; then
97 RDEPEND+=" >=virtual/jre-${ANT_TASK_JREVER}"
98 DEPEND+=" >=virtual/jdk-${ANT_TASK_JDKVER}"
101 # Would run the full ant test suite for every ant task
104 S="${WORKDIR}/${MY_P}"
106 # @FUNCTION: ant-tasks_src_unpack
107 # @USAGE: [ base ] [ jar-dep ] [ all ]
109 # The function Is split into two parts, defaults to both of them ('all').
111 # base: performs the unpack, build.xml replacement and symlinks ant.jar from
114 # jar-dep: symlinks the jar file(s) from dependency package
115 ant-tasks_src_unpack() {
116 [[ -z "${1}" ]] && ant-tasks_src_unpack all
118 while [[ -n "${1}" ]]; do
124 # replace build.xml with our modified for split building
125 if [ -e "${WORKDIR}"/${PV}-build.patch ] ; then
126 if [ ${EAPI:-0} -eq 5 ]; then
127 die "ant-tasks.eclass: build.xml patching not supported for EAPI 5 ebuilds"
130 eapply "${WORKDIR}"/${PV}-build.patch
132 mv -f "${WORKDIR}"/build.xml .
136 # remove bundled xerces
139 # ant.jar to build against
140 java-pkg_jar-from --build-only ant-core ant.jar;;
142 # get jar from the dependency package
143 if [[ -n "${ANT_TASK_DEPNAME}" ]]; then
144 java-pkg_jar-from ${ANT_TASK_DEPNAME}
147 ant-tasks_src_unpack base jar-dep;;
154 # @FUNCTION: ant-tasks_src_compile
156 # Compiles the jar with installed ant-core.
157 ant-tasks_src_compile() {
158 ANT_TASKS="none" eant -Dbuild.dep=${ANT_TASK_NAME} jar-dep
161 # @FUNCTION: ant-tasks_src_install
163 # Installs the jar and registers its presence for the ant launcher script.
164 # Version param ensures it won't get loaded (thus break) when ant-core is
165 # updated to newer version.
166 ant-tasks_src_install() {
167 java-pkg_dojar build/lib/${PN}.jar
168 java-pkg_register-ant-task --version "${ANT_TASK_PV}"
170 # create the compatibility symlink
171 dodir /usr/share/ant/lib
172 dosym /usr/share/${PN}/lib/${PN}.jar /usr/share/ant/lib/${PN}.jar