Skip to content

Commit 5eb4153

Browse files
authored
Merge pull request #286 from ydah/fix-ci-for-jruby
Fix Java version mismatch errors
2 parents 438d200 + 2336833 commit 5eb4153

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ jobs:
4040
- uses: ruby/setup-ruby@v1
4141
with:
4242
ruby-version: ${{matrix.ruby}}
43+
- uses: actions/setup-java@v4
44+
with:
45+
distribution: zulu
46+
java-version: 21
47+
if: >-
48+
startsWith(matrix.ruby, 'jruby')
4349
- run: bundle install --jobs 4 --retry 3
4450
- run: rake test
4551
- run: rake build

Rakefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,15 @@ if jruby?
6868
lib_dir = ext.lib_dir += "/#{ext.platform}/racc"
6969
ext.ext_dir = 'ext/racc'
7070
# source/target jvm
71-
ext.source_version = '1.8'
72-
ext.target_version = '1.8'
71+
if defined?(JRUBY_VERSION) && Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('10.0.0.0')
72+
# Use Java 21 for JRuby 10.0.0.0 or higher
73+
ext.source_version = '21'
74+
ext.target_version = '21'
75+
else
76+
# Use Java 8 if its lower than JRuby 10.0.0.0
77+
ext.source_version = '1.8'
78+
ext.target_version = '1.8'
79+
end
7380
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
7481
ext.classpath = jars.map { |x| File.expand_path x }.join( ':' )
7582
ext.name = 'cparse-jruby'

0 commit comments

Comments
 (0)