Diff stringtemplate-3.2.1-r2 with a stringtemplate-4.3.2

/usr/portage/dev-java/stringtemplate/stringtemplate-4.3.2.ebuild 2023-10-09 14:52:29.444368349 +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
# Skeleton command:
5
# java-ebuilder --generate-ebuild --workdir . --pom pom.xml --download-uri https://github.com/antlr/stringtemplate3/archive/68f2a42e8038f8e716e9666909ea485ee8aff45a.tar.gz --slot 0 --keywords "~amd64 ~arm ~arm64 ~ppc64 ~x86" --ebuild stringtemplate-3.2.1-r2.ebuild
6

  
7
EAPI=7
4
EAPI=8
8 5

  
9 6
JAVA_PKG_IUSE="doc source test"
10
MAVEN_ID="org.antlr:stringtemplate:3.2.2"
7
MAVEN_ID="org.antlr:ST4:4.3.2"
11 8
JAVA_TESTING_FRAMEWORKS="junit-4"
12 9

  
13 10
inherit java-pkg-2 java-pkg-simple
14 11

  
15
MY_COMMIT="68f2a42e8038f8e716e9666909ea485ee8aff45a"
16 12
DESCRIPTION="A Java template engine"
17 13
HOMEPAGE="https://www.stringtemplate.org/"
18
SRC_URI="https://github.com/antlr/stringtemplate3/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz"
14
# Maven Central sources JAR for *.java sources pre-generated from *.g files;
15
# the source generation requires antlr-tool-3.5, which depends on this package.
16
# Tarball for the test suite and DOCS files
17
SRC_URI="
18
	https://repo1.maven.org/maven2/org/antlr/ST4/${PV}/ST4-${PV}-sources.jar
19
	https://github.com/antlr/${PN}4/archive/${PV}.tar.gz -> ${P}.tar.gz
20
"
19 21

  
20
LICENSE="BSD-1"
21
SLOT="0"
22
LICENSE="BSD"
23
SLOT="4"
22 24
KEYWORDS="amd64 ~arm arm64 ppc64 x86 ~amd64-linux ~x86-linux ~x64-solaris"
23 25

  
24
# Common dependencies
25
# POM: pom.xml
26
# antlr:antlr:2.7.7 -> >=dev-java/antlr-2.7.7:0
26
CP_DEPEND="
27
	dev-java/antlr-runtime:3.5
28
"
27 29

  
28
CDEPEND="
29
	dev-java/antlr:0
30
BDEPEND="
31
	app-arch/unzip
30 32
"
31 33

  
32 34
DEPEND="
33 35
	>=virtual/jdk-1.8:*
34
	${CDEPEND}
36
	${CP_DEPEND}
37
	test? (
38
		dev-java/antlr-tool:3.5
39
	)
35 40
"
36 41

  
37 42
RDEPEND="
38 43
	>=virtual/jre-1.8:*
39
	${CDEPEND}
44
	${CP_DEPEND}
40 45
"
41 46

  
42
DOCS=( {CHANGES,README}.txt )
47
S="${WORKDIR}"
48
TARBALL_S="${S}/${PN}4-${PV}"
43 49

  
44
S="${WORKDIR}/${PN}3-${MY_COMMIT}"
50
JAVA_SRC_DIR="org"
45 51

  
46
JAVA_GENTOO_CLASSPATH="antlr"
47
JAVA_SRC_DIR="src"
48

  
49
JAVA_TEST_GENTOO_CLASSPATH="junit-4"
50
JAVA_TEST_SRC_DIR="test"
51
JAVA_TEST_RESOURCE_DIRS="test"
52
JAVA_TEST_GENTOO_CLASSPATH="junit-4,antlr-tool-3.5"
53
JAVA_TEST_SRC_DIR="${TARBALL_S}/test"
54
JAVA_TEST_RESOURCE_DIRS=( "${TARBALL_S}/test/resources" )
55

  
56
DOCS=( "${TARBALL_S}/"{CHANGES.txt,README.md} )
57

  
58
src_prepare() {
59
	# Do not call java-pkg_clean; otherwise, it would remove
60
	# ${TARBALL_S}/test/test.jar, which is merely used as a
61
	# test resource file, does not contain any *.class files,
62
	# and is required to pass the tests as of version 4.3.2
63
	pushd "${TARBALL_S}" > /dev/null ||
64
		die "Failed to enter directory storing tarball contents"
65
	eapply "${FILESDIR}/${PN}-4.3.1-BaseTest-javac-source-target.patch"
66
	popd > /dev/null ||
67
		die "Failed to leave directory storing tarball contents"
68
	java-pkg-2_src_prepare
69
	# Some of these tests requires a graphical display.
70
	rm -v "${JAVA_TEST_SRC_DIR}/org/stringtemplate/v4/test/TestEarlyEvaluation.java" || die
71
}
52 72

  
53
src_compile() {
54
	local G; for G in action template angle.bracket.template eval group interface; do # from build.xml
55
		antlr -o src/org/antlr/stringtemplate/language/{,${G}.g} || die
56
	done
73
src_test() {
74
	# Make sure no older versions of this slot are present in the classpath
75
	# https://bugs.gentoo.org/834138#c4
76
	local old_ver_cp="$(nonfatal java-pkg_getjars "${PN}-${SLOT}")"
77
	local new_test_cp="$(\
78
		java-pkg_getjars --with-dependencies "${JAVA_TEST_GENTOO_CLASSPATH}")"
79
	new_test_cp="${new_test_cp//"${old_ver_cp}"/}"
80

  
81
	# Some of the test cases require an absolute path to the JAR being tested
82
	# against to be in the classpath, due to the fact that they call the 'java'
83
	# command outside ${S} and reuse the classpath for the tests:
84
	# https://github.com/antlr/stringtemplate4/blob/4.3.1/test/org/stringtemplate/v4/test/TestImports.java#L103
85
	# https://github.com/antlr/stringtemplate4/blob/4.3.1/test/org/stringtemplate/v4/test/BaseTest.java#L174
86
	new_test_cp="${S}/${JAVA_JAR_FILENAME}:${new_test_cp}"
87

  
88
	# The JAR used as a test resource file needs to be in the classpath
89
	# https://github.com/antlr/stringtemplate4/blob/4.3.2/pom.xml#L53-L58
90
	new_test_cp+=":${JAVA_TEST_SRC_DIR}/test.jar"
91

  
92
	# Use JAVA_GENTOO_CLASSPATH_EXTRA to set test classpath
93
	local JAVA_TEST_GENTOO_CLASSPATH=""
94
	[[ -n "${JAVA_GENTOO_CLASSPATH_EXTRA}" ]] &&
95
		JAVA_GENTOO_CLASSPATH_EXTRA+=":"
96
	JAVA_GENTOO_CLASSPATH_EXTRA+="${new_test_cp}"
97
	java-pkg-simple_src_test
98
}
57 99

  
58
	java-pkg-simple_src_compile
100
src_install() {
101
	java-pkg-simple_src_install
102
	einstalldocs # https://bugs.gentoo.org/789582
59 103
}
Thank you!