#
# spec file for package derive4j
#
# 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/
#
%global base_name derive4j
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "bootstrap"
%bcond_without bootstrap
%else
%bcond_with bootstrap
%endif
%if %{with bootstrap}
%global name %{base_name}-%{flavor}
%else
%global name %{base_name}
%endif
Name: %{name}
Version: 1.1.1
Release: 0
Summary: Java 8 annotation processor and framework
License: GPL-3.0-only AND LGPL-3.0-only AND BSD-3-Clause
Group: Development/Libraries/Java
URL: https://github.com/%{base_name}/%{base_name}
Source0: %{url}/archive/refs/tags/v%{version}.tar.gz#/%{base_name}-%{version}.tar.gz
Source1: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}/%{version}/%{base_name}-%{version}.jar
Source2: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}/%{version}/%{base_name}-%{version}.pom
Source3: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}-annotation/%{version}/%{base_name}-annotation-%{version}.jar
Source4: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}-annotation/%{version}/%{base_name}-annotation-%{version}.pom
Source5: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}-processor-api/%{version}/%{base_name}-processor-api-%{version}.jar
Source6: https://repo1.maven.org/maven2/org/%{base_name}/%{base_name}-processor-api/%{version}/%{base_name}-processor-api-%{version}.pom
BuildRequires: maven-local
BuildArch: noarch
%if %{without bootstrap}
BuildRequires: mvn(com.google.auto.service:auto-service)
BuildRequires: mvn(com.squareup:javapoet)
BuildRequires: mvn(org.derive4j:derive4j-bootstrap) = %{version}
%endif
%description
Java 8 annotation processor and framework for deriving algebraic data types
constructors, pattern-matching, folds, optics and typeclasses.
%if %{without bootstrap}
%package javadoc
Summary: API documentation for %{name}
Group: Documentation/HTML
%description javadoc
API documentation for %{name}.
%endif
%prep
%if %{with bootstrap}
cp %{SOURCE2} %{SOURCE4} %{SOURCE6} .
%pom_xpath_set 'pom:project/pom:artifactId' '%{base_name}-bootstrap' \
%{base_name}-%{version}.pom
%pom_xpath_set 'pom:project/pom:artifactId' '%{base_name}-annotation-bootstrap' \
%{base_name}-annotation-%{version}.pom
%pom_xpath_set 'pom:project/pom:artifactId' '%{base_name}-processor-api-bootstrap' \
%{base_name}-processor-api-%{version}.pom
%pom_remove_dep 'org.derive4j' %{base_name}{,-processor-api}-%{version}.pom
%{mvn_file} ':%{name}{*}' %{name}/@1
%else
%setup -q
cp %{SOURCE2} processor/pom.xml
cp %{SOURCE4} annotation/pom.xml
cp %{SOURCE6} processor-api/pom.xml
cat <<__POM__ >pom.xml
4.0.0
org.derive4j
derive4j-parent
pom
%{version}
Derive4J - Parent POM
annotation
processor-api
processor
__POM__
cp processor/LICENSE.txt GPL-3.0-only.txt
cp annotation/LICENSE.txt LGPL-3.0-only.txt
cp examples/LICENSE.txt BSD-3-Clause.txt
%pom_add_plugin org.apache.maven.plugins:maven-compiler-plugin annotation processor-api \
'
org.derive4j
derive4j-bootstrap
%{version}
org.derive4j
derive4j-annotation-bootstrap
%{version}
org.derive4j
derive4j-processor-api-bootstrap
%{version}
org.derive4j.processor.DerivingProcessor
'
%pom_add_plugin org.apache.maven.plugins:maven-compiler-plugin processor \
'
com.google.auto.service
auto-service
1.0-rc5
org.derive4j
derive4j-bootstrap
%{version}
org.derive4j
derive4j-annotation-bootstrap
%{version}
org.derive4j
derive4j-processor-api-bootstrap
%{version}
org.derive4j.processor.DerivingProcessor
com.google.auto.service.processor.AutoServiceProcessor
'
%pom_add_dep com.google.auto.service:auto-service processor
%endif
%build
%if %{without bootstrap}
%{mvn_build} -f -- -Dmaven.compiler.{source,target}=8
%endif
%install
%if %{with bootstrap}
%{mvn_artifact} --skip-dependencies %{base_name}-%{version}.pom %{SOURCE1}
%{mvn_artifact} --skip-dependencies %{base_name}-annotation-%{version}.pom %{SOURCE3}
%{mvn_artifact} --skip-dependencies %{base_name}-processor-api-%{version}.pom %{SOURCE5}
%else
%{mvn_package} org.derive4j:%{name}-parent __noinstall
%endif
%mvn_install
%files -f .mfiles
%if %{without bootstrap}
%license LICENSES {GPL-3.0-only,LGPL-3.0-only,BSD-3-Clause}.txt
%doc README.md
%endif
%if %{without bootstrap}
%files javadoc -f .mfiles-javadoc
%license LICENSES {GPL-3.0-only,LGPL-3.0-only,BSD-3-Clause}.txt
%endif
%changelog