File snappy-java.spec of Package snappy-java

#
# spec file for package snappy-java
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
#


%global bitshuffle_version 0.5.2
%global soname snappyjava
Name:           snappy-java
Version:        1.1.10.7
Release:        0
Summary:        Snappy compressor/decompressor for Java
License:        Apache-2.0
Group:          Development/Libraries/Java
URL:            https://github.com/xerial/%{name}
Source0:        %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        https://repo1.maven.org/maven2/org/xerial/snappy/%{name}/%{version}/%{name}-%{version}.pom
Source2:        https://github.com/kiyo-masui/bitshuffle/archive/refs/tags/%{bitshuffle_version}.tar.gz#/bitshuffle-%{bitshuffle_version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  maven-local
BuildRequires:  mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires:  mvn(org.osgi:osgi.core)
BuildRequires:  snappy-devel

%description
%{name} is a Java port of the snappy, a fast C++ compresser/decompresser
developed by Google.

%package javadoc
Summary:        API documentation for %{name}
Group:          Documentation/HTML
BuildArch:      noarch

%description javadoc
API documentation for %{name}.

%prep
%autosetup

chmod 0644 NOTICE README.md

cat <<__VERSION__ >src/main/resources/org/xerial/snappy/VERSION
SNAPPY_VERSION=%{pkg_version snappy-devel}
BITSHUFFLE_VERSION=%{bitshuffle_version}
__VERSION__

rm -rf src/main/resources/org/xerial/snappy/native

cp %{SOURCE1} pom.xml

mkdir -p target/classes

tar -Ctarget -xf %{SOURCE2}

%pom_change_dep org.osgi:org.osgi.core :osgi.core

%pom_add_plugin org.apache.felix:maven-bundle-plugin \
'<extensions>true</extensions>
<configuration>
	<instructions>
		<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
		<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
		<Bundle-DocURL>http://www.xerial.org/</Bundle-DocURL>
		<Bundle-License>http://www.apache.org/licenses/LICENSE-2.0.txt</Bundle-License>
		<Bundle-Name>snappy-java: A fast compression/decompression library</Bundle-Name>
		<Bundle-SymbolicName>org.xerial.snappy.snappy-java</Bundle-SymbolicName>
		<Bundle-Vendor>xerial.org</Bundle-Vendor>
		<Implementation-Title>%{name}</Implementation-Title>
		<Implementation-URL>%{url}</Implementation-URL>
		<Implementation-Vendor-Id>org.xerial.snappy</Implementation-Vendor-Id>
		<Implementation-Vendor>xerial.org</Implementation-Vendor>
		<Implementation-Version>%{version}</Implementation-Version>
		<Specification-Title>snappy-java</Specification-Title>
		<Specification-Vendor>xerial.org</Specification-Vendor>
		<Specification-Version>%{version}</Specification-Version>
	</instructions>
</configuration>
<executions>
	<execution>
		<id>bundle-manifest</id>
		<phase>process-classes</phase>
		<goals>
			<goal>manifest</goal>
		</goals>
	</execution>
</executions>'

%{mvn_file} : %{name}

%build
g++ %{optflags} \
	-fPIC -fpermissive -fvisibility=hidden -std=c++11 \
	-I%{_jvmdir}/java/include{,/linux} \
	-Itarget/bitshuffle-%{bitshuffle_version}/src \
	target/bitshuffle-%{bitshuffle_version}/src/{bitshuffle_core,iochain}.c \
	src/main/java/org/xerial/snappy/{Snappy,BitShuffle}Native.{cpp,h} \
	-lsnappy -shared -Wl,-soname,%{soname} -otarget/lib%{soname}.so

cat <<__PROPERTIES__ >target/classes/org-xerial-snappy.properties
org.xerial.snappy.use.systemlib=true
__PROPERTIES__

%{mvn_build} -f -- \
	-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ)

%install
%mvn_install
%fdupes %{buildroot}%{_javadocdir}/%{name}

install -dm0755 %{buildroot}%{_libdir}
install -pm0755 target/lib%{soname}.so %{buildroot}%{_libdir}

%files -f .mfiles
%license NOTICE LICENSE
%doc {SECURITY,README}.md
%{_libdir}/lib%{soname}.so

%files javadoc -f .mfiles-javadoc
%license NOTICE LICENSE

%changelog
openSUSE Build Service is sponsored by