File junit.spec of Package junit

# spec file for package junit
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           junit
Version:        4.12
Release:        0
Summary:        Java regression test package
License:        EPL-1.0
Group:          Development/Libraries/Java
Source1:        build.xml
Patch0:         junit-jdk10.patch
Patch1:         junit-jdk11.patch
BuildRequires:  ant
BuildRequires:  fdupes
BuildRequires:  hamcrest-core >= 1.3
BuildRequires:  java-devel >= 1.6
BuildRequires:  javapackages-local
Requires:       mvn(org.hamcrest:hamcrest-core)
Provides:       %{name}-demo = %{version}-%{release}
Obsoletes:      %{name}-demo < %{version}-%{release}
Provides:       %{name}4-demo = %{version}-%{release}
Obsoletes:      %{name}4-demo < %{version}-%{release}
Provides:       %{name}4 = %{version}-%{release}
Obsoletes:      %{name}4 < %{version}-%{release}
BuildArch:      noarch

JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
It is used by the developer who implements unit tests in Java.

%package javadoc
Summary:        Javadoc for %{name}
Group:          Documentation/HTML
Provides:       %{name}4-javadoc = %{version}-%{release}
Obsoletes:      %{name}4-javadoc < %{version}-%{release}

%description javadoc
Javadoc for %{name}.

%package manual
Summary:        Manual for %{name}
Group:          Documentation/Other
Provides:       %{name}4-manual = %{version}-%{release}
Obsoletes:      %{name}4-manual < %{version}-%{release}

%description manual
Documentation for %{name}.

%setup -q -n %{name}4-r%{version}
cp %{SOURCE1} .
%patch0 -p1
%patch1 -p1

find . -type f -name "*.jar" -or -name "*.class" | xargs -t rm -rf

ln -s $(build-classpath hamcrest/core) lib/hamcrest-core-1.3.jar

export CLASSPATH=$(build-classpath hamcrest/core)
ant jars javadoc -Dversion-status=

# jars
install -d -m 755 %{buildroot}%{_javadir}
install -m 644 %{name}%{version}/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
# compat symlink
ln -sf %{_javadir}/%{name}.jar %{buildroot}%{_javadir}/%{name}4.jar

# pom
install -d -m 755 %{buildroot}%{_mavenpomdir}
install -m 644 pom.xml %{buildroot}%{_mavenpomdir}/%{name}.pom
%add_maven_depmap %{name}.pom %{name}.jar

# javadoc
install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
cp -pr %{name}%{version}/javadoc/* %{buildroot}%{_javadocdir}/%{name}
%fdupes -s %{buildroot}%{_javadocdir}/%{name}


cat > <<EOF
import org.junit.Assert;
class test {

    public static void main(String[] args) {"Hello world from junit");

javac -cp %{buildroot}/%{_javadir}/%{name}.jar
java -cp %{buildroot}/%{_javadir}/%{name}.jar: test 2>&1 | \
   grep 'Exception in thread "main" java.lang.AssertionError: Hello world from junit'

%files -f .mfiles
%license LICENSE-junit.txt
%doc CODING_STYLE.txt acknowledgements.txt

%files javadoc
%license LICENSE-junit.txt

%files manual
%license LICENSE-junit.txt
%doc doc/*