%define         release_version %(echo %{version} | awk -F. '{print $1"_"$2"_"$3}')
Name:           glassfish-jaxb
Version:        2.2.11
Release:        11
Summary:        JAXB Reference Implementation
License:        CDDL-1.1 and GPLv2 with exceptions
URL:            http://jaxb.java.net
Source0:        https://github.com/javaee/jaxb-v2/archive/jaxb-%{release_version}-branch.zip
Patch0000:      txw2-args4j.patch

BuildRequires:  maven-local mvn(args4j:args4j) mvn(com.sun.istack:istack-commons-runtime)
BuildRequires:  mvn(com.sun.istack:istack-commons-tools) mvn(relaxngDatatype:relaxngDatatype)
BuildRequires:  mvn(com.sun.xml.dtd-parser:dtd-parser) mvn(com.sun.xml.fastinfoset:FastInfoset)
BuildRequires:  mvn(com.sun.xsom:xsom) mvn(javax.xml.bind:jaxb-api) mvn(net.java.dev.msv:msv-core)
BuildRequires:  mvn(org.apache.maven.plugins:maven-dependency-plugin) mvn(org.apache.ant:ant)
BuildRequires:  mvn(org.apache.maven.plugins:maven-enforcer-plugin) mvn(net.java:jvnet-parent:pom:)
BuildRequires:  mvn(org.apache.maven.plugins:maven-source-plugin)  mvn(org.jvnet.staxex:stax-ex)
BuildRequires:  mvn(org.codehaus.mojo:build-helper-maven-plugin) mvn(com.sun:tools)

Requires:       glassfish-jaxb1-impl = %{version}-%{release} glassfish-jaxb-bom = %{version}-%{release}
Requires:       glassfish-jaxb-bom-ext = %{version}-%{release} glassfish-jaxb-codemodel = %{version}-%{release}
Requires:       glassfish-jaxb-core = %{version}-%{release} glassfish-jaxb-jxc = %{version}-%{release}
Requires:       glassfish-jaxb-parent = %{version}-%{release} glassfish-jaxb-rngom = %{version}-%{release}
Requires:       glassfish-jaxb-runtime = %{version}-%{release} glassfish-jaxb-xjc = %{version}-%{release}
Requires:       glassfish-jaxb-txw2 = %{version}-%{release}
BuildArch:      noarch

%description
GlassFish JAXB Implementation Reference.

%package        codemodel
provides:       glassfish-jaxb-codemodel-parent = %{version}-%{release}
Obsoletes:      glassfish-jaxb-codemodel-parent < %{version}-%{release}
provides:       glassfish-jaxb-codemodel-annotation-compiler = %{version}-%{release}
Obsoletes:      glassfish-jaxb-codemodel-annotation-compiler < %{version}-%{release}
Summary:        Codemodel Core

%description    codemodel
The CodeModel core functional library generated by java source code.

%package -n     glassfish-jaxb1-impl
Summary:        JAXB1 Runtime

%description -n glassfish-jaxb1-impl
JAXB1 runtime classes implementation.

%package        bom
Summary:        JAXB BOM

%description    bom
JAXB Bill of Materials

%package        bom-ext
Summary:        JAXB BOM`s all dependencies

%description    bom-ext
JAXB BOM`s all dependencies.

%package        core
Summary:        JAXB Core

%description    core
Core module of JAXB. Provides sources required by JXC, XJC and Runtime modules.

%package        jxc
Summary:        JAXB schema generator

%description    jxc
The tool based on java classes which to generate XML schema.

%package        parent
provides:       glassfish-jaxb-runtime-parent = %{version}-%{release}
Obsoletes:      glassfish-jaxb-runtime-parent < %{version}-%{release}
Provides:       glassfish-jaxb-txw-parent = %{version}-%{release}
Obsoletes:      glassfish-jaxb-txw-parent < %{version}-%{release}
Provides:       glassfish-jaxb-external-parent = %{version}-%{release}
Obsoletes:      glassfish-jaxb-external-parent < %{version}-%{release}
Summary:        JAXB parent POM

%description    parent
This package include parent POM.

%package        runtime
Summary:        JAXB Runtime

%description    runtime
The Implementation Reference of JAXB (JSR 222)

%package        xjc
Summary:        JAXB XJC

%description    xjc
The JAXB Contains source code which bing compiler needed for binding
customization files into java sources. Means that the tool generate
java classes by the given xml representation.

