Name:           guava20
Version:        20.0
Release:        11
Summary:        Google Libraries for Java
License:        ASL 2.0 and CC0
URL:            https://github.com/google/guava
Source0:        https://github.com/google/guava/archive/v%{version}.tar.gz
BuildArch:      noarch
Patch0000:      0001-Avoid-presizing-arrays.patch
Patch0001:      CVE-2020-8908.patch
Patch0002:      CVE-2023-2976-pre.patch
Patch0003:      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.codehaus.mojo:build-helper-maven-plugin)
BuildRequires:  mvn(org.sonatype.oss:oss-parent:pom:)
Provides:       guava20-testlib = %{version}-%{release}
Obsoletes:      guava20-testlib < %{version}-%{release}

%description
Guava is a set of core libraries that includes new collection types ,immutable collections,
a graph library, and utilities for concurrency, I/O, hashing, primitives, strings, and more.

%package        help
Summary:        API documentation for guava20
Provides:       guava20-javadoc = %{version}-%{release}
Obsoletes:      guava20-javadoc < %{version}-%{release}

%description    help
Javadoc document for guava20.

%prep
%autosetup -n guava-%{version} -p1
find . -name '*.jar' -delete


%pom_disable_module guava-gwt
%pom_remove_plugin -r :animal-sniffer-maven-plugin
%pom_remove_plugin :maven-gpg-plugin
%pom_remove_dep jdk:srczip guava
%pom_remove_dep :caliper guava-tests
%mvn_package :guava-parent guava
%mvn_package :guava-tests __noinstall
%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 :animal-sniffer-annotations
%pom_remove_dep -r :error_prone_annotations
%pom_remove_dep -r :j2objc-annotations


annotations=$(fgrep -hr -e com.google.j2objc.annotations -e com.google.errorprone.annotation -e org.codehaus.mojo.animal_sniffer \
    | sort -u | sed 's/.*\.\([^.]*\);/\1/' | paste -sd\|)
find -name '*.java' | xargs sed -ri "s/^import .*\.($annotations);//;s/@($annotations)"'\>\s*(\((("[^"]*")|([^)]*))\))?//'

%build
%mvn_compat_version : 20.0 19.0 18.0 17.0 16.0.1 16.0 15.0 14.0.1 14.0 13.0.1 13.0 12.0.1 12.0 11.0.2 11.0.1 11.0 10.0.1 10.0
%mvn_alias :guava com.google.collections:google-collections com.google.guava:guava-jdk5
%mvn_build -s -f

%install
%mvn_install

%files -f .mfiles-guava -f .mfiles-guava-testlib
%license COPYING

%files help -f .mfiles-javadoc
%doc CONTRIBUTORS README*

%changelog
* Tue Jul 04 2023 wangkai <13474090681@163.com> - 20.0-11
- Fix CVE-2023-2976

* Fri Feb 26 2021 zhanghua <zhanghua40@huawei.com> - 20.0-10
- fix CVE-2020-8908

* Thu Dec 5 2019 zhujunhao <zhujunhao5@huawei.com> - 20.0-9
- Package init