Name:		jcsp
Version:	1.1
Release:	0.13
Summary:	Communicating Sequential Processes for Java (JCSP)
License:	LGPLv2+
URL:		https://github.com/codehaus/jcsp
Source0:	https://github.com/codehaus/jcsp/archive/1.1-rc5.tar.gz

BuildArch:     	noarch
BuildRequires:	maven-local junit maven-plugin-bundle osgi-core 

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

%description
JCSP is an implementation of Communicating Sequential Processes 
(CSP) for the Java programming language.

%prep
%autosetup -n %{name}-%{version}-rc5 -p1
find ./ -name "*.jar" -delete
find ./ -name "*.class" -delete                                               
rm -Rf ./*gradle* ./wrapper ./.gitignore ./src/jcsp-demos 
rm -Rf ./src/org/jcsp/win32/Installing\ NT\ Services.txt
rm -Rf ./src/org/jcsp/win32/*.c* ./src/org/jcsp/win32/*.h*
rm -Rf ./JCSP\ Networking.pdf
for plugin in cobertura-maven-plugin findbugs-maven-plugin jdepend-maven-plugin \
    rat-maven-plugin taglist-maven-plugin ; do 
%pom_remove_plugin :$plugin
done

%pom_change_dep :org.osgi.core org.osgi:osgi.core

%pom_xpath_remove "pom:project/pom:build/pom:extensions"

%pom_xpath_inject "pom:project/pom:build" "
<resources>
  <resource>
    <directory>src</directory>
    <excludes>
      <exclude>**/*.java</exclude>
      <exclude>**/doc-files/**</exclude>
      <exclude>**/win32/*Services.txt</exclude>
      <exclude>**/package.html</exclude>
    </excludes>
  </resource>
</resources>"

%pom_xpath_remove "pom:project/pom:reporting/pom:plugins/pom:plugin[pom:artifactId='maven-javadoc-plugin']/pom:configuration/pom:excludePackageNames"
%pom_xpath_remove "pom:project/pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-bundle-plugin']/pom:configuration/pom:instructions/pom:Export-Package"
%pom_xpath_inject "pom:project/pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-bundle-plugin']/pom:configuration/pom:instructions" '
<Export-Package>org.jcsp.*;version="${project.version}"</Export-Package>'

sed -i 's|${name}|${project.name}|' pom.xml

pushd src/org/jcsp
rm -r win32 net/remote/SpawnerServiceNT.java net/tcpip/TCPIPCNSServerNT.java
popd

%mvn_file : jcsp

%build
%mvn_build -- -Dproject.build.sourceEncoding=UTF-8

%install
%mvn_install

%files
%defattr(-,root,root)
%doc README.txt
%license LICENCE.txt
%{_datadir}/java/*
%{_datadir}/javadoc/*
%{_datadir}/maven-poms/*
%{_datadir}/maven-metadata/*

%changelog
* Fri Feb 14 2020 gulining<gulining1@huawei.com> - 1.1-0.13
- Package init