%package        rngom
Summary:        RELAX NG Object Model/Parser

%description    rngom
This package contains RELAX NG Object Model/Parser.

%package        txw2
Summary:        TXW2 Runtime
Provides:       glassfish-jaxb-txwc2 = %{version}-%{release}
Obsoletes:      glassfish-jaxb-txwc2 < %{version}-%{release}

%description    txw2
TXW is a library that allows you to write XML documents.

%package        help
Summary:        Javadocs for glassfish-jaxb
Provides:       glassfish-jaxb-javadoc = %{version}-%{release}
Obsoletes:      glassfish-jaxb-javadoc <  %{version}-%{release}

%description    help
This package contains the API documentation for glassfish-jaxb.

%prep

%autosetup -c -n  glassfish-jaxb-%{version} -p1
mv jaxb-v2-jaxb-%{release_version}-branch/jaxb-ri/* .
rm -rf jaxb-v2-jaxb-%{release_version}-branch

%pom_disable_module bundles

%pom_remove_dep com.sun:tools
%pom_add_dep_mgmt com.sun:tools
%pom_remove_dep com.sun:tools jxc
%pom_add_dep com.sun:tools jxc

%pom_remove_dep com.sun.xml.bind:jaxb-release-documentation bundles/ri
%pom_remove_dep com.sun.xml.bind:jaxb-samples bundles/ri

%pom_remove_plugin :gfnexus-maven-plugin
%pom_remove_plugin :maven-site-plugin
%pom_remove_plugin :buildnumber-maven-plugin

%mvn_alias org.glassfish.jaxb:jaxb-runtime "com.sun.xml.bind:jaxb-impl"
%mvn_alias org.glassfish.jaxb:jaxb-xjc "com.sun.xml.bind:jaxb-xjc"

%build
%mvn_build -f -s -- -Ddev -DbuildNumber=unknown

%install
%mvn_install

%files
%doc License.txt licenceheader.txt License.html

%files codemodel -f .mfiles-codemodel
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html
%{_datadir}/java/glassfish-jaxb/codemodel-annotation-compiler.jar
%{_datadir}/maven-metadata/glassfish-jaxb-codemodel-annotation-compiler.xml
%{_datadir}/maven-metadata/glassfish-jaxb-jaxb-codemodel-parent.xml
%{_datadir}/maven-poms/glassfish-jaxb/codemodel-annotation-compiler.pom
%{_datadir}/maven-poms/glassfish-jaxb/jaxb-codemodel-parent.pom

%files -n glassfish-jaxb1-impl -f .mfiles-jaxb1-impl
%dir %{_javadir}/glassfish-jaxb

%files bom -f .mfiles-jaxb-bom
%doc License.txt licenceheader.txt License.html

%files bom-ext -f .mfiles-jaxb-bom-ext

%files core -f .mfiles-jaxb-core
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html


%files jxc -f .mfiles-jaxb-jxc
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html

%files parent -f .mfiles-jaxb-parent
%{_datadir}/maven-metadata/glassfish-jaxb-jaxb-external-parent.xml
%{_datadir}/maven-metadata/glassfish-jaxb-jaxb-runtime-parent.xml
%{_datadir}/maven-metadata/glassfish-jaxb-jaxb-txw-parent.xml
%{_datadir}/maven-poms/glassfish-jaxb/jaxb-external-parent.pom
%{_datadir}/maven-poms/glassfish-jaxb/jaxb-runtime-parent.pom
%{_datadir}/maven-poms/glassfish-jaxb/jaxb-txw-parent.pom

%files runtime -f .mfiles-jaxb-runtime
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html

%files xjc -f .mfiles-jaxb-xjc
%dir %{_javadir}/glassfish-jaxb

%files rngom -f .mfiles-rngom
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html

%files txw2 -f .mfiles-txw2
%dir %{_javadir}/glassfish-jaxb
%doc License.txt licenceheader.txt License.html
%{_datadir}/java/glassfish-jaxb/txwc2.jar
%{_datadir}/maven-metadata/glassfish-jaxb-txwc2.xml
%{_datadir}/maven-poms/glassfish-jaxb/txwc2.pom

%files help -f .mfiles-javadoc
%doc License.txt licenceheader.txt License.html

%changelog
* Wed Apr 15 2020 Jeffery.Gao <gaojianxing@huawei.com> - 2.2.11-11
- Package init
