Diff antlr-2.7.7-r9 with a antlr-3.2-r1

/usr/portage/dev-java/antlr/antlr-3.2-r1.ebuild 2023-10-09 14:52:29.412368348 +0300
3 3

  
4 4
EAPI=7
5 5

  
6
JAVA_PKG_IUSE="doc source"
7
MAVEN_ID="antlr:antlr:2.7.7"
6
JAVA_PKG_IUSE="doc test"
8 7

  
9 8
inherit java-pkg-2 java-pkg-simple
10 9

  
11 10
DESCRIPTION="A parser generator for many languages"
12
HOMEPAGE="https://www.antlr2.org/"
13
SRC_URI="https://www.antlr2.org/download/${P}.tar.gz"
11
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.
14 14

  
15
LICENSE="public-domain"
16
SLOT="0"
15
LICENSE="BSD"
16
SLOT="3"
17 17
KEYWORDS="amd64 ~arm arm64 ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
18
IUSE="examples"
18
RESTRICT="!test? ( test )"
19 19

  
20
RDEPEND=">=virtual/jre-1.8:*"
21
DEPEND=">=virtual/jdk-1.8:*"
20
CDEPEND=">=dev-java/antlr-2.7.7-r7:0
21
	dev-java/stringtemplate:0"
22 22

  
23
S="${WORKDIR}/${P}"
23
RDEPEND="${CDEPEND}
24
	>=virtual/jre-1.8:*"
25

  
26
DEPEND="${CDEPEND}
27
	>=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
)
24 35

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

  
27
DOCS=( CHANGES.txt README.txt )
40
src_unpack() {
41
	unpack ${P}.tar.gz
42
}
28 43

  
29 44
src_prepare() {
30 45
	default
31 46
	java-pkg_clean
32 47

  
33
	# Delete build files from examples.
34
	find examples \( -name Makefile.in -o -name shiplist \) -delete || die
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
55

  
56
	# 3.2 has strange hidden files.
57
	find -type f -name "._*.*" -delete || die
35 58
}
36 59

  
37
# Avoid configure script.
38
src_configure() { :; }
60
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
83
}
39 84

  
40 85
src_install() {
41
	java-pkg-simple_src_install
42
	java-pkg_dolauncher antlr --main antlr.Tool
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
}
43 90

  
44
	use doc && java-pkg_dohtml -r doc/*
45
	use examples && java-pkg_doexamples examples/java
46
	use source && java-pkg_dosrc antlr
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//\//.}"
47 98

  
48
	# https://bugs.gentoo.org/789582
49
	einstalldocs
99
	ejavac -classpath "${CP}" $(find -name "*.java")
100
	ejunit4 -classpath "${CP}" ${TESTS}
50 101
}
Thank you!