Name:                mojarra
Version:             2.2.13
Release:             2
Summary:             JSF Reference Implementation
License:             CDDL or GPLv2 with exceptions
URL:                 http://javaserverfaces.java.net
Source0:             https://github.com/javaserverfaces/mojarra/archive/%{version}/mojarra-%{version}.tar.gz
Source1:             http://repo1.maven.org/maven2/com/sun/faces/jsf-api/%{version}/jsf-api-%{version}.pom
Source2:             http://repo1.maven.org/maven2/com/sun/faces/jsf-impl/%{version}/jsf-impl-%{version}.pom

Patch0:              mojarra-2.2.13-remove-installer-builder.patch
Patch1:              mojarra-2.2.13-fix-maven-ant-tasks-classpath.patch
Patch2:              mojarra-2.2.13-dont-download-dependencies.patch
Patch3:              mojarra-2.2.13-jdk7.patch
Patch4:              mojarra-2.2.13-fix-classpaths.patch
Patch5:              mojarra-2.2.13-dont-use-yuicompressor.patch
Patch6:              mojarra-2.2.13-dont-build-injection-providers.patch
Patch7:              mojarra-2.2.13-dont-bundle-api.patch
Patch8:              mojarra-dont-use-namespace-alias.patch
Patch9:              mojarra-servlet-3.1.patch
Patch10:             mojarra-2.2.13-disable-references-to-com.sun.faces.spi.InjectionProvider.patch
Patch11:             mojarra-2.2.13-disabling-stripping-API-jars.patch
Patch12:             CVE-2020-6950.patch

BuildArch:           noarch
BuildRequires:       ant ant-contrib apache-commons-digester aqute-bnd atinject cdi-api
BuildRequires:       bean-validation-api glassfish-annotation-api glassfish-ejb-api glassfish-el-api
BuildRequires:       glassfish-jsp-api glassfish-servlet-api groovy hibernate-jpa-2.1-api java-devel
BuildRequires:       jboss-jstl-1.2-api maven-install-plugin maven-local
Requires:            apache-commons-digester atinject bean-validation-api cdi-api
Requires:            glassfish-annotation-api glassfish-ejb-api glassfish-el-api glassfish-jsp-api
Requires:            glassfish-servlet-api hibernate-jpa-2.1-api jboss-jstl-1.2-api
%description
JvaServer(TM) Faces technology simplifies building user interfaces for
JavaServer applications. Developers of various skill levels can quickly build
web applications by: assembling reusable UI components in a page; connecting
these components to an application data source; and wiring client-generated
events to server-side event handlers.

%package javadoc
Summary:             Javadoc for mojarra
%description javadoc
This package contains the API documentation for mojarra.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
sed -i "s|-f @{pomFile}|-o -f @{pomFile}|" common/ant/maven.xml common/ant/maven-pre-maven-rename.xml
find . -name '*.class' -print -delete
find . -name '*.jar' -print -delete
mv LICENSE LICENSE.tmp
iconv -f ISO-8859-1 -t UTF-8 LICENSE.tmp > LICENSE
native2ascii -encoding UTF8 jsf-api/src/main/java/javax/faces/component/UIComponent.java \
 jsf-api/src/main/java/javax/faces/component/UIComponent.java
%pom_change_dep :ant org.apache.ant: jsf-tools
cp -p %{SOURCE1} jsf-api.pom
cp -p %{SOURCE2} jsf-impl.pom
for a in jsf-api.pom jsf-impl.pom; do
 %pom_change_dep javax.servlet.jsp.jstl:jstl-api org.jboss.spec.javax.servlet.jstl:jboss-jstl-api_1.2_spec:1.0.3.Final ${a}
done

%build
mkdir -p lib
names='
apache-commons-collections
apache-commons-digester
apache-commons-beanutils
apache-commons-logging
'
for name in ${names}
do
  ln -s `build-classpath ${name}` lib/$(basename ${name}).jar
done
mkdir -p lib/compile
names='
atinject
bean-validation-api
cdi-api
glassfish-annotation-api
glassfish-ejb-api
glassfish-el-api
glassfish-jsp-api
glassfish-servlet-api
groovy/groovy-all
hibernate-jpa-2.1-api
jboss-jstl-1.2-api
'
for name in ${names}
do
  ln -s `build-classpath ${name}` lib/compile/$(basename ${name}).jar
done
mkdir -p common/lib
ln -s `build-classpath aqute-bnd/biz.aQute.bnd` common/lib/bnd.jar
ln -s `build-classpath aqute-bnd/biz.aQute.bndlib` common/lib/bndlib.jar
ant \
  -Dbuild.sysclasspath=last \
  -Djsf.build.home=$PWD \
  -Dcontainer.name=tomcat7 \
  -Dmvn.cmd=xmvn
ant \
  -Dbuild.sysclasspath=last \
  -Djsf.build.home=$PWD \
  -Dcontainer.name=tomcat7 \
  -f jsf-api/build.xml \
  javadocs
ant \
  -Dbuild.sysclasspath=last \
  -Djsf.build.home=$PWD \
  -Dcontainer.name=tomcat7 \
  -f jsf-ri/build.xml \
  javadocs
%mvn_artifact jsf-api.pom jsf-api/build/lib/jsf-api-intermediate.jar
%mvn_artifact jsf-impl.pom jsf-ri/build/lib/javax.faces.jar
%mvn_alias com.sun.faces:jsf-api javax.faces:javax.faces-api
%mvn_alias com.sun.faces:jsf-impl org.glassfish:javax.faces

%install
%mvn_install
install -d -m 755 %{buildroot}%{_javadocdir}/mojarra/jsf-api
cp -rp jsf-api/build/javadocs/* %{buildroot}%{_javadocdir}/mojarra/jsf-api/.
install -d -m 755 %{buildroot}%{_javadocdir}/mojarra/jsf-impl
cp -rp jsf-ri/build/javadocs/* %{buildroot}%{_javadocdir}/mojarra/jsf-impl/.

%files -f .mfiles
%license LICENSE
%doc docs/index.html
%doc docs/releasenotes.html
%doc docs/community.html
%doc docs/jsf-2_1-changelog.html

%files javadoc
%{_javadocdir}/mojarra
%license LICENSE

%changelog
* Thu Jun 10 2021 wutao <wutao61@huawei.com> - 2.2.13-2
- fix CVE-2020-6950

* Fri Sep 11 2020 huanghaitao <huanghaitao8@huawei.com> - 2.2.13-1
- package init
