fix broken headers in a few random files
[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 # $Id$
4
5 # @ECLASS: ant-tasks.eclass
6 # @MAINTAINER:
7 # java@gentoo.org
8 # @AUTHOR:
9 # Vlastimil Babka <caster@gentoo.org>
10 # @BLURB: Eclass for building dev-java/ant-* packages
11 # @DESCRIPTION:
12 # This eclass provides functionality and default ebuild variables for building
13 # dev-java/ant-* packages easily.
14
15
16 # we set ant-core dep ourselves, restricted
17 JAVA_ANT_DISABLE_ANT_CORE_DEP=true
18 # rewriting build.xml for are the testcases has no reason atm
19 JAVA_PKG_BSFIX_ALL=no
20 inherit versionator java-pkg-2 java-ant-2
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 overriden 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 overriden 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=$(get_version_component_range 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=$(get_version_component_range 1-3)
70 else
71         # default for final releases
72         MY_PV=${PV}
73         UPSTREAM_PREFIX="mirror://apache/ant/source"
74         case ${PV} in
75         1.9.*)
76                 GENTOO_PREFIX="https://dev.gentoo.org/~tomwij/files/dist"
77                 ;;
78         1.8.4)
79                 GENTOO_PREFIX="https://dev.gentoo.org/~sera/distfiles"
80                 ;;
81         *)
82                 GENTOO_PREFIX="https://dev.gentoo.org/~caster/distfiles"
83                 ;;
84         esac
85 fi
86
87 # source/workdir name
88 MY_P="apache-ant-${MY_PV}"
89
90 # Default values for standard ebuild variables, can be overriden from ebuild.
91 DESCRIPTION="Apache Ant's optional tasks depending on ${ANT_TASK_DEPNAME}"
92 HOMEPAGE="http://ant.apache.org/"
93 SRC_URI="${UPSTREAM_PREFIX}/${MY_P}-src.tar.bz2
94         ${GENTOO_PREFIX}/ant-${PV}-gentoo.tar.bz2"
95 LICENSE="Apache-2.0"
96 SLOT="0"
97
98 RDEPEND="~dev-java/ant-core-${PV}:0"
99 DEPEND="${RDEPEND}"
100
101 if [[ -z "${ANT_TASK_DISABLE_VM_DEPS}" ]]; then
102         RDEPEND+=" >=virtual/jre-${ANT_TASK_JREVER}"
103         DEPEND+=" >=virtual/jdk-${ANT_TASK_JDKVER}"
104 fi
105
106 # we need direct blockers with old ant-tasks for file collisions - bug #252324
107 if version_is_at_least 1.7.1 ; then
108         DEPEND+=" !dev-java/ant-tasks"
109 fi
110
111 # Would run the full ant test suite for every ant task
112 RESTRICT="test"
113
114 S="${WORKDIR}/${MY_P}"
115
116 # @FUNCTION: ant-tasks_src_unpack
117 # @USAGE: [ base ] [ jar-dep ] [ all ]
118 # @DESCRIPTION:
119 # The function Is split into two parts, defaults to both of them ('all').
120 #
121 # base: performs the unpack, build.xml replacement and symlinks ant.jar from
122 #       ant-core
123 #
124 # jar-dep: symlinks the jar file(s) from dependency package
125 ant-tasks_src_unpack() {
126         [[ -z "${1}" ]] && ant-tasks_src_unpack all
127
128         while [[ -n "${1}" ]]; do
129                 case ${1} in
130                         base)
131                                 unpack ${A}
132                                 cd "${S}"
133
134                                 # replace build.xml with our modified for split building
135                                 mv -f "${WORKDIR}"/build.xml .
136
137                                 cd lib
138                                 # remove bundled xerces
139                                 rm -f *.jar
140
141                                 # ant.jar to build against
142                                 java-pkg_jar-from --build-only ant-core ant.jar;;
143                         jar-dep)
144                                 # get jar from the dependency package
145                                 if [[ -n "${ANT_TASK_DEPNAME}" ]]; then
146                                         java-pkg_jar-from ${ANT_TASK_DEPNAME}
147                                 fi;;
148                         all)
149                                 ant-tasks_src_unpack base jar-dep;;
150                 esac
151                 shift
152         done
153
154 }
155
156 # @FUNCTION: ant-tasks_src_compile
157 # @DESCRIPTION:
158 # Compiles the jar with installed ant-core.
159 ant-tasks_src_compile() {
160         ANT_TASKS="none" eant -Dbuild.dep=${ANT_TASK_NAME} jar-dep
161 }
162
163 # @FUNCTION: ant-tasks_src_install
164 # @DESCRIPTION:
165 # Installs the jar and registers its presence for the ant launcher script.
166 # Version param ensures it won't get loaded (thus break) when ant-core is
167 # updated to newer version.
168 ant-tasks_src_install() {
169         java-pkg_dojar build/lib/${PN}.jar
170         java-pkg_register-ant-task --version "${ANT_TASK_PV}"
171
172         # create the compatibility symlink
173         if version_is_at_least 1.7.1_beta2; then
174                 dodir /usr/share/ant/lib
175                 dosym /usr/share/${PN}/lib/${PN}.jar /usr/share/ant/lib/${PN}.jar
176         fi
177 }