Diff antlr-3.2-r1 with a antlr-3.5.3

/usr/portage/dev-java/antlr/antlr-3.5.3.ebuild 2023-10-09 14:52:29.412368348 +0300
1
# Copyright 1999-2021 Gentoo Authors
1
# Copyright 1999-2022 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
EAPI=7
4
EAPI=8
5 5

  
6
JAVA_PKG_IUSE="doc test"
7

  
8
inherit java-pkg-2 java-pkg-simple
6
inherit java-pkg-2
9 7

  
10 8
DESCRIPTION="A parser generator for many languages"
11 9
HOMEPAGE="https://www.antlr3.org/"
12
SRC_URI="https://www.antlr3.org/download/${P}.tar.gz
13
	https://www.antlr3.org/download/${P}.jar" # Prebuilt version needed.
10
# Reuse tarball for DOCS
11
SRC_URI="https://github.com/${PN}/${PN}3/archive/${PV}.tar.gz -> ${P}.tar.gz"
14 12

  
15 13
LICENSE="BSD"
16
SLOT="3"
14
SLOT="3.5"
17 15
KEYWORDS="amd64 ~arm arm64 ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
18
RESTRICT="!test? ( test )"
19

  
20
CDEPEND=">=dev-java/antlr-2.7.7-r7:0
21
	dev-java/stringtemplate:0"
22 16

  
23
RDEPEND="${CDEPEND}
24
	>=virtual/jre-1.8:*"
17
CP_DEPEND="
18
	~dev-java/antlr-runtime-${PV}:${SLOT}
19
	~dev-java/antlr-tool-${PV}:${SLOT}
20
"
25 21

  
26
DEPEND="${CDEPEND}
22
DEPEND="
27 23
	>=virtual/jdk-1.8:*
28
	test? ( dev-java/junit:4 )"
29

  
30
PATCHES=(
31
	# These fixes have been applied in 3.5.
32
	"${FILESDIR}/${PV}-test-fixes.patch"
33
	"${FILESDIR}/${PV}-java-8.patch"
34
)
35

  
36
S="${WORKDIR}/${P}"
37
JAVA_GENTOO_CLASSPATH_EXTRA="${S}/${PN}-runtime.jar"
38
JAVA_GENTOO_CLASSPATH="antlr,stringtemplate"
24
	${CP_DEPEND}
25
"
39 26

  
40
src_unpack() {
41
	unpack ${P}.tar.gz
42
}
27
RDEPEND="
28
	>=virtual/jre-1.8:*
29
	${CP_DEPEND}
30
"
43 31

  
44
src_prepare() {
45
	default
46
	java-pkg_clean
47

  
48
	# Some tests fail under Java 8 in ways that probably aren't limited
49
	# to the tests. This is bad but upstream is never going to update
50
	# 3.2 even though other projects still rely on it. If any issues
51
	# arise, we can only put pressure on those projects to upgrade.
52
	if java-pkg_is-vm-version-ge 1.8; then
53
		rm -v tool/src/test/java/org/antlr/test/Test{DFAConversion,SemanticPredicates,TopologicalSort}.java || die
54
	fi
32
S="${WORKDIR}/${PN}3-${PV}"
55 33

  
56
	# 3.2 has strange hidden files.
57
	find -type f -name "._*.*" -delete || die
58
}
34
DOCS=( contributors.txt README.txt )
59 35

  
60 36
src_compile() {
61
	cd "${S}/runtime/Java/src/main" || die
62
	JAVA_JAR_FILENAME="${S}/${PN}-runtime.jar" java-pkg-simple_src_compile
63

  
64
	cd "${S}/tool/src/main" || die
65

  
66
	local G; for G in antlr codegen antlr.print assign.types buildnfa define; do # from pom.xml
67
		antlr -o antlr2/org/antlr/grammar/v2/{,${G}.g} || die
68
	done
69

  
70
	# We have applied a patch to fix this version under Java 8. Trouble
71
	# is that we need to run a prebuilt version before we can build our
72
	# own and that version doesn't have the fix applied. We work around
73
	# this by building just the offending class against the prebuilt
74
	# version and then putting them together in the classpath. That
75
	# isn't all. Due to a compiler limitation that Chewi doesn't fully
76
	# understand, this class cannot be compiled by itself without a
77
	# couple of tweaks that have been applied in the Java 8 patch.
78
	ejavac -classpath "${DISTDIR}/${P}.jar" java/org/antlr/tool/CompositeGrammar.java
79

  
80
	java -classpath "java:${DISTDIR}/${P}.jar" org.antlr.Tool $(find antlr3 -name "*.g") || die
81
	JAVA_JAR_FILENAME="${S}/${PN}-tool.jar" java-pkg-simple_src_compile
82
	java-pkg_addres "${S}/${PN}-tool.jar" resources
37
	:
83 38
}
84 39

  
85 40
src_install() {
86
	java-pkg_dojar ${PN}-{runtime,tool}.jar
87
	java-pkg_dolauncher ${PN}${SLOT} --main org.antlr.Tool
88
	use doc && java-pkg_dojavadoc runtime/Java/src/main/target/api
89
}
41
	java-pkg_regjar "$(java-pkg_getjar "antlr-runtime-${SLOT}" antlr-runtime.jar)"
42
	java-pkg_regjar "$(java-pkg_getjar "antlr-tool-${SLOT}" antlr-tool.jar)"
90 43

  
91
src_test() {
92
	cd tool/src/test/java || die
93
	local CP=".:${S}/${PN}-runtime.jar:${S}/${PN}-tool.jar:$(java-pkg_getjars junit-4,${JAVA_GENTOO_CLASSPATH})"
94

  
95
	local TESTS=$(find * -name "Test*.java")
96
	TESTS="${TESTS//.java}"
97
	TESTS="${TESTS//\//.}"
44
	java-pkg_dolauncher "${PN}${SLOT}" --main org.antlr.Tool
45
	einstalldocs # https://bugs.gentoo.org/789582
46
}
98 47

  
99
	ejavac -classpath "${CP}" $(find -name "*.java")
100
	ejunit4 -classpath "${CP}" ${TESTS}
48
pkg_postinst() {
49
	# If upgrading from a version of this slot that installs JARs,
50
	# display a message about submodule split
51
	local changed_ver="3.5.2-r2"
52
	local should_show_msg
53
	for replaced_ver in ${REPLACING_VERSIONS}; do
54
		if ver_test "${replaced_ver}" -lt "${changed_ver}"; then
55
			should_show_msg=1
56
			break
57
		fi
58
	done
59
	[[ "${should_show_msg}" ]] || return
60
	elog "Since version ${changed_ver}, ${PN}-${SLOT} no longer installs JARs."
61
	elog "Please find the JARs from files installed by submodule packages"
62
	elog "antlr-runtime-${SLOT} and antlr-tool-${SLOT}."
101 63
}
Thank you!