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