diff --git a/.gitignore b/.gitignore index 73d0666..8f2ea6e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ deploy.docs.sh .ruby-version .idea spec/examples.txt +target/ diff --git a/AGENTS.md b/AGENTS.md index 77f645f..fbe9625 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 `` 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 diff --git a/Rakefile b/Rakefile index 5237170..bceedd0 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/lib/ext/netty-buffer.jar b/lib/ext/netty-buffer.jar deleted file mode 100644 index 516940e..0000000 Binary files a/lib/ext/netty-buffer.jar and /dev/null differ diff --git a/lib/ext/netty-codec-base.jar b/lib/ext/netty-codec-base.jar deleted file mode 100644 index cb9b62c..0000000 Binary files a/lib/ext/netty-codec-base.jar and /dev/null differ diff --git a/lib/ext/netty-common.jar b/lib/ext/netty-common.jar deleted file mode 100644 index e98db90..0000000 Binary files a/lib/ext/netty-common.jar and /dev/null differ diff --git a/lib/ext/netty-handler.jar b/lib/ext/netty-handler.jar deleted file mode 100644 index ea75df7..0000000 Binary files a/lib/ext/netty-handler.jar and /dev/null differ diff --git a/lib/ext/netty-resolver.jar b/lib/ext/netty-resolver.jar deleted file mode 100644 index dae539b..0000000 Binary files a/lib/ext/netty-resolver.jar and /dev/null differ diff --git a/lib/ext/netty-transport.jar b/lib/ext/netty-transport.jar deleted file mode 100644 index 908cd00..0000000 Binary files a/lib/ext/netty-transport.jar and /dev/null differ diff --git a/lib/ext/rabbitmq-client-netty-shaded.jar b/lib/ext/rabbitmq-client-netty-shaded.jar new file mode 100644 index 0000000..5e70595 Binary files /dev/null and b/lib/ext/rabbitmq-client-netty-shaded.jar differ diff --git a/lib/ext/rabbitmq-client.jar b/lib/ext/rabbitmq-client.jar deleted file mode 100644 index 41363ce..0000000 Binary files a/lib/ext/rabbitmq-client.jar and /dev/null differ diff --git a/lib/march_hare.rb b/lib/march_hare.rb index 8fb29d1..15b39cf 100644 --- a/lib/march_hare.rb +++ b/lib/march_hare.rb @@ -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' diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5769864 --- /dev/null +++ b/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + com.rabbitmq + march-hare-shaded + 1.0.0 + jar + 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. + + + + + + com.rabbitmq + amqp-client + + 5.36.0 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + false + + ${project.basedir}/lib/ext/rabbitmq-client-netty-shaded.jar + + + + + io.netty + com.rabbitmq.marchhare.shaded.netty + + + + + + + + + + + + + + org.slf4j:* + + ** + + + + + + *:* + + META-INF/MANIFEST.MF + META-INF/maven/** + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + +