commit:     314e6c223bc95dcc30f857b13a17332d9b759b79
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 15 09:44:26 2025 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Tue Apr 15 10:34:53 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=314e6c22

dev-java/protobuf-java: update SRC_URI and fix src_test

The protobuf packages use a shared distfile. However, some packages use
github's release artifacts, e.g.,
https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protobuf-30.2.tar.gz
while protobuf-java used github's archive artifacts, e.g.,
https://github.com/protocolbuffers/protobuf/archive/v${MY_PV}.tar.gz

This can cause a distfile mismatch. If the user has protobuf-30.2.tar.gz
from releases in its DISTDIR and then tries to emerge protobuf-java.

Fix this by switching protobuf-java's SRC_URI to the release artifacts.

Furthermore, fix src_test. The JAVA_TEST_RUN_ONLY array would contain
fully qualified Java class names prefixed by two dots. For example
'..com.example.FooTest' instead of 'com.example.FooTest'. This is caused
by invoking 'find' with ./* instead of *, and the
JAVA_TEST_RUN_ONLY="${JAVA_TEST_RUN_ONLY//\//.}" substitution.

Fix this by adjusting the 'find' invocation.

Furthermore, move a 'rm' from src_test to src_prepare, where it
belongs. Having 'rm' in src_test makes it harder to re-execute
subsequent ebuild phases using the 'ebuild' command, e.g., "ebuild
protobuf-java-4.30.2.ebuild test", as the 'rm' would fail because the
file no longer exists.

Also zap CodedInputStreamTest as it requires the TestParameterInjector
library, which is currently not available in ::gentoo.

It seems like the ebuild's src_test could never have succeeded so far.

Finally, drop unused protobuf_ABSL_PROVIDER=package cmake argument and
fix this QA warning. This option is replaced with upstream's
protobuf_LOCAL_DEPENDENCIES_ONLY=ON to prevent automatic dep fetching.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 dev-java/protobuf-java/protobuf-java-4.30.2.ebuild | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/dev-java/protobuf-java/protobuf-java-4.30.2.ebuild 
b/dev-java/protobuf-java/protobuf-java-4.30.2.ebuild
index d6c978e01de4..23bafe370339 100644
--- a/dev-java/protobuf-java/protobuf-java-4.30.2.ebuild
+++ b/dev-java/protobuf-java/protobuf-java-4.30.2.ebuild
@@ -21,7 +21,7 @@ MY_PV="$(ver_cut 2-3)"
 MY_PV="${MY_PV/_rc/-rc}"
 TV="1.4.4"
 SRC_URI="
-       https://github.com/protocolbuffers/protobuf/archive/v${MY_PV}.tar.gz -> 
protobuf-${MY_PV}.tar.gz
+       
https://github.com/protocolbuffers/protobuf/releases/download/v${MY_PV}/protobuf-${MY_PV}.tar.gz
        test? (
                
https://repo1.maven.org/maven2/com/google/truth/truth/${TV}/truth-${TV}.jar
        )
@@ -97,12 +97,19 @@ src_prepare() {
        # Split the file in two parts, one for each run-protoc call
        awk '/--java_out/{x="test-sources-build-"++i;}{print > x;}' \
                java/core/generate-test-sources-build.xml || die
+
+       # Requires TestParameterInjector library, currently not available in 
Gentoo.
+       rm 
java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java || die
+
+       # java/core/src/test/java/editions_unittest/TestDelimited.java:2867:
+       # error: package editions_unittest.MessageImport does not exist
+       rm java/core/src/test/java/com/google/protobuf/TextFormatTest.java || 
die
 }
 
 src_configure() {
        local mycmakeargs=(
                -Dprotobuf_BUILD_TESTS=OFF
-               -Dprotobuf_ABSL_PROVIDER=package
+               -Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON
        )
        if ! use system-protoc; then
                cmake_src_configure
@@ -136,21 +143,17 @@ src_test() {
        run-protoc @test-sources-build-2 \
                || die "run-protoc test-sources-build-2 failed"
 
-       # java/core/src/test/java/editions_unittest/TestDelimited.java:2867:
-       # error: package editions_unittest.MessageImport does not exist
-       rm java/core/src/test/java/com/google/protobuf/TextFormatTest.java || 
die
-
        einfo "Running tests"
        # Invalid test class 'map_test.MapInitializationOrderTest':
        # 1. Test class should have exactly one public constructor
        # Invalid test class 'protobuf_unittest.CachedFieldSizeTest':
        # 1. Test class should have exactly one public constructor
        pushd "${JAVA_TEST_SRC_DIR}" >/dev/null || die
-               local JAVA_TEST_RUN_ONLY=$(find ./* \
+               local JAVA_TEST_RUN_ONLY=$(find * \
                        -path "**/*Test.java" \
                        ! -path "**/Abstract*Test.java" \
                        ! -name "MapInitializationOrderTest.java" \
-                       ! -path '*protobuf_unittest/CachedFieldSizeTest.java'
+                       ! -name CachedFieldSizeTest.java
                        )
        popd >/dev/null || die
        JAVA_TEST_RUN_ONLY="${JAVA_TEST_RUN_ONLY//.java}"

Reply via email to