summaryrefslogtreecommitdiff
blob: 02142ebf6d3f0cc3392d3ca525516bb5d8182c6f (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Skeleton command:
# java-ebuilder --generate-ebuild --workdir . --pom pom.xml --download-uri https://github.com/unicode-org/icu/archive/refs/tags/release-70-1.tar.gz --slot 70 --keywords "~amd64 ~arm64 ~ppc64 ~x86" --ebuild icu4j-70.1.ebuild

EAPI=8

JAVA_PKG_IUSE="doc source test"
MAVEN_ID="com.ibm.icu:icu4j:71.1"
JAVA_TESTING_FRAMEWORKS="junit-4"

inherit java-pkg-2 java-pkg-simple

DESCRIPTION="A set of Java libraries providing Unicode and Globalization support"
HOMEPAGE="https://icu.unicode.org"
SRC_URI="https://github.com/unicode-org/icu/archive/refs/tags/release-${PV/./-}.tar.gz -> ${P}.tar.gz"

LICENSE="icu"
SLOT="70"
KEYWORDS="amd64 ~arm ~arm64 ~ppc64 x86"

DEPEND=">=virtual/jdk-1.8:*
	test? ( dev-java/junitparams:0 )"

RDEPEND=">=virtual/jre-1.8:*"

S="${WORKDIR}/icu-release-${PV/./-}/icu4j/main"

HTML_DOCS=( ../{APIChangeReport,license,readme}.html )

JAVA_GENTOO_CLASSPATH_EXTRA="icu4j.jar:icu4j-charset.jar:icu4j-localespi.jar:testdata.jar:framework.jar"
JAVA_TEST_GENTOO_CLASSPATH="junit-4,junitparams"
JAVA_TEST_EXTRA_ARGS="-Djava.locale.providers=CLDR,COMPAT,SPI"

JAVA_TEST_SRC_DIR=(
	tests/charset/src
	tests/collate/src
	tests/core/src
#	tests/framework/src # we compile it in src_compile
	tests/localespi/src
	tests/packaging/src
	tests/translit/src
)

JAVA_TEST_RESOURCE_DIRS=(
	tests/charset/resources
	tests/collate/resources
	tests/core/resources
#	tests/framework/resources
	tests/localespi/resources
	tests/packaging/resources
	tests/translit/resources
)

JAVA_TEST_EXCLUDES=(
	"com.ibm.icu.dev.data.TestDataElements_testtypes" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.data.resources.TestDataElements_en_Latn_US" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.data.resources.TestDataElements_en_US" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.data.resources.TestDataElements_fr_Latn_FR" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.data.resources.TestDataElements_te" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.data.resources.TestMessages" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.test.translit.TestUtility" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.test.localespi.TestUtil" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.test.stringprep.TestData" # Invalid test class 1. No runnable methods
	"com.ibm.icu.dev.test.calendar.ChineseTestCase" # Invalid test class 1. Test class should have exactly one public zero-argument constructor
	"com.ibm.icu.dev.test.calendar.TestCase" # java.lang.IllegalArgumentException: Test class can only have one constructor
	"com.ibm.icu.dev.test.bidi.TestData" # Invalid test class 1. Test class should have exactly one public constructor
	# following kills 98 tests and and avoids 9 test failures
	# coverage tests fail because test handlers for the parametrized tests are not defined so the tests are broken and cannot succeed
	"com.ibm.icu.dev.test.serializable.CoverageTest"
)

src_prepare() {
	default

	# create the resources directories
	mkdir resources || die
	cp -r classes/* resources || die

	# remove .java files from resources
	find resources -type f -name '*.java' -exec rm -rf {} + || die "deleting classes failed"

	# this should not go in the jar files
	mv shared/licenses/license.html .. || die

	# icudata and icutzdata for "icu4j.jar"
	pushd resources/core/src || die
		jar -xf "${S}"/shared/data/icudata.jar || die
		jar -xf "${S}"/shared/data/icutzdata.jar || die
		# move these resources to "icu4j-charset.jar"
		mkdir -p "${S}"/resources/charset/src/com/ibm/icu/impl/data/icudt"$(ver_cut 1)"b || die
		mv com/ibm/icu/impl/data/icudt"$(ver_cut 1)"b/{*.cnv,cnvalias.icu} \
			"${S}"/resources/charset/src/com/ibm/icu/impl/data/icudt"$(ver_cut 1)"b || die

		# create 9 files com/ibm/icu/impl/data/icudt69b/*/fullLocaleNames.lst
		for dir in $(find com/ibm/icu/impl/data/icudt"$(ver_cut 1)"b/ -type d ! -name 'unit' -exec echo {} +); do
			ls -1 $dir/*.res | sed -e 's%.*\/%%' -e 's%\..*$%%' -e '/pool/d' -e '/res_index/d' -e '/tzdbNames/d'\
				> $dir/'fullLocaleNames.lst';
		done || die "fullLocaleNames.lst failed"
	popd

	# this test class was failing with "No runnable methods"
	# but test_excluding it would kill tousands of other tests.
	mkdir -p tests/framework/src/com/ibm/icu/dev/data/resources || die
	mv tests/{core,framework}/src/com/ibm/icu/dev/data/resources/TestDataElements.java || die

	# testdata.jar needs to be on classpath
	cp shared/data/testdata.jar . || die

	# clone tests src
	for i in charset collate core framework localespi packaging translit; do \
		cp -r tests/$i/{src,resources} ; \
		done || die "copying tests from src to resources failed"
	cp -r ../tools/misc/{src,resources} || die

	# separate tests resources from tests src
	find tests/*/resources -type f -name '*.java' -exec rm -rf {} + || die
	find ../tools/misc/resources -type f -name '*.java' -exec rm -rf {} + || die
}

src_compile() {
	# "icu4j.jar"
	JAVA_SRC_DIR=(
		classes/collate/src
		classes/core/src
		classes/currdata/src
		classes/langdata/src
		classes/regiondata/src
		classes/translit/src
	)
	JAVA_RESOURCE_DIRS=(
		resources/collate/src
		resources/core/src
		resources/currdata/src
		resources/langdata/src
		resources/regiondata/src
		resources/translit/src
		shared/licenses
	)
	JAVA_JAR_FILENAME="icu4j.jar"
	JAVA_MAIN_CLASS="com.ibm.icu.util.VersionInfo"
	java-pkg-simple_src_compile
	rm -r target || die

	# "icu4j-charset.jar"
	JAVA_SRC_DIR=( classes/charset/src )
	JAVA_RESOURCE_DIRS=( resources/charset/src shared/licenses )
	JAVA_JAR_FILENAME="icu4j-charset.jar"
	JAVA_MAIN_CLASS=""
	java-pkg-simple_src_compile
	rm -r target || die

	# "icu4j-localespi.jar"
	JAVA_SRC_DIR=( classes/localespi/src )
	JAVA_RESOURCE_DIRS=( resources/localespi/src shared/licenses )
	JAVA_JAR_FILENAME="icu4j-localespi.jar"
	java-pkg-simple_src_compile
	rm -r target || die

	# main/test/framework
	# needed for compilicg the tests
	# but "No runnable methods" ("Invalid test class")
	if use test; then
		JAVA_SRC_DIR=( tests/framework/src ../tools/misc/src )
		JAVA_RESOURCE_DIRS=( tests/framework/resources ../tools/misc/resources )
		JAVA_JAR_FILENAME="framework.jar"
		java-pkg-simple_src_compile
		rm -fr target || die
	fi

	# javadocs
	if use doc; then
		JAVA_SRC_DIR=( classes )
		JAVA_JAR_FILENAME="ignoreme.jar"
		java-pkg-simple_src_compile
	fi
}

src_test () {
	# https://bugs.gentoo.org/827212
	local vm_version="$(java-config -g PROVIDES_VERSION)"
	if [[ "${vm_version}" != "1.8" ]] ; then
		java-pkg-simple_src_test
	fi
}

src_install() {
	default
	java-pkg_dojar "icu4j.jar"
	java-pkg_dojar "icu4j-charset.jar"
	java-pkg_dojar "icu4j-localespi.jar"

	if use doc; then
		java-pkg_dojavadoc target/api
	fi
	if use source; then
		java-pkg_dosrc "classes"
	fi
}