From 47e8cdd183debe34ec7fb472a632405c9d661fc3 Mon Sep 17 00:00:00 2001 From: donoghuc Date: Tue, 7 Jul 2026 11:17:38 -0700 Subject: [PATCH 1/3] Prepare a 0.5.2 release and guard against incomplete gem publish This commit prepares a 0.5.2 release to fix the incomplete gem publish for 0.5.1. I have also included a guard against this happening in the future. Closes https://github.com/guyboertje/jrjackson/issues/102 --- changelog.md | 9 +++++++++ lib/jrjackson/build_info.rb | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 4989519..de63de9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,12 @@ +v0.5.2 + Fix packaging: the generated lib/jrjackson_jars.rb shim was omitted from the + v0.5.1 gem, making it fail to load with `LoadError: cannot load such file -- + jrjackson_jars`. Guard generated_files so a missing generated file now fails + the build instead of shipping a broken gem. + +v0.5.1 + Upgrade jackson and jackson-databind to v2.21.4 + v0.5.0 Upgrade jackson and jackson-databind to v2.21.2 Require JRuby 9.4.14.0 and Java 11 toolchain for builds diff --git a/lib/jrjackson/build_info.rb b/lib/jrjackson/build_info.rb index dd31bd9..c0c36b3 100644 --- a/lib/jrjackson/build_info.rb +++ b/lib/jrjackson/build_info.rb @@ -1,11 +1,11 @@ module JrJackson module BuildInfo def self.version - '0.5.1' + '0.5.2' end def self.release_date - '2026-06-26' + '2026-07-07' end def self.files @@ -31,7 +31,14 @@ def self.jar_version private def self.generated_files - Dir.glob( %w(pom.xml lib/jrjackson_jars.rb) ) + files = %w(pom.xml lib/jrjackson_jars.rb) + missing = files.reject { |f| File.file?(f) } + unless missing.empty? + raise "jrjackson packaging error: generated file(s) missing at build time: " \ + "#{missing.join(', ')}. Run `rake vendor_jars` (or `rake compile`) to " \ + "regenerate them before building the gem." + end + files end def self.repo_files From 32ffa83a51b75c70a1569843f9b881cdba801e1d Mon Sep 17 00:00:00 2001 From: donoghuc Date: Tue, 7 Jul 2026 11:51:26 -0700 Subject: [PATCH 2/3] update based on understanding of gemspec load time --- Rakefile | 12 ++++++++++++ changelog.md | 7 +++---- lib/jrjackson/build_info.rb | 12 ++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Rakefile b/Rakefile index 07c4601..026acf6 100644 --- a/Rakefile +++ b/Rakefile @@ -18,6 +18,7 @@ task :compile do RubyMaven.exec('prepare-package') # after packaging the jrjackson-x.y.z.jar vendor jar dependencies Rake::Task['vendor_jars'].invoke + Rake::Task['verify_generated_files'].invoke end task :vendor_jars do @@ -25,6 +26,17 @@ task :vendor_jars do Jars::Installer.vendor_jars! end +# Fail the build if a file the gemspec lists is missing on disk. This stops a +# broken gem from shipping, as happened with 0.5.1. +task :verify_generated_files do + $LOAD_PATH.unshift(File.expand_path('lib', __dir__)) + require 'jrjackson/build_info' + missing = JrJackson::BuildInfo.files.reject { |f| File.file?(f) } + unless missing.empty? + raise "These files are listed in the gemspec but missing after compile #{missing.join(', ')}" + end +end + desc "Clean build" task :clean do RubyMaven.exec('clean') diff --git a/changelog.md b/changelog.md index de63de9..9c7bffe 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,7 @@ v0.5.2 - Fix packaging: the generated lib/jrjackson_jars.rb shim was omitted from the - v0.5.1 gem, making it fail to load with `LoadError: cannot load such file -- - jrjackson_jars`. Guard generated_files so a missing generated file now fails - the build instead of shipping a broken gem. + Fix packaging so the generated lib/jrjackson_jars.rb is included in the gem + List generated files explicitly instead of using Dir.glob so they are packaged even when generated after the gemspec is evaluated + Add a build step that fails when a file listed in the gemspec is missing v0.5.1 Upgrade jackson and jackson-databind to v2.21.4 diff --git a/lib/jrjackson/build_info.rb b/lib/jrjackson/build_info.rb index c0c36b3..db97226 100644 --- a/lib/jrjackson/build_info.rb +++ b/lib/jrjackson/build_info.rb @@ -30,15 +30,11 @@ def self.jar_version private + # Use an explicit list, not Dir.glob. The gemspec is evaluated at Rakefile + # load time, before rake compile regenerates these files, so a glob would + # drop them. def self.generated_files - files = %w(pom.xml lib/jrjackson_jars.rb) - missing = files.reject { |f| File.file?(f) } - unless missing.empty? - raise "jrjackson packaging error: generated file(s) missing at build time: " \ - "#{missing.join(', ')}. Run `rake vendor_jars` (or `rake compile`) to " \ - "regenerate them before building the gem." - end - files + %w(pom.xml lib/jrjackson_jars.rb) end def self.repo_files From 7d5769584c03986b57367ead9aee4aef1f0dc196 Mon Sep 17 00:00:00 2001 From: donoghuc Date: Tue, 7 Jul 2026 11:59:08 -0700 Subject: [PATCH 3/3] handle the case where there are leftover older jackson jars --- lib/jrjackson/build_info.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jrjackson/build_info.rb b/lib/jrjackson/build_info.rb index db97226..c4ea672 100644 --- a/lib/jrjackson/build_info.rb +++ b/lib/jrjackson/build_info.rb @@ -37,8 +37,11 @@ def self.generated_files %w(pom.xml lib/jrjackson_jars.rb) end + # Exclude jars from the glob. They are listed with their exact versions in + # generated_jar_files, so leftover jars from an older version are not + # packaged. def self.repo_files - Dir["lib/**/*"].select{ |f| File.file? f } + ["README.md", "jrjackson.gemspec", ] + Dir["lib/**/*"].select{ |f| File.file?(f) && !f.end_with?(".jar") } + ["README.md", "jrjackson.gemspec", ] end def self.generated_jar_files