Summary:             An open source data binding framework for Java
Name:                castor
Version:             1.3.3
Release:             4
License:             BSD and ASL 2.0
URL:                 http://castor-data-binding.github.io/castor/
Source0:             http://dist.codehaus.org/castor/%{version}/castor-%{version}-src.tgz
Patch0:              castor-1.3.2-fix-unmappable-chars.patch
BuildArch:           noarch
BuildRequires:       maven-local mvn(ant:ant) mvn(commons-cli:commons-cli)
BuildRequires:       mvn(commons-collections:commons-collections) mvn(commons-lang:commons-lang)
BuildRequires:       mvn(commons-logging:commons-logging) mvn(edu.umd.cs:multithreadedtc)
BuildRequires:       mvn(jakarta-regexp:jakarta-regexp) mvn(javax.inject:javax.inject)
BuildRequires:       mvn(junit:junit) mvn(ldapsdk:ldapsdk) mvn(log4j:log4j:1.2.16)
BuildRequires:       mvn(org.apache.maven.plugins:maven-source-plugin)
BuildRequires:       mvn(org.codehaus.castor:castor-xml) mvn(org.codehaus:codehaus-parent:pom:)
BuildRequires:       mvn(org.codehaus.mojo:castor-maven-plugin) mvn(org.easymock:easymock)
BuildRequires:       mvn(org.springframework:spring-context) mvn(oro:oro) mvn(velocity:velocity)
BuildRequires:       mvn(xmlunit:xmlunit) java-latest-openjdk-devel
Requires:	     java-latest-openjdk-headless
Obsoletes:           castor-demo < 1.3.2
Obsoletes:           castor-test < 1.3.2
Obsoletes:           castor-xml < 1.3.2
Obsoletes:           castor-doc < 1.3.2
%description
Castor is an open source data binding framework for Java. It's basically
the shortest path between Java objects, XML documents and SQL tables.
Castor provides Java to XML binding, Java to SQL persistence, and more.

%package javadoc
Summary:             API documentation for %{name}
%description javadoc
This package contains the API documentation for %{name}.

%prep
%setup -q
find . -name "*.jar" -exec rm -f {} \;
find . -name "*.class" -exec rm -f {} \;
%patch0 -p0 -b.orig
%pom_disable_module anttask
%pom_disable_module xmlctf-framework
%pom_disable_module maven-plugins
%pom_disable_module xml-annotations
%pom_disable_module cpactf
%pom_disable_module jpa-extensions-it
%pom_disable_module xmlctf
%pom_remove_dep tyrex:tyrex
%pom_remove_dep tyrex:tyrex cpa
%pom_remove_dep org.springframework:spring-test xml
%pom_xpath_remove "pom:build/pom:extensions"
sed -i 's@cglib-nodep@cglib@g' pom.xml cpa/pom.xml
sed -i 's@edu.umd.cs.mtc@edu.umd.cs@g' pom.xml xml/pom.xml
%pom_remove_dep "javax.xml.stream:stax-api" . xml
%pom_remove_dep "stax:stax" . xml

%pom_xpath_set "pom:configuration/pom:source" 1.8
%pom_xpath_set "pom:configuration/pom:target" 1.8

%build
openjdk_latest_version=`rpm -qi java-latest-openjdk-headless | grep Version | cut -b 15-16`
home_path=`ls /usr/lib/jvm | grep java-${openjdk_latest_version}-openjdk-${openjdk_latest_version}`
export JAVA_HOME=/usr/lib/jvm/${home_path}
%mvn_build -- -Dsource=${openjdk_latest_version} -Dmaven.compiler.target=${openjdk_latest_version} -Dmaven.compiler.source=${openjdk_latest_version} -Dgpg.skip=true -Dmaven.test.skip=true 

%install
%mvn_install

%files -f .mfiles
%doc src/doc/license.txt src/doc/new-license.txt
%dir %{_javadir}/%{name}

%files javadoc -f .mfiles-javadoc
%doc src/doc/license.txt src/doc/new-license.txt

%changelog
* Tue Nov 22 2022 xu_ping <xuping33@h-partners.com> - 1.3.3-4
- Optimize to get the path of JAVA_HOME

* Sat Nov 19 2022 xu_ping <xuping33@h-partners.com> - 1.3.3-3
- Use jdk-19 to compile for fixing build error

* Mon Jun 13 2022 baizhonggui <baizhonggui@h-partners.com> - 1.3.3-2
- Use jdk-18 to compile for fixing build error

* Wed Oct 28 2020 shaoqiang kang <kangshaoqiang1@huawei.com> - 1.3.3-1
- Package init
