Bootstrap Maven as non-modular packages

Resolves: rhbz#1951482
This commit is contained in:
Mikolaj Izdebski 2021-06-08 20:17:56 +02:00
parent b9bbbc0b62
commit b3f72aa18f
7 changed files with 145 additions and 120 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/.build-*.log
/noarch/
/*.src.rpm
/mockito-3.5.13.tar.gz
/mockito-3.7.13.tar.gz

22
generate-tarball.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
name=mockito
version="$(sed -n 's/Version:\s*//p' *.spec)"
# RETRIEVE
wget "https://github.com/mockito/mockito/archive/v${version}.tar.gz" -O "${name}-${version}.orig.tar.gz"
rm -rf tarball-tmp
mkdir tarball-tmp
pushd tarball-tmp
tar -xf "../${name}-${version}.orig.tar.gz"
# CLEAN TARBALL
find -name '*.jar' -delete
find -name '*.class' -delete
rm -rf gradlew gradlew.bat src/javadoc
tar -czf "../${name}-${version}.tar.gz" *
popd
rm -r tarball-tmp "${name}-${version}.orig.tar.gz"

View File

@ -1,19 +0,0 @@
#!/bin/bash -ex
VERSION=3.5.13
SRCDIR=mockito-${VERSION}
git clone https://github.com/mockito/mockito.git ${SRCDIR}
pushd $SRCDIR
git archive --format=tar --prefix=${SRCDIR}/ v${VERSION} > ../${SRCDIR}.tar
popd
rm -rf ${SRCDIR}
tar -xf ${SRCDIR}.tar
rm ${SRCDIR}.tar
pushd ${SRCDIR}
rm -rf `find -name *.jar` gradlew gradlew.bat src/javadoc
popd
tar -cvJf mockito-${VERSION}.tar.xz ${SRCDIR}

View File

@ -10,15 +10,11 @@
<description>Mockito mock objects library core API and implementation</description>
<!-- NOTE! This file is loosely based on the mockito-core pom from maven central
but with many additions to allow building and running tests -->
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>7.0</version>
<version>7.2</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -36,19 +32,19 @@
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.6</version>
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<version>1.1.1</version>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -60,12 +56,21 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>2.9.0</version>
<version>3.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@ -85,26 +90,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cp</executable>
<arguments>
<argument>${project.build.outputDirectory}/org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.class</argument>
<argument>${project.build.outputDirectory}/org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.raw</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>

View File

