-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: produce a no-dependencies shaded Mutiny jar
Ref: #1577
- Loading branch information
Showing
4 changed files
with
208 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,133 @@ | ||
<?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> | ||
</excludes> | ||
</filter> | ||
<filter> | ||
<artifact>org.jctools:jctools-core</artifact> | ||
<excludes> | ||
<exclude>org/jctools/counters/**</exclude> | ||
<exclude>org/jctools/maps/**</exclude> | ||
<exclude>org/jctools/queues/atomic/**</exclude> | ||
</excludes> | ||
</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 { | ||
} |
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
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_shaded_classes() throws ClassNotFoundException { | ||
Class.forName("io.smallrye.mutiny.shaded.org.jctools.queues.BaseLinkedQueue"); | ||
Class.forName("io.smallrye.mutiny.shaded.org.jctools.queues.unpadded.BaseLinkedUnpaddedQueue"); | ||
Class.forName("io.smallrye.mutiny.shaded.io.smallrye.common.annotation.CheckReturnValue"); | ||
} | ||
|
||
@Test | ||
public void mpsc_queue_factory() { | ||
Queue<String> queue = Queues.createMpscArrayQueue(256); | ||
|
||
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 spsc_queue_factory() { | ||
Queue<String> queue = Queues.createSpscArrayQueue(256); | ||
|
||
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