Name:           velocity
Epoch:          0
Version:        1.7
Release:        27
Summary:        Java-based template engine
License:        ASL 2.0
URL:            http://velocity.apache.org/
BuildArch:      noarch

Source0:        %{name}-%{version}.tar.gz
Source1:        http://repo1.maven.org/maven2/org/apache/%{name}/%{name}/%{version}/%{name}-%{version}.pom
Source2:        generate-tarball.sh

Patch0001:      0001-Remove-avalon-logkit.patch
Patch0002:      0004-Use-log4j-1.2.17.patch
Patch0003:      0003-Use-system-jars.patch
Patch0004:      0004-JDBC-41-compat.patch
Patch0005:      0001-Don-t-use-Werken-XPath.patch
Patch0006:      0006-Skip-Java-8-incompatible-test.patch
Patch0007:      velocity-1.7-doclint.patch
Patch0008:      velocity-1.7-osgi.patch
Patch0009:      CVE-2020-13936-1.patch
Patch0010:      CVE-2020-13936-2.patch
Patch0011:      CVE-2020-13936-3.patch

BuildRequires:  javapackages-local ant antlr junit ant-junit
BuildRequires:  apache-commons-collections apache-commons-logging apache-commons-lang
BuildRequires:  glassfish-servlet-api jakarta-oro jaxen jdom bcel log4j12 apache-parent
BuildRequires:  hsqldb-lib java-devel >= 1:1.6.0

%description
Velocity is a Java-based template engine.
It permits anyone to use the simple yet powerful template language
to reference objects defined in Java code.

When Velocity is used for web development,
Web designers can work in parallel with Java programmers
to develop web sites according to the Model-View-Controller (MVC) model,
meaning that web page designers can focus solely
on creating a site that looks good,
and programmers can focus solely on writing top-notch code.
Velocity separates Java code from the web pages,
making the web site more maintainable over the long run
and providing a viable alternative to Java Server Pages (JSPs) or PHP.

Velocity's capabilities reach well beyond the realm of web sites;
for example, it can generate SQL and PostScript and XML from templates.
It can be used either as a standalone utility for generating source code and reports,
or as an integrated component of other systems.
Velocity also provides template services for the Turbine web application framework.
Velocity+Turbine provides a template service that will
allow web applications to be developed according to a true MVC model.

%package        help
Summary:        Documentation and samples for %{name}
Requires:       %{name} = %{epoch}:%{version}-%{release}

Provides:       %{name}-manual = %{version}-%{release}
Obsoletes:      %{name}-manual < %{version}-%{release}
Provides:       %{name}-javadoc = %{version}-%{release}
Obsoletes:      %{name}-javadoc < %{version}-%{release}
Provides:       %{name}-demo = %{version}-%{release}
Obsoletes:      %{name}-demo < %{version}-%{release}

%description    help
Documentation and samples for %{name}


%prep
%setup -q

find . -name '*.jar' ! -name 'test*.jar' -print -delete
find . -name '*.class' ! -name 'Foo.class' -print -delete

rm -f src/java/org/apache/velocity/runtime/log/{AvalonLogChute,AvalonLogSystem,VelocityFormatter}.java
rm src/test/org/apache/velocity/test/VelocityServletTestCase.java
rm src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java

cp %{SOURCE1} ./pom.xml

%patch0001 -p1
%patch0002 -p1
%patch0003 -p1
%patch0004 -p1
%patch0005 -p1
%patch0006 -p1
%patch0007 -p1
%patch0008 -p1
%patch0009 -p1
%patch0010 -p1
%patch0011 -p1

%build
export CLASSPATH=$(build-classpath antlr apache-commons-collections \
commons-lang commons-logging glassfish-servlet-api junit \
jakarta-oro log4j:log4j:1.2.17 jaxen jdom bcel hsqldb junit)
ant -buildfile build/build.xml  -Dbuild.sysclasspath=first \
-Djavac.target=1.6  -Djavac.source=1.6  jar javadocs test

export BEP_GTDLIST=$(echo $BEP_GTDLIST | sed 's/\<java\>//g')
ant -buildfile build/build.xml -Dbuild.sysclasspath=first \
  -Djavac.target=1.6  -Djavac.source=1.6  test
export BEP_GTDLIST="$BEP_GTDLIST java"

sed -i 's/\r//' docs/api/stylesheet.css docs/api/package-list


%install
%mvn_file : %{name}
%mvn_alias : %{name}:%{name}
%mvn_artifact pom.xml bin/%{name}-%{version}.jar
%mvn_install -J docs/api

rm -r test/issues/velocity-537/compare/velocity537.vm.cmp
install -d -m 755 %{buildroot}%{_datadir}/%{name}
cp -pr examples test %{buildroot}%{_datadir}/%{name}


%files -f .mfiles
%doc README.txt
%license LICENSE NOTICE

%files help -f .mfiles-javadoc
%doc docs/*
%{_datadir}/%{name}


%changelog
* Fri Feb 25 2022 wangkai <wangkai385@huawei.com> - 1.7-27
- Rebuild for fix log4j1.x cves

* Fri Apr 23 2021 wangyue <wangyue92@huawei.com> - 1.7-26
- Fix CVE-2020-13936

* Wed Dec 04 2019 zoushuangshuang<zoushuangshuang@huawei.com> - 1.7-25
- Package init

