Name:           guava
Version:        31.1
Release:        1
Summary:        Google Core Libraries for Java
License:        ASL 2.0 and CC0
URL:            https://github.com/google/guava
BuildArch:      noarch

Source0:        https://github.com/google/guava/archive/v%{version}/guava-%{version}.tar.gz
Source1:        java_remove_symbols.lua
Source2:        java_symbols_lib.lua

Patch0001:      CVE-2023-2976-pre.patch
Patch0002:      CVE-2023-2976.patch

BuildRequires:  maven-local mvn(com.google.code.findbugs:jsr305) mvn(junit:junit)
BuildRequires:  mvn(org.apache.felix:maven-bundle-plugin) mvn(org.sonatype.oss:oss-parent:pom:)
BuildRequires:  java-17-openjdk-devel
Requires:       java-17-openjdk


%description
Guava is a set of core Java libraries from Google that includes new collection
types (such as multimap and multiset), immutable collections, a graph library,
and utilities for concurrency, I/O, hashing, caching, primitives, strings,
and more! It is widely used on most Java projects within Google, and widely 
used by many other companies as well.

%package help
Summary:        javadoc for guava
Provides:       %{name}-javadoc = %{version}-%{release}
Obsoletes:      %{name}-javadoc < %{version}-%{release}

%description help
API documentation for guava

%package testlib
Summary:        The guava-testlib artifact

%description testlib
To facilitate unit testing, guava-testlib provides additional features

%prep
%autosetup -p1 -n %{name}-%{version}

find . -name '*.jar' -delete

%pom_remove_parent guava-bom

%pom_disable_module guava-gwt
%pom_disable_module guava-tests

%pom_xpath_inject pom:modules "<module>futures/failureaccess</module>"
%pom_xpath_inject pom:parent "<relativePath>../..</relativePath>" futures/failureaccess
%pom_xpath_set pom:parent/pom:version %{version}-jre futures/failureaccess

%pom_remove_plugin -r :animal-sniffer-maven-plugin
%pom_remove_plugin :maven-dependency-plugin guava

%pom_remove_dep :caliper guava-tests

%mvn_package :guava-parent guava

%pom_remove_plugin -r :maven-javadoc-plugin

%pom_xpath_inject /pom:project/pom:build/pom:plugins/pom:plugin/pom:configuration/pom:instructions "<_nouses>true</_nouses>" guava/pom.xml
 
%pom_remove_dep -r :error_prone_annotations
%pom_remove_dep -r :j2objc-annotations
%pom_remove_dep -r org.checkerframework:
%pom_remove_dep -r :listenablefuture

export LUA_PATH=%{SOURCE2}

/usr/bin/lua %{SOURCE1} -a guava guava-testlib -p org[.]checkerframework[.]
/usr/bin/lua %{SOURCE1} -a guava guava-testlib -p com[.]google[.]common[.]annotations[.]
/usr/bin/lua %{SOURCE1} -a guava guava-testlib -p com[.]google[.]errorprone[.]annotations[.]
/usr/bin/lua %{SOURCE1} -a guava guava-testlib -p com[.]google[.]j2objc[.]annotations[.]


%mvn_package "com.google.guava:failureaccess" guava

%mvn_package "com.google.guava:guava-bom" __noinstall

%build
export JAVA_HOME=%{_jvmdir}/java-17-openjdk
export CFLAGS="${RPM_OPT_FLAGS}"
export CXXFLAGS="${RPM_OPT_FLAGS}"
%mvn_build -s -f

%install
%mvn_install

%files -f .mfiles-guava
%doc CONTRIBUTORS README*
%license COPYING

%files help -f .mfiles-javadoc
%license COPYING

%files testlib -f .mfiles-guava-testlib

%changelog
* Wed Sep 27 2023 chenchen <chen_aka_jan@163.com> - 31.1-1
- Upgrade to version 31.1

* Tue Jul 04 2023 wangkai <13474090681@163.com> - 25.0-6
- Fix CVE-2023-2976

* Fri Feb 19 2021 wangxiao <wangxiao65@huawei.com> - 25.0-5
- Fix CVE-2020-8908

* Fri Mar 6 2020 dingyiming <dingyiming3@huawei.com> - 25.0-4
- Package init
