summaryrefslogtreecommitdiff
blob: ca9f2bc74b2934aa1cbdee77955e48e68115dd22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

JAVA_PKG_IUSE="doc source test"
MAVEN_ID="com.thoughtworks.qdox:qdox:2.0.1"
JAVA_TESTING_FRAMEWORKS="junit-4"

inherit java-pkg-2 java-pkg-simple

DESCRIPTION="Parser for extracting class/interface/method definitions"
HOMEPAGE="https://github.com/paul-hammant/qdox"
SRC_URI="https://github.com/paul-hammant/qdox/archive/qdox-${PV}.tar.gz"

LICENSE="Apache-2.0"
SLOT="2"
KEYWORDS="~amd64 ~arm arm64 ~ppc64 ~x86 ~ppc-macos ~x64-macos"

DEPEND="
	dev-java/jflex:0
	>=virtual/jdk-1.8:*
	test? (
		dev-java/junit:4
		dev-java/mockito:0
	)
"
RDEPEND=">=virtual/jre-1.8:*"
BDEPEND="dev-java/byaccj:0"

S="${WORKDIR}/qdox-${P}"

JAVA_AUTOMATIC_MODULE_NAME="com.thoughtworks.qdox"
JAVA_SRC_DIR="src/main/java"
JAVA_CLASSPATH_EXTRA="jflex"

JAVA_TEST_SRC_DIR="src/test/java"
JAVA_TEST_RESOURCE_DIRS="src/test/resources"
JAVA_TEST_GENTOO_CLASSPATH="
	junit-4
	mockito
"

src_compile() {
	einfo "Running jflex"
	jflex src/grammar/lexer.flex src/grammar/commentlexer.flex \
		-d src/main/java/com/thoughtworks/qdox/parser/impl || die

	einfo "Running byaccj for DefaultJavaCommentParser"
	byaccj -v \
		-Jnorun \
		-Jnoconstruct \
		-Jclass=DefaultJavaCommentParser \
		-Jpackage=com.thoughtworks.qdox.parser.impl \
		src/grammar/commentparser.y || die

	einfo "Running byaccj for Parser"
	byaccj -v \
		-Jnorun \
		-Jnoconstruct \
		-Jclass=Parser \
		-Jimplements=CommentHandler \
		-Jsemantic=Value \
		-Jpackage=com.thoughtworks.qdox.parser.impl \
		src/grammar/parser.y || die

	mv Parser.java src/main/java/com/thoughtworks/qdox/parser/impl/ || die
	mv DefaultJavaCommentParser.java src/main/java/com/thoughtworks/qdox/parser/impl/ || die
	mv DefaultJavaCommentParserVal.java src/main/java/com/thoughtworks/qdox/parser/impl/ || die

	einfo "Running java-pkg-simple_src_compile"
	java-pkg-simple_src_compile
}

src_test() {
	# Too many tests fail with Java 17.
	local vm_version="$(java-config -g PROVIDES_VERSION)"
	if ver_test "${vm_version}" -ge 17 ; then
		einfo "Tests only for Java < 17"
	else
		einfo "Running tests"
		pushd src/test/java || die
			local JAVA_TEST_RUN_ONLY=$(find * \
				\( -wholename "**/*Test.java" \
				-o -name 'TestMultipleLevelGenericInheritance.java' \)\
				! -name "ClassLibraryBuilderTest.java" \
				! -name "JavaClassTest.java" \
				! -name "JavaConstructorTest.java" \
				! -name "JavaFieldTest.java" \
				! -name "JavaMethodTest.java" \
				! -name "JavaPackageTest.java" \
				! -name "JavaParameterTest.java" \
				! -name "JavaSourceTest.java" \
				! -name "JavaTypeTest.java" \
				! -name "AbstractDocletTagTest.java" \
				)
		popd
		JAVA_TEST_RUN_ONLY="${JAVA_TEST_RUN_ONLY//.java}"
		JAVA_TEST_RUN_ONLY="${JAVA_TEST_RUN_ONLY//\//.}"
		java-pkg-simple_src_test
	fi
}