File epublib.spec of Package epublib

#
# spec file for package epublib
#
# Copyright (c) 2024 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 git_hash 4936fd9
%global git_date 20210503
Name:           epublib
Version:        4.0+git%{git_date}.%{git_hash}
Release:        0
Summary:        A java library for reading and writing epub files
# See CREDITS, http://www.siegmann.nl/epublib/license
License:        LGPL-3.0-only AND CC-BY-3.0
Group:          Development/Libraries/Java
URL:            http://www.siegmann.nl/%{name}
Source0:        https://github.com/psiegman/%{name}/tarball/%{git_hash}#/%{name}-%{version}.tar.gz
Source1:        https://www.gnu.org/licenses/lgpl-3.0.txt
Source2:        https://creativecommons.org/licenses/by/3.0/legalcode.txt
Patch0:         00-htmlcleaner-2.29.patch
BuildRequires:  fdupes
BuildRequires:  maven-local
BuildRequires:  mvn(net.sf.kxml:kxml2)
BuildRequires:  mvn(net.sourceforge.htmlcleaner:htmlcleaner)
BuildRequires:  mvn(org.apache.commons:commons-lang3)
BuildRequires:  mvn(org.apache.commons:commons-vfs2)
BuildArch:      noarch

%description
Epublib is a java library for reading/writing/manipulating epub files.

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

%description javadoc
API documentation for %{name}.

%prep
%setup -q -n psiegman-%{name}-%{git_hash}
%patch -P0 -p1
cp %{SOURCE1} .
cp %{SOURCE2} .

%pom_remove_plugin :maven-shade-plugin %{name}-{core,tools}
%pom_remove_plugin :maven-source-plugin %{name}-parent
%pom_remove_plugin :maven-javadoc-plugin %{name}-parent
%pom_remove_plugin com.jolira:onejar-maven-plugin %{name}-tools

%pom_change_dep xmlpull:xmlpull xpp3:xpp3 %{name}-{core,tools}
%pom_change_dep commons-vfs:commons-vfs org.apache.commons:commons-vfs2 %{name}-tools
%pom_change_dep -r commons-lang:commons-lang org.apache.commons:commons-lang3 %{name}-tools

pushd epublib-tools/src/main/java/nl/siegmann/epublib/
sed -i -e 's/\<org\.apache\.commons\.lang\>/org.apache.commons.lang3/g' \
	Fileset2Epub.java \
	bookprocessor/CoverpageBookProcessor.java \
	bookprocessor/SectionHrefSanityCheckBookProcessor.java \
	bookprocessor/SectionTitleBookProcessor.java \
	chm/HHCParser.java \
	search/SearchIndex.java \
	util/ToolsResourceUtil.java \
	viewer/ContentPane.java \
	viewer/ImageLoaderCache.java \
	viewer/MetadataPane.java \
	viewer/TableOfContentsPane.java \
	viewer/Viewer.java

sed -i -e 's/\<org\.apache\.commons\.vfs\>/org.apache.commons.vfs2/g' \
	Fileset2Epub.java \
	chm/ChmParser.java \
	fileset/FilesetBookCreator.java \
	util/VFSUtil.java

sed -i -e 's/\<unescapeHtml\>/unescapeHtml4/g' \
	search/SearchIndex.java \
	util/ToolsResourceUtil.java

sed -i -e 's/\<escapeHtml\>/escapeHtml4/g' \
	bookprocessor/CoverpageBookProcessor.java

popd

%build
%{mvn_build} -f -- \
	-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
	-D{source,target}.version=8 \
	-f %{name}-parent

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

%jpackage_script nl.siegmann.epublib.Fileset2Epub "" "" %{name}:htmlcleaner:commons-io:commons-vfs:apache-commons-lang:slf4j/api:xpp3 %{name} true

%files -f .mfiles
%license CREDITS lgpl-3.0.txt legalcode.txt
%doc README.md
%{_bindir}/%{name}

%files javadoc -f .mfiles-javadoc
%license CREDITS lgpl-3.0.txt legalcode.txt

%changelog
openSUSE Build Service is sponsored by