Skip to content

Replace Ant in rake helpers with Ruby process launching - #9761

Merged
headius merged 2 commits into
jruby:masterfrom
zev:rake-without-ant
Oct 2, 2026
Merged

headius merged 2 commits into
jruby:masterfrom
zev:rake-without-ant

Conversation

@zev

@zev zev commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This removes JRuby's last dependency on Apache Ant for building and testing.

Rake helpers

The jruby and mspec helpers in rakelib/commands.rake used Ant only for its <path> and <java fork="true"> tasks. This PR replaces them with a small Ruby JRuby::Rake::JavaCommand class, whose run method takes the same nested elements (classpath, jvmarg, sysproperty, arg, env). The helper bodies are unchanged apart from the line that called Ant.

JavaCommand.run builds the same command Ant's java task did:

  • java from the running JVM's java.home, then the jvmargs, -Xmx, the -D sysproperties, -classpath, the main class and the args.
  • Classpath entries are made absolute, missing entries are dropped, and duplicates are removed.
  • It supports dir, output and the extra env vars, and a non-zero exit fails the task (failonerror).

There are no top-level constants or shared state:

  • The test.class.path classpath used by mspec comes from JRuby::Rake::JavaCommand.classpaths. It used to be registered by initialize_paths at the start of every jruby call and read straight back by that same call. The other registered path, jruby.execute.classpath, was never used.
  • The resultproperty exit codes and spec_run_error are removed. failonerror is always on (no caller overrides it), so the first failing mspec run aborts rake before spec_run_error is reached, and when every run passes all the codes are 0. That was also true under Ant, so spec_run_error could never report a failure. There's a comment on spec:tagged explaining this.

Removed

These were the other users of the Ant helpers, and they already fail on master:

Ant integration specs

spec/java_integration/ant/ and ant_spec_helper.rb test the rake-ant gem, so they are removed here and moved to rake-ant in jruby/rake-ant#6. Two related changes:

  • java_method_spec.rb relied on a global def import(*args); java_import(*args); end defined by the old ant/rake_spec.rb, which loads in the same rspec process. It now calls java_import directly.
  • test/pom.rb no longer downloads jarjar, which only ant/task_spec.rb used.

BUILDING.md and CONTRIBUTING.md no longer list Ant as a prerequisite.

The two cedx/SetupAnt steps in .github/workflows/dist-verification-ci.yml are removed. A run on my fork passed with Ant removed from the runner; the real install4j build and installer-verification only run on jruby/jruby.

Testing

I ran the helpers on master with Ant's verbose logging to capture the exact java command Ant forks, then compared it with what JavaCommand.run runs, for an mspec call (env vars, dir, test.class.path, tags) and a jruby call (output, jvmarg, sysproperty). Arguments, env vars, working directory and output-file contents were identical.

Before is master with Ant; after is this branch with Ant not installed (macOS, Temurin 21):

before after
spec:ruby:fast 31323 examples, 5 failures 31323 examples, same 5 failures
spec:ruby:debug 100 examples, 0 failures 100 examples, 0 failures
spec:ji (includes the Ant specs) 1007 examples, 1 failure
  • The 5 spec:ruby:fast failures are local macOS environment issues that also fail on unmodified master.
  • The spec:ji failure (jar_glob_spec.rb:81) also fails locally with master's files and Ant installed.
  • The spec process's JVM command line, captured with ps, is identical before and after.
  • ./mvnw -Pbootstrap clean package passes with the test/pom.rb change.

Follow-ups

  • spec:all depends on :all_compiled, but that task is named :all_compiled_18. Separate PR.

Co-authored with Claude Code.

@zev

zev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@headius I'd like your call on rakelib/bench.rake (rake bench:language) before the follow-up cleanup PR.

What it is: a rake port (0104198, 2010) of the old Ant bench-language target. It runs bench/language/bench_all.rb 5 six times: with the -client and -server JVM flags, each in interpreted (-X-C), JIT (threshold 5) and precompiled (-X+C) mode. Results go to bench.language.*.txt files.

Why it fails on master: all 56 files in bench/language/ were moved to rubybench in 996aedd ("Move language benchmarks to rubybench", 2012), but the task wasn't updated. It now fails immediately with:

Error opening script file: bench/language/bench_all.rb (No such file or directory)

This PR doesn't change that. The task now runs through java_fork instead of Ant, and it fails the same way.

Where the benchmarks are now: jruby/rubybench time/language/. That repo isn't archived, but its last push was in 2020. bench_all.rb loads 38 sibling benchmark files, so it can't be copied back on its own.

Everything else in the task still works on the current stack:

  • JDK 21 accepts and ignores -client and -server.
  • -X-C / -X+C still give compile mode OFF / FORCE.
  • With a rubybench checkout, bench_all.rb 1 ran all 38 benchmarks on current JRuby master, exit 0.

Options:

  1. Delete bench.rake. The benchmarks live in rubybench, and nothing in CI or the docs uses this task.
  2. Point it at a rubybench checkout, for example through an env var or a path in default.build.properties. That's only worth it if this six-way comparison is still useful to you.