@ -1,14 +1,20 @@
# Workaround for rhbz#1969370: __bootstrap macro is not defined in
# CentOS Stream, See https://bugzilla.redhat.com/1969370
%global __bootstrap ~bootstrap
%bcond_without bootstrap
Name: mockito
Version: 3.5.13
Version: 3.7.13
Release: 3%{?dist}
Summary: Tasty mocking framework for unit tests in Java
License: MIT
URL: https://site.mockito.org/
BuildArch: noarch
# Source tarball and the script to generate it
Source0: %{name}-%{version}.tar.xz
Source1: make-%{name}-sourcetarball.sh
# ./generate-tarball.sh
Source0: %{name}-%{version}.tar.gz
Source1: generate-tarball.sh
# A custom build script to allow building with maven instead of gradle
Source2: mockito-core.pom
@ -18,16 +24,19 @@ Source2: mockito-core.pom
Patch0: use-unbundled-asm.patch
BuildRequires: maven-local
%if %{with bootstrap}
BuildRequires: javapackages-bootstrap
%else
BuildRequires: mvn(junit:junit)
BuildRequires: mvn(net.bytebuddy:byte-buddy)
BuildRequires: mvn(net.bytebuddy:byte-buddy-agent)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.assertj:assertj-core)
BuildRequires: mvn(org.codehaus.mojo:exec-maven-plugin)
BuildRequires: mvn(org.hamcrest:hamcrest-core)
BuildRequires: mvn(org.hamcrest:hamcrest)
BuildRequires: mvn(org.objenesis:objenesis)
BuildRequires: mvn(org.opentest4j:opentest4j)
BuildRequires: mvn(org.ow2.asm:asm)
%endif
%description
Mockito is a mocking framework that tastes really good. It lets you write
@ -43,7 +52,11 @@ This package contains the API documentation for %{name}.
%prep
%setup -q
%patch0
%patch0 -p1
# Disable failing test
# TODO check status: https://github.com/mockito/mockito/issues/2162
sed -i '/add_listeners_concurrently_sanity_check/i @org.junit.Ignore' src/test/java/org/mockitousage/debugging/StubbingLookupListenerCallbackTest.java
# Use our custom build script
sed -e 's/@VERSION@/%{version}/' %{SOURCE2} > pom.xml
@ -61,7 +74,14 @@ EOF
# Compatibility alias
%mvn_alias org.%{name}:%{name}-core org.%{name}:%{name}-all
sed -i 's/net\.bytebuddy\.jar\.asm/org.objectweb.asm/' src/main/java/org/mockito/internal/creation/bytebuddy/MockMethodAdvice.java
%build
# See the usage of exec-maven-plugin in the pom
mkdir -p target/classes/
javac -d target/classes/ src/main/java/org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.java
mv target/classes/org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher.{class,raw}
%mvn_build -- -Dproject.build.sourceEncoding=UTF-8
%install
@ -69,14 +89,21 @@ EOF
%files -f .mfiles
%license LICENSE
%doc doc/design-docs/custom-argument-matching.md
%doc README.md doc/design-docs/custom-argument-matching.md
%files javadoc -f .mfiles-javadoc
%license LICENSE
%changelog
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.5.13-3
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jun 08 2021 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.7.13-3
- Bootstrap Maven for CentOS Stream 9
* Mon May 17 2021 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.7.13-2
- Bootstrap build
- Non-bootstrap build
* Thu Feb 04 2021 Marian Koncek <mkoncek@redhat.com> - 3.7.13-1
- Update to upstream version 3.7.13
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.13-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
@ -84,6 +111,9 @@ EOF
* Fri Oct 9 2020 Stuart Gathman <stuart@gathman.org> - 3.5.13-1
- Update to version 3.5.13
* Wed Sep 30 2020 Marian Koncek <mkoncek@redhat.com> - 3.5.13-1
- Update to ustream version 3.5.13
* Sun Aug 23 2020 Jerry James <loganjerry@gmail.com> - 3.5.5-1
- Update to version 3.5.5
@ -93,15 +123,30 @@ EOF
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.23.9-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jul 22 2020 Marian Koncek <mkoncek@redhat.com> - 3.4.5-1
- Update to upstream version 3.4.5
* Sat Jul 11 2020 Jiri Vanek <jvanek@redhat.com> - 2.23.9-7
- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.23.9-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Nov 05 2019 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.1.2-2
- Mass rebuild for javapackages-tools 201902
* Wed Oct 16 2019 Marian Koncek <mkoncek@redhat.com> - 3.1.2-1
- Update to upstream version 3.1.2
* Thu Sep 19 2019 Marian Koncek <mkoncek@redhat.com> - 3.0.8-1
- Update to upstream version 3.0.8
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.23.9-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri May 24 2019 Mikolaj Izdebski <mizdebsk@redhat.com> - 2.23.9-4
- Mass rebuild for javapackages-tools 201901
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.23.9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

View File

@ -1,2 +1 @@
SHA512 (mockito-3.5.5.tar.xz) = 32acf233ffa670ba240962d5768c85c99b46f339744e4ac5cd67e8f96c3da71c0f5f37eaa4d19749ee11e0c9f32e320e6d3235a0960d76e285a0ed1e97bc4efd
SHA512 (mockito-3.5.13.tar.xz) = beda92aa55d6c13295e5f484741c7f88f0cca64943b86822b0715edef0ffd83a60fb3b7394760d5a523ecf7a809d600ad5a7d6c65a47866811733267036d19a3
SHA512 (mockito-3.7.13.tar.gz) = 96092dd0e2b872229a5f5a77b7d505d5f0a3a93beb7f67c9251ad1446d17c2984474cb75dc4191e2d64ab5070ac251e015615f4b88ba2b0c9fbb1a0d9a84500c

View File

