blob: f958347a176bb236c90b6d7759d8ff867666bdf7 (
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
|
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
JAVA_PKG_IUSE="doc source test"
MAVEN_ID="commons-logging:commons-logging:${PV}"
JAVA_TESTING_FRAMEWORKS="junit-4"
inherit java-pkg-2 java-pkg-simple verify-sig
DESCRIPTION="Thin adapter allowing configurable bridging to other well known logging systems"
HOMEPAGE="https://commons.apache.org/proper/commons-logging/"
SRC_URI="mirror://apache/commons/logging/source/${P}-src.tar.gz
verify-sig? ( https://downloads.apache.org/commons/logging/source/${P}-src.tar.gz.asc )"
S="${WORKDIR}/${P}-src"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64 ~arm64 ~ppc64 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
IUSE="log4j"
# src/test/java/org/apache/commons/logging/tccl/logfactory/AdaptersTcclTestCase.java:26:
# error: cannot find symbol
# import org.apache.commons.logging.impl.Log4jApiLogFactory;
# ^
# symbol: class Log4jApiLogFactory
# location: package org.apache.commons.logging.impl
REQUIRED_USE="test? ( log4j )"
VERIFY_SIG_OPENPGP_KEY_PATH="/usr/share/openpgp-keys/commons.apache.org.asc"
BDEPEND="verify-sig? ( sec-keys/openpgp-keys-apache-commons )"
COMMON_DEPEND="
dev-java/jakarta-servlet-api:4
dev-java/slf4j-api:0
log4j? (
dev-java/log4j-12-api:2
dev-java/log4j-api:2
)
"
DEPEND="
${COMMON_DEPEND}
>=virtual/jdk-11:*
test? (
dev-java/commons-io:1
dev-java/junit:5
)
"
RDEPEND="
${COMMON_DEPEND}
>=virtual/jre-1.8:*
"
DOCS=( NOTICE.txt src/changes/changes.xml )
HTML_DOCS=( PROPOSAL.html )
JAVA_GENTOO_CLASSPATH="
jakarta-servlet-api-4
slf4j-api
"
JAVA_SRC_DIR="src/main/java"
src_prepare() {
java-pkg-2_src_prepare
# https://avalon.apache.org/closed.html Apache Avalon has closed.
rm src/main/java/org/apache/commons/logging/impl/{Avalon,LogKit}Logger.java || die
rm src/test/java/org/apache/commons/logging/{avalon/AvalonLogger,logkit/Standard}TestCase.java || die
if use !log4j; then
rm src/main/java/org/apache/commons/logging/impl/Log4JLogger.java || die
rm src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java || die
else
JAVA_GENTOO_CLASSPATH+="
log4j-12-api-2
log4j-api-2
"
fi
}
src_compile() {
# getting dependencies into the modulepath
DEPENDENCIES=(
jakarta-servlet-api-4
slf4j-api
$(use log4j && echo log4j-12-api-2)
$(use log4j && echo log4j-api-2)
)
local modulepath
for dependency in ${DEPENDENCIES[@]}; do
modulepath="${modulepath}:$(java-pkg_getjars --build-only ${dependency})"
done
local JAVA_MODULE_NAME="org.apache.${PN/-/.}"
JAVA_JAR_FILENAME="${JAVA_MODULE_NAME}.jar"
java-pkg-simple_src_compile # creates a legacy jar file without module-info
# generate module-info.java
jdeps \
--module-path "${modulepath}" \
--add-modules=ALL-MODULE-PATH \
--generate-module-info src/main \
--multi-release 9 \
"${JAVA_MODULE_NAME}.jar" || die
# compile module-info.java
ejavac \
-source 9 -target 9 \
--module-path "${modulepath}" \
--patch-module "${JAVA_MODULE_NAME}"="${JAVA_MODULE_NAME}.jar" \
-d target/versions/9 \
src/main/"${JAVA_MODULE_NAME}"/versions/9/module-info.java
# package
JAVA_JAR_FILENAME="${PN}.jar"
jar cvf "${JAVA_JAR_FILENAME}" \
-C target/classes . \
--release 9 -C target/versions/9 . || die
pushd target/classes > /dev/null || die
# pom.xml, lines 81-103
jar -cvf ../../commons-logging-api.jar \
$(find . -type f -name '*.class' \
! -name 'Jdk13LumberjackLogger.class' \
! -name 'ServletContextCleaner.class' \
) || die
# pom.xml, lines 205-124
jar -cvf ../../commons-logging-adapters.jar \
$(find . -type f -path './org/apache/commons/logging/impl/**.class' \
! -name 'WeakHashtable*.class' \
! -name 'LogFactoryImpl*.class' \
) || die
popd > /dev/null || die
}
src_test() {
# Do not run Log4j tests because these tests use an Appender to verify
# logging correctness. The log4j-12-api bridge no longer supports using an
# Appender for verifications since the methods for adding an Appender in
# the bridge "are largely no-ops". This means an Appender's state would
# never be changed by log4j-12-api after new messages are logged. The test
# cases, however, expect changes to the Appender's state in such an event,
# so they would fail with log4j-12-api.
# https://logging.apache.org/log4j/log4j-2.8/log4j-1.2-api/index.html
rm src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java || die # Log4JLogger
rm src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java || die # Log4JLogger
rm -r src/test/java/org/apache/commons/logging/log4j || die
rm src/test/java/org/apache/commons/logging/log4j2/CallerInformationTestCase.java || die
# error: package ch.qos.logback.classic does not exist
rm src/test/java/org/apache/commons/logging/slf4j/CallerInformationTestCase.java || die
JAVA_TEST_EXCLUDES=(
org.apache.commons.logging.jdk14.TestHandler # No runnable methods
# junit.framework.AssertionFailedError: Wrong factory retrieved through
# ServiceLoader: org.apache.commons.logging.impl.Slf4jLogFactory
org.apache.commons.logging.serviceloader.ServiceLoaderTestCase
# junit.framework.ComparisonFailure: Log class expected:<...ommons.logging.impl.[NoOp]Log>
# but was:<...ommons.logging.impl.[Slf4jLogFactory$Slf4j]Log>
org.apache.commons.logging.noop.NoOpLogTestCase
# org.junit.runners.model.InvalidTestClassyyError: Invalid test class
org.apache.commons.logging.LogSourceTest # No runnable methods
# junit.framework.AssertionFailedError: Logging config succeeded when context class loader was null!
org.apache.commons.logging.LoadTestCase
# junit.framework.AssertionFailedError:
# expected:<org.apache.commons.logging.PathableClassLoader@1edf1c96>
# but was:<org.apache.commons.logging.PathableClassLoader@15615099>
org.apache.commons.logging.tccl.logfactory.AdaptersTcclTestCase
)
JAVA_TEST_EXTRA_ARGS=(
-Dcommons-lang3="$(java-pkg_getjars commons-lang-3.6)"
-Dlog4j-api="commons-logging-api.jar"
-Dservlet-api="$(java-pkg_getjars jakarta-servlet-api-4)"
-Dcommons-logging="commons-logging.jar"
-Dcommons-logging-api="commons-logging-api.jar"
-Dcommons-logging-adapters="commons-logging-adapters.jar"
-Dtestclasses="target/test-classes"
)
if use log4j; then
JAVA_TEST_EXTRA_ARGS+=" -Dlog4j12=$(java-pkg_getjars log4j-12-api-2,log4j-core-2)"
fi
JAVA_TEST_GENTOO_CLASSPATH="commons-io-1 commons-lang-3.6 junit-4 junit-5"
JAVA_TEST_RESOURCE_DIRS="src/test/resources"
JAVA_TEST_SRC_DIR="src/test/java"
java-pkg-simple_src_test
}
|