Name:           junit
Epoch:          1
Version:        4.13.2
Release:        2
Summary:        A Java package for unit testing frameworks
License:        EPL-1.0
URL:            http://www.junit.org/
Source0:        https://github.com/%{name}-team/%{name}/archive/r%{version}.tar.gz
Patch0000:      0001-Port-to-hamcrest-2.2.patch

BuildArch:      noarch
BuildRequires:  maven-local mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires:  mvn(org.apache.maven.plugins:maven-enforcer-plugin)
BuildRequires:  mvn(org.hamcrest:hamcrest-core)
BuildRequires:  java-11-openjdk-devel
Requires:       java-11-openjdk

Obsoletes:      %{name}-demo < 4.12

%description
JUnit is a simple framework to write repeatable tests. It is an
instance of the xUnit architecture for unit testing frameworks.

%package help
Summary:        Documents for junit

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

%description help
The junit-help package contains related documents.

%prep
%autosetup -n %{name}4-r%{version} -p1

find . -name "*.jar" -delete
find . -name "*.class" -delete

# InaccessibleBaseClassTest fails with Java 8
sed -i /InaccessibleBaseClassTest/d src/test/java/org/junit/tests/AllTests.java

%pom_remove_plugin :replacer
sed s/@version@/%{version}/ src/main/java/junit/runner/Version.java.template >src/main/java/junit/runner/Version.java

%pom_remove_plugin :animal-sniffer-maven-plugin

%pom_remove_plugin :maven-javadoc-plugin

%pom_xpath_inject pom:project "<packaging>bundle</packaging>"
%pom_xpath_inject pom:build/pom:plugins "
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <extensions>true</extensions>
      <configuration>
        <instructions>
          <Bundle-SymbolicName>org.junit</Bundle-SymbolicName>
          <Export-Package>{local-packages},!org.hamcrest*,*;x-internal:=true</Export-Package>
          <_nouses>true</_nouses>
        </instructions>
      </configuration>
    </plugin>"

%mvn_file : junit
%mvn_alias junit:junit junit:junit-dep

%build
#set openjdk11 for build
export JAVA_HOME=%{_jvmdir}/java-11-openjdk
%mvn_build -- -DjdkVersion=1.7 -P\!restrict-doclint

%install
%mvn_install

%files -f .mfiles
%doc LICENSE-junit.txt README.md

%files help -f .mfiles-javadoc
%doc doc/*

%changelog
* Mon Sep 25 2023 wangkai <13474090681@163.com> - 1:4.13.2-2
- Enable test for build

* Mon Sep 25 2023 wangkai <13474090681@163.com> - 1:4.13.2-1
- Update to 4.13.2

* Fri Feb 19 2021 wangxiao <wangxiao65@huawei.com> - 1:4.12-13
- Fix CVE-2020-15250

* Sun Jan 19 2020 Jiangping Hu <hujp1985@foxmail.com> - 1:4.12-12
- Package init
