protobuf/protobuf-java.spec

213 lines
6.4 KiB
RPMSpec
Raw Normal View History

#
# spec file for package protobuf-java
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Andreas Stieger <Andreas.Stieger@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define tarname protobuf
%define baseversion 28.2
%global buildarch %{_arch}
%ifarch x86_64
%global buildarch x86_64
%endif
%ifarch ppc
%global buildarch ppc_32
%endif
%ifarch ppc64
%global buildarch ppc_64
%endif
%ifarch ppc64le
%global buildarch ppcle_64
%endif
%ifarch %{ix86}
%global buildarch x86_32
%endif
%ifarch ia64
%global buildarch itanium_64
%endif
%ifarch s390
%global buildarch s390_32
%endif
%ifarch s390x
%global buildarch s390_64
%endif
%ifarch %{arm}
%global buildarch arm_32
%endif
%ifarch %{aarch64}
%global buildarch aarch_64
%endif
# 32 bit sparc, optimized for v9
%ifarch sparcv9
%global buildarch sparc_32
%endif
# 64 bit sparc
%ifarch sparc64
%global buildarch sparc_64
%endif
Name: protobuf-java
Version: 4.%{baseversion}
Release: 0
Summary: Java Bindings for Google Protocol Buffers
License: BSD-3-Clause
Group: Development/Libraries/Java
URL: https://github.com/protocolbuffers/protobuf
Source0: https://github.com/protocolbuffers/protobuf/releases/download/v%{baseversion}/%{tarname}-%{baseversion}.tar.gz
Source1: https://repo1.maven.org/maven2/com/google/protobuf/%{name}/%{version}/%{name}-%{version}.pom
Source2: https://repo1.maven.org/maven2/com/google/protobuf/%{name}lite/%{version}/%{name}lite-%{version}.pom
Source3: https://repo1.maven.org/maven2/com/google/protobuf/%{name}-util/%{version}/%{name}-util-%{version}.pom
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: maven-local
BuildRequires: protobuf-devel >= %{baseversion}
BuildRequires: mvn(com.google.code.findbugs:jsr305)
BuildRequires: mvn(com.google.code.gson:gson)
BuildRequires: mvn(com.google.errorprone:error_prone_annotations)
BuildRequires: mvn(com.google.guava:guava)
BuildRequires: mvn(com.google.j2objc:j2objc-annotations)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
Requires: %{tarname}-devel >= %{baseversion}
Requires: java >= 1.8
Obsoletes: %{tarname}-devel < %{baseversion}
%description
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
This package contains the Java bindings.
%package parent
Summary: Java Bindings for Google Protocol Buffers (parent pom)
BuildArch: noarch
%description parent
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
This package contains the parent pom of the Java bindings.
%package bom
Summary: Java Bindings for Google Protocol Buffers (bom)
BuildArch: noarch
%description bom
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
This package contains the bill-of-materials pom of the Java bindings.
%package javadoc
Summary: Javadoc for %{name}
Group: Documentation/HTML
BuildArch: noarch
%description javadoc
This package contains the API documentation for %{name}.
%prep
%autosetup -p1 -n %{tarname}-%{baseversion}
# The previous blank line is crucial for older system being able
# to use the autosetup macro
pushd java
cp %{SOURCE1} core/pom.xml
cp %{SOURCE2} lite/pom.xml
cp %{SOURCE3} util/pom.xml
%pom_disable_module kotlin
%pom_disable_module kotlin-lite
%pom_disable_module lite
%pom_remove_plugin :animal-sniffer-maven-plugin
%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:source" "1.8"
%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:target" "1.8"
%{mvn_package} :{*}-parent parent
%{mvn_package} :{*}-bom bom
%{mvn_file} :{*} @1
%{mvn_file} :%{name} %{tarname}
popd
%build
pushd java
protoc \
--java_out=core/src/main/java \
--proto_path=../src \
--proto_path=core/src/main/resources/google/protobuf \
core/src/main/resources/google/protobuf/java_features.proto
for i in \
../src/google/protobuf/any.proto \
../src/google/protobuf/api.proto \
../src/google/protobuf/descriptor.proto \
../src/google/protobuf/duration.proto \
../src/google/protobuf/empty.proto \
../src/google/protobuf/field_mask.proto \
../src/google/protobuf/source_context.proto \
../src/google/protobuf/struct.proto \
../src/google/protobuf/timestamp.proto \
../src/google/protobuf/type.proto \
../src/google/protobuf/wrappers.proto \
../src/google/protobuf/compiler/plugin.proto; do
protoc \
--java_out=core/src/main/java \
--proto_path=../src \
--proto_path=core/src/main/resources/google/protobuf \
${i}
cp ${i} core/src/main/resources/google/protobuf/
done
%{mvn_build} -f -- -Dprotoc=$(type -p protoc)
popd
%install
pushd java
%mvn_install
%fdupes -s %{buildroot}%{_javadocdir}
# create maven metadata for the protoc executable
install -dm 0755 %{buildroot}%{_datadir}/maven-metadata
cat <<__PROTOBUF__ >>%{buildroot}%{_datadir}/maven-metadata/%{name}-protoc.xml
<metadata xmlns="http://fedorahosted.org/xmvn/METADATA/2.3.0">
<artifacts>
<artifact>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<extension>exe</extension>
<classifier>linux-%{buildarch}</classifier>
<version>%{version}</version>
<path>$(type -p protoc)</path>
</artifact>
</artifacts>
</metadata>
__PROTOBUF__
popd
%files -f java/.mfiles
%license LICENSE
%{_datadir}/maven-metadata/%{name}-protoc.xml
%files bom -f java/.mfiles-bom
%files parent -f java/.mfiles-parent
%files javadoc -f java/.mfiles-javadoc
%license LICENSE
%changelog