jruby-maven-plugins icon indicating copy to clipboard operation
jruby-maven-plugins copied to clipboard

gem plugin does not like snapshot JRuby versions

Open headius opened this issue 1 month ago • 2 comments

When running a maven build using the gem plugin and specifying a jruby.version that is a SNAPSHOT version, the build will fail with an error like this:

[INFO] --- gem:3.0.6:initialize (default-initialize) @ warbler ---
[WARNING] OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=warn; support was removed in 17.0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.932 s
[INFO] Finished at: 2025-10-15T10:41:07-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jruby.maven:gem-maven-plugin:3.0.6:initialize (default-initialize) on project warbler: Execution default-initialize of goal org.jruby.maven:gem-maven-plugin:3.0.6:initialize failed: For input string: "0-SNAPSHOT" -> [Help 1]
...

In my case, this was running with jruby.version set to the local build of JRuby 10.0.3.0-SNAPSHOT. It appears the plugin stumbles over the 0-SNAPSHOT portion, perhaps trying to convert to an integer or otherwise parse the version as a normal dotted number sequence.

Running the build with a release version of JRuby avoids the issue.

headius avatar Oct 15 '25 15:10 headius

An example to use would be to attempt to release warbler using a snapshot version of JRuby and calling rake build. The Rakefile passes the current JRuby version through as the jruby.version property, and then the error results. Forcing that version to a non-snapshot release also fixes the issue, but pins the build to that JRuby version (which may be fine).

headius avatar Oct 15 '25 16:10 headius

I attempted to force warbler's build to use a non-snapshot version for jruby.version when invoking maven (via the ruby-maven wrapper) but it still picks up the currently-running JRuby version somewhere (or simply can't handle running the build and booting plugins with different JRuby versions).

Patch attempt is below.

diff --git a/Rakefile b/Rakefile
index 5750baa..d7048a2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -22,7 +22,14 @@ task :default => :spec
 # use Mavenfile to define :jar task
 require 'maven/ruby/maven'
 mvn = Maven::Ruby::Maven.new
-mvn << "-Djruby.version=#{JRUBY_VERSION}"
+
+# use a known release version if building with a snapshot version of JRuby (https://github.com/jruby/jruby-maven-plugins/issues/143)
+jruby_version = JRUBY_VERSION
+if jruby_version =~ /-SNAPSHOT$/
+  jruby_version = "10.0.2.0"
+end
+
+mvn << "-Djruby.version=#{jruby_version}"
 mvn << "-Dbundler.version=#{Bundler::VERSION}"
 mvn << '--no-transfer-progress'
 mvn << '--color=always'

headius avatar Oct 15 '25 16:10 headius