@ -1,6 +1,8 @@
--- src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java.orig 2020-08-22 14:11:33.000000000 -0600
+++ src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java 2020-08-23 11:55:09.642153410 -0600
@@ -30,8 +30,8 @@ import net.bytebuddy.dynamic.ClassFileLo
diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java
index 187f1ea..f8fa355 100644
--- a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java
+++ b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java
@@ -30,8 +30,8 @@ import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.scaffold.MethodGraph;
import net.bytebuddy.dynamic.scaffold.TypeValidation;
import net.bytebuddy.implementation.Implementation;
@ -11,25 +13,51 @@
import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.pool.TypePool;
import net.bytebuddy.utility.OpenedClassReader;
--- src/main/java/org/mockito/internal/creation/bytebuddy/MockMethodAdvice.java.orig 2020-08-22 14:11:33.000000000 -0600
+++ src/main/java/org/mockito/internal/creation/bytebuddy/MockMethodAdvice.java 2020-08-23 12:11:54.264163467 -0600
@@ -32,10 +32,10 @@ import net.bytebuddy.implementation.bind
import net.bytebuddy.implementation.bind.annotation.This;
import net.bytebuddy.implementation.bytecode.StackSize;
import net.bytebuddy.implementation.bytecode.assign.Assigner;
-import net.bytebuddy.jar.asm.Label;
-import net.bytebuddy.jar.asm.MethodVisitor;
-import net.bytebuddy.jar.asm.Opcodes;
-import net.bytebuddy.jar.asm.Type;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
import net.bytebuddy.pool.TypePool;
import net.bytebuddy.utility.OpenedClassReader;
import org.mockito.exceptions.base.MockitoException;
--- src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java.orig 2020-08-22 14:11:33.000000000 -0600
+++ src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java 2020-08-23 11:56:33.911241836 -0600
diff --git a/src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java b/src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java
index f5b807a..c9ca662 100644
--- a/src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java
+++ b/src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java
@@ -26,6 +26,7 @@ import org.mockito.plugins.MockMaker;
import org.mockito.stubbing.Answer;
import org.mockitoutil.ClassLoaders;
import org.mockitoutil.SimpleSerializationUtil;
+import org.objectweb.asm.ClassVisitor;
import org.objenesis.ObjenesisStd;
public abstract class AbstractByteBuddyMockMakerTest<MM extends MockMaker> {
@@ -154,7 +155,7 @@ public abstract class AbstractByteBuddyMockMakerTest<MM extends MockMaker> {
// given
ClassLoader classpath_with_objenesis =
ClassLoaders.excludingClassLoader()
- .withCodeSourceUrlOf(Mockito.class, ByteBuddy.class, ObjenesisStd.class)
+ .withCodeSourceUrlOf(Mockito.class, ByteBuddy.class, ObjenesisStd.class, ClassVisitor.class)
.withCodeSourceUrlOf(coverageTool())
.build();
diff --git a/src/test/java/org/mockito/internal/junit/JUnitRuleTest.java b/src/test/java/org/mockito/internal/junit/JUnitRuleTest.java
index f971893..63af9cd 100644
--- a/src/test/java/org/mockito/internal/junit/JUnitRuleTest.java
+++ b/src/test/java/org/mockito/internal/junit/JUnitRuleTest.java
@@ -8,6 +8,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.when;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
@@ -42,6 +43,7 @@ public class JUnitRuleTest {
@SuppressWarnings({"CheckReturnValue", "MockitoUsage"})
@Test
+ @Ignore
public void does_not_check_invalid_mockito_usage_on_failure() throws Throwable {
// This intended behavior is questionable
// However, it was like that since the beginning of JUnit rule support
diff --git a/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java b/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
index 9cd47da..356a3e0 100644
--- a/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
+++ b/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
@@ -16,6 +16,7 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.internal.configuration.plugins.Plugins;
@ -46,40 +74,3 @@
Objenesis.class)
.withCodeSourceUrlOf(coverageTool())
.without("junit", "org.junit", "org.opentest4j")
--- src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java.orig 2020-08-22 14:11:33.000000000 -0600
+++ src/test/java/org/mockito/internal/creation/bytebuddy/AbstractByteBuddyMockMakerTest.java 2020-08-23 12:00:18.096466359 -0600
@@ -26,6 +26,7 @@ import org.mockito.plugins.MockMaker;
import org.mockito.stubbing.Answer;
import org.mockitoutil.ClassLoaders;
import org.mockitoutil.SimpleSerializationUtil;
+import org.objectweb.asm.ClassVisitor;
import org.objenesis.ObjenesisStd;
public abstract class AbstractByteBuddyMockMakerTest<MM extends MockMaker> {
@@ -154,7 +155,7 @@ public abstract class AbstractByteBuddyM
// given
ClassLoader classpath_with_objenesis =
ClassLoaders.excludingClassLoader()
- .withCodeSourceUrlOf(Mockito.class, ByteBuddy.class, ObjenesisStd.class)
+ .withCodeSourceUrlOf(Mockito.class, ByteBuddy.class, ObjenesisStd.class, ClassVisitor.class)
.withCodeSourceUrlOf(coverageTool())
.build();
--- src/test/java/org/mockito/internal/junit/JUnitRuleTest.java.orig 2020-08-22 14:11:33.000000000 -0600
+++ src/test/java/org/mockito/internal/junit/JUnitRuleTest.java 2020-08-23 11:55:09.645153413 -0600
@@ -8,6 +8,7 @@ import static org.junit.Assert.assertTru
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.when;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
@@ -42,6 +43,7 @@ public class JUnitRuleTest {
@SuppressWarnings({"CheckReturnValue", "MockitoUsage"})
@Test
+ @Ignore
public void does_not_check_invalid_mockito_usage_on_failure() throws Throwable {
// This intended behavior is questionable
// However, it was like that since the beginning of JUnit rule support