-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1613 from smallrye/feat/no-deps-shading
feat: produce a no-dependencies shaded Mutiny jar
- Loading branch information
Showing
4 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny-project</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>mutiny-no-deps</artifactId> | ||
<name>SmallRye Mutiny - Shaded library</name> | ||
<description>Variant of Mutiny with shaded dependencies</description> | ||
|
||
<properties> | ||
<revapi.skip>true</revapi.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.smallrye.reactive</groupId> | ||
<artifactId>mutiny</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>${maven-shade-plugin.version}</version> | ||
<configuration> | ||
<createSourcesJar>true</createSourcesJar> | ||
<shadeSourcesContent>true</shadeSourcesContent> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>module-info.class</exclude> | ||
<exclude>META-INF/jandex.idx</exclude> | ||
<exclude>META-INF/MANIFEST.MF</exclude> | ||
<exclude>META-INF/maven/**</exclude> | ||
</excludes> | ||
</filter> | ||
<filter> | ||
<artifact>org.jctools:jctools-core</artifact> | ||
<includes> | ||
<include>org/jctools/queues/atomic/unpadded/**</include> | ||
<include>org/jctools/queues/MessagePassingQueue*</include> | ||
<include>org/jctools/queues/IndexedQueueSizeUtil*</include> | ||
<include>org/jctools/queues/QueueProgressIndicators*</include> | ||
<include>org/jctools/queues/SupportsIterator*</include> | ||
<include>org/jctools/queues/BaseLinkedQueue*</include> | ||
<include>org/jctools/queues/LinkedQueueNode*</include> | ||
<include>org/jctools/queues/atomic/AtomicQueueUtil*</include> | ||
<include>org/jctools/queues/atomic/AtomicReferenceArrayQueue*</include> | ||
<include>org/jctools/queues/atomic/SequencedAtomicReferenceArrayQueue*</include> | ||
<include>org/jctools/queues/atomic/LinkedQueueAtomicNode*</include> | ||
<include>org/jctools/util/SpscLookAheadUtil*</include> | ||
<include>org/jctools/util/Pow2*</include> | ||
<include>org/jctools/util/RangeUtil*</include> | ||
<include>org/jctools/util/UnsafeAccess*</include> | ||
</includes> | ||
</filter> | ||
</filters> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<manifestEntries></manifestEntries> | ||
</transformer> | ||
</transformers> | ||
<relocations> | ||
<relocation> | ||
<pattern>org.jctools</pattern> | ||
<shadedPattern>io.smallrye.mutiny.shaded.org.jctools</shadedPattern> | ||
</relocation> | ||
<relocation> | ||
<pattern>io.smallrye.common</pattern> | ||
<shadedPattern>io.smallrye.mutiny.shaded.io.smallrye.common</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.smallrye</groupId> | ||
<artifactId>jandex-maven-plugin</artifactId> | ||
<configuration> | ||
<jar>${project.build.directory}/${project.build.finalName}.jar</jar> | ||
<includes> | ||
<include>io/smallrye/mutiny/**/*.class</include> | ||
</includes> | ||
<excludes> | ||
<exclude>io/smallrye/mutiny/shaded/**/*.class</exclude> | ||
</excludes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jandex-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.cyclonedx</groupId> | ||
<artifactId>cyclonedx-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${maven-failsafe-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.smallrye.mutiny.nodeps; | ||
|
||
/** | ||
* This is used as a placeholder to force the maven-javadoc-plugin to create a javadoc jar. | ||
* Yes, you read it right :-) | ||
*/ | ||
public interface Empty { | ||
} |
58 changes: 58 additions & 0 deletions
58
no-deps/src/test/java/io/smallrye/mutiny/nodeps/ShadingIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.smallrye.mutiny.nodeps; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Queue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.helpers.queues.Queues; | ||
import io.smallrye.mutiny.subscription.BackPressureStrategy; | ||
|
||
public class ShadingIT { | ||
|
||
@Test | ||
public void check_class_relocation() throws ClassNotFoundException { | ||
Class.forName("io.smallrye.mutiny.shaded.org.jctools.queues.BaseLinkedQueue"); | ||
Class.forName("io.smallrye.mutiny.shaded.org.jctools.queues.atomic.unpadded.BaseLinkedAtomicUnpaddedQueue"); | ||
Class.forName("io.smallrye.mutiny.shaded.io.smallrye.common.annotation.CheckReturnValue"); | ||
} | ||
|
||
@Test | ||
public void check_factories() { | ||
List<Queue<String>> queues = List.of( | ||
Queues.createSpscArrayQueue(256), | ||
Queues.createSpscUnboundedArrayQueue(256), | ||
Queues.createSpscChunkedArrayQueue(256), | ||
Queues.createMpscQueue(), | ||
Queues.createSpscUnboundedQueue(256), | ||
Queues.createMpscArrayQueue(256)); | ||
|
||
queues.forEach(queue -> { | ||
queue.add("foo"); | ||
queue.add("bar"); | ||
assertEquals("foo", queue.poll()); | ||
assertEquals("bar", queue.poll()); | ||
assertNull(queue.poll()); | ||
assertTrue(queue.getClass().getCanonicalName().contains("shaded")); | ||
}); | ||
} | ||
|
||
@Test | ||
public void multi_emitter() { | ||
Multi<Integer> multi = Multi.createFrom().emitter(emitter -> { | ||
for (int i = 0; i < 100; i++) { | ||
emitter.emit(i); | ||
} | ||
emitter.complete(); | ||
}, BackPressureStrategy.BUFFER); | ||
|
||
List<Integer> suite = multi.collect().asList().await().atMost(Duration.ofSeconds(5)); | ||
assertEquals(100, suite.size()); | ||
assertEquals(0, suite.get(0)); | ||
assertEquals(99, suite.get(99)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters