File xmlbeans.spec of Package xmlbeans.26572

#
# spec file for package xmlbeans
#
# Copyright (c) 2022 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 bootstrap 0
%global real xmlbeans
Name:           xmlbeans
Version:        2.6.0
Release:        0
Summary:        XML-Java binding tool
License:        Apache-2.0
Group:          Development/Libraries/Java
URL:            http://xmlbeans.apache.org
Source0:        http://archive.apache.org/dist/xmlbeans/source/%{real}-%{version}-src.tgz
Source1000:     pre_checkin.sh
Patch0:         xmlbeans-2.4.0-nodownload.patch
#PATCH-FIX-UPSTREAM: saxon 9.3+ moved VirtualNode interface
Patch1:         xmlbeans-saxon-virtualnode.patch
#PATCH-FIX-UPSTREAM bsc#1180915 CVE-2021-23926 XML parsers does not protect from malicious XML input
Patch2:         xmlbeans-CVE-2021-23926.patch
BuildRequires:  ant >= 1.6
BuildRequires:  bea-stax-api
BuildRequires:  javapackages-tools
BuildRequires:  unzip
#!BuildIgnore:  antlr antlr-java
#!BuildIgnore:  xml-commons-jaxp-1.3-apis xml-commons-resolver12
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if %{bootstrap}
BuildRequires:  java-1_5_0-gcj-compat-devel
BuildRequires:  xml-commons-apis-bootstrap
BuildRequires:  xml-commons-resolver-bootstrap
Conflicts:      xmlbeans
#!BuildIgnore:  xerces-j2-bootstrap
#!BuildIgnore:  xerces-j2 xml-commons xml-commons-apis xml-commons-resolver
%else
BuildRequires:  ant-contrib
BuildRequires:  ant-junit
BuildRequires:  ant-nodeps
BuildRequires:  ant-trax
BuildRequires:  java-devel
BuildRequires:  junit
BuildRequires:  saxon9
BuildRequires:  xml-commons-resolver >= 1.1
BuildRequires:  xmlbeans-mini
Conflicts:      xmlbeans-mini
#!BuildIgnore:  xmlbeans
%endif

%description
XMLBeans is a tool that allows you to access the full power of XML in a
Java friendly way. It is an XML-Java binding tool. The idea is that you
can take advantage the richness and features of XML and XML Schema and
have these features mapped as naturally as possible to the equivalent
Java language and typing constructs. XMLBeans uses XML Schema to
compile Java interfaces and classes that you can then use to access and
modify XML instance data. Using XMLBeans is similar to using any other
Java interface/class, you will see things like getFoo or setFoo just as
you would expect when working with Java. While a major use of XMLBeans
is to access your XML instance data with strongly typed Java classes
there are also API's that allow you access to the full XML infoset
(XMLBeans keeps full XML Infoset fidelity) as well as to allow you to
reflect into the XML schema itself through an XML Schema Object model.

%package scripts
Summary:        XML-Java binding tool
Group:          Development/Libraries/Java
Requires:       %{name} = %{version}

%description scripts
XMLBeans is a tool that allows you to access the full power of XML in a
Java friendly way. It is an XML-Java binding tool. The idea is that you
can take advantage the richness and features of XML and XML Schema and
have these features mapped as naturally as possible to the equivalent
Java language and typing constructs. XMLBeans uses XML Schema to
compile Java interfaces and classes that you can then use to access and
modify XML instance data. Using XMLBeans is similar to using any other
Java interface/class, you will see things like getFoo or setFoo just as
you would expect when working with Java. While a major use of XMLBeans
is to access your XML instance data with strongly typed Java classes
there are also API's that allow you access to the full XML infoset
(XMLBeans keeps full XML Infoset fidelity) as well as to allow you to
reflect into the XML schema itself through an XML Schema Object model.

%prep
%setup -q -n %{real}-%{version}
%patch0 -p1 -b .nodownload
%patch1 -p1
%patch2 -p1

%build
# Piccolo and jam are rebuilt from source and bundled with xbean
# ant clean.jars leaves some dangling jars around, do not use it
find . \( -name '*.jar' -o -name '*.zip' \) \
        -not -name 'piccolo*.jar' -not -name 'jam*.jar' \
%if %{bootstrap}
        -not -name 'oldxbean.jar' \
%endif
        -print -delete

# Replace bundled libraries
mkdir -p build/lib
ln -sf $(build-classpath xml-commons-resolver) build/lib/resolver.jar
ln -sf $(build-classpath xmlbeans/oldxbean) external/lib/oldxbean.jar
ln -sf $(build-classpath bea-stax-api) external/lib/jsr173_1.0_api.jar
ln -sf $(build-classpath saxon9) external/lib/saxon9.jar
ln -sf $(build-classpath saxon9) external/lib/saxon9-dom.jar

# Fix CRLF
sed 's/\r//' -i LICENSE.txt NOTICE.txt README.txt docs/stylesheet.css
%if %{bootstrap}
ant xmlpublic.jar
%else
ant default
%endif

%install
# jar
install -d -m 0755 %{buildroot}%{_javadir}/%{real}
install -p -m 0644 build/lib/xmlpublic.jar %{buildroot}%{_javadir}/%{real}/xmlpublic.jar

%if ! %{bootstrap}
install -p -m 0644 build/lib/xbean_xpath.jar %{buildroot}%{_javadir}/%{name}/xbean_xpath.jar
install -p -m 0644 build/lib/xbean.jar %{buildroot}%{_javadir}/%{name}/xbean.jar

# bin
install -d -m 0755 %{buildroot}%{_bindir}
install -p -m 0755 bin/dumpxsb   %{buildroot}%{_bindir}
install -p -m 0755 bin/inst2xsd  %{buildroot}%{_bindir}
install -p -m 0755 bin/scomp     %{buildroot}%{_bindir}
install -p -m 0755 bin/sdownload %{buildroot}%{_bindir}
install -p -m 0755 bin/sfactor   %{buildroot}%{_bindir}
install -p -m 0755 bin/svalidate %{buildroot}%{_bindir}
install -p -m 0755 bin/validate  %{buildroot}%{_bindir}
install -p -m 0755 bin/xpretty   %{buildroot}%{_bindir}
install -p -m 0755 bin/xsd2inst  %{buildroot}%{_bindir}
install -p -m 0755 bin/xsdtree   %{buildroot}%{_bindir}
install -p -m 0755 bin/xstc      %{buildroot}%{_bindir}

%else
# install oldxbean.jar, which is needed to build xmlbeans itself
install -p -m 0644 external/lib/oldxbean.jar %{buildroot}%{_javadir}/%{real}/oldxbean.jar
%endif #if ! % { bootstrap}

%files
%defattr(-,root,root,-)
%doc LICENSE.txt NOTICE.txt README.txt
%dir %{_javadir}/xmlbeans/
%{_javadir}/xmlbeans/*.jar

%if ! %{bootstrap}
%files scripts
%defattr(0644,root,root,0755)
%attr(0755,root,root) %{_bindir}/*
%endif #!bootstrap

%changelog
openSUSE Build Service is sponsored by