I lean towards deleting it. Which do you prefer?

Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
@zev
zev force-pushed the rake-without-ant branch from d8c9f30 to 9b72626 Compare October 1, 2026 20:33
@zev
zev marked this pull request as ready for review October 1, 2026 20:40
@headius

headius commented Oct 1, 2026

Copy link
Copy Markdown
Member

Answers and comments before review:

  • Removed: graph:viz

This could move to the rake-ant project, which is where we moved the standard library rake+ant integration about a decade ago. Fine for it to leave jruby/jruby though.

  • rakelib/bench.rake

Yes, remove. A future task would be to integrate the benchmarks that Rails (railsbench?) and the CRuby JIT teams use (yjit-bench or something) so we could start setting up a benchmark CI somewhere. CRuby has a very nice performance regression server that I drool over.

  • rakelib/gem_installers.rake ... spec:fetch_stable_specs and spec:fetch_latest_specs also fail

Yeah just kill all of that. Specs are synced periodically through a new process, and obviously gem_installers hasn't been functional for a long time without anyone missing it.

  • jrake in commands.rake: has no callers.

Delete.

@headius

headius commented Oct 1, 2026

Copy link
Copy Markdown
Member
  • Should the spec:ji Ant specs skip when Ant isn't installed?

I think we should move those specs to rake-ant along with the graphviz thing: https://github.com/jruby/rake-ant.

Seems like a waste to do this work and still have one target that needs ant, when nobody in the world uses that integration anymore.

  • Can the cedx/SetupAnt steps in dist-verification-ci.yml be removed?

I think Claude is wrong here, because I had to add that to get all of those subprocess runners to work. But once we're free of Ant, this can be removed too.

  • spec:all depends on :all_compiled, but that task is named :all_compiled_18.

Not relevant to this PR, but that could certainly be cleaned up in a separate PR.

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes but it's great to se this Ant requirement go away.

Future PR can make this all more idiomatic.

Comment thread rakelib/commands.rake Outdated
Comment thread rakelib/commands.rake Outdated
@zev
zev force-pushed the rake-without-ant branch from 9b72626 to 11eaa05 Compare October 1, 2026 22:10
Comment thread test/pom.rb
Comment thread spec/java_integration/methods/java_method_spec.rb
@zev
zev force-pushed the rake-without-ant branch from 11eaa05 to 8fd09f4 Compare October 1, 2026 22:39
zev added a commit to zev/jruby that referenced this pull request Oct 1, 2026
Throwaway branch on top of jruby#9761 to check the dist verification
workflow without Ant:
- remove both cedx/SetupAnt steps and hide the Ant preinstalled on
  ubuntu-latest
- let build-installer run on a fork, without install4j, so
  `rake installer` runs up to the install4j step and skips it
- remove the other workflows on this branch only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zev

zev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@headius About the cedx/SetupAnt steps in dist-verification-ci.yml: I tested removing them on my fork, and I'd like your call on whether to remove them in this PR or in a follow-up.

Test branch: zev:rake-without-ant-ci-setupant is this PR's current head (8fd09f4) plus one throwaway commit, 3c05816, that is not for merging:

  • both SetupAnt steps removed;
  • a step that hides the Ant preinstalled on ubuntu-latest (moves ant off PATH and blanks ANT_HOME), so the run really has no Ant;
  • build-installer allowed to run on a fork without install4j (no licence secret there), so bin/jruby -S rake installer runs everything up to install4j and then skips it;
  • the other workflows removed on that branch only, to avoid a full CI run.

Result: run 36936502331. The two jobs that had SetupAnt, "Build JRuby release artifacts" and "Build JRuby Windows installers", both passed. The rails, src, jruby-complete and misc verification jobs never used SetupAnt; most have passed and the rest were still queued on my fork's runners when I posted this, so the link shows the final status. An earlier run of the same test on the previous revision of this PR passed every job. In the installer job log:

ANT_HOME:
...
unziped into /tmp/d20261001-3098-s2dfrd/jruby-10.1.3.0-SNAPSHOT
/tmp/.../bin/jruby -S gem install jruby-win32ole
Successfully installed jruby-win32ole-0.8.5
Skipping windows installers since install4j is not available

There is no "could not load ant" line, since nothing in rake loads Ant any more.

Why it was added: this is my reading of the runs from when you added it in 141121f. SetupAnt came in while you were getting rake installer to pass, and what fixed it was running JRuby's rake:

Run Change build installer
26208005043 (9e025d1) added SetupAnt failed
26208167639 (931c13a) moved SetupAnt before bundle install failed
26208328543 (8977cb7) rake installer → bin/jruby -S rake installer passed

Those logs have expired, so I can't show the original error. Also, ubuntu-latest ships Ant already, and on master a missing Ant only made commands.rake print a warning. So I don't think SetupAnt was needed even then, and with this PR it certainly isn't.

What the fork can't test: the real install4j build and installer-verification, which only run on pushes to jruby/jruby. If removing SetupAnt somehow broke them, putting the step back would be a one-line revert.

Should I remove both SetupAnt steps in this PR, or leave that for a follow-up?

@zev

