Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ deploy.docs.sh
.ruby-version
.idea
spec/examples.txt
target/
23 changes: 22 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@

This is March Hare, a JRuby AMQP 0-9-1 client for RabbitMQ built on top of the
[RabbitMQ Java client](https://github.com/rabbitmq/rabbitmq-java-client).
The Java client and its dependencies are bundled as JARs under `lib/ext`.
The Java client and its dependencies are bundled as a single shaded JAR under `lib/ext`.

### Bundled JARs and the Maven shade build

`lib/ext/rabbitmq-client-netty-shaded.jar` is a shaded uber-JAR produced by `mvn package` using the
Maven Shade plugin (see `pom.xml`). It contains the RabbitMQ Java client together with
all Netty modules. All Netty classes are relocated from `io.netty.*` to
`com.rabbitmq.marchhare.shaded.netty.*` so that other JRuby gems bundling a different
Netty version on the same JVM (e.g. Logstash plugins) cannot conflict with march_hare's
own Netty.

The SLF4J JARs (`slf4j-api.jar`, `slf4j-simple.jar`) are kept as separate files and are
**not** shaded — this lets the RabbitMQ client's log output flow through whatever SLF4J
backend the user's application configures.

**To update the RabbitMQ client or Netty version:**
1. Edit the `<version>` of `com.rabbitmq:amqp-client` in `pom.xml` (Netty is pulled in
transitively at whatever version the client requires)
2. Run `mvn package` (or `rake jars:build`) — this writes the new JAR to `lib/ext/rabbitmq-client-netty-shaded.jar`
3. Download the matching `slf4j-api` and `slf4j-simple` JARs from Maven Central if the
SLF4J version changed, and replace the files in `lib/ext/`
4. Commit all changed files under `lib/ext/` together with `pom.xml`

## Change Log

Expand Down
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ require 'bundler'


Bundler::GemHelper.install_tasks

namespace :jars do
desc 'Rebuild lib/ext/rabbitmq-client-netty-shaded.jar via Maven (run after bumping amqp-client or Netty versions in pom.xml)'
task :build do
sh 'mvn package -q'
puts 'Built lib/ext/rabbitmq-client-netty-shaded.jar'
end
end
Binary file removed lib/ext/netty-buffer.jar
Binary file not shown.
Binary file removed lib/ext/netty-codec-base.jar
Binary file not shown.
Binary file removed lib/ext/netty-common.jar
Binary file not shown.
Binary file removed lib/ext/netty-handler.jar
Binary file not shown.
Binary file removed lib/ext/netty-resolver.jar
Binary file not shown.
Binary file removed lib/ext/netty-transport.jar
Binary file not shown.
Binary file added lib/ext/rabbitmq-client-netty-shaded.jar
Binary file not shown.
Binary file removed lib/ext/rabbitmq-client.jar
Binary file not shown.
14 changes: 5 additions & 9 deletions lib/march_hare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
require 'ext/slf4j-api'
require 'ext/slf4j-simple'

# Modern RabbitMQ Java client depends on Netty
require 'ext/netty-common'
require 'ext/netty-buffer'
require 'ext/netty-resolver'
require 'ext/netty-transport'
require 'ext/netty-codec-base'
require 'ext/netty-handler'

require 'ext/rabbitmq-client'
# Single shaded JAR bundling the RabbitMQ Java client together with all Netty
# dependencies. Netty classes are relocated from io.netty.* to
# com.rabbitmq.marchhare.shaded.netty.* so they cannot conflict with other gems
# (e.g. Logstash plugins) that bundle a different Netty version on the same JVM.
require 'ext/rabbitmq-client-netty-shaded'

require 'march_hare/version'
require 'march_hare/exceptions'
Expand Down
96 changes: 96 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?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>

<groupId>com.rabbitmq</groupId>
<artifactId>march-hare-shaded</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<description>Shaded JAR bundling the RabbitMQ Java client with Netty relocated to a private
namespace, so that other JRuby gems shipping their own Netty version do not conflict.</description>

<!--
Run `mvn package` to regenerate lib/ext/rabbitmq-client-netty-shaded.jar after bumping dependency versions.
The output JAR is committed to git so gem consumers do not need Maven.
-->

<dependencies>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<!-- Keep in sync with ChangeLog.md / version bump commits -->
<version>5.36.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<!-- Write directly into lib/ext so the gemspec git ls-files picks it up -->
<outputFile>${project.basedir}/lib/ext/rabbitmq-client-netty-shaded.jar</outputFile>

<relocations>
<!--
Relocate every io.netty class to a private package so that other gems
bundling a different Netty version do not clash with ours.
The RabbitMQ client's internal references are rewritten automatically.
-->
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>com.rabbitmq.marchhare.shaded.netty</shadedPattern>
</relocation>
</relocations>

<transformers>
<!-- Merge META-INF/services/* entries from all shaded JARs -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
</transformers>

<filters>
<!--
SLF4J API is kept as a separate JAR (lib/ext/slf4j-api.jar) so that
the RabbitMQ client's log output flows through whatever SLF4J backend
the user's application configures. Including it in the shaded JAR
would isolate logging and prevent users from routing it to Logback, etc.
-->
<filter>
<artifact>org.slf4j:*</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>

<!-- Strip JAR signatures, per-artifact manifests, and Maven metadata -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>