%global oname jamon
Name:                jamonapi
Version:             2.74
Release:             2
Summary:             A Java monitoring API
License:             BSD
URL:                 http://jamonapi.sourceforge.net/
Source0:             https://sourceforge.net/projects/%{name}/files/%{name}/v2_74/jamonall-%{version}.zip
Source1:             https://repo1.maven.org/maven2/com/%{name}/%{oname}/2.75/%{oname}-2.75.pom
#wget https://github.com/stevensouza/jamonapi/archive/v2_82.tar.gz
#tar -xvf v2_82.tar.gz
#get build.xml
Source2:             build.xml
#https://repo1.maven.org/maven2/com/%{name}/%{oname}/2.75/%{oname}-2.75.pom
#git clone https://git.code.sf.net/p/jamonapi/jamonapi jamonapi-jamonapi
#cd jamonapi-jamonapi/src
#tar -cvf jamonapi-JAMonUsersGuide.tar.gz JAMonUsersGuide
Source3:             jamonapi-JAMonUsersGuide.tar.gz
Patch0:              0001-fix-build-script.patch
Patch1:              %{name}-jetty8.patch
Patch2:              %{name}-jetty93.patch
BuildRequires: java-devel javapackages-local
BuildRequires: ant jetty log4j12 dos2unix geronimo-interceptor
BuildRequires: tomcat-lib tomcat-servlet-4.0-api tomcat-el-3.0-api
Requires:      geronimo-interceptor log4j12
BuildArch:           noarch
%description
JAMon API is a free, simple, high performance, thread safe,
Java API that allows developers to easily monitor the
performance and scalability of production applications. JAMon
tracks hits, execution times (total, avg, min, max, std dev),
and more.

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

%prep
%setup -q -c -n %{name}
rm -rf binaries
rm -rf javadoc
mkdir -p ./src/ant
mv ./java ./src/
mv ./osmon ./src/
cp %{SOURCE1} ./pom.xml
cp %{SOURCE2} src/ant
cp %{SOURCE3} ./src/
pushd ./src
tar -xvf %{name}-JAMonUsersGuide.tar.gz
rm -f %{name}-JAMonUsersGuide.tar.gz
popd
%patch0 -p1
%patch1 -p1
%patch2 -p1
mkdir dist
mkdir lib

%build
pushd src/ant
ant JAR
ant javadoc
popd

find src/JAMonUsersGuide -type f | xargs chmod -x
find src/JAMonUsersGuide -regex '.*\(xml\|css\|js\)' -o -name package-list | xargs dos2unix

pushd src/JAMonUsersGuide/presentation/jamon_files/
mv master04_stylesheet.css master04_stylesheet.css.iso8859-1
iconv -f ISO-8859-1 -t UTF-8 master04_stylesheet.css.iso8859-1 > master04_stylesheet.css
rm master04_stylesheet.css.iso8859-1
popd

cp -p src/JAMonUsersGuide/JAMonLicense.html .

%install
%mvn_artifact %{_builddir}/%{name}/pom.xml dist/%{oname}-%{version}.jar
%mvn_file com.jamonapi:jamon %{oname} %{name}
%mvn_install
mkdir -p %{buildroot}%{_javadocdir}/jamonapi
cp -r %{_builddir}/%{name}/src/doc/javadoc/* %{buildroot}%{_javadocdir}/jamonapi

%files -f .mfiles 
%doc src/JAMonUsersGuide
%license JAMonLicense.html

%files javadoc
/usr/share/javadoc/jamonapi
%license JAMonLicense.html

%changelog
* Tue Oct 20 2020 Ge Wang <wangge20@huawei.com> - 2.74-2
- modify compile script to solve defect of jar package

* Sat Sep 5 2020 Ge Wang <wangge20@huawei.com> - 2.74-1
- Package init
