File google-java-format.spec of Package google-java-format

#
# spec file for package google-java-format
#
# Copyright (c) 2023 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/
#


Name:           google-java-format
Version:        1.17.0
Release:        0
Summary:        Reformats Java source code to comply with Google Java Style
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
# How to describe LLVM-Release-License?
# License:        Apache-2.0 AND LLVM-Release-License
License:        Apache-2.0
Group:          Development/Libraries/Java
URL:            https://github.com/google/%{name}
Source0:        %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}.pod
BuildRequires:  fdupes
BuildRequires:  maven-local
BuildRequires:  mvn(com.google.auto.service:auto-service)
BuildRequires:  mvn(com.google.auto.service:auto-service-annotations)
BuildRequires:  mvn(com.google.auto.value:auto-value)
BuildRequires:  mvn(com.google.auto.value:auto-value-annotations)
BuildRequires:  mvn(com.google.code.maven-replacer-plugin:maven-replacer-plugin)
BuildRequires:  mvn(com.google.errorprone:error_prone_annotations)
BuildRequires:  mvn(org.checkerframework:checker-qual)
BuildRequires:  mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildArch:      noarch

%description
google-java-format is a program that reformats Java source code to comply with
Google Java Style.

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

%description javadoc
API documentation for %{name}.

%prep
%setup -q
%if %{?pkg_vcmp:%pkg_vcmp java-devel < 17}%{!?pkg_vcmp:0}
rm -rf core/src/main/java/com/google/googlejavaformat/java/java17
%endif

%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin :maven-shade-plugin core

%pom_xpath_remove 'pom:annotationProcessorPaths/pom:path[pom:artifactId="error_prone_core"]'
%pom_xpath_remove 'pom:arg[.="-Xplugin:ErrorProne"]'
%pom_xpath_remove 'pom:profile[pom:id="eclipse"]'

%build
%{mvn_build} -f -- -Djava.version=8 -Dsource=8

pod2man --release='%{name} %{version}' --section=1 --center='User Commands' --quotes=none %{SOURCE1} %{name}.1

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


%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 8}%{!?pkg_vcmp:0}
%define java_opts --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED\
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED\
%{nil}
%else
%define java_opts %{nil}
%endif

%jpackage_script com.google.googlejavaformat.java.Main "" "%{java_opts}" %{name}:guava:auto:google-errorprone %{name} true

install -dm0755 %{buildroot}%{_mandir}/man1
install -Dm0644 %{name}.1 %{buildroot}%{_mandir}/man1

%files -f .mfiles
%license LICENSE
%doc {README,CONTRIBUTING}.md
#%{_sysconfdir}/java/%{name}.conf
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}

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

%changelog
openSUSE Build Service is sponsored by