File woodstox.spec of Package woodstox

#
# spec file for package woodstox
#
# Copyright (c) 2025 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/
#


%define section   	free
%define mvn_version 4.4.1

Name:           woodstox
Version:        4.4.2
Release:        0
Summary:        The gold standard Stax XML API implementation
License:        LGPL-2.1-only
Group:          Development/Libraries/Java
URL:            https://github.com/FasterXML/Woodstox4
Source0:        master.zip
Patch0:         java6-compat.patch
Patch1:         limit-recursion-for-DTD-parsing-CVE-2022-40152.patch
BuildRequires:  ant
BuildRequires:  java-devel
BuildRequires:  javapackages-tools
BuildRequires:  javapackages-local
BuildRequires:  unzip
BuildRequires:  woodstox-kit = 1.0
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Woodstox is an XML-parser that allows parsing of XML documents in so-called pull mode (aka "pull parsing").

%prep
%setup -n Woodstox4-master
ln -s /usr/share/tetra lib
%patch0 -p0
%patch1 -p1

%build
export CLASSPATH=$(build-classpath jzlib)
export OPT_JAR_LIST=:

# Override the version and rollback to 4.4.1. This is needed because version as 4.4.2 was never released on Maven.
# The artifact became com.fasterxml.woodstox:woodstox-core and was released as 5.0.0
# Any maven project depending on this artifact will look for version 4.4.1

%if 0%{?rhel}
JAVA_HOME=%{_jvmdir}/java-11 ant -DIMPL_VERSION=%{mvn_version} dist javadoc
%else
ant -DIMPL_VERSION=%{mvn_version} dist javadoc
%endif

# Remove stax-api dependency, it's bundled with JDK 6+
%pom_remove_dep javax.xml.stream:stax-api dist/%{name}-core-asl-%{mvn_version}.pom
%pom_remove_dep javax.xml.stream:stax-api src/maven/stax2-api.pom

%install
# jars
install -Dpm 644 dist/woodstox-core-asl-%{mvn_version}.jar %{buildroot}%{_javadir}/%{name}-core-asl-%{mvn_version}.jar
install -Dpm 644 lib/stax2-api-3.1.4.jar %{buildroot}%{_javadir}/stax2-api-3.1.4.jar
ln -s %{name}-core-asl-%{mvn_version}.jar %{buildroot}%{_javadir}/%{name}-core-asl.jar
ln -s %{name}-core-asl-%{mvn_version}.jar %{buildroot}%{_javadir}/%{name}-core-asl-%{version}.jar
ln -s stax2-api-3.1.4.jar %{buildroot}%{_javadir}/stax2-api.jar

# Maven metadata
install -d -m 0755 %{buildroot}/%{_mavenpomdir}/
%{mvn_install_pom} src/maven/stax2-api.pom %{buildroot}/%{_mavenpomdir}/JPP-stax2-api.pom
%add_maven_depmap JPP-stax2-api.pom stax2-api.jar
%{mvn_install_pom} dist/%{name}-core-asl-%{mvn_version}.pom %{buildroot}/%{_mavenpomdir}/JPP-%{name}.pom
%add_maven_depmap JPP-%{name}.pom %{name}-core-asl.jar

%clean
rm -rf %{buildroot}

%files -f .mfiles
%defattr(0644,root,root,0755)
%license release-notes/asl/LICENSE
%{_javadir}/%{name}-core-asl.jar
%{_javadir}/%{name}-core-asl-%{version}.jar
%{_javadir}/%{name}-core-asl-%{mvn_version}.jar
%{_javadir}/stax2-api.jar
%{_javadir}/stax2-api-3.1.4.jar

%changelog
openSUSE Build Service is sponsored by