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