%global githash a5341c2b19c5b1161ec410935e191e3a9c3d21d3
Name: jmockit
Version: 1.18
Release: 1%{?dist}
Summary: Java toolkit for unit/integration testing
License: MIT
URL: http://jmockit.org/
Source0: https://github.com/jmockit/jmockit1/archive/%{githash}/%{name}1-%{githash}.tar.gz
Source1: jmockit-external-asm-errors.txt
# https://raw.githubusercontent.com/jmockit/jmockit.github.io/master/api1x/overview.html
Source2: jmockit-overview.html
# https://raw.githubusercontent.com/jmockit/jmockit.github.io/master/api1x/stylesheet.css
Source3: jmockit-stylesheet.css
#Task info: http://koji.fedoraproject.org/koji/taskinfo?taskID=9837003
BuildRequires: maven-local
# package java.util.function does not exist
# package java.util.stream does not exist
# package PrimitiveIterator does not exist (java.util.PrimitiveIterator$OfInt)
BuildRequires: java >= 1.8.0
BuildRequires: mvn(com.google.code.findbugs:jsr305)
BuildRequires: mvn(javax.inject:javax.inject)
BuildRequires: mvn(javax.persistence:persistence-api)
BuildRequires: mvn(javax.servlet:javax.servlet-api)
BuildRequires: mvn(junit:junit)
BuildRequires: mvn(org.apache.geronimo.specs:geronimo-ejb_3.1_spec)
BuildRequires: mvn(org.apache.geronimo.specs:specs:pom:)
BuildRequires: mvn(org.testng:testng)
#BuildRequires: mvn(org.ow2.asm:asm)
Requires: java >= 1.8.0
BuildArch: noarch
%description
JMockit is a Java toolkit for developer (unit/integration) testing.
It contains mocking APIs and other tools, supporting both JUnit and
TestNG. The mocking APIs allow all kinds of Java code, without testability
restrictions, to be tested in isolation from selected dependencies.
%package coverage
Summary: JMockit Coverage
%description coverage
JMockit Coverage is a code coverage tool with several metrics (line,
path, data) capable of generating HTML reports. It is designed with
ease of use in mind, avoiding the need for complex configuration.
Instead, smart (but overridable) defaults are employed, such as the
selection of which classes to consider for coverage, and where to
find sources files for report generation.
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
This package contains javadoc for %{name}.
%prep
%setup -q -n %{name}1-%{githash}
# Cleanup
find -name "*.class" -print -delete
find -name "*.jar" -print -delete
# see SOURCE1
#rm -r main/src/mockit/external/asm
#rm -r main/src/mockit/external
#%% pom_add_dep org.ow2.asm:asm main
#sed -i "s|mockit.external.asm|org.objectweb.asm|" $(find -name "*.java")
#sed -i "s|mockit.external.asm|org.objectweb.asm|" \
# main/src/mockit/internal/BaseClassModifier.java \
# main/src/mockit/internal/expectations/transformation/InvocationBlockModifier.java
# Unwanted
for p in coverage main; do
%pom_remove_plugin :maven-source-plugin ${p}
%pom_remove_plugin :maven-gpg-plugin ${p}
%pom_remove_plugin :nexus-staging-maven-plugin ${p}
%pom_xpath_remove "pom:plugin[pom:artifactId = 'maven-javadoc-plugin']/pom:executions" ${p}
%pom_xpath_remove "pom:plugin[pom:artifactId = 'maven-javadoc-plugin']/pom:configuration/pom:additionalparam" ${p}
done
%pom_xpath_set "pom:dependency[pom:groupId='javax.servlet']/pom:artifactId" javax.servlet-api main
%pom_xpath_set "pom:dependency[pom:groupId='javax.servlet']/pom:version" 3.1.0 main
%pom_remove_dep javax:javaee-api main
# package javax.inject does not exist
%pom_add_dep javax.inject:javax.inject main
# package javax.ejb does not exist
%pom_add_dep org.apache.geronimo.specs:geronimo-ejb_3.1_spec:1.0 main
# java.lang.NoClassDefFoundError: org.junit.runner.Runner
# at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:61)
# at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
# at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262)
# at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
# at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
rm -r main/test/*
# This is a dummy POM added just to ease building in the RPM platforms
# Build only these module. Other java modules require unavailable, too old, libraries
cat > pom.xml << EOF
4.0.0
org.jmockit
jmockit-project
pom
%{version}
main
coverage
coverageTests
org.apache.maven.plugins
maven-javadoc-plugin
2.9.1
integrationTests*
true
JMockit %{version} API Documentation
JMockit %{version} API
EOF
sed -i 's|"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar|../main/target/jmockit-${jmockit.version}.jar|' coverageTests/pom.xml
# fix non ASCII chars
for s in $(find . -name "*.java");do
native2ascii -encoding UTF8 ${s} ${s}
done
%mvn_package :jmockit-project __noinstall
%mvn_package :coverage-tests __noinstall
%mvn_file :%{name} %{name}
%mvn_file :%{name}-coverage %{name}-coverage
%build
%mvn_build -s
%install
%mvn_install
%files -f .mfiles-%{name}
%doc README.md
%license LICENSE.txt NOTICE.txt
%files coverage -f .mfiles-%{name}-coverage
%license LICENSE.txt NOTICE.txt
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt NOTICE.txt
%changelog
* Sun May 24 2015 gil cattaneo 1.18-1
- initial rpm