zev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: run 36936502331 has now finished. All 26 jobs that ran passed, with no Ant on the runner. The only skipped job is installer-verification, which runs only on pushes to jruby/jruby.

@headius

headius commented Oct 1, 2026

Copy link
Copy Markdown
Member

build-installer allowed to run on a fork without install4j

I get that it's trying to make this job runnable for non-jruby/jruby pushes but obviously that should not be merged. There's not much value in the installer jobs without actually building the installers.

Removing all the SetupAnt stuff other than that is fine to include in this PR.

The jruby and mspec rake helpers used Ant only for its <path> and
forked <java> tasks. Replace those with a small Ruby
JRuby::Rake::JavaCommand that takes the same nested elements and
builds the same java command line, so the spec:ruby:* tasks no longer
need Ant.

The classpath used by mspec is now returned by
JRuby::Rake::JavaCommand.classpaths instead of being registered in
shared state. The resultproperty exit codes and spec_run_error are
removed: every run fails the task on a non-zero exit, so
spec_run_error could never report a failure.

Remove rake tasks that have been broken for years and that were the
other users of the Ant helpers:
- graph:viz drew the targets of the Ant build.xml, removed in 2014
- bench:language ran benchmarks that moved to rubybench in 2012
- gem_installers.rake, plus spec:fetch_latest_specs,
  spec:fetch_stable_specs, spec:fast_forward_to_rubyspec_head and
  spec:ci_latest, which depend on build properties commented out in 2013
- jrake and gem_install, which had no remaining callers

Remove the Ant integration specs from spec:ji; they test the rake-ant
gem and are moving to the rake-ant project. java_method_spec relied on
a global `import` defined by one of them, so it now uses java_import.
Also stop downloading jarjar for tests, which only those specs used.

Remove the cedx/SetupAnt steps from dist-verification-ci.yml; nothing in
the build or the rake tasks loads Ant any more.

Ant is no longer needed to build or test JRuby.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zev
zev force-pushed the rake-without-ant branch from 8fd09f4 to d4ae53a Compare October 2, 2026 00:29
@zev

zev commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, done in d4ae53a: this PR now removes only the two cedx/SetupAnt steps. The install4j bypass and the other workflow changes were only in the throwaway commit on my fork (3c05816), there to get the installer job running without a licence; they were never meant to be in this PR. The fork branch is now deleted. The real install4j build and installer-verification will first run without SetupAnt on jruby/jruby after merge; if they need Ant after all, putting the step back is a one-line revert.

zev added a commit to zev/rake-ant that referenced this pull request Oct 2, 2026
JRuby's rakelib/graph.rake (graph:viz, added in 2011 as an "ant target
visualizer") drew the targets of JRuby's Ant build.xml with Graphviz.
JRuby no longer has an Ant build and removes it in jruby/jruby#9761, so
move the idea here as a reusable feature:

- Rake::Ant.dot(project) returns Graphviz DOT text with an edge from
  each dependency to the target that depends on it, sanitizing - and .
  in target names as graph.rake did
- ant_graph_task(name, buildfile, output) defines a task that
  ant_imports the build file and pipes the DOT text to `dot -Tpng -x`
- CI installs Graphviz so the PNG test runs; it skips without `dot`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in JRuby uses rake-ant any more: the rake helpers no longer
load Ant and the Ant integration specs are moving to the rake-ant
project. Anyone who still wants the integration can install the gem.

Remove it from the default gems in lib/pom.rb and regenerate
lib/pom.xml, and drop the .gitignore entries and TestRequireLib
excludes for the files it installed into lib/ruby/stdlib.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zev

zev commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@headius Should this go in the release notes?

One change here is visible to users: rake-ant is no longer installed as a default gem. On a stock JRuby, code that does require 'ant' (or uses Rake::Ant / ant_import from a Rakefile) now raises LoadError until the user runs gem install rake-ant or adds it to their Gemfile.

Everything else here only affects JRuby's own build: the rake helpers no longer need Ant, and the deleted rake tasks were already broken.

If it should be mentioned, a suggested line:

rake-ant is no longer shipped as a default gem. If you use JRuby's Ant integration (require 'ant'), install the rake-ant gem or add it to your Gemfile.

If so, should I add it somewhere in this PR, or do you collect release notes separately at release time? Related: would you like a rake-ant release once jruby/rake-ant#6 and #7 merge, so the gem has a current version when people go to install it?

@headius

headius commented Oct 2, 2026

Copy link
Copy Markdown
Member

Should this go in the release notes?

The release notes include a generated of all issues and PRs marked for that release milestone, so it will be in there. I handcraft a few call-out notes for the release based on what I think is extra important. Standard library changes always go in those notes.

It probably could have a better process, but I enjoy reading through everything we fixed at release time.

FWIW we push out master builds daily as jruby-head for the setup-ruby GHA action, so that will be our first indication whether this will affect people.

would you like a rake-ant release

Yes, we'll want to get the rake-ant gem updated soonish now that the rest of the bits are leaving JRuby.

@headius
headius merged commit e86e249 into jruby:master Oct 2, 2026
242 of 243 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants