diff --git a/xstream.spec b/xstream.spec
index fe5f993..eefa700 100644
--- a/xstream.spec
+++ b/xstream.spec
@@ -30,13 +30,18 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+%bcond_with dom4j
%bcond_with hibernate
+%bcond_with jdom
+%bcond_with jdom2
%bcond_with joda
+%bcond_with kxml
%bcond_with stax
+%bcond_with woodstox
Name: xstream
Version: 1.4.12
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Java XML serialization library
License: BSD
URL: http://x-stream.github.io/
@@ -49,19 +54,18 @@ Patch0: xstream-java-8-target.patch
BuildRequires: maven-local
BuildRequires: mvn(cglib:cglib)
-BuildRequires: mvn(dom4j:dom4j)
BuildRequires: mvn(javax.xml.bind:jaxb-api)
-BuildRequires: mvn(net.sf.kxml:kxml2-min)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-enforcer-plugin)
BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin)
-BuildRequires: mvn(org.codehaus.woodstox:woodstox-core-asl)
-BuildRequires: mvn(org.jdom:jdom)
-BuildRequires: mvn(org.jdom:jdom2)
BuildRequires: mvn(xpp3:xpp3)
BuildRequires: mvn(xpp3:xpp3_min)
+%if %{with dom4j}
+BuildRequires: mvn(dom4j:dom4j)
+%endif
+
%if %{with hibernate}
BuildRequires: mvn(javassist:javassist)
BuildRequires: mvn(org.codehaus.jettison:jettison)
@@ -71,15 +75,31 @@ BuildRequires: mvn(org.slf4j:slf4j-simple)
BuildRequires: mvn(xom:xom)
%endif
+%if %{with jdom}
+BuildRequires: mvn(org.jdom:jdom)
+%endif
+
+%if %{with jdom2}
+BuildRequires: mvn(org.jdom:jdom2)
+%endif
+
%if %{with joda}
BuildRequires: mvn(joda-time:joda-time)
%endif
+%if %{with kxml}
+BuildRequires: mvn(net.sf.kxml:kxml2-min)
+%endif
+
%if %{with stax}
BuildRequires: mvn(stax:stax)
BuildRequires: mvn(stax:stax-api)
%endif
+%if %{with woodstox}
+BuildRequires: mvn(org.codehaus.woodstox:woodstox-core-asl)
+%endif
+
%description
XStream is a simple library to serialize objects to XML
@@ -176,6 +196,15 @@ find . -name "*.jar" -print -delete
%pom_xpath_inject "pom:project/pom:dependencies/pom:dependency[pom:groupId = 'junit' ]" "test" xstream-benchmark
%pom_remove_plugin :maven-javadoc-plugin xstream-benchmark
+%if %{without dom4j}
+%pom_remove_dep -r dom4j:dom4j
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/Dom4JDriver.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/Dom4JReader.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/Dom4JWriter.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/Dom4JXmlWriter.java
+rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamDom4J.java
+%endif
+
%if %{without hibernate}
# Don't build hibernate module
%pom_disable_module xstream-hibernate
@@ -187,12 +216,35 @@ rm xstream/src/java/com/thoughtworks/xstream/io/json/Jettison*
rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamXom.java
%endif
+%if %{without jdom}
+%pom_remove_dep -r org.jdom:jdom
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDomDriver.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDomReader.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDomWriter.java
+rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamJDom.java
+%endif
+
+%if %{without jdom2}
+%pom_remove_dep -r org.jdom:jdom2
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDom2Driver.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDom2Reader.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/JDom2Writer.java
+%endif
+
%if %{without joda}
%pom_remove_dep -r joda-time:joda-time
rm xstream/src/java/com/thoughtworks/xstream/core/util/ISO8601JodaTimeConverter.java
rm xstream/src/test/com/thoughtworks/acceptance/JodaTimeTypesTest.java
%endif
+%if %{without kxml}
+%pom_remove_dep -r net.sf.kxml:kxml2-min
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/KXml2DomDriver.java
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/KXml2Driver.java
+rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamKXml2.java
+rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamKXml2DOM.java
+%endif
+
%if %{without stax}
%pom_remove_dep -r stax:stax
%pom_remove_dep -r stax:stax-api
@@ -202,6 +254,12 @@ rm xstream/src/test/com/thoughtworks/xstream/io/xml/BEAStaxWriterTest.java
rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamBEAStax.java
%endif
+%if %{without woodstox}
+%pom_remove_dep -r org.codehaus.woodstox:woodstox-core-asl
+rm xstream/src/java/com/thoughtworks/xstream/io/xml/WstxDriver.java
+rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/XStreamWoodstox.java
+%endif
+
%mvn_file :%{name} %{name}/%{name} %{name}
%mvn_file :%{name}-benchmark %{name}/%{name}-benchmark %{name}-benchmark
@@ -230,6 +288,9 @@ rm xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/products/
%license LICENSE.txt
%changelog
+* Wed Jun 17 2020 Fabio Valentini - 1.4.12-3
+- Disable unused optional dom4j, jdom, jdom2, kxml, and woodstox support.
+
* Mon Jun 08 2020 Fabio Valentini - 1.4.12-2
- Disable optional support for joda-time by default.