dev-java/tomcat-servlet-api: x86 stable wrt bug #722654
[gentoo.git] / dev-java / antlr / antlr-3.5.2.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils java-pkg-2 java-pkg-simple
7
8 DESCRIPTION="A parser generator for many languages"
9 HOMEPAGE="https://www.antlr3.org/"
10 SRC_URI="https://github.com/${PN}/${PN}3/archive/${PV}.tar.gz -> ${P}.tar.gz
11         https://www.antlr3.org/download/${P}-complete.jar" # Prebuilt version needed.
12 LICENSE="BSD"
13 SLOT="3.5"
14 KEYWORDS="amd64 ~arm ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
15 IUSE="doc test"
16 RESTRICT="!test? ( test )"
17
18 CDEPEND="dev-java/stringtemplate:4"
19
20 RDEPEND="${CDEPEND}
21         >=virtual/jre-1.6"
22
23 DEPEND="${CDEPEND}
24         >=virtual/jdk-1.6
25         test? ( dev-java/junit:4 )"
26
27 S="${WORKDIR}/${PN}3-${PV}"
28 JAVA_GENTOO_CLASSPATH_EXTRA="${S}/${PN}-runtime.jar"
29 JAVA_GENTOO_CLASSPATH="stringtemplate-4"
30
31 src_unpack() {
32         unpack ${P}.tar.gz
33 }
34
35 java_prepare() {
36         java-pkg_clean
37
38         # This requires StringTemplate v3 and is only needed for
39         # output=template. Nothing in the tree currently needs that and the
40         # dependency situation is already hairy enough as it is.
41         rm -v runtime/Java/src/main/java/org/antlr/runtime/tree/DOTTreeGenerator.java || die
42
43         # Some tests have to be removed as a result.
44         rm -v tool/src/test/java/org/antlr/test/Test{RewriteTemplates,Templates}.java || die
45         epatch "${FILESDIR}/${PV}-test-fixes.patch"
46
47         # Some tests fail under Java 8 in ways that probably aren't limited
48         # to the tests. This is bad but upstream is never going to update
49         # 3.5. At the time of writing, we only use it to build 4 anyway.
50         if java-pkg_is-vm-version-ge 1.8; then
51                 rm -v tool/src/test/java/org/antlr/test/Test{DFAConversion,SemanticPredicates,TopologicalSort}.java || die
52         fi
53 }
54
55 src_compile() {
56         cd "${S}/runtime/Java/src/main" || die
57         JAVA_JAR_FILENAME="${S}/${PN}-runtime.jar" JAVA_PKG_IUSE="doc" java-pkg-simple_src_compile
58
59         cd "${S}/tool/src/main" || die
60         java -jar "${DISTDIR}/${P}-complete.jar" $(find antlr3 -name "*.g") || die
61         JAVA_JAR_FILENAME="${S}/${PN}-tool.jar" java-pkg-simple_src_compile
62         java-pkg_addres "${S}/${PN}-tool.jar" resources
63 }
64
65 src_install() {
66         java-pkg_dojar ${PN}-{runtime,tool}.jar
67         java-pkg_dolauncher ${PN}${SLOT} --main org.antlr.Tool
68         use doc && java-pkg_dojavadoc runtime/Java/src/main/target/api
69 }
70
71 src_test() {
72         cd tool/src/test/java || die
73         local CP=".:${S}/${PN}-runtime.jar:${S}/${PN}-tool.jar:$(java-pkg_getjars junit-4,${JAVA_GENTOO_CLASSPATH})"
74
75         local TESTS=$(find * -name "Test*.java")
76         TESTS="${TESTS//.java}"
77         TESTS="${TESTS//\//.}"
78
79         ejavac -classpath "${CP}" $(find -name "*.java")
80
81         # ejunit automatically adds all registered subdependencies to the
82         # classpath, which is annoying in this case because of the cyclic
83         # dependency on stringtemplate. It will blow up when trying to find
84         # antlr-3.5 on the system before it is installed. The easiest but
85         # somewhat ugly way to avoid this is to unset JAVA_PKG_DEPEND_FILE.
86         JAVA_PKG_DEPEND_FILE= ejunit4 -classpath "${CP}" ${TESTS}
87 }