Gentoo Archives: gentoo-commits

From: "Miroslav Šulc" <fordfrog@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-java/commons-logging/
Date: Sat, 26 Feb 2022 08:52:25
Message-Id: 1645865305.de2db80524e6e55868462ac22d89c48ff37e341a.fordfrog@gentoo
1 commit: de2db80524e6e55868462ac22d89c48ff37e341a
2 Author: Yuan Liao <liaoyuan <AT> gmail <DOT> com>
3 AuthorDate: Sat Feb 26 02:59:49 2022 +0000
4 Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 26 08:48:25 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de2db805
7
8 dev-java/commons-logging: Let build.xml accept log4j-12-api as Log4j 1.2
9
10 Closes: https://bugs.gentoo.org/834036
11 Signed-off-by: Yuan Liao <liaoyuan <AT> gmail.com>
12 Closes: https://github.com/gentoo/gentoo/pull/24352
13 Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
14
15 ...1.2-r4.ebuild => commons-logging-1.2-r5.ebuild} | 48 ++++++++++++++++++----
16 1 file changed, 41 insertions(+), 7 deletions(-)
17
18 diff --git a/dev-java/commons-logging/commons-logging-1.2-r4.ebuild b/dev-java/commons-logging/commons-logging-1.2-r5.ebuild
19 similarity index 53%
20 rename from dev-java/commons-logging/commons-logging-1.2-r4.ebuild
21 rename to dev-java/commons-logging/commons-logging-1.2-r5.ebuild
22 index d32f9e36c65e..cfe4860720b9 100644
23 --- a/dev-java/commons-logging/commons-logging-1.2-r4.ebuild
24 +++ b/dev-java/commons-logging/commons-logging-1.2-r5.ebuild
25 @@ -22,7 +22,11 @@ RESTRICT="!test? ( test ) !servletapi? ( test )"
26 CDEPEND="
27 avalon-logkit? ( dev-java/avalon-logkit:2.0 )
28 avalon-framework? ( dev-java/avalon-framework:4.2 )
29 - log4j? ( dev-java/log4j-12-api:2 )
30 + log4j? (
31 + dev-java/log4j-12-api:2
32 + dev-java/log4j-api:2
33 + dev-java/log4j-core:2
34 + )
35 servletapi? ( dev-java/tomcat-servlet-api:4.0 )"
36
37 RDEPEND="
38 @@ -38,7 +42,6 @@ S="${WORKDIR}/${P}-src"
39
40 EANT_BUILD_TARGET="compile"
41 JAVA_ANT_REWRITE_CLASSPATH="yes"
42 -JAVA_ANT_CLASSPATH_TAGS="javac javadoc"
43 JAVA_ANT_IGNORE_SYSTEM_CLASSES="yes"
44
45 DOCS=( RELEASE-NOTES.txt PROPOSAL.html )
46 @@ -55,20 +58,41 @@ src_prepare() {
47
48 if use avalon-framework; then
49 echo "avalon-framework.jar=$(java-pkg_getjars avalon-framework-4.2)" >> build.properties || die
50 - EANT_GENTOO_CLASSPATH+=" avalon-framework-4.2"
51 fi
52 if use avalon-logkit; then
53 echo "logkit.jar=$(java-pkg_getjars avalon-logkit-2.0)" >> build.properties || die
54 - EANT_GENTOO_CLASSPATH+=" avalon-logkit-2.0"
55 fi
56 if use log4j; then
57 - echo "log4j12.jar=$(java-pkg_getjars log4j-12-api-2,log4j-core-2)" >> build.properties || die
58 - EANT_GENTOO_CLASSPATH+=" log4j-12-api-2 log4j-core-2"
59 + # log4j12.jar can only contain path to one single file because
60 + # build.xml decides whether the Log4JLogger should be built with
61 + # <available file="${log4j12.jar}" property="log4j12.present"/>,
62 + # and a value that contains multiple file paths will cause the
63 + # test to return a negative result. However, classes from multiple
64 + # Log4j 2 JARs are needed to compile the sources. So, we combine
65 + # them into a single JAR on the go.
66 + # https://bugs.gentoo.org/834036
67 + mkdir -p "${T}/log4j-2" ||
68 + die "Failed to create temporary directory for Log4j 2 classes"
69 + pushd "${T}/log4j-2" > /dev/null ||
70 + die "Failed to enter temporary directory for Log4j 2 classes"
71 +
72 + local jar="$(java-config -j)"
73 + local dep
74 + for dep in log4j-{12-api,api,core}; do
75 + # Assuming SLOT="2" for Log4j 2 dependencies
76 + "${jar}" -xf "$(java-pkg_getjar "${dep}-2" "${dep}.jar")" ||
77 + die "Failed to extract files from ${dep}-2 installed on system"
78 + done
79 + "${jar}" -cf log4j-2.jar . || die "Failed to create JAR for Log4j"
80 +
81 + popd > /dev/null ||
82 + die "Failed to leave temporary directory for Log4j 2 classes"
83 +
84 + echo "log4j12.jar=${T}/log4j-2/log4j-2.jar" >> build.properties || die
85 fi
86
87 if use servletapi; then
88 echo "servletapi.jar=$(java-pkg_getjar tomcat-servlet-api-4.0 servlet-api.jar)" >> build.properties || die
89 - EANT_GENTOO_CLASSPATH+=" tomcat-servlet-api-4.0"
90 fi
91 }
92
93 @@ -84,5 +108,15 @@ src_install() {
94 }
95
96 src_test() {
97 + # Do not run Log4j tests because these tests use an Appender to verify
98 + # logging correctness. The log4j-12-api bridge no longer supports using an
99 + # Appender for verifications since the methods for adding an Appender in
100 + # the bridge "are largely no-ops". This means an Appender's state would
101 + # never be changed by log4j-12-api after new messages are logged. The test
102 + # cases, however, expect changes to the Appender's state in such an event,
103 + # so they would fail with log4j-12-api.
104 + # https://logging.apache.org/log4j/log4j-2.8/log4j-1.2-api/index.html
105 + sed -i -e "/^log4j12\.jar=/d" build.properties ||
106 + die "Failed to skip Log4j tests by modifying build.properties"
107 java-pkg-2_src_test
